vue.runtime.global.js 417 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798
  1. var Vue = (function (exports) {
  2. 'use strict';
  3. /**
  4. * Make a map and return a function for checking if a key
  5. * is in that map.
  6. * IMPORTANT: all calls of this function must be prefixed with
  7. * \/\*#\_\_PURE\_\_\*\/
  8. * So that rollup can tree-shake them if necessary.
  9. */
  10. function makeMap(str, expectsLowerCase) {
  11. const map = Object.create(null);
  12. const list = str.split(',');
  13. for (let i = 0; i < list.length; i++) {
  14. map[list[i]] = true;
  15. }
  16. return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
  17. }
  18. const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
  19. 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
  20. 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
  21. const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
  22. /**
  23. * On the client we only need to offer special cases for boolean attributes that
  24. * have different names from their corresponding dom properties:
  25. * - itemscope -> N/A
  26. * - allowfullscreen -> allowFullscreen
  27. * - formnovalidate -> formNoValidate
  28. * - ismap -> isMap
  29. * - nomodule -> noModule
  30. * - novalidate -> noValidate
  31. * - readonly -> readOnly
  32. */
  33. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  34. const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
  35. /**
  36. * Boolean attributes should be included if the value is truthy or ''.
  37. * e.g. `<select multiple>` compiles to `{ multiple: '' }`
  38. */
  39. function includeBooleanAttr(value) {
  40. return !!value || value === '';
  41. }
  42. function normalizeStyle(value) {
  43. if (isArray(value)) {
  44. const res = {};
  45. for (let i = 0; i < value.length; i++) {
  46. const item = value[i];
  47. const normalized = isString(item)
  48. ? parseStringStyle(item)
  49. : normalizeStyle(item);
  50. if (normalized) {
  51. for (const key in normalized) {
  52. res[key] = normalized[key];
  53. }
  54. }
  55. }
  56. return res;
  57. }
  58. else if (isString(value)) {
  59. return value;
  60. }
  61. else if (isObject(value)) {
  62. return value;
  63. }
  64. }
  65. const listDelimiterRE = /;(?![^(]*\))/g;
  66. const propertyDelimiterRE = /:(.+)/;
  67. function parseStringStyle(cssText) {
  68. const ret = {};
  69. cssText.split(listDelimiterRE).forEach(item => {
  70. if (item) {
  71. const tmp = item.split(propertyDelimiterRE);
  72. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  73. }
  74. });
  75. return ret;
  76. }
  77. function normalizeClass(value) {
  78. let res = '';
  79. if (isString(value)) {
  80. res = value;
  81. }
  82. else if (isArray(value)) {
  83. for (let i = 0; i < value.length; i++) {
  84. const normalized = normalizeClass(value[i]);
  85. if (normalized) {
  86. res += normalized + ' ';
  87. }
  88. }
  89. }
  90. else if (isObject(value)) {
  91. for (const name in value) {
  92. if (value[name]) {
  93. res += name + ' ';
  94. }
  95. }
  96. }
  97. return res.trim();
  98. }
  99. function normalizeProps(props) {
  100. if (!props)
  101. return null;
  102. let { class: klass, style } = props;
  103. if (klass && !isString(klass)) {
  104. props.class = normalizeClass(klass);
  105. }
  106. if (style) {
  107. props.style = normalizeStyle(style);
  108. }
  109. return props;
  110. }
  111. // These tag configs are shared between compiler-dom and runtime-dom, so they
  112. // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
  113. const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
  114. 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
  115. 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
  116. 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
  117. 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
  118. 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
  119. 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
  120. 'option,output,progress,select,textarea,details,dialog,menu,' +
  121. 'summary,template,blockquote,iframe,tfoot';
  122. // https://developer.mozilla.org/en-US/docs/Web/SVG/Element
  123. const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
  124. 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
  125. 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
  126. 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
  127. 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
  128. 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
  129. 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
  130. 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
  131. 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
  132. 'text,textPath,title,tspan,unknown,use,view';
  133. const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
  134. const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
  135. function looseCompareArrays(a, b) {
  136. if (a.length !== b.length)
  137. return false;
  138. let equal = true;
  139. for (let i = 0; equal && i < a.length; i++) {
  140. equal = looseEqual(a[i], b[i]);
  141. }
  142. return equal;
  143. }
  144. function looseEqual(a, b) {
  145. if (a === b)
  146. return true;
  147. let aValidType = isDate(a);
  148. let bValidType = isDate(b);
  149. if (aValidType || bValidType) {
  150. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  151. }
  152. aValidType = isArray(a);
  153. bValidType = isArray(b);
  154. if (aValidType || bValidType) {
  155. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  156. }
  157. aValidType = isObject(a);
  158. bValidType = isObject(b);
  159. if (aValidType || bValidType) {
  160. /* istanbul ignore if: this if will probably never be called */
  161. if (!aValidType || !bValidType) {
  162. return false;
  163. }
  164. const aKeysCount = Object.keys(a).length;
  165. const bKeysCount = Object.keys(b).length;
  166. if (aKeysCount !== bKeysCount) {
  167. return false;
  168. }
  169. for (const key in a) {
  170. const aHasKey = a.hasOwnProperty(key);
  171. const bHasKey = b.hasOwnProperty(key);
  172. if ((aHasKey && !bHasKey) ||
  173. (!aHasKey && bHasKey) ||
  174. !looseEqual(a[key], b[key])) {
  175. return false;
  176. }
  177. }
  178. }
  179. return String(a) === String(b);
  180. }
  181. function looseIndexOf(arr, val) {
  182. return arr.findIndex(item => looseEqual(item, val));
  183. }
  184. /**
  185. * For converting {{ interpolation }} values to displayed strings.
  186. * @private
  187. */
  188. const toDisplayString = (val) => {
  189. return val == null
  190. ? ''
  191. : isArray(val) ||
  192. (isObject(val) &&
  193. (val.toString === objectToString || !isFunction(val.toString)))
  194. ? JSON.stringify(val, replacer, 2)
  195. : String(val);
  196. };
  197. const replacer = (_key, val) => {
  198. // can't use isRef here since @vue/shared has no deps
  199. if (val && val.__v_isRef) {
  200. return replacer(_key, val.value);
  201. }
  202. else if (isMap(val)) {
  203. return {
  204. [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
  205. entries[`${key} =>`] = val;
  206. return entries;
  207. }, {})
  208. };
  209. }
  210. else if (isSet(val)) {
  211. return {
  212. [`Set(${val.size})`]: [...val.values()]
  213. };
  214. }
  215. else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  216. return String(val);
  217. }
  218. return val;
  219. };
  220. const EMPTY_OBJ = Object.freeze({})
  221. ;
  222. const EMPTY_ARR = Object.freeze([]) ;
  223. const NOOP = () => { };
  224. /**
  225. * Always return false.
  226. */
  227. const NO = () => false;
  228. const onRE = /^on[^a-z]/;
  229. const isOn = (key) => onRE.test(key);
  230. const isModelListener = (key) => key.startsWith('onUpdate:');
  231. const extend = Object.assign;
  232. const remove = (arr, el) => {
  233. const i = arr.indexOf(el);
  234. if (i > -1) {
  235. arr.splice(i, 1);
  236. }
  237. };
  238. const hasOwnProperty = Object.prototype.hasOwnProperty;
  239. const hasOwn = (val, key) => hasOwnProperty.call(val, key);
  240. const isArray = Array.isArray;
  241. const isMap = (val) => toTypeString(val) === '[object Map]';
  242. const isSet = (val) => toTypeString(val) === '[object Set]';
  243. const isDate = (val) => val instanceof Date;
  244. const isFunction = (val) => typeof val === 'function';
  245. const isString = (val) => typeof val === 'string';
  246. const isSymbol = (val) => typeof val === 'symbol';
  247. const isObject = (val) => val !== null && typeof val === 'object';
  248. const isPromise = (val) => {
  249. return isObject(val) && isFunction(val.then) && isFunction(val.catch);
  250. };
  251. const objectToString = Object.prototype.toString;
  252. const toTypeString = (value) => objectToString.call(value);
  253. const toRawType = (value) => {
  254. // extract "RawType" from strings like "[object RawType]"
  255. return toTypeString(value).slice(8, -1);
  256. };
  257. const isPlainObject = (val) => toTypeString(val) === '[object Object]';
  258. const isIntegerKey = (key) => isString(key) &&
  259. key !== 'NaN' &&
  260. key[0] !== '-' &&
  261. '' + parseInt(key, 10) === key;
  262. const isReservedProp = /*#__PURE__*/ makeMap(
  263. // the leading comma is intentional so empty string "" is also included
  264. ',key,ref,ref_for,ref_key,' +
  265. 'onVnodeBeforeMount,onVnodeMounted,' +
  266. 'onVnodeBeforeUpdate,onVnodeUpdated,' +
  267. 'onVnodeBeforeUnmount,onVnodeUnmounted');
  268. const cacheStringFunction = (fn) => {
  269. const cache = Object.create(null);
  270. return ((str) => {
  271. const hit = cache[str];
  272. return hit || (cache[str] = fn(str));
  273. });
  274. };
  275. const camelizeRE = /-(\w)/g;
  276. /**
  277. * @private
  278. */
  279. const camelize = cacheStringFunction((str) => {
  280. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  281. });
  282. const hyphenateRE = /\B([A-Z])/g;
  283. /**
  284. * @private
  285. */
  286. const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
  287. /**
  288. * @private
  289. */
  290. const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
  291. /**
  292. * @private
  293. */
  294. const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
  295. // compare whether a value has changed, accounting for NaN.
  296. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  297. const invokeArrayFns = (fns, arg) => {
  298. for (let i = 0; i < fns.length; i++) {
  299. fns[i](arg);
  300. }
  301. };
  302. const def = (obj, key, value) => {
  303. Object.defineProperty(obj, key, {
  304. configurable: true,
  305. enumerable: false,
  306. value
  307. });
  308. };
  309. const toNumber = (val) => {
  310. const n = parseFloat(val);
  311. return isNaN(n) ? val : n;
  312. };
  313. let _globalThis;
  314. const getGlobalThis = () => {
  315. return (_globalThis ||
  316. (_globalThis =
  317. typeof globalThis !== 'undefined'
  318. ? globalThis
  319. : typeof self !== 'undefined'
  320. ? self
  321. : typeof window !== 'undefined'
  322. ? window
  323. : typeof global !== 'undefined'
  324. ? global
  325. : {}));
  326. };
  327. function warn(msg, ...args) {
  328. console.warn(`[Vue warn] ${msg}`, ...args);
  329. }
  330. let activeEffectScope;
  331. const effectScopeStack = [];
  332. class EffectScope {
  333. constructor(detached = false) {
  334. this.active = true;
  335. this.effects = [];
  336. this.cleanups = [];
  337. if (!detached && activeEffectScope) {
  338. this.parent = activeEffectScope;
  339. this.index =
  340. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  341. }
  342. }
  343. run(fn) {
  344. if (this.active) {
  345. try {
  346. this.on();
  347. return fn();
  348. }
  349. finally {
  350. this.off();
  351. }
  352. }
  353. else {
  354. warn(`cannot run an inactive effect scope.`);
  355. }
  356. }
  357. on() {
  358. if (this.active) {
  359. effectScopeStack.push(this);
  360. activeEffectScope = this;
  361. }
  362. }
  363. off() {
  364. if (this.active) {
  365. effectScopeStack.pop();
  366. activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
  367. }
  368. }
  369. stop(fromParent) {
  370. if (this.active) {
  371. this.effects.forEach(e => e.stop());
  372. this.cleanups.forEach(cleanup => cleanup());
  373. if (this.scopes) {
  374. this.scopes.forEach(e => e.stop(true));
  375. }
  376. // nested scope, dereference from parent to avoid memory leaks
  377. if (this.parent && !fromParent) {
  378. // optimized O(1) removal
  379. const last = this.parent.scopes.pop();
  380. if (last && last !== this) {
  381. this.parent.scopes[this.index] = last;
  382. last.index = this.index;
  383. }
  384. }
  385. this.active = false;
  386. }
  387. }
  388. }
  389. function effectScope(detached) {
  390. return new EffectScope(detached);
  391. }
  392. function recordEffectScope(effect, scope) {
  393. scope = scope || activeEffectScope;
  394. if (scope && scope.active) {
  395. scope.effects.push(effect);
  396. }
  397. }
  398. function getCurrentScope() {
  399. return activeEffectScope;
  400. }
  401. function onScopeDispose(fn) {
  402. if (activeEffectScope) {
  403. activeEffectScope.cleanups.push(fn);
  404. }
  405. else {
  406. warn(`onScopeDispose() is called when there is no active effect scope` +
  407. ` to be associated with.`);
  408. }
  409. }
  410. const createDep = (effects) => {
  411. const dep = new Set(effects);
  412. dep.w = 0;
  413. dep.n = 0;
  414. return dep;
  415. };
  416. const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
  417. const newTracked = (dep) => (dep.n & trackOpBit) > 0;
  418. const initDepMarkers = ({ deps }) => {
  419. if (deps.length) {
  420. for (let i = 0; i < deps.length; i++) {
  421. deps[i].w |= trackOpBit; // set was tracked
  422. }
  423. }
  424. };
  425. const finalizeDepMarkers = (effect) => {
  426. const { deps } = effect;
  427. if (deps.length) {
  428. let ptr = 0;
  429. for (let i = 0; i < deps.length; i++) {
  430. const dep = deps[i];
  431. if (wasTracked(dep) && !newTracked(dep)) {
  432. dep.delete(effect);
  433. }
  434. else {
  435. deps[ptr++] = dep;
  436. }
  437. // clear bits
  438. dep.w &= ~trackOpBit;
  439. dep.n &= ~trackOpBit;
  440. }
  441. deps.length = ptr;
  442. }
  443. };
  444. const targetMap = new WeakMap();
  445. // The number of effects currently being tracked recursively.
  446. let effectTrackDepth = 0;
  447. let trackOpBit = 1;
  448. /**
  449. * The bitwise track markers support at most 30 levels of recursion.
  450. * This value is chosen to enable modern JS engines to use a SMI on all platforms.
  451. * When recursion depth is greater, fall back to using a full cleanup.
  452. */
  453. const maxMarkerBits = 30;
  454. const effectStack = [];
  455. let activeEffect;
  456. const ITERATE_KEY = Symbol('iterate' );
  457. const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
  458. class ReactiveEffect {
  459. constructor(fn, scheduler = null, scope) {
  460. this.fn = fn;
  461. this.scheduler = scheduler;
  462. this.active = true;
  463. this.deps = [];
  464. recordEffectScope(this, scope);
  465. }
  466. run() {
  467. if (!this.active) {
  468. return this.fn();
  469. }
  470. if (!effectStack.includes(this)) {
  471. try {
  472. effectStack.push((activeEffect = this));
  473. enableTracking();
  474. trackOpBit = 1 << ++effectTrackDepth;
  475. if (effectTrackDepth <= maxMarkerBits) {
  476. initDepMarkers(this);
  477. }
  478. else {
  479. cleanupEffect(this);
  480. }
  481. return this.fn();
  482. }
  483. finally {
  484. if (effectTrackDepth <= maxMarkerBits) {
  485. finalizeDepMarkers(this);
  486. }
  487. trackOpBit = 1 << --effectTrackDepth;
  488. resetTracking();
  489. effectStack.pop();
  490. const n = effectStack.length;
  491. activeEffect = n > 0 ? effectStack[n - 1] : undefined;
  492. }
  493. }
  494. }
  495. stop() {
  496. if (this.active) {
  497. cleanupEffect(this);
  498. if (this.onStop) {
  499. this.onStop();
  500. }
  501. this.active = false;
  502. }
  503. }
  504. }
  505. function cleanupEffect(effect) {
  506. const { deps } = effect;
  507. if (deps.length) {
  508. for (let i = 0; i < deps.length; i++) {
  509. deps[i].delete(effect);
  510. }
  511. deps.length = 0;
  512. }
  513. }
  514. function effect(fn, options) {
  515. if (fn.effect) {
  516. fn = fn.effect.fn;
  517. }
  518. const _effect = new ReactiveEffect(fn);
  519. if (options) {
  520. extend(_effect, options);
  521. if (options.scope)
  522. recordEffectScope(_effect, options.scope);
  523. }
  524. if (!options || !options.lazy) {
  525. _effect.run();
  526. }
  527. const runner = _effect.run.bind(_effect);
  528. runner.effect = _effect;
  529. return runner;
  530. }
  531. function stop(runner) {
  532. runner.effect.stop();
  533. }
  534. let shouldTrack = true;
  535. const trackStack = [];
  536. function pauseTracking() {
  537. trackStack.push(shouldTrack);
  538. shouldTrack = false;
  539. }
  540. function enableTracking() {
  541. trackStack.push(shouldTrack);
  542. shouldTrack = true;
  543. }
  544. function resetTracking() {
  545. const last = trackStack.pop();
  546. shouldTrack = last === undefined ? true : last;
  547. }
  548. function track(target, type, key) {
  549. if (!isTracking()) {
  550. return;
  551. }
  552. let depsMap = targetMap.get(target);
  553. if (!depsMap) {
  554. targetMap.set(target, (depsMap = new Map()));
  555. }
  556. let dep = depsMap.get(key);
  557. if (!dep) {
  558. depsMap.set(key, (dep = createDep()));
  559. }
  560. const eventInfo = { effect: activeEffect, target, type, key }
  561. ;
  562. trackEffects(dep, eventInfo);
  563. }
  564. function isTracking() {
  565. return shouldTrack && activeEffect !== undefined;
  566. }
  567. function trackEffects(dep, debuggerEventExtraInfo) {
  568. let shouldTrack = false;
  569. if (effectTrackDepth <= maxMarkerBits) {
  570. if (!newTracked(dep)) {
  571. dep.n |= trackOpBit; // set newly tracked
  572. shouldTrack = !wasTracked(dep);
  573. }
  574. }
  575. else {
  576. // Full cleanup mode.
  577. shouldTrack = !dep.has(activeEffect);
  578. }
  579. if (shouldTrack) {
  580. dep.add(activeEffect);
  581. activeEffect.deps.push(dep);
  582. if (activeEffect.onTrack) {
  583. activeEffect.onTrack(Object.assign({
  584. effect: activeEffect
  585. }, debuggerEventExtraInfo));
  586. }
  587. }
  588. }
  589. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  590. const depsMap = targetMap.get(target);
  591. if (!depsMap) {
  592. // never been tracked
  593. return;
  594. }
  595. let deps = [];
  596. if (type === "clear" /* CLEAR */) {
  597. // collection being cleared
  598. // trigger all effects for target
  599. deps = [...depsMap.values()];
  600. }
  601. else if (key === 'length' && isArray(target)) {
  602. depsMap.forEach((dep, key) => {
  603. if (key === 'length' || key >= newValue) {
  604. deps.push(dep);
  605. }
  606. });
  607. }
  608. else {
  609. // schedule runs for SET | ADD | DELETE
  610. if (key !== void 0) {
  611. deps.push(depsMap.get(key));
  612. }
  613. // also run for iteration key on ADD | DELETE | Map.SET
  614. switch (type) {
  615. case "add" /* ADD */:
  616. if (!isArray(target)) {
  617. deps.push(depsMap.get(ITERATE_KEY));
  618. if (isMap(target)) {
  619. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  620. }
  621. }
  622. else if (isIntegerKey(key)) {
  623. // new index added to array -> length changes
  624. deps.push(depsMap.get('length'));
  625. }
  626. break;
  627. case "delete" /* DELETE */:
  628. if (!isArray(target)) {
  629. deps.push(depsMap.get(ITERATE_KEY));
  630. if (isMap(target)) {
  631. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  632. }
  633. }
  634. break;
  635. case "set" /* SET */:
  636. if (isMap(target)) {
  637. deps.push(depsMap.get(ITERATE_KEY));
  638. }
  639. break;
  640. }
  641. }
  642. const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
  643. ;
  644. if (deps.length === 1) {
  645. if (deps[0]) {
  646. {
  647. triggerEffects(deps[0], eventInfo);
  648. }
  649. }
  650. }
  651. else {
  652. const effects = [];
  653. for (const dep of deps) {
  654. if (dep) {
  655. effects.push(...dep);
  656. }
  657. }
  658. {
  659. triggerEffects(createDep(effects), eventInfo);
  660. }
  661. }
  662. }
  663. function triggerEffects(dep, debuggerEventExtraInfo) {
  664. // spread into array for stabilization
  665. for (const effect of isArray(dep) ? dep : [...dep]) {
  666. if (effect !== activeEffect || effect.allowRecurse) {
  667. if (effect.onTrigger) {
  668. effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
  669. }
  670. if (effect.scheduler) {
  671. effect.scheduler();
  672. }
  673. else {
  674. effect.run();
  675. }
  676. }
  677. }
  678. }
  679. const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
  680. const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
  681. .map(key => Symbol[key])
  682. .filter(isSymbol));
  683. const get = /*#__PURE__*/ createGetter();
  684. const shallowGet = /*#__PURE__*/ createGetter(false, true);
  685. const readonlyGet = /*#__PURE__*/ createGetter(true);
  686. const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
  687. const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
  688. function createArrayInstrumentations() {
  689. const instrumentations = {};
  690. ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
  691. instrumentations[key] = function (...args) {
  692. const arr = toRaw(this);
  693. for (let i = 0, l = this.length; i < l; i++) {
  694. track(arr, "get" /* GET */, i + '');
  695. }
  696. // we run the method using the original args first (which may be reactive)
  697. const res = arr[key](...args);
  698. if (res === -1 || res === false) {
  699. // if that didn't work, run it again using raw values.
  700. return arr[key](...args.map(toRaw));
  701. }
  702. else {
  703. return res;
  704. }
  705. };
  706. });
  707. ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
  708. instrumentations[key] = function (...args) {
  709. pauseTracking();
  710. const res = toRaw(this)[key].apply(this, args);
  711. resetTracking();
  712. return res;
  713. };
  714. });
  715. return instrumentations;
  716. }
  717. function createGetter(isReadonly = false, shallow = false) {
  718. return function get(target, key, receiver) {
  719. if (key === "__v_isReactive" /* IS_REACTIVE */) {
  720. return !isReadonly;
  721. }
  722. else if (key === "__v_isReadonly" /* IS_READONLY */) {
  723. return isReadonly;
  724. }
  725. else if (key === "__v_raw" /* RAW */ &&
  726. receiver ===
  727. (isReadonly
  728. ? shallow
  729. ? shallowReadonlyMap
  730. : readonlyMap
  731. : shallow
  732. ? shallowReactiveMap
  733. : reactiveMap).get(target)) {
  734. return target;
  735. }
  736. const targetIsArray = isArray(target);
  737. if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
  738. return Reflect.get(arrayInstrumentations, key, receiver);
  739. }
  740. const res = Reflect.get(target, key, receiver);
  741. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  742. return res;
  743. }
  744. if (!isReadonly) {
  745. track(target, "get" /* GET */, key);
  746. }
  747. if (shallow) {
  748. return res;
  749. }
  750. if (isRef(res)) {
  751. // ref unwrapping - does not apply for Array + integer key.
  752. const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
  753. return shouldUnwrap ? res.value : res;
  754. }
  755. if (isObject(res)) {
  756. // Convert returned value into a proxy as well. we do the isObject check
  757. // here to avoid invalid value warning. Also need to lazy access readonly
  758. // and reactive here to avoid circular dependency.
  759. return isReadonly ? readonly(res) : reactive(res);
  760. }
  761. return res;
  762. };
  763. }
  764. const set = /*#__PURE__*/ createSetter();
  765. const shallowSet = /*#__PURE__*/ createSetter(true);
  766. function createSetter(shallow = false) {
  767. return function set(target, key, value, receiver) {
  768. let oldValue = target[key];
  769. if (!shallow && !isReadonly(value)) {
  770. value = toRaw(value);
  771. oldValue = toRaw(oldValue);
  772. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  773. oldValue.value = value;
  774. return true;
  775. }
  776. }
  777. const hadKey = isArray(target) && isIntegerKey(key)
  778. ? Number(key) < target.length
  779. : hasOwn(target, key);
  780. const result = Reflect.set(target, key, value, receiver);
  781. // don't trigger if target is something up in the prototype chain of original
  782. if (target === toRaw(receiver)) {
  783. if (!hadKey) {
  784. trigger(target, "add" /* ADD */, key, value);
  785. }
  786. else if (hasChanged(value, oldValue)) {
  787. trigger(target, "set" /* SET */, key, value, oldValue);
  788. }
  789. }
  790. return result;
  791. };
  792. }
  793. function deleteProperty(target, key) {
  794. const hadKey = hasOwn(target, key);
  795. const oldValue = target[key];
  796. const result = Reflect.deleteProperty(target, key);
  797. if (result && hadKey) {
  798. trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
  799. }
  800. return result;
  801. }
  802. function has(target, key) {
  803. const result = Reflect.has(target, key);
  804. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  805. track(target, "has" /* HAS */, key);
  806. }
  807. return result;
  808. }
  809. function ownKeys(target) {
  810. track(target, "iterate" /* ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
  811. return Reflect.ownKeys(target);
  812. }
  813. const mutableHandlers = {
  814. get,
  815. set,
  816. deleteProperty,
  817. has,
  818. ownKeys
  819. };
  820. const readonlyHandlers = {
  821. get: readonlyGet,
  822. set(target, key) {
  823. {
  824. console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
  825. }
  826. return true;
  827. },
  828. deleteProperty(target, key) {
  829. {
  830. console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
  831. }
  832. return true;
  833. }
  834. };
  835. const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
  836. get: shallowGet,
  837. set: shallowSet
  838. });
  839. // Props handlers are special in the sense that it should not unwrap top-level
  840. // refs (in order to allow refs to be explicitly passed down), but should
  841. // retain the reactivity of the normal readonly object.
  842. const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
  843. get: shallowReadonlyGet
  844. });
  845. const toShallow = (value) => value;
  846. const getProto = (v) => Reflect.getPrototypeOf(v);
  847. function get$1(target, key, isReadonly = false, isShallow = false) {
  848. // #1772: readonly(reactive(Map)) should return readonly + reactive version
  849. // of the value
  850. target = target["__v_raw" /* RAW */];
  851. const rawTarget = toRaw(target);
  852. const rawKey = toRaw(key);
  853. if (key !== rawKey) {
  854. !isReadonly && track(rawTarget, "get" /* GET */, key);
  855. }
  856. !isReadonly && track(rawTarget, "get" /* GET */, rawKey);
  857. const { has } = getProto(rawTarget);
  858. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  859. if (has.call(rawTarget, key)) {
  860. return wrap(target.get(key));
  861. }
  862. else if (has.call(rawTarget, rawKey)) {
  863. return wrap(target.get(rawKey));
  864. }
  865. else if (target !== rawTarget) {
  866. // #3602 readonly(reactive(Map))
  867. // ensure that the nested reactive `Map` can do tracking for itself
  868. target.get(key);
  869. }
  870. }
  871. function has$1(key, isReadonly = false) {
  872. const target = this["__v_raw" /* RAW */];
  873. const rawTarget = toRaw(target);
  874. const rawKey = toRaw(key);
  875. if (key !== rawKey) {
  876. !isReadonly && track(rawTarget, "has" /* HAS */, key);
  877. }
  878. !isReadonly && track(rawTarget, "has" /* HAS */, rawKey);
  879. return key === rawKey
  880. ? target.has(key)
  881. : target.has(key) || target.has(rawKey);
  882. }
  883. function size(target, isReadonly = false) {
  884. target = target["__v_raw" /* RAW */];
  885. !isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY);
  886. return Reflect.get(target, 'size', target);
  887. }
  888. function add(value) {
  889. value = toRaw(value);
  890. const target = toRaw(this);
  891. const proto = getProto(target);
  892. const hadKey = proto.has.call(target, value);
  893. if (!hadKey) {
  894. target.add(value);
  895. trigger(target, "add" /* ADD */, value, value);
  896. }
  897. return this;
  898. }
  899. function set$1(key, value) {
  900. value = toRaw(value);
  901. const target = toRaw(this);
  902. const { has, get } = getProto(target);
  903. let hadKey = has.call(target, key);
  904. if (!hadKey) {
  905. key = toRaw(key);
  906. hadKey = has.call(target, key);
  907. }
  908. else {
  909. checkIdentityKeys(target, has, key);
  910. }
  911. const oldValue = get.call(target, key);
  912. target.set(key, value);
  913. if (!hadKey) {
  914. trigger(target, "add" /* ADD */, key, value);
  915. }
  916. else if (hasChanged(value, oldValue)) {
  917. trigger(target, "set" /* SET */, key, value, oldValue);
  918. }
  919. return this;
  920. }
  921. function deleteEntry(key) {
  922. const target = toRaw(this);
  923. const { has, get } = getProto(target);
  924. let hadKey = has.call(target, key);
  925. if (!hadKey) {
  926. key = toRaw(key);
  927. hadKey = has.call(target, key);
  928. }
  929. else {
  930. checkIdentityKeys(target, has, key);
  931. }
  932. const oldValue = get ? get.call(target, key) : undefined;
  933. // forward the operation before queueing reactions
  934. const result = target.delete(key);
  935. if (hadKey) {
  936. trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
  937. }
  938. return result;
  939. }
  940. function clear() {
  941. const target = toRaw(this);
  942. const hadItems = target.size !== 0;
  943. const oldTarget = isMap(target)
  944. ? new Map(target)
  945. : new Set(target)
  946. ;
  947. // forward the operation before queueing reactions
  948. const result = target.clear();
  949. if (hadItems) {
  950. trigger(target, "clear" /* CLEAR */, undefined, undefined, oldTarget);
  951. }
  952. return result;
  953. }
  954. function createForEach(isReadonly, isShallow) {
  955. return function forEach(callback, thisArg) {
  956. const observed = this;
  957. const target = observed["__v_raw" /* RAW */];
  958. const rawTarget = toRaw(target);
  959. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  960. !isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);
  961. return target.forEach((value, key) => {
  962. // important: make sure the callback is
  963. // 1. invoked with the reactive map as `this` and 3rd arg
  964. // 2. the value received should be a corresponding reactive/readonly.
  965. return callback.call(thisArg, wrap(value), wrap(key), observed);
  966. });
  967. };
  968. }
  969. function createIterableMethod(method, isReadonly, isShallow) {
  970. return function (...args) {
  971. const target = this["__v_raw" /* RAW */];
  972. const rawTarget = toRaw(target);
  973. const targetIsMap = isMap(rawTarget);
  974. const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
  975. const isKeyOnly = method === 'keys' && targetIsMap;
  976. const innerIterator = target[method](...args);
  977. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  978. !isReadonly &&
  979. track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
  980. // return a wrapped iterator which returns observed versions of the
  981. // values emitted from the real iterator
  982. return {
  983. // iterator protocol
  984. next() {
  985. const { value, done } = innerIterator.next();
  986. return done
  987. ? { value, done }
  988. : {
  989. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  990. done
  991. };
  992. },
  993. // iterable protocol
  994. [Symbol.iterator]() {
  995. return this;
  996. }
  997. };
  998. };
  999. }
  1000. function createReadonlyMethod(type) {
  1001. return function (...args) {
  1002. {
  1003. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1004. console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
  1005. }
  1006. return type === "delete" /* DELETE */ ? false : this;
  1007. };
  1008. }
  1009. function createInstrumentations() {
  1010. const mutableInstrumentations = {
  1011. get(key) {
  1012. return get$1(this, key);
  1013. },
  1014. get size() {
  1015. return size(this);
  1016. },
  1017. has: has$1,
  1018. add,
  1019. set: set$1,
  1020. delete: deleteEntry,
  1021. clear,
  1022. forEach: createForEach(false, false)
  1023. };
  1024. const shallowInstrumentations = {
  1025. get(key) {
  1026. return get$1(this, key, false, true);
  1027. },
  1028. get size() {
  1029. return size(this);
  1030. },
  1031. has: has$1,
  1032. add,
  1033. set: set$1,
  1034. delete: deleteEntry,
  1035. clear,
  1036. forEach: createForEach(false, true)
  1037. };
  1038. const readonlyInstrumentations = {
  1039. get(key) {
  1040. return get$1(this, key, true);
  1041. },
  1042. get size() {
  1043. return size(this, true);
  1044. },
  1045. has(key) {
  1046. return has$1.call(this, key, true);
  1047. },
  1048. add: createReadonlyMethod("add" /* ADD */),
  1049. set: createReadonlyMethod("set" /* SET */),
  1050. delete: createReadonlyMethod("delete" /* DELETE */),
  1051. clear: createReadonlyMethod("clear" /* CLEAR */),
  1052. forEach: createForEach(true, false)
  1053. };
  1054. const shallowReadonlyInstrumentations = {
  1055. get(key) {
  1056. return get$1(this, key, true, true);
  1057. },
  1058. get size() {
  1059. return size(this, true);
  1060. },
  1061. has(key) {
  1062. return has$1.call(this, key, true);
  1063. },
  1064. add: createReadonlyMethod("add" /* ADD */),
  1065. set: createReadonlyMethod("set" /* SET */),
  1066. delete: createReadonlyMethod("delete" /* DELETE */),
  1067. clear: createReadonlyMethod("clear" /* CLEAR */),
  1068. forEach: createForEach(true, true)
  1069. };
  1070. const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
  1071. iteratorMethods.forEach(method => {
  1072. mutableInstrumentations[method] = createIterableMethod(method, false, false);
  1073. readonlyInstrumentations[method] = createIterableMethod(method, true, false);
  1074. shallowInstrumentations[method] = createIterableMethod(method, false, true);
  1075. shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
  1076. });
  1077. return [
  1078. mutableInstrumentations,
  1079. readonlyInstrumentations,
  1080. shallowInstrumentations,
  1081. shallowReadonlyInstrumentations
  1082. ];
  1083. }
  1084. const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
  1085. function createInstrumentationGetter(isReadonly, shallow) {
  1086. const instrumentations = shallow
  1087. ? isReadonly
  1088. ? shallowReadonlyInstrumentations
  1089. : shallowInstrumentations
  1090. : isReadonly
  1091. ? readonlyInstrumentations
  1092. : mutableInstrumentations;
  1093. return (target, key, receiver) => {
  1094. if (key === "__v_isReactive" /* IS_REACTIVE */) {
  1095. return !isReadonly;
  1096. }
  1097. else if (key === "__v_isReadonly" /* IS_READONLY */) {
  1098. return isReadonly;
  1099. }
  1100. else if (key === "__v_raw" /* RAW */) {
  1101. return target;
  1102. }
  1103. return Reflect.get(hasOwn(instrumentations, key) && key in target
  1104. ? instrumentations
  1105. : target, key, receiver);
  1106. };
  1107. }
  1108. const mutableCollectionHandlers = {
  1109. get: /*#__PURE__*/ createInstrumentationGetter(false, false)
  1110. };
  1111. const shallowCollectionHandlers = {
  1112. get: /*#__PURE__*/ createInstrumentationGetter(false, true)
  1113. };
  1114. const readonlyCollectionHandlers = {
  1115. get: /*#__PURE__*/ createInstrumentationGetter(true, false)
  1116. };
  1117. const shallowReadonlyCollectionHandlers = {
  1118. get: /*#__PURE__*/ createInstrumentationGetter(true, true)
  1119. };
  1120. function checkIdentityKeys(target, has, key) {
  1121. const rawKey = toRaw(key);
  1122. if (rawKey !== key && has.call(target, rawKey)) {
  1123. const type = toRawType(target);
  1124. console.warn(`Reactive ${type} contains both the raw and reactive ` +
  1125. `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
  1126. `which can lead to inconsistencies. ` +
  1127. `Avoid differentiating between the raw and reactive versions ` +
  1128. `of an object and only use the reactive version if possible.`);
  1129. }
  1130. }
  1131. const reactiveMap = new WeakMap();
  1132. const shallowReactiveMap = new WeakMap();
  1133. const readonlyMap = new WeakMap();
  1134. const shallowReadonlyMap = new WeakMap();
  1135. function targetTypeMap(rawType) {
  1136. switch (rawType) {
  1137. case 'Object':
  1138. case 'Array':
  1139. return 1 /* COMMON */;
  1140. case 'Map':
  1141. case 'Set':
  1142. case 'WeakMap':
  1143. case 'WeakSet':
  1144. return 2 /* COLLECTION */;
  1145. default:
  1146. return 0 /* INVALID */;
  1147. }
  1148. }
  1149. function getTargetType(value) {
  1150. return value["__v_skip" /* SKIP */] || !Object.isExtensible(value)
  1151. ? 0 /* INVALID */
  1152. : targetTypeMap(toRawType(value));
  1153. }
  1154. function reactive(target) {
  1155. // if trying to observe a readonly proxy, return the readonly version.
  1156. if (target && target["__v_isReadonly" /* IS_READONLY */]) {
  1157. return target;
  1158. }
  1159. return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
  1160. }
  1161. /**
  1162. * Return a shallowly-reactive copy of the original object, where only the root
  1163. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1164. * root level).
  1165. */
  1166. function shallowReactive(target) {
  1167. return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
  1168. }
  1169. /**
  1170. * Creates a readonly copy of the original object. Note the returned copy is not
  1171. * made reactive, but `readonly` can be called on an already reactive object.
  1172. */
  1173. function readonly(target) {
  1174. return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
  1175. }
  1176. /**
  1177. * Returns a reactive-copy of the original object, where only the root level
  1178. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1179. * returned properties.
  1180. * This is used for creating the props proxy object for stateful components.
  1181. */
  1182. function shallowReadonly(target) {
  1183. return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
  1184. }
  1185. function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
  1186. if (!isObject(target)) {
  1187. {
  1188. console.warn(`value cannot be made reactive: ${String(target)}`);
  1189. }
  1190. return target;
  1191. }
  1192. // target is already a Proxy, return it.
  1193. // exception: calling readonly() on a reactive object
  1194. if (target["__v_raw" /* RAW */] &&
  1195. !(isReadonly && target["__v_isReactive" /* IS_REACTIVE */])) {
  1196. return target;
  1197. }
  1198. // target already has corresponding Proxy
  1199. const existingProxy = proxyMap.get(target);
  1200. if (existingProxy) {
  1201. return existingProxy;
  1202. }
  1203. // only a whitelist of value types can be observed.
  1204. const targetType = getTargetType(target);
  1205. if (targetType === 0 /* INVALID */) {
  1206. return target;
  1207. }
  1208. const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers);
  1209. proxyMap.set(target, proxy);
  1210. return proxy;
  1211. }
  1212. function isReactive(value) {
  1213. if (isReadonly(value)) {
  1214. return isReactive(value["__v_raw" /* RAW */]);
  1215. }
  1216. return !!(value && value["__v_isReactive" /* IS_REACTIVE */]);
  1217. }
  1218. function isReadonly(value) {
  1219. return !!(value && value["__v_isReadonly" /* IS_READONLY */]);
  1220. }
  1221. function isProxy(value) {
  1222. return isReactive(value) || isReadonly(value);
  1223. }
  1224. function toRaw(observed) {
  1225. const raw = observed && observed["__v_raw" /* RAW */];
  1226. return raw ? toRaw(raw) : observed;
  1227. }
  1228. function markRaw(value) {
  1229. def(value, "__v_skip" /* SKIP */, true);
  1230. return value;
  1231. }
  1232. const toReactive = (value) => isObject(value) ? reactive(value) : value;
  1233. const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  1234. function trackRefValue(ref) {
  1235. if (isTracking()) {
  1236. ref = toRaw(ref);
  1237. if (!ref.dep) {
  1238. ref.dep = createDep();
  1239. }
  1240. {
  1241. trackEffects(ref.dep, {
  1242. target: ref,
  1243. type: "get" /* GET */,
  1244. key: 'value'
  1245. });
  1246. }
  1247. }
  1248. }
  1249. function triggerRefValue(ref, newVal) {
  1250. ref = toRaw(ref);
  1251. if (ref.dep) {
  1252. {
  1253. triggerEffects(ref.dep, {
  1254. target: ref,
  1255. type: "set" /* SET */,
  1256. key: 'value',
  1257. newValue: newVal
  1258. });
  1259. }
  1260. }
  1261. }
  1262. function isRef(r) {
  1263. return Boolean(r && r.__v_isRef === true);
  1264. }
  1265. function ref(value) {
  1266. return createRef(value, false);
  1267. }
  1268. function shallowRef(value) {
  1269. return createRef(value, true);
  1270. }
  1271. function createRef(rawValue, shallow) {
  1272. if (isRef(rawValue)) {
  1273. return rawValue;
  1274. }
  1275. return new RefImpl(rawValue, shallow);
  1276. }
  1277. class RefImpl {
  1278. constructor(value, _shallow) {
  1279. this._shallow = _shallow;
  1280. this.dep = undefined;
  1281. this.__v_isRef = true;
  1282. this._rawValue = _shallow ? value : toRaw(value);
  1283. this._value = _shallow ? value : toReactive(value);
  1284. }
  1285. get value() {
  1286. trackRefValue(this);
  1287. return this._value;
  1288. }
  1289. set value(newVal) {
  1290. newVal = this._shallow ? newVal : toRaw(newVal);
  1291. if (hasChanged(newVal, this._rawValue)) {
  1292. this._rawValue = newVal;
  1293. this._value = this._shallow ? newVal : toReactive(newVal);
  1294. triggerRefValue(this, newVal);
  1295. }
  1296. }
  1297. }
  1298. function triggerRef(ref) {
  1299. triggerRefValue(ref, ref.value );
  1300. }
  1301. function unref(ref) {
  1302. return isRef(ref) ? ref.value : ref;
  1303. }
  1304. const shallowUnwrapHandlers = {
  1305. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1306. set: (target, key, value, receiver) => {
  1307. const oldValue = target[key];
  1308. if (isRef(oldValue) && !isRef(value)) {
  1309. oldValue.value = value;
  1310. return true;
  1311. }
  1312. else {
  1313. return Reflect.set(target, key, value, receiver);
  1314. }
  1315. }
  1316. };
  1317. function proxyRefs(objectWithRefs) {
  1318. return isReactive(objectWithRefs)
  1319. ? objectWithRefs
  1320. : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1321. }
  1322. class CustomRefImpl {
  1323. constructor(factory) {
  1324. this.dep = undefined;
  1325. this.__v_isRef = true;
  1326. const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
  1327. this._get = get;
  1328. this._set = set;
  1329. }
  1330. get value() {
  1331. return this._get();
  1332. }
  1333. set value(newVal) {
  1334. this._set(newVal);
  1335. }
  1336. }
  1337. function customRef(factory) {
  1338. return new CustomRefImpl(factory);
  1339. }
  1340. function toRefs(object) {
  1341. if (!isProxy(object)) {
  1342. console.warn(`toRefs() expects a reactive object but received a plain one.`);
  1343. }
  1344. const ret = isArray(object) ? new Array(object.length) : {};
  1345. for (const key in object) {
  1346. ret[key] = toRef(object, key);
  1347. }
  1348. return ret;
  1349. }
  1350. class ObjectRefImpl {
  1351. constructor(_object, _key, _defaultValue) {
  1352. this._object = _object;
  1353. this._key = _key;
  1354. this._defaultValue = _defaultValue;
  1355. this.__v_isRef = true;
  1356. }
  1357. get value() {
  1358. const val = this._object[this._key];
  1359. return val === undefined ? this._defaultValue : val;
  1360. }
  1361. set value(newVal) {
  1362. this._object[this._key] = newVal;
  1363. }
  1364. }
  1365. function toRef(object, key, defaultValue) {
  1366. const val = object[key];
  1367. return isRef(val)
  1368. ? val
  1369. : new ObjectRefImpl(object, key, defaultValue);
  1370. }
  1371. class ComputedRefImpl {
  1372. constructor(getter, _setter, isReadonly) {
  1373. this._setter = _setter;
  1374. this.dep = undefined;
  1375. this._dirty = true;
  1376. this.__v_isRef = true;
  1377. this.effect = new ReactiveEffect(getter, () => {
  1378. if (!this._dirty) {
  1379. this._dirty = true;
  1380. triggerRefValue(this);
  1381. }
  1382. });
  1383. this["__v_isReadonly" /* IS_READONLY */] = isReadonly;
  1384. }
  1385. get value() {
  1386. // the computed ref may get wrapped by other proxies e.g. readonly() #3376
  1387. const self = toRaw(this);
  1388. trackRefValue(self);
  1389. if (self._dirty) {
  1390. self._dirty = false;
  1391. self._value = self.effect.run();
  1392. }
  1393. return self._value;
  1394. }
  1395. set value(newValue) {
  1396. this._setter(newValue);
  1397. }
  1398. }
  1399. function computed(getterOrOptions, debugOptions) {
  1400. let getter;
  1401. let setter;
  1402. const onlyGetter = isFunction(getterOrOptions);
  1403. if (onlyGetter) {
  1404. getter = getterOrOptions;
  1405. setter = () => {
  1406. console.warn('Write operation failed: computed value is readonly');
  1407. }
  1408. ;
  1409. }
  1410. else {
  1411. getter = getterOrOptions.get;
  1412. setter = getterOrOptions.set;
  1413. }
  1414. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter);
  1415. if (debugOptions) {
  1416. cRef.effect.onTrack = debugOptions.onTrack;
  1417. cRef.effect.onTrigger = debugOptions.onTrigger;
  1418. }
  1419. return cRef;
  1420. }
  1421. /* eslint-disable no-restricted-globals */
  1422. let isHmrUpdating = false;
  1423. const hmrDirtyComponents = new Set();
  1424. // Expose the HMR runtime on the global object
  1425. // This makes it entirely tree-shakable without polluting the exports and makes
  1426. // it easier to be used in toolings like vue-loader
  1427. // Note: for a component to be eligible for HMR it also needs the __hmrId option
  1428. // to be set so that its instances can be registered / removed.
  1429. {
  1430. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  1431. createRecord: tryWrap(createRecord),
  1432. rerender: tryWrap(rerender),
  1433. reload: tryWrap(reload)
  1434. };
  1435. }
  1436. const map = new Map();
  1437. function registerHMR(instance) {
  1438. const id = instance.type.__hmrId;
  1439. let record = map.get(id);
  1440. if (!record) {
  1441. createRecord(id, instance.type);
  1442. record = map.get(id);
  1443. }
  1444. record.instances.add(instance);
  1445. }
  1446. function unregisterHMR(instance) {
  1447. map.get(instance.type.__hmrId).instances.delete(instance);
  1448. }
  1449. function createRecord(id, initialDef) {
  1450. if (map.has(id)) {
  1451. return false;
  1452. }
  1453. map.set(id, {
  1454. initialDef: normalizeClassComponent(initialDef),
  1455. instances: new Set()
  1456. });
  1457. return true;
  1458. }
  1459. function normalizeClassComponent(component) {
  1460. return isClassComponent(component) ? component.__vccOpts : component;
  1461. }
  1462. function rerender(id, newRender) {
  1463. const record = map.get(id);
  1464. if (!record) {
  1465. return;
  1466. }
  1467. // update initial record (for not-yet-rendered component)
  1468. record.initialDef.render = newRender;
  1469. [...record.instances].forEach(instance => {
  1470. if (newRender) {
  1471. instance.render = newRender;
  1472. normalizeClassComponent(instance.type).render = newRender;
  1473. }
  1474. instance.renderCache = [];
  1475. // this flag forces child components with slot content to update
  1476. isHmrUpdating = true;
  1477. instance.update();
  1478. isHmrUpdating = false;
  1479. });
  1480. }
  1481. function reload(id, newComp) {
  1482. const record = map.get(id);
  1483. if (!record)
  1484. return;
  1485. newComp = normalizeClassComponent(newComp);
  1486. // update initial def (for not-yet-rendered components)
  1487. updateComponentDef(record.initialDef, newComp);
  1488. // create a snapshot which avoids the set being mutated during updates
  1489. const instances = [...record.instances];
  1490. for (const instance of instances) {
  1491. const oldComp = normalizeClassComponent(instance.type);
  1492. if (!hmrDirtyComponents.has(oldComp)) {
  1493. // 1. Update existing comp definition to match new one
  1494. if (oldComp !== record.initialDef) {
  1495. updateComponentDef(oldComp, newComp);
  1496. }
  1497. // 2. mark definition dirty. This forces the renderer to replace the
  1498. // component on patch.
  1499. hmrDirtyComponents.add(oldComp);
  1500. }
  1501. // 3. invalidate options resolution cache
  1502. instance.appContext.optionsCache.delete(instance.type);
  1503. // 4. actually update
  1504. if (instance.ceReload) {
  1505. // custom element
  1506. hmrDirtyComponents.add(oldComp);
  1507. instance.ceReload(newComp.styles);
  1508. hmrDirtyComponents.delete(oldComp);
  1509. }
  1510. else if (instance.parent) {
  1511. // 4. Force the parent instance to re-render. This will cause all updated
  1512. // components to be unmounted and re-mounted. Queue the update so that we
  1513. // don't end up forcing the same parent to re-render multiple times.
  1514. queueJob(instance.parent.update);
  1515. // instance is the inner component of an async custom element
  1516. // invoke to reset styles
  1517. if (instance.parent.type.__asyncLoader &&
  1518. instance.parent.ceReload) {
  1519. instance.parent.ceReload(newComp.styles);
  1520. }
  1521. }
  1522. else if (instance.appContext.reload) {
  1523. // root instance mounted via createApp() has a reload method
  1524. instance.appContext.reload();
  1525. }
  1526. else if (typeof window !== 'undefined') {
  1527. // root instance inside tree created via raw render(). Force reload.
  1528. window.location.reload();
  1529. }
  1530. else {
  1531. console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
  1532. }
  1533. }
  1534. // 5. make sure to cleanup dirty hmr components after update
  1535. queuePostFlushCb(() => {
  1536. for (const instance of instances) {
  1537. hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
  1538. }
  1539. });
  1540. }
  1541. function updateComponentDef(oldComp, newComp) {
  1542. extend(oldComp, newComp);
  1543. for (const key in oldComp) {
  1544. if (key !== '__file' && !(key in newComp)) {
  1545. delete oldComp[key];
  1546. }
  1547. }
  1548. }
  1549. function tryWrap(fn) {
  1550. return (id, arg) => {
  1551. try {
  1552. return fn(id, arg);
  1553. }
  1554. catch (e) {
  1555. console.error(e);
  1556. console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
  1557. `Full reload required.`);
  1558. }
  1559. };
  1560. }
  1561. let buffer = [];
  1562. let devtoolsNotInstalled = false;
  1563. function emit(event, ...args) {
  1564. if (exports.devtools) {
  1565. exports.devtools.emit(event, ...args);
  1566. }
  1567. else if (!devtoolsNotInstalled) {
  1568. buffer.push({ event, args });
  1569. }
  1570. }
  1571. function setDevtoolsHook(hook, target) {
  1572. var _a, _b;
  1573. exports.devtools = hook;
  1574. if (exports.devtools) {
  1575. exports.devtools.enabled = true;
  1576. buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
  1577. buffer = [];
  1578. }
  1579. else if (
  1580. // handle late devtools injection - only do this if we are in an actual
  1581. // browser environment to avoid the timer handle stalling test runner exit
  1582. // (#4815)
  1583. // eslint-disable-next-line no-restricted-globals
  1584. typeof window !== 'undefined' &&
  1585. // some envs mock window but not fully
  1586. window.HTMLElement &&
  1587. // also exclude jsdom
  1588. !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
  1589. const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
  1590. target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
  1591. replay.push((newHook) => {
  1592. setDevtoolsHook(newHook, target);
  1593. });
  1594. // clear buffer after 3s - the user probably doesn't have devtools installed
  1595. // at all, and keeping the buffer will cause memory leaks (#4738)
  1596. setTimeout(() => {
  1597. if (!exports.devtools) {
  1598. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  1599. devtoolsNotInstalled = true;
  1600. buffer = [];
  1601. }
  1602. }, 3000);
  1603. }
  1604. else {
  1605. // non-browser env, assume not installed
  1606. devtoolsNotInstalled = true;
  1607. buffer = [];
  1608. }
  1609. }
  1610. function devtoolsInitApp(app, version) {
  1611. emit("app:init" /* APP_INIT */, app, version, {
  1612. Fragment,
  1613. Text,
  1614. Comment,
  1615. Static
  1616. });
  1617. }
  1618. function devtoolsUnmountApp(app) {
  1619. emit("app:unmount" /* APP_UNMOUNT */, app);
  1620. }
  1621. const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
  1622. const devtoolsComponentUpdated =
  1623. /*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
  1624. const devtoolsComponentRemoved =
  1625. /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);
  1626. function createDevtoolsComponentHook(hook) {
  1627. return (component) => {
  1628. emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
  1629. };
  1630. }
  1631. const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
  1632. const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
  1633. function createDevtoolsPerformanceHook(hook) {
  1634. return (component, type, time) => {
  1635. emit(hook, component.appContext.app, component.uid, component, type, time);
  1636. };
  1637. }
  1638. function devtoolsComponentEmit(component, event, params) {
  1639. emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);
  1640. }
  1641. function emit$1(instance, event, ...rawArgs) {
  1642. const props = instance.vnode.props || EMPTY_OBJ;
  1643. {
  1644. const { emitsOptions, propsOptions: [propsOptions] } = instance;
  1645. if (emitsOptions) {
  1646. if (!(event in emitsOptions) &&
  1647. !(false )) {
  1648. if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
  1649. warn$1(`Component emitted event "${event}" but it is neither declared in ` +
  1650. `the emits option nor as an "${toHandlerKey(event)}" prop.`);
  1651. }
  1652. }
  1653. else {
  1654. const validator = emitsOptions[event];
  1655. if (isFunction(validator)) {
  1656. const isValid = validator(...rawArgs);
  1657. if (!isValid) {
  1658. warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
  1659. }
  1660. }
  1661. }
  1662. }
  1663. }
  1664. let args = rawArgs;
  1665. const isModelListener = event.startsWith('update:');
  1666. // for v-model update:xxx events, apply modifiers on args
  1667. const modelArg = isModelListener && event.slice(7);
  1668. if (modelArg && modelArg in props) {
  1669. const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
  1670. const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
  1671. if (trim) {
  1672. args = rawArgs.map(a => a.trim());
  1673. }
  1674. else if (number) {
  1675. args = rawArgs.map(toNumber);
  1676. }
  1677. }
  1678. {
  1679. devtoolsComponentEmit(instance, event, args);
  1680. }
  1681. {
  1682. const lowerCaseEvent = event.toLowerCase();
  1683. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  1684. warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
  1685. `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
  1686. `Note that HTML attributes are case-insensitive and you cannot use ` +
  1687. `v-on to listen to camelCase events when using in-DOM templates. ` +
  1688. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  1689. }
  1690. }
  1691. let handlerName;
  1692. let handler = props[(handlerName = toHandlerKey(event))] ||
  1693. // also try camelCase event handler (#2249)
  1694. props[(handlerName = toHandlerKey(camelize(event)))];
  1695. // for v-model update:xxx events, also trigger kebab-case equivalent
  1696. // for props passed via kebab-case
  1697. if (!handler && isModelListener) {
  1698. handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
  1699. }
  1700. if (handler) {
  1701. callWithAsyncErrorHandling(handler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
  1702. }
  1703. const onceHandler = props[handlerName + `Once`];
  1704. if (onceHandler) {
  1705. if (!instance.emitted) {
  1706. instance.emitted = {};
  1707. }
  1708. else if (instance.emitted[handlerName]) {
  1709. return;
  1710. }
  1711. instance.emitted[handlerName] = true;
  1712. callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
  1713. }
  1714. }
  1715. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  1716. const cache = appContext.emitsCache;
  1717. const cached = cache.get(comp);
  1718. if (cached !== undefined) {
  1719. return cached;
  1720. }
  1721. const raw = comp.emits;
  1722. let normalized = {};
  1723. // apply mixin/extends props
  1724. let hasExtends = false;
  1725. if (!isFunction(comp)) {
  1726. const extendEmits = (raw) => {
  1727. const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
  1728. if (normalizedFromExtend) {
  1729. hasExtends = true;
  1730. extend(normalized, normalizedFromExtend);
  1731. }
  1732. };
  1733. if (!asMixin && appContext.mixins.length) {
  1734. appContext.mixins.forEach(extendEmits);
  1735. }
  1736. if (comp.extends) {
  1737. extendEmits(comp.extends);
  1738. }
  1739. if (comp.mixins) {
  1740. comp.mixins.forEach(extendEmits);
  1741. }
  1742. }
  1743. if (!raw && !hasExtends) {
  1744. cache.set(comp, null);
  1745. return null;
  1746. }
  1747. if (isArray(raw)) {
  1748. raw.forEach(key => (normalized[key] = null));
  1749. }
  1750. else {
  1751. extend(normalized, raw);
  1752. }
  1753. cache.set(comp, normalized);
  1754. return normalized;
  1755. }
  1756. // Check if an incoming prop key is a declared emit event listener.
  1757. // e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
  1758. // both considered matched listeners.
  1759. function isEmitListener(options, key) {
  1760. if (!options || !isOn(key)) {
  1761. return false;
  1762. }
  1763. key = key.slice(2).replace(/Once$/, '');
  1764. return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
  1765. hasOwn(options, hyphenate(key)) ||
  1766. hasOwn(options, key));
  1767. }
  1768. /**
  1769. * mark the current rendering instance for asset resolution (e.g.
  1770. * resolveComponent, resolveDirective) during render
  1771. */
  1772. let currentRenderingInstance = null;
  1773. let currentScopeId = null;
  1774. /**
  1775. * Note: rendering calls maybe nested. The function returns the parent rendering
  1776. * instance if present, which should be restored after the render is done:
  1777. *
  1778. * ```js
  1779. * const prev = setCurrentRenderingInstance(i)
  1780. * // ...render
  1781. * setCurrentRenderingInstance(prev)
  1782. * ```
  1783. */
  1784. function setCurrentRenderingInstance(instance) {
  1785. const prev = currentRenderingInstance;
  1786. currentRenderingInstance = instance;
  1787. currentScopeId = (instance && instance.type.__scopeId) || null;
  1788. return prev;
  1789. }
  1790. /**
  1791. * Set scope id when creating hoisted vnodes.
  1792. * @private compiler helper
  1793. */
  1794. function pushScopeId(id) {
  1795. currentScopeId = id;
  1796. }
  1797. /**
  1798. * Technically we no longer need this after 3.0.8 but we need to keep the same
  1799. * API for backwards compat w/ code generated by compilers.
  1800. * @private
  1801. */
  1802. function popScopeId() {
  1803. currentScopeId = null;
  1804. }
  1805. /**
  1806. * Only for backwards compat
  1807. * @private
  1808. */
  1809. const withScopeId = (_id) => withCtx;
  1810. /**
  1811. * Wrap a slot function to memoize current rendering instance
  1812. * @private compiler helper
  1813. */
  1814. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only
  1815. ) {
  1816. if (!ctx)
  1817. return fn;
  1818. // already normalized
  1819. if (fn._n) {
  1820. return fn;
  1821. }
  1822. const renderFnWithContext = (...args) => {
  1823. // If a user calls a compiled slot inside a template expression (#1745), it
  1824. // can mess up block tracking, so by default we disable block tracking and
  1825. // force bail out when invoking a compiled slot (indicated by the ._d flag).
  1826. // This isn't necessary if rendering a compiled `<slot>`, so we flip the
  1827. // ._d flag off when invoking the wrapped fn inside `renderSlot`.
  1828. if (renderFnWithContext._d) {
  1829. setBlockTracking(-1);
  1830. }
  1831. const prevInstance = setCurrentRenderingInstance(ctx);
  1832. const res = fn(...args);
  1833. setCurrentRenderingInstance(prevInstance);
  1834. if (renderFnWithContext._d) {
  1835. setBlockTracking(1);
  1836. }
  1837. {
  1838. devtoolsComponentUpdated(ctx);
  1839. }
  1840. return res;
  1841. };
  1842. // mark normalized to avoid duplicated wrapping
  1843. renderFnWithContext._n = true;
  1844. // mark this as compiled by default
  1845. // this is used in vnode.ts -> normalizeChildren() to set the slot
  1846. // rendering flag.
  1847. renderFnWithContext._c = true;
  1848. // disable block tracking by default
  1849. renderFnWithContext._d = true;
  1850. return renderFnWithContext;
  1851. }
  1852. /**
  1853. * dev only flag to track whether $attrs was used during render.
  1854. * If $attrs was used during render then the warning for failed attrs
  1855. * fallthrough can be suppressed.
  1856. */
  1857. let accessedAttrs = false;
  1858. function markAttrsAccessed() {
  1859. accessedAttrs = true;
  1860. }
  1861. function renderComponentRoot(instance) {
  1862. const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
  1863. let result;
  1864. let fallthroughAttrs;
  1865. const prev = setCurrentRenderingInstance(instance);
  1866. {
  1867. accessedAttrs = false;
  1868. }
  1869. try {
  1870. if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
  1871. // withProxy is a proxy with a different `has` trap only for
  1872. // runtime-compiled render functions using `with` block.
  1873. const proxyToUse = withProxy || proxy;
  1874. result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
  1875. fallthroughAttrs = attrs;
  1876. }
  1877. else {
  1878. // functional
  1879. const render = Component;
  1880. // in dev, mark attrs accessed if optional props (attrs === props)
  1881. if (true && attrs === props) {
  1882. markAttrsAccessed();
  1883. }
  1884. result = normalizeVNode(render.length > 1
  1885. ? render(props, true
  1886. ? {
  1887. get attrs() {
  1888. markAttrsAccessed();
  1889. return attrs;
  1890. },
  1891. slots,
  1892. emit
  1893. }
  1894. : { attrs, slots, emit })
  1895. : render(props, null /* we know it doesn't need it */));
  1896. fallthroughAttrs = Component.props
  1897. ? attrs
  1898. : getFunctionalFallthrough(attrs);
  1899. }
  1900. }
  1901. catch (err) {
  1902. blockStack.length = 0;
  1903. handleError(err, instance, 1 /* RENDER_FUNCTION */);
  1904. result = createVNode(Comment);
  1905. }
  1906. // attr merging
  1907. // in dev mode, comments are preserved, and it's possible for a template
  1908. // to have comments along side the root element which makes it a fragment
  1909. let root = result;
  1910. let setRoot = undefined;
  1911. if (result.patchFlag > 0 &&
  1912. result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
  1913. [root, setRoot] = getChildRoot(result);
  1914. }
  1915. if (fallthroughAttrs && inheritAttrs !== false) {
  1916. const keys = Object.keys(fallthroughAttrs);
  1917. const { shapeFlag } = root;
  1918. if (keys.length) {
  1919. if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
  1920. if (propsOptions && keys.some(isModelListener)) {
  1921. // If a v-model listener (onUpdate:xxx) has a corresponding declared
  1922. // prop, it indicates this component expects to handle v-model and
  1923. // it should not fallthrough.
  1924. // related: #1543, #1643, #1989
  1925. fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
  1926. }
  1927. root = cloneVNode(root, fallthroughAttrs);
  1928. }
  1929. else if (!accessedAttrs && root.type !== Comment) {
  1930. const allAttrs = Object.keys(attrs);
  1931. const eventAttrs = [];
  1932. const extraAttrs = [];
  1933. for (let i = 0, l = allAttrs.length; i < l; i++) {
  1934. const key = allAttrs[i];
  1935. if (isOn(key)) {
  1936. // ignore v-model handlers when they fail to fallthrough
  1937. if (!isModelListener(key)) {
  1938. // remove `on`, lowercase first letter to reflect event casing
  1939. // accurately
  1940. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  1941. }
  1942. }
  1943. else {
  1944. extraAttrs.push(key);
  1945. }
  1946. }
  1947. if (extraAttrs.length) {
  1948. warn$1(`Extraneous non-props attributes (` +
  1949. `${extraAttrs.join(', ')}) ` +
  1950. `were passed to component but could not be automatically inherited ` +
  1951. `because component renders fragment or text root nodes.`);
  1952. }
  1953. if (eventAttrs.length) {
  1954. warn$1(`Extraneous non-emits event listeners (` +
  1955. `${eventAttrs.join(', ')}) ` +
  1956. `were passed to component but could not be automatically inherited ` +
  1957. `because component renders fragment or text root nodes. ` +
  1958. `If the listener is intended to be a component custom event listener only, ` +
  1959. `declare it using the "emits" option.`);
  1960. }
  1961. }
  1962. }
  1963. }
  1964. // inherit directives
  1965. if (vnode.dirs) {
  1966. if (!isElementRoot(root)) {
  1967. warn$1(`Runtime directive used on component with non-element root node. ` +
  1968. `The directives will not function as intended.`);
  1969. }
  1970. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  1971. }
  1972. // inherit transition data
  1973. if (vnode.transition) {
  1974. if (!isElementRoot(root)) {
  1975. warn$1(`Component inside <Transition> renders non-element root node ` +
  1976. `that cannot be animated.`);
  1977. }
  1978. root.transition = vnode.transition;
  1979. }
  1980. if (setRoot) {
  1981. setRoot(root);
  1982. }
  1983. else {
  1984. result = root;
  1985. }
  1986. setCurrentRenderingInstance(prev);
  1987. return result;
  1988. }
  1989. /**
  1990. * dev only
  1991. * In dev mode, template root level comments are rendered, which turns the
  1992. * template into a fragment root, but we need to locate the single element
  1993. * root for attrs and scope id processing.
  1994. */
  1995. const getChildRoot = (vnode) => {
  1996. const rawChildren = vnode.children;
  1997. const dynamicChildren = vnode.dynamicChildren;
  1998. const childRoot = filterSingleRoot(rawChildren);
  1999. if (!childRoot) {
  2000. return [vnode, undefined];
  2001. }
  2002. const index = rawChildren.indexOf(childRoot);
  2003. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  2004. const setRoot = (updatedRoot) => {
  2005. rawChildren[index] = updatedRoot;
  2006. if (dynamicChildren) {
  2007. if (dynamicIndex > -1) {
  2008. dynamicChildren[dynamicIndex] = updatedRoot;
  2009. }
  2010. else if (updatedRoot.patchFlag > 0) {
  2011. vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
  2012. }
  2013. }
  2014. };
  2015. return [normalizeVNode(childRoot), setRoot];
  2016. };
  2017. function filterSingleRoot(children) {
  2018. let singleRoot;
  2019. for (let i = 0; i < children.length; i++) {
  2020. const child = children[i];
  2021. if (isVNode(child)) {
  2022. // ignore user comment
  2023. if (child.type !== Comment || child.children === 'v-if') {
  2024. if (singleRoot) {
  2025. // has more than 1 non-comment child, return now
  2026. return;
  2027. }
  2028. else {
  2029. singleRoot = child;
  2030. }
  2031. }
  2032. }
  2033. else {
  2034. return;
  2035. }
  2036. }
  2037. return singleRoot;
  2038. }
  2039. const getFunctionalFallthrough = (attrs) => {
  2040. let res;
  2041. for (const key in attrs) {
  2042. if (key === 'class' || key === 'style' || isOn(key)) {
  2043. (res || (res = {}))[key] = attrs[key];
  2044. }
  2045. }
  2046. return res;
  2047. };
  2048. const filterModelListeners = (attrs, props) => {
  2049. const res = {};
  2050. for (const key in attrs) {
  2051. if (!isModelListener(key) || !(key.slice(9) in props)) {
  2052. res[key] = attrs[key];
  2053. }
  2054. }
  2055. return res;
  2056. };
  2057. const isElementRoot = (vnode) => {
  2058. return (vnode.shapeFlag & (6 /* COMPONENT */ | 1 /* ELEMENT */) ||
  2059. vnode.type === Comment // potential v-if branch switch
  2060. );
  2061. };
  2062. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  2063. const { props: prevProps, children: prevChildren, component } = prevVNode;
  2064. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  2065. const emits = component.emitsOptions;
  2066. // Parent component's render function was hot-updated. Since this may have
  2067. // caused the child component's slots content to have changed, we need to
  2068. // force the child to update as well.
  2069. if ((prevChildren || nextChildren) && isHmrUpdating) {
  2070. return true;
  2071. }
  2072. // force child update for runtime directive or transition on component vnode.
  2073. if (nextVNode.dirs || nextVNode.transition) {
  2074. return true;
  2075. }
  2076. if (optimized && patchFlag >= 0) {
  2077. if (patchFlag & 1024 /* DYNAMIC_SLOTS */) {
  2078. // slot content that references values that might have changed,
  2079. // e.g. in a v-for
  2080. return true;
  2081. }
  2082. if (patchFlag & 16 /* FULL_PROPS */) {
  2083. if (!prevProps) {
  2084. return !!nextProps;
  2085. }
  2086. // presence of this flag indicates props are always non-null
  2087. return hasPropsChanged(prevProps, nextProps, emits);
  2088. }
  2089. else if (patchFlag & 8 /* PROPS */) {
  2090. const dynamicProps = nextVNode.dynamicProps;
  2091. for (let i = 0; i < dynamicProps.length; i++) {
  2092. const key = dynamicProps[i];
  2093. if (nextProps[key] !== prevProps[key] &&
  2094. !isEmitListener(emits, key)) {
  2095. return true;
  2096. }
  2097. }
  2098. }
  2099. }
  2100. else {
  2101. // this path is only taken by manually written render functions
  2102. // so presence of any children leads to a forced update
  2103. if (prevChildren || nextChildren) {
  2104. if (!nextChildren || !nextChildren.$stable) {
  2105. return true;
  2106. }
  2107. }
  2108. if (prevProps === nextProps) {
  2109. return false;
  2110. }
  2111. if (!prevProps) {
  2112. return !!nextProps;
  2113. }
  2114. if (!nextProps) {
  2115. return true;
  2116. }
  2117. return hasPropsChanged(prevProps, nextProps, emits);
  2118. }
  2119. return false;
  2120. }
  2121. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2122. const nextKeys = Object.keys(nextProps);
  2123. if (nextKeys.length !== Object.keys(prevProps).length) {
  2124. return true;
  2125. }
  2126. for (let i = 0; i < nextKeys.length; i++) {
  2127. const key = nextKeys[i];
  2128. if (nextProps[key] !== prevProps[key] &&
  2129. !isEmitListener(emitsOptions, key)) {
  2130. return true;
  2131. }
  2132. }
  2133. return false;
  2134. }
  2135. function updateHOCHostEl({ vnode, parent }, el // HostNode
  2136. ) {
  2137. while (parent && parent.subTree === vnode) {
  2138. (vnode = parent.vnode).el = el;
  2139. parent = parent.parent;
  2140. }
  2141. }
  2142. const isSuspense = (type) => type.__isSuspense;
  2143. // Suspense exposes a component-like API, and is treated like a component
  2144. // in the compiler, but internally it's a special built-in type that hooks
  2145. // directly into the renderer.
  2146. const SuspenseImpl = {
  2147. name: 'Suspense',
  2148. // In order to make Suspense tree-shakable, we need to avoid importing it
  2149. // directly in the renderer. The renderer checks for the __isSuspense flag
  2150. // on a vnode's type and calls the `process` method, passing in renderer
  2151. // internals.
  2152. __isSuspense: true,
  2153. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
  2154. // platform-specific impl passed from renderer
  2155. rendererInternals) {
  2156. if (n1 == null) {
  2157. mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
  2158. }
  2159. else {
  2160. patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
  2161. }
  2162. },
  2163. hydrate: hydrateSuspense,
  2164. create: createSuspenseBoundary,
  2165. normalize: normalizeSuspenseChildren
  2166. };
  2167. // Force-casted public typing for h and TSX props inference
  2168. const Suspense = (SuspenseImpl );
  2169. function triggerEvent(vnode, name) {
  2170. const eventListener = vnode.props && vnode.props[name];
  2171. if (isFunction(eventListener)) {
  2172. eventListener();
  2173. }
  2174. }
  2175. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2176. const { p: patch, o: { createElement } } = rendererInternals;
  2177. const hiddenContainer = createElement('div');
  2178. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
  2179. // start mounting the content subtree in an off-dom container
  2180. patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
  2181. // now check if we have encountered any async deps
  2182. if (suspense.deps > 0) {
  2183. // has async
  2184. // invoke @fallback event
  2185. triggerEvent(vnode, 'onPending');
  2186. triggerEvent(vnode, 'onFallback');
  2187. // mount the fallback tree
  2188. patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2189. isSVG, slotScopeIds);
  2190. setActiveBranch(suspense, vnode.ssFallback);
  2191. }
  2192. else {
  2193. // Suspense has no async deps. Just resolve.
  2194. suspense.resolve();
  2195. }
  2196. }
  2197. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
  2198. const suspense = (n2.suspense = n1.suspense);
  2199. suspense.vnode = n2;
  2200. n2.el = n1.el;
  2201. const newBranch = n2.ssContent;
  2202. const newFallback = n2.ssFallback;
  2203. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  2204. if (pendingBranch) {
  2205. suspense.pendingBranch = newBranch;
  2206. if (isSameVNodeType(newBranch, pendingBranch)) {
  2207. // same root type but content may have changed.
  2208. patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2209. if (suspense.deps <= 0) {
  2210. suspense.resolve();
  2211. }
  2212. else if (isInFallback) {
  2213. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2214. isSVG, slotScopeIds, optimized);
  2215. setActiveBranch(suspense, newFallback);
  2216. }
  2217. }
  2218. else {
  2219. // toggled before pending tree is resolved
  2220. suspense.pendingId++;
  2221. if (isHydrating) {
  2222. // if toggled before hydration is finished, the current DOM tree is
  2223. // no longer valid. set it as the active branch so it will be unmounted
  2224. // when resolved
  2225. suspense.isHydrating = false;
  2226. suspense.activeBranch = pendingBranch;
  2227. }
  2228. else {
  2229. unmount(pendingBranch, parentComponent, suspense);
  2230. }
  2231. // increment pending ID. this is used to invalidate async callbacks
  2232. // reset suspense state
  2233. suspense.deps = 0;
  2234. // discard effects from pending branch
  2235. suspense.effects.length = 0;
  2236. // discard previous container
  2237. suspense.hiddenContainer = createElement('div');
  2238. if (isInFallback) {
  2239. // already in fallback state
  2240. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2241. if (suspense.deps <= 0) {
  2242. suspense.resolve();
  2243. }
  2244. else {
  2245. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2246. isSVG, slotScopeIds, optimized);
  2247. setActiveBranch(suspense, newFallback);
  2248. }
  2249. }
  2250. else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2251. // toggled "back" to current active branch
  2252. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2253. // force resolve
  2254. suspense.resolve(true);
  2255. }
  2256. else {
  2257. // switched to a 3rd branch
  2258. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2259. if (suspense.deps <= 0) {
  2260. suspense.resolve();
  2261. }
  2262. }
  2263. }
  2264. }
  2265. else {
  2266. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2267. // root did not change, just normal patch
  2268. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2269. setActiveBranch(suspense, newBranch);
  2270. }
  2271. else {
  2272. // root node toggled
  2273. // invoke @pending event
  2274. triggerEvent(n2, 'onPending');
  2275. // mount pending branch in off-dom container
  2276. suspense.pendingBranch = newBranch;
  2277. suspense.pendingId++;
  2278. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2279. if (suspense.deps <= 0) {
  2280. // incoming branch has no async deps, resolve now.
  2281. suspense.resolve();
  2282. }
  2283. else {
  2284. const { timeout, pendingId } = suspense;
  2285. if (timeout > 0) {
  2286. setTimeout(() => {
  2287. if (suspense.pendingId === pendingId) {
  2288. suspense.fallback(newFallback);
  2289. }
  2290. }, timeout);
  2291. }
  2292. else if (timeout === 0) {
  2293. suspense.fallback(newFallback);
  2294. }
  2295. }
  2296. }
  2297. }
  2298. }
  2299. let hasWarned = false;
  2300. function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
  2301. /* istanbul ignore if */
  2302. if (!hasWarned) {
  2303. hasWarned = true;
  2304. // @ts-ignore `console.info` cannot be null error
  2305. console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
  2306. }
  2307. const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
  2308. const timeout = toNumber(vnode.props && vnode.props.timeout);
  2309. const suspense = {
  2310. vnode,
  2311. parent,
  2312. parentComponent,
  2313. isSVG,
  2314. container,
  2315. hiddenContainer,
  2316. anchor,
  2317. deps: 0,
  2318. pendingId: 0,
  2319. timeout: typeof timeout === 'number' ? timeout : -1,
  2320. activeBranch: null,
  2321. pendingBranch: null,
  2322. isInFallback: true,
  2323. isHydrating,
  2324. isUnmounted: false,
  2325. effects: [],
  2326. resolve(resume = false) {
  2327. {
  2328. if (!resume && !suspense.pendingBranch) {
  2329. throw new Error(`suspense.resolve() is called without a pending branch.`);
  2330. }
  2331. if (suspense.isUnmounted) {
  2332. throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
  2333. }
  2334. }
  2335. const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
  2336. if (suspense.isHydrating) {
  2337. suspense.isHydrating = false;
  2338. }
  2339. else if (!resume) {
  2340. const delayEnter = activeBranch &&
  2341. pendingBranch.transition &&
  2342. pendingBranch.transition.mode === 'out-in';
  2343. if (delayEnter) {
  2344. activeBranch.transition.afterLeave = () => {
  2345. if (pendingId === suspense.pendingId) {
  2346. move(pendingBranch, container, anchor, 0 /* ENTER */);
  2347. }
  2348. };
  2349. }
  2350. // this is initial anchor on mount
  2351. let { anchor } = suspense;
  2352. // unmount current active tree
  2353. if (activeBranch) {
  2354. // if the fallback tree was mounted, it may have been moved
  2355. // as part of a parent suspense. get the latest anchor for insertion
  2356. anchor = next(activeBranch);
  2357. unmount(activeBranch, parentComponent, suspense, true);
  2358. }
  2359. if (!delayEnter) {
  2360. // move content from off-dom container to actual container
  2361. move(pendingBranch, container, anchor, 0 /* ENTER */);
  2362. }
  2363. }
  2364. setActiveBranch(suspense, pendingBranch);
  2365. suspense.pendingBranch = null;
  2366. suspense.isInFallback = false;
  2367. // flush buffered effects
  2368. // check if there is a pending parent suspense
  2369. let parent = suspense.parent;
  2370. let hasUnresolvedAncestor = false;
  2371. while (parent) {
  2372. if (parent.pendingBranch) {
  2373. // found a pending parent suspense, merge buffered post jobs
  2374. // into that parent
  2375. parent.effects.push(...effects);
  2376. hasUnresolvedAncestor = true;
  2377. break;
  2378. }
  2379. parent = parent.parent;
  2380. }
  2381. // no pending parent suspense, flush all jobs
  2382. if (!hasUnresolvedAncestor) {
  2383. queuePostFlushCb(effects);
  2384. }
  2385. suspense.effects = [];
  2386. // invoke @resolve event
  2387. triggerEvent(vnode, 'onResolve');
  2388. },
  2389. fallback(fallbackVNode) {
  2390. if (!suspense.pendingBranch) {
  2391. return;
  2392. }
  2393. const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
  2394. // invoke @fallback event
  2395. triggerEvent(vnode, 'onFallback');
  2396. const anchor = next(activeBranch);
  2397. const mountFallback = () => {
  2398. if (!suspense.isInFallback) {
  2399. return;
  2400. }
  2401. // mount the fallback tree
  2402. patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2403. isSVG, slotScopeIds, optimized);
  2404. setActiveBranch(suspense, fallbackVNode);
  2405. };
  2406. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
  2407. if (delayEnter) {
  2408. activeBranch.transition.afterLeave = mountFallback;
  2409. }
  2410. suspense.isInFallback = true;
  2411. // unmount current active branch
  2412. unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
  2413. true // shouldRemove
  2414. );
  2415. if (!delayEnter) {
  2416. mountFallback();
  2417. }
  2418. },
  2419. move(container, anchor, type) {
  2420. suspense.activeBranch &&
  2421. move(suspense.activeBranch, container, anchor, type);
  2422. suspense.container = container;
  2423. },
  2424. next() {
  2425. return suspense.activeBranch && next(suspense.activeBranch);
  2426. },
  2427. registerDep(instance, setupRenderEffect) {
  2428. const isInPendingSuspense = !!suspense.pendingBranch;
  2429. if (isInPendingSuspense) {
  2430. suspense.deps++;
  2431. }
  2432. const hydratedEl = instance.vnode.el;
  2433. instance
  2434. .asyncDep.catch(err => {
  2435. handleError(err, instance, 0 /* SETUP_FUNCTION */);
  2436. })
  2437. .then(asyncSetupResult => {
  2438. // retry when the setup() promise resolves.
  2439. // component may have been unmounted before resolve.
  2440. if (instance.isUnmounted ||
  2441. suspense.isUnmounted ||
  2442. suspense.pendingId !== instance.suspenseId) {
  2443. return;
  2444. }
  2445. // retry from this component
  2446. instance.asyncResolved = true;
  2447. const { vnode } = instance;
  2448. {
  2449. pushWarningContext(vnode);
  2450. }
  2451. handleSetupResult(instance, asyncSetupResult, false);
  2452. if (hydratedEl) {
  2453. // vnode may have been replaced if an update happened before the
  2454. // async dep is resolved.
  2455. vnode.el = hydratedEl;
  2456. }
  2457. const placeholder = !hydratedEl && instance.subTree.el;
  2458. setupRenderEffect(instance, vnode,
  2459. // component may have been moved before resolve.
  2460. // if this is not a hydration, instance.subTree will be the comment
  2461. // placeholder.
  2462. parentNode(hydratedEl || instance.subTree.el),
  2463. // anchor will not be used if this is hydration, so only need to
  2464. // consider the comment placeholder case.
  2465. hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
  2466. if (placeholder) {
  2467. remove(placeholder);
  2468. }
  2469. updateHOCHostEl(instance, vnode.el);
  2470. {
  2471. popWarningContext();
  2472. }
  2473. // only decrease deps count if suspense is not already resolved
  2474. if (isInPendingSuspense && --suspense.deps === 0) {
  2475. suspense.resolve();
  2476. }
  2477. });
  2478. },
  2479. unmount(parentSuspense, doRemove) {
  2480. suspense.isUnmounted = true;
  2481. if (suspense.activeBranch) {
  2482. unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
  2483. }
  2484. if (suspense.pendingBranch) {
  2485. unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
  2486. }
  2487. }
  2488. };
  2489. return suspense;
  2490. }
  2491. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  2492. /* eslint-disable no-restricted-globals */
  2493. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true /* hydrating */));
  2494. // there are two possible scenarios for server-rendered suspense:
  2495. // - success: ssr content should be fully resolved
  2496. // - failure: ssr content should be the fallback branch.
  2497. // however, on the client we don't really know if it has failed or not
  2498. // attempt to hydrate the DOM assuming it has succeeded, but we still
  2499. // need to construct a suspense boundary first
  2500. const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
  2501. if (suspense.deps === 0) {
  2502. suspense.resolve();
  2503. }
  2504. return result;
  2505. /* eslint-enable no-restricted-globals */
  2506. }
  2507. function normalizeSuspenseChildren(vnode) {
  2508. const { shapeFlag, children } = vnode;
  2509. const isSlotChildren = shapeFlag & 32 /* SLOTS_CHILDREN */;
  2510. vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
  2511. vnode.ssFallback = isSlotChildren
  2512. ? normalizeSuspenseSlot(children.fallback)
  2513. : createVNode(Comment);
  2514. }
  2515. function normalizeSuspenseSlot(s) {
  2516. let block;
  2517. if (isFunction(s)) {
  2518. const trackBlock = isBlockTreeEnabled && s._c;
  2519. if (trackBlock) {
  2520. // disableTracking: false
  2521. // allow block tracking for compiled slots
  2522. // (see ./componentRenderContext.ts)
  2523. s._d = false;
  2524. openBlock();
  2525. }
  2526. s = s();
  2527. if (trackBlock) {
  2528. s._d = true;
  2529. block = currentBlock;
  2530. closeBlock();
  2531. }
  2532. }
  2533. if (isArray(s)) {
  2534. const singleChild = filterSingleRoot(s);
  2535. if (!singleChild) {
  2536. warn$1(`<Suspense> slots expect a single root node.`);
  2537. }
  2538. s = singleChild;
  2539. }
  2540. s = normalizeVNode(s);
  2541. if (block && !s.dynamicChildren) {
  2542. s.dynamicChildren = block.filter(c => c !== s);
  2543. }
  2544. return s;
  2545. }
  2546. function queueEffectWithSuspense(fn, suspense) {
  2547. if (suspense && suspense.pendingBranch) {
  2548. if (isArray(fn)) {
  2549. suspense.effects.push(...fn);
  2550. }
  2551. else {
  2552. suspense.effects.push(fn);
  2553. }
  2554. }
  2555. else {
  2556. queuePostFlushCb(fn);
  2557. }
  2558. }
  2559. function setActiveBranch(suspense, branch) {
  2560. suspense.activeBranch = branch;
  2561. const { vnode, parentComponent } = suspense;
  2562. const el = (vnode.el = branch.el);
  2563. // in case suspense is the root node of a component,
  2564. // recursively update the HOC el
  2565. if (parentComponent && parentComponent.subTree === vnode) {
  2566. parentComponent.vnode.el = el;
  2567. updateHOCHostEl(parentComponent, el);
  2568. }
  2569. }
  2570. function provide(key, value) {
  2571. if (!currentInstance) {
  2572. {
  2573. warn$1(`provide() can only be used inside setup().`);
  2574. }
  2575. }
  2576. else {
  2577. let provides = currentInstance.provides;
  2578. // by default an instance inherits its parent's provides object
  2579. // but when it needs to provide values of its own, it creates its
  2580. // own provides object using parent provides object as prototype.
  2581. // this way in `inject` we can simply look up injections from direct
  2582. // parent and let the prototype chain do the work.
  2583. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  2584. if (parentProvides === provides) {
  2585. provides = currentInstance.provides = Object.create(parentProvides);
  2586. }
  2587. // TS doesn't allow symbol as index type
  2588. provides[key] = value;
  2589. }
  2590. }
  2591. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  2592. // fallback to `currentRenderingInstance` so that this can be called in
  2593. // a functional component
  2594. const instance = currentInstance || currentRenderingInstance;
  2595. if (instance) {
  2596. // #2400
  2597. // to support `app.use` plugins,
  2598. // fallback to appContext's `provides` if the intance is at root
  2599. const provides = instance.parent == null
  2600. ? instance.vnode.appContext && instance.vnode.appContext.provides
  2601. : instance.parent.provides;
  2602. if (provides && key in provides) {
  2603. // TS doesn't allow symbol as index type
  2604. return provides[key];
  2605. }
  2606. else if (arguments.length > 1) {
  2607. return treatDefaultAsFactory && isFunction(defaultValue)
  2608. ? defaultValue.call(instance.proxy)
  2609. : defaultValue;
  2610. }
  2611. else {
  2612. warn$1(`injection "${String(key)}" not found.`);
  2613. }
  2614. }
  2615. else {
  2616. warn$1(`inject() can only be used inside setup() or functional components.`);
  2617. }
  2618. }
  2619. function useTransitionState() {
  2620. const state = {
  2621. isMounted: false,
  2622. isLeaving: false,
  2623. isUnmounting: false,
  2624. leavingVNodes: new Map()
  2625. };
  2626. onMounted(() => {
  2627. state.isMounted = true;
  2628. });
  2629. onBeforeUnmount(() => {
  2630. state.isUnmounting = true;
  2631. });
  2632. return state;
  2633. }
  2634. const TransitionHookValidator = [Function, Array];
  2635. const BaseTransitionImpl = {
  2636. name: `BaseTransition`,
  2637. props: {
  2638. mode: String,
  2639. appear: Boolean,
  2640. persisted: Boolean,
  2641. // enter
  2642. onBeforeEnter: TransitionHookValidator,
  2643. onEnter: TransitionHookValidator,
  2644. onAfterEnter: TransitionHookValidator,
  2645. onEnterCancelled: TransitionHookValidator,
  2646. // leave
  2647. onBeforeLeave: TransitionHookValidator,
  2648. onLeave: TransitionHookValidator,
  2649. onAfterLeave: TransitionHookValidator,
  2650. onLeaveCancelled: TransitionHookValidator,
  2651. // appear
  2652. onBeforeAppear: TransitionHookValidator,
  2653. onAppear: TransitionHookValidator,
  2654. onAfterAppear: TransitionHookValidator,
  2655. onAppearCancelled: TransitionHookValidator
  2656. },
  2657. setup(props, { slots }) {
  2658. const instance = getCurrentInstance();
  2659. const state = useTransitionState();
  2660. let prevTransitionKey;
  2661. return () => {
  2662. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  2663. if (!children || !children.length) {
  2664. return;
  2665. }
  2666. // warn multiple elements
  2667. if (children.length > 1) {
  2668. warn$1('<transition> can only be used on a single element or component. Use ' +
  2669. '<transition-group> for lists.');
  2670. }
  2671. // there's no need to track reactivity for these props so use the raw
  2672. // props for a bit better perf
  2673. const rawProps = toRaw(props);
  2674. const { mode } = rawProps;
  2675. // check mode
  2676. if (mode &&
  2677. mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
  2678. warn$1(`invalid <transition> mode: ${mode}`);
  2679. }
  2680. // at this point children has a guaranteed length of 1.
  2681. const child = children[0];
  2682. if (state.isLeaving) {
  2683. return emptyPlaceholder(child);
  2684. }
  2685. // in the case of <transition><keep-alive/></transition>, we need to
  2686. // compare the type of the kept-alive children.
  2687. const innerChild = getKeepAliveChild(child);
  2688. if (!innerChild) {
  2689. return emptyPlaceholder(child);
  2690. }
  2691. const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
  2692. setTransitionHooks(innerChild, enterHooks);
  2693. const oldChild = instance.subTree;
  2694. const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  2695. let transitionKeyChanged = false;
  2696. const { getTransitionKey } = innerChild.type;
  2697. if (getTransitionKey) {
  2698. const key = getTransitionKey();
  2699. if (prevTransitionKey === undefined) {
  2700. prevTransitionKey = key;
  2701. }
  2702. else if (key !== prevTransitionKey) {
  2703. prevTransitionKey = key;
  2704. transitionKeyChanged = true;
  2705. }
  2706. }
  2707. // handle mode
  2708. if (oldInnerChild &&
  2709. oldInnerChild.type !== Comment &&
  2710. (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  2711. const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
  2712. // update old tree's hooks in case of dynamic transition
  2713. setTransitionHooks(oldInnerChild, leavingHooks);
  2714. // switching between different views
  2715. if (mode === 'out-in') {
  2716. state.isLeaving = true;
  2717. // return placeholder node and queue update when leave finishes
  2718. leavingHooks.afterLeave = () => {
  2719. state.isLeaving = false;
  2720. instance.update();
  2721. };
  2722. return emptyPlaceholder(child);
  2723. }
  2724. else if (mode === 'in-out' && innerChild.type !== Comment) {
  2725. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  2726. const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
  2727. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  2728. // early removal callback
  2729. el._leaveCb = () => {
  2730. earlyRemove();
  2731. el._leaveCb = undefined;
  2732. delete enterHooks.delayedLeave;
  2733. };
  2734. enterHooks.delayedLeave = delayedLeave;
  2735. };
  2736. }
  2737. }
  2738. return child;
  2739. };
  2740. }
  2741. };
  2742. // export the public type for h/tsx inference
  2743. // also to avoid inline import() in generated d.ts files
  2744. const BaseTransition = BaseTransitionImpl;
  2745. function getLeavingNodesForType(state, vnode) {
  2746. const { leavingVNodes } = state;
  2747. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  2748. if (!leavingVNodesCache) {
  2749. leavingVNodesCache = Object.create(null);
  2750. leavingVNodes.set(vnode.type, leavingVNodesCache);
  2751. }
  2752. return leavingVNodesCache;
  2753. }
  2754. // The transition hooks are attached to the vnode as vnode.transition
  2755. // and will be called at appropriate timing in the renderer.
  2756. function resolveTransitionHooks(vnode, props, state, instance) {
  2757. const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
  2758. const key = String(vnode.key);
  2759. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  2760. const callHook = (hook, args) => {
  2761. hook &&
  2762. callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
  2763. };
  2764. const hooks = {
  2765. mode,
  2766. persisted,
  2767. beforeEnter(el) {
  2768. let hook = onBeforeEnter;
  2769. if (!state.isMounted) {
  2770. if (appear) {
  2771. hook = onBeforeAppear || onBeforeEnter;
  2772. }
  2773. else {
  2774. return;
  2775. }
  2776. }
  2777. // for same element (v-show)
  2778. if (el._leaveCb) {
  2779. el._leaveCb(true /* cancelled */);
  2780. }
  2781. // for toggled element with same key (v-if)
  2782. const leavingVNode = leavingVNodesCache[key];
  2783. if (leavingVNode &&
  2784. isSameVNodeType(vnode, leavingVNode) &&
  2785. leavingVNode.el._leaveCb) {
  2786. // force early removal (not cancelled)
  2787. leavingVNode.el._leaveCb();
  2788. }
  2789. callHook(hook, [el]);
  2790. },
  2791. enter(el) {
  2792. let hook = onEnter;
  2793. let afterHook = onAfterEnter;
  2794. let cancelHook = onEnterCancelled;
  2795. if (!state.isMounted) {
  2796. if (appear) {
  2797. hook = onAppear || onEnter;
  2798. afterHook = onAfterAppear || onAfterEnter;
  2799. cancelHook = onAppearCancelled || onEnterCancelled;
  2800. }
  2801. else {
  2802. return;
  2803. }
  2804. }
  2805. let called = false;
  2806. const done = (el._enterCb = (cancelled) => {
  2807. if (called)
  2808. return;
  2809. called = true;
  2810. if (cancelled) {
  2811. callHook(cancelHook, [el]);
  2812. }
  2813. else {
  2814. callHook(afterHook, [el]);
  2815. }
  2816. if (hooks.delayedLeave) {
  2817. hooks.delayedLeave();
  2818. }
  2819. el._enterCb = undefined;
  2820. });
  2821. if (hook) {
  2822. hook(el, done);
  2823. if (hook.length <= 1) {
  2824. done();
  2825. }
  2826. }
  2827. else {
  2828. done();
  2829. }
  2830. },
  2831. leave(el, remove) {
  2832. const key = String(vnode.key);
  2833. if (el._enterCb) {
  2834. el._enterCb(true /* cancelled */);
  2835. }
  2836. if (state.isUnmounting) {
  2837. return remove();
  2838. }
  2839. callHook(onBeforeLeave, [el]);
  2840. let called = false;
  2841. const done = (el._leaveCb = (cancelled) => {
  2842. if (called)
  2843. return;
  2844. called = true;
  2845. remove();
  2846. if (cancelled) {
  2847. callHook(onLeaveCancelled, [el]);
  2848. }
  2849. else {
  2850. callHook(onAfterLeave, [el]);
  2851. }
  2852. el._leaveCb = undefined;
  2853. if (leavingVNodesCache[key] === vnode) {
  2854. delete leavingVNodesCache[key];
  2855. }
  2856. });
  2857. leavingVNodesCache[key] = vnode;
  2858. if (onLeave) {
  2859. onLeave(el, done);
  2860. if (onLeave.length <= 1) {
  2861. done();
  2862. }
  2863. }
  2864. else {
  2865. done();
  2866. }
  2867. },
  2868. clone(vnode) {
  2869. return resolveTransitionHooks(vnode, props, state, instance);
  2870. }
  2871. };
  2872. return hooks;
  2873. }
  2874. // the placeholder really only handles one special case: KeepAlive
  2875. // in the case of a KeepAlive in a leave phase we need to return a KeepAlive
  2876. // placeholder with empty content to avoid the KeepAlive instance from being
  2877. // unmounted.
  2878. function emptyPlaceholder(vnode) {
  2879. if (isKeepAlive(vnode)) {
  2880. vnode = cloneVNode(vnode);
  2881. vnode.children = null;
  2882. return vnode;
  2883. }
  2884. }
  2885. function getKeepAliveChild(vnode) {
  2886. return isKeepAlive(vnode)
  2887. ? vnode.children
  2888. ? vnode.children[0]
  2889. : undefined
  2890. : vnode;
  2891. }
  2892. function setTransitionHooks(vnode, hooks) {
  2893. if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) {
  2894. setTransitionHooks(vnode.component.subTree, hooks);
  2895. }
  2896. else if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  2897. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  2898. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  2899. }
  2900. else {
  2901. vnode.transition = hooks;
  2902. }
  2903. }
  2904. function getTransitionRawChildren(children, keepComment = false) {
  2905. let ret = [];
  2906. let keyedFragmentCount = 0;
  2907. for (let i = 0; i < children.length; i++) {
  2908. const child = children[i];
  2909. // handle fragment children case, e.g. v-for
  2910. if (child.type === Fragment) {
  2911. if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
  2912. keyedFragmentCount++;
  2913. ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
  2914. }
  2915. // comment placeholders should be skipped, e.g. v-if
  2916. else if (keepComment || child.type !== Comment) {
  2917. ret.push(child);
  2918. }
  2919. }
  2920. // #1126 if a transition children list contains multiple sub fragments, these
  2921. // fragments will be merged into a flat children array. Since each v-for
  2922. // fragment may contain different static bindings inside, we need to de-op
  2923. // these children to force full diffs to ensure correct behavior.
  2924. if (keyedFragmentCount > 1) {
  2925. for (let i = 0; i < ret.length; i++) {
  2926. ret[i].patchFlag = -2 /* BAIL */;
  2927. }
  2928. }
  2929. return ret;
  2930. }
  2931. // implementation, close to no-op
  2932. function defineComponent(options) {
  2933. return isFunction(options) ? { setup: options, name: options.name } : options;
  2934. }
  2935. const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
  2936. function defineAsyncComponent(source) {
  2937. if (isFunction(source)) {
  2938. source = { loader: source };
  2939. }
  2940. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  2941. suspensible = true, onError: userOnError } = source;
  2942. let pendingRequest = null;
  2943. let resolvedComp;
  2944. let retries = 0;
  2945. const retry = () => {
  2946. retries++;
  2947. pendingRequest = null;
  2948. return load();
  2949. };
  2950. const load = () => {
  2951. let thisRequest;
  2952. return (pendingRequest ||
  2953. (thisRequest = pendingRequest =
  2954. loader()
  2955. .catch(err => {
  2956. err = err instanceof Error ? err : new Error(String(err));
  2957. if (userOnError) {
  2958. return new Promise((resolve, reject) => {
  2959. const userRetry = () => resolve(retry());
  2960. const userFail = () => reject(err);
  2961. userOnError(err, userRetry, userFail, retries + 1);
  2962. });
  2963. }
  2964. else {
  2965. throw err;
  2966. }
  2967. })
  2968. .then((comp) => {
  2969. if (thisRequest !== pendingRequest && pendingRequest) {
  2970. return pendingRequest;
  2971. }
  2972. if (!comp) {
  2973. warn$1(`Async component loader resolved to undefined. ` +
  2974. `If you are using retry(), make sure to return its return value.`);
  2975. }
  2976. // interop module default
  2977. if (comp &&
  2978. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  2979. comp = comp.default;
  2980. }
  2981. if (comp && !isObject(comp) && !isFunction(comp)) {
  2982. throw new Error(`Invalid async component load result: ${comp}`);
  2983. }
  2984. resolvedComp = comp;
  2985. return comp;
  2986. })));
  2987. };
  2988. return defineComponent({
  2989. name: 'AsyncComponentWrapper',
  2990. __asyncLoader: load,
  2991. get __asyncResolved() {
  2992. return resolvedComp;
  2993. },
  2994. setup() {
  2995. const instance = currentInstance;
  2996. // already resolved
  2997. if (resolvedComp) {
  2998. return () => createInnerComp(resolvedComp, instance);
  2999. }
  3000. const onError = (err) => {
  3001. pendingRequest = null;
  3002. handleError(err, instance, 13 /* ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
  3003. };
  3004. // suspense-controlled or SSR.
  3005. if ((suspensible && instance.suspense) ||
  3006. (false )) {
  3007. return load()
  3008. .then(comp => {
  3009. return () => createInnerComp(comp, instance);
  3010. })
  3011. .catch(err => {
  3012. onError(err);
  3013. return () => errorComponent
  3014. ? createVNode(errorComponent, {
  3015. error: err
  3016. })
  3017. : null;
  3018. });
  3019. }
  3020. const loaded = ref(false);
  3021. const error = ref();
  3022. const delayed = ref(!!delay);
  3023. if (delay) {
  3024. setTimeout(() => {
  3025. delayed.value = false;
  3026. }, delay);
  3027. }
  3028. if (timeout != null) {
  3029. setTimeout(() => {
  3030. if (!loaded.value && !error.value) {
  3031. const err = new Error(`Async component timed out after ${timeout}ms.`);
  3032. onError(err);
  3033. error.value = err;
  3034. }
  3035. }, timeout);
  3036. }
  3037. load()
  3038. .then(() => {
  3039. loaded.value = true;
  3040. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  3041. // parent is keep-alive, force update so the loaded component's
  3042. // name is taken into account
  3043. queueJob(instance.parent.update);
  3044. }
  3045. })
  3046. .catch(err => {
  3047. onError(err);
  3048. error.value = err;
  3049. });
  3050. return () => {
  3051. if (loaded.value && resolvedComp) {
  3052. return createInnerComp(resolvedComp, instance);
  3053. }
  3054. else if (error.value && errorComponent) {
  3055. return createVNode(errorComponent, {
  3056. error: error.value
  3057. });
  3058. }
  3059. else if (loadingComponent && !delayed.value) {
  3060. return createVNode(loadingComponent);
  3061. }
  3062. };
  3063. }
  3064. });
  3065. }
  3066. function createInnerComp(comp, { vnode: { ref, props, children } }) {
  3067. const vnode = createVNode(comp, props, children);
  3068. // ensure inner component inherits the async wrapper's ref owner
  3069. vnode.ref = ref;
  3070. return vnode;
  3071. }
  3072. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  3073. const KeepAliveImpl = {
  3074. name: `KeepAlive`,
  3075. // Marker for special handling inside the renderer. We are not using a ===
  3076. // check directly on KeepAlive in the renderer, because importing it directly
  3077. // would prevent it from being tree-shaken.
  3078. __isKeepAlive: true,
  3079. props: {
  3080. include: [String, RegExp, Array],
  3081. exclude: [String, RegExp, Array],
  3082. max: [String, Number]
  3083. },
  3084. setup(props, { slots }) {
  3085. const instance = getCurrentInstance();
  3086. // KeepAlive communicates with the instantiated renderer via the
  3087. // ctx where the renderer passes in its internals,
  3088. // and the KeepAlive instance exposes activate/deactivate implementations.
  3089. // The whole point of this is to avoid importing KeepAlive directly in the
  3090. // renderer to facilitate tree-shaking.
  3091. const sharedContext = instance.ctx;
  3092. // if the internal renderer is not registered, it indicates that this is server-side rendering,
  3093. // for KeepAlive, we just need to render its children
  3094. if (!sharedContext.renderer) {
  3095. return slots.default;
  3096. }
  3097. const cache = new Map();
  3098. const keys = new Set();
  3099. let current = null;
  3100. {
  3101. instance.__v_cache = cache;
  3102. }
  3103. const parentSuspense = instance.suspense;
  3104. const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
  3105. const storageContainer = createElement('div');
  3106. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  3107. const instance = vnode.component;
  3108. move(vnode, container, anchor, 0 /* ENTER */, parentSuspense);
  3109. // in case props have changed
  3110. patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
  3111. queuePostRenderEffect(() => {
  3112. instance.isDeactivated = false;
  3113. if (instance.a) {
  3114. invokeArrayFns(instance.a);
  3115. }
  3116. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  3117. if (vnodeHook) {
  3118. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3119. }
  3120. }, parentSuspense);
  3121. {
  3122. // Update components tree
  3123. devtoolsComponentAdded(instance);
  3124. }
  3125. };
  3126. sharedContext.deactivate = (vnode) => {
  3127. const instance = vnode.component;
  3128. move(vnode, storageContainer, null, 1 /* LEAVE */, parentSuspense);
  3129. queuePostRenderEffect(() => {
  3130. if (instance.da) {
  3131. invokeArrayFns(instance.da);
  3132. }
  3133. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  3134. if (vnodeHook) {
  3135. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3136. }
  3137. instance.isDeactivated = true;
  3138. }, parentSuspense);
  3139. {
  3140. // Update components tree
  3141. devtoolsComponentAdded(instance);
  3142. }
  3143. };
  3144. function unmount(vnode) {
  3145. // reset the shapeFlag so it can be properly unmounted
  3146. resetShapeFlag(vnode);
  3147. _unmount(vnode, instance, parentSuspense);
  3148. }
  3149. function pruneCache(filter) {
  3150. cache.forEach((vnode, key) => {
  3151. const name = getComponentName(vnode.type);
  3152. if (name && (!filter || !filter(name))) {
  3153. pruneCacheEntry(key);
  3154. }
  3155. });
  3156. }
  3157. function pruneCacheEntry(key) {
  3158. const cached = cache.get(key);
  3159. if (!current || cached.type !== current.type) {
  3160. unmount(cached);
  3161. }
  3162. else if (current) {
  3163. // current active instance should no longer be kept-alive.
  3164. // we can't unmount it now but it might be later, so reset its flag now.
  3165. resetShapeFlag(current);
  3166. }
  3167. cache.delete(key);
  3168. keys.delete(key);
  3169. }
  3170. // prune cache on include/exclude prop change
  3171. watch(() => [props.include, props.exclude], ([include, exclude]) => {
  3172. include && pruneCache(name => matches(include, name));
  3173. exclude && pruneCache(name => !matches(exclude, name));
  3174. },
  3175. // prune post-render after `current` has been updated
  3176. { flush: 'post', deep: true });
  3177. // cache sub tree after render
  3178. let pendingCacheKey = null;
  3179. const cacheSubtree = () => {
  3180. // fix #1621, the pendingCacheKey could be 0
  3181. if (pendingCacheKey != null) {
  3182. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  3183. }
  3184. };
  3185. onMounted(cacheSubtree);
  3186. onUpdated(cacheSubtree);
  3187. onBeforeUnmount(() => {
  3188. cache.forEach(cached => {
  3189. const { subTree, suspense } = instance;
  3190. const vnode = getInnerChild(subTree);
  3191. if (cached.type === vnode.type) {
  3192. // current instance will be unmounted as part of keep-alive's unmount
  3193. resetShapeFlag(vnode);
  3194. // but invoke its deactivated hook here
  3195. const da = vnode.component.da;
  3196. da && queuePostRenderEffect(da, suspense);
  3197. return;
  3198. }
  3199. unmount(cached);
  3200. });
  3201. });
  3202. return () => {
  3203. pendingCacheKey = null;
  3204. if (!slots.default) {
  3205. return null;
  3206. }
  3207. const children = slots.default();
  3208. const rawVNode = children[0];
  3209. if (children.length > 1) {
  3210. {
  3211. warn$1(`KeepAlive should contain exactly one component child.`);
  3212. }
  3213. current = null;
  3214. return children;
  3215. }
  3216. else if (!isVNode(rawVNode) ||
  3217. (!(rawVNode.shapeFlag & 4 /* STATEFUL_COMPONENT */) &&
  3218. !(rawVNode.shapeFlag & 128 /* SUSPENSE */))) {
  3219. current = null;
  3220. return rawVNode;
  3221. }
  3222. let vnode = getInnerChild(rawVNode);
  3223. const comp = vnode.type;
  3224. // for async components, name check should be based in its loaded
  3225. // inner component if available
  3226. const name = getComponentName(isAsyncWrapper(vnode)
  3227. ? vnode.type.__asyncResolved || {}
  3228. : comp);
  3229. const { include, exclude, max } = props;
  3230. if ((include && (!name || !matches(include, name))) ||
  3231. (exclude && name && matches(exclude, name))) {
  3232. current = vnode;
  3233. return rawVNode;
  3234. }
  3235. const key = vnode.key == null ? comp : vnode.key;
  3236. const cachedVNode = cache.get(key);
  3237. // clone vnode if it's reused because we are going to mutate it
  3238. if (vnode.el) {
  3239. vnode = cloneVNode(vnode);
  3240. if (rawVNode.shapeFlag & 128 /* SUSPENSE */) {
  3241. rawVNode.ssContent = vnode;
  3242. }
  3243. }
  3244. // #1513 it's possible for the returned vnode to be cloned due to attr
  3245. // fallthrough or scopeId, so the vnode here may not be the final vnode
  3246. // that is mounted. Instead of caching it directly, we store the pending
  3247. // key and cache `instance.subTree` (the normalized vnode) in
  3248. // beforeMount/beforeUpdate hooks.
  3249. pendingCacheKey = key;
  3250. if (cachedVNode) {
  3251. // copy over mounted state
  3252. vnode.el = cachedVNode.el;
  3253. vnode.component = cachedVNode.component;
  3254. if (vnode.transition) {
  3255. // recursively update transition hooks on subTree
  3256. setTransitionHooks(vnode, vnode.transition);
  3257. }
  3258. // avoid vnode being mounted as fresh
  3259. vnode.shapeFlag |= 512 /* COMPONENT_KEPT_ALIVE */;
  3260. // make this key the freshest
  3261. keys.delete(key);
  3262. keys.add(key);
  3263. }
  3264. else {
  3265. keys.add(key);
  3266. // prune oldest entry
  3267. if (max && keys.size > parseInt(max, 10)) {
  3268. pruneCacheEntry(keys.values().next().value);
  3269. }
  3270. }
  3271. // avoid vnode being unmounted
  3272. vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  3273. current = vnode;
  3274. return rawVNode;
  3275. };
  3276. }
  3277. };
  3278. // export the public type for h/tsx inference
  3279. // also to avoid inline import() in generated d.ts files
  3280. const KeepAlive = KeepAliveImpl;
  3281. function matches(pattern, name) {
  3282. if (isArray(pattern)) {
  3283. return pattern.some((p) => matches(p, name));
  3284. }
  3285. else if (isString(pattern)) {
  3286. return pattern.split(',').indexOf(name) > -1;
  3287. }
  3288. else if (pattern.test) {
  3289. return pattern.test(name);
  3290. }
  3291. /* istanbul ignore next */
  3292. return false;
  3293. }
  3294. function onActivated(hook, target) {
  3295. registerKeepAliveHook(hook, "a" /* ACTIVATED */, target);
  3296. }
  3297. function onDeactivated(hook, target) {
  3298. registerKeepAliveHook(hook, "da" /* DEACTIVATED */, target);
  3299. }
  3300. function registerKeepAliveHook(hook, type, target = currentInstance) {
  3301. // cache the deactivate branch check wrapper for injected hooks so the same
  3302. // hook can be properly deduped by the scheduler. "__wdc" stands for "with
  3303. // deactivation check".
  3304. const wrappedHook = hook.__wdc ||
  3305. (hook.__wdc = () => {
  3306. // only fire the hook if the target instance is NOT in a deactivated branch.
  3307. let current = target;
  3308. while (current) {
  3309. if (current.isDeactivated) {
  3310. return;
  3311. }
  3312. current = current.parent;
  3313. }
  3314. return hook();
  3315. });
  3316. injectHook(type, wrappedHook, target);
  3317. // In addition to registering it on the target instance, we walk up the parent
  3318. // chain and register it on all ancestor instances that are keep-alive roots.
  3319. // This avoids the need to walk the entire component tree when invoking these
  3320. // hooks, and more importantly, avoids the need to track child components in
  3321. // arrays.
  3322. if (target) {
  3323. let current = target.parent;
  3324. while (current && current.parent) {
  3325. if (isKeepAlive(current.parent.vnode)) {
  3326. injectToKeepAliveRoot(wrappedHook, type, target, current);
  3327. }
  3328. current = current.parent;
  3329. }
  3330. }
  3331. }
  3332. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  3333. // injectHook wraps the original for error handling, so make sure to remove
  3334. // the wrapped version.
  3335. const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
  3336. onUnmounted(() => {
  3337. remove(keepAliveRoot[type], injected);
  3338. }, target);
  3339. }
  3340. function resetShapeFlag(vnode) {
  3341. let shapeFlag = vnode.shapeFlag;
  3342. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  3343. shapeFlag -= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  3344. }
  3345. if (shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  3346. shapeFlag -= 512 /* COMPONENT_KEPT_ALIVE */;
  3347. }
  3348. vnode.shapeFlag = shapeFlag;
  3349. }
  3350. function getInnerChild(vnode) {
  3351. return vnode.shapeFlag & 128 /* SUSPENSE */ ? vnode.ssContent : vnode;
  3352. }
  3353. function injectHook(type, hook, target = currentInstance, prepend = false) {
  3354. if (target) {
  3355. const hooks = target[type] || (target[type] = []);
  3356. // cache the error handling wrapper for injected hooks so the same hook
  3357. // can be properly deduped by the scheduler. "__weh" stands for "with error
  3358. // handling".
  3359. const wrappedHook = hook.__weh ||
  3360. (hook.__weh = (...args) => {
  3361. if (target.isUnmounted) {
  3362. return;
  3363. }
  3364. // disable tracking inside all lifecycle hooks
  3365. // since they can potentially be called inside effects.
  3366. pauseTracking();
  3367. // Set currentInstance during hook invocation.
  3368. // This assumes the hook does not synchronously trigger other hooks, which
  3369. // can only be false when the user does something really funky.
  3370. setCurrentInstance(target);
  3371. const res = callWithAsyncErrorHandling(hook, target, type, args);
  3372. unsetCurrentInstance();
  3373. resetTracking();
  3374. return res;
  3375. });
  3376. if (prepend) {
  3377. hooks.unshift(wrappedHook);
  3378. }
  3379. else {
  3380. hooks.push(wrappedHook);
  3381. }
  3382. return wrappedHook;
  3383. }
  3384. else {
  3385. const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
  3386. warn$1(`${apiName} is called when there is no active component instance to be ` +
  3387. `associated with. ` +
  3388. `Lifecycle injection APIs can only be used during execution of setup().` +
  3389. (` If you are using async setup(), make sure to register lifecycle ` +
  3390. `hooks before the first await statement.`
  3391. ));
  3392. }
  3393. }
  3394. const createHook = (lifecycle) => (hook, target = currentInstance) =>
  3395. // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
  3396. (!isInSSRComponentSetup || lifecycle === "sp" /* SERVER_PREFETCH */) &&
  3397. injectHook(lifecycle, hook, target);
  3398. const onBeforeMount = createHook("bm" /* BEFORE_MOUNT */);
  3399. const onMounted = createHook("m" /* MOUNTED */);
  3400. const onBeforeUpdate = createHook("bu" /* BEFORE_UPDATE */);
  3401. const onUpdated = createHook("u" /* UPDATED */);
  3402. const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */);
  3403. const onUnmounted = createHook("um" /* UNMOUNTED */);
  3404. const onServerPrefetch = createHook("sp" /* SERVER_PREFETCH */);
  3405. const onRenderTriggered = createHook("rtg" /* RENDER_TRIGGERED */);
  3406. const onRenderTracked = createHook("rtc" /* RENDER_TRACKED */);
  3407. function onErrorCaptured(hook, target = currentInstance) {
  3408. injectHook("ec" /* ERROR_CAPTURED */, hook, target);
  3409. }
  3410. function createDuplicateChecker() {
  3411. const cache = Object.create(null);
  3412. return (type, key) => {
  3413. if (cache[key]) {
  3414. warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
  3415. }
  3416. else {
  3417. cache[key] = type;
  3418. }
  3419. };
  3420. }
  3421. let shouldCacheAccess = true;
  3422. function applyOptions(instance) {
  3423. const options = resolveMergedOptions(instance);
  3424. const publicThis = instance.proxy;
  3425. const ctx = instance.ctx;
  3426. // do not cache property access on public proxy during state initialization
  3427. shouldCacheAccess = false;
  3428. // call beforeCreate first before accessing other options since
  3429. // the hook may mutate resolved options (#2791)
  3430. if (options.beforeCreate) {
  3431. callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
  3432. }
  3433. const {
  3434. // state
  3435. data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
  3436. // lifecycle
  3437. created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
  3438. // public API
  3439. expose, inheritAttrs,
  3440. // assets
  3441. components, directives, filters } = options;
  3442. const checkDuplicateProperties = createDuplicateChecker() ;
  3443. {
  3444. const [propsOptions] = instance.propsOptions;
  3445. if (propsOptions) {
  3446. for (const key in propsOptions) {
  3447. checkDuplicateProperties("Props" /* PROPS */, key);
  3448. }
  3449. }
  3450. }
  3451. // options initialization order (to be consistent with Vue 2):
  3452. // - props (already done outside of this function)
  3453. // - inject
  3454. // - methods
  3455. // - data (deferred since it relies on `this` access)
  3456. // - computed
  3457. // - watch (deferred since it relies on `this` access)
  3458. if (injectOptions) {
  3459. resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
  3460. }
  3461. if (methods) {
  3462. for (const key in methods) {
  3463. const methodHandler = methods[key];
  3464. if (isFunction(methodHandler)) {
  3465. // In dev mode, we use the `createRenderContext` function to define
  3466. // methods to the proxy target, and those are read-only but
  3467. // reconfigurable, so it needs to be redefined here
  3468. {
  3469. Object.defineProperty(ctx, key, {
  3470. value: methodHandler.bind(publicThis),
  3471. configurable: true,
  3472. enumerable: true,
  3473. writable: true
  3474. });
  3475. }
  3476. {
  3477. checkDuplicateProperties("Methods" /* METHODS */, key);
  3478. }
  3479. }
  3480. else {
  3481. warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
  3482. `Did you reference the function correctly?`);
  3483. }
  3484. }
  3485. }
  3486. if (dataOptions) {
  3487. if (!isFunction(dataOptions)) {
  3488. warn$1(`The data option must be a function. ` +
  3489. `Plain object usage is no longer supported.`);
  3490. }
  3491. const data = dataOptions.call(publicThis, publicThis);
  3492. if (isPromise(data)) {
  3493. warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
  3494. `intend to perform data fetching before component renders, use ` +
  3495. `async setup() + <Suspense>.`);
  3496. }
  3497. if (!isObject(data)) {
  3498. warn$1(`data() should return an object.`);
  3499. }
  3500. else {
  3501. instance.data = reactive(data);
  3502. {
  3503. for (const key in data) {
  3504. checkDuplicateProperties("Data" /* DATA */, key);
  3505. // expose data on ctx during dev
  3506. if (key[0] !== '$' && key[0] !== '_') {
  3507. Object.defineProperty(ctx, key, {
  3508. configurable: true,
  3509. enumerable: true,
  3510. get: () => data[key],
  3511. set: NOOP
  3512. });
  3513. }
  3514. }
  3515. }
  3516. }
  3517. }
  3518. // state initialization complete at this point - start caching access
  3519. shouldCacheAccess = true;
  3520. if (computedOptions) {
  3521. for (const key in computedOptions) {
  3522. const opt = computedOptions[key];
  3523. const get = isFunction(opt)
  3524. ? opt.bind(publicThis, publicThis)
  3525. : isFunction(opt.get)
  3526. ? opt.get.bind(publicThis, publicThis)
  3527. : NOOP;
  3528. if (get === NOOP) {
  3529. warn$1(`Computed property "${key}" has no getter.`);
  3530. }
  3531. const set = !isFunction(opt) && isFunction(opt.set)
  3532. ? opt.set.bind(publicThis)
  3533. : () => {
  3534. warn$1(`Write operation failed: computed property "${key}" is readonly.`);
  3535. }
  3536. ;
  3537. const c = computed({
  3538. get,
  3539. set
  3540. });
  3541. Object.defineProperty(ctx, key, {
  3542. enumerable: true,
  3543. configurable: true,
  3544. get: () => c.value,
  3545. set: v => (c.value = v)
  3546. });
  3547. {
  3548. checkDuplicateProperties("Computed" /* COMPUTED */, key);
  3549. }
  3550. }
  3551. }
  3552. if (watchOptions) {
  3553. for (const key in watchOptions) {
  3554. createWatcher(watchOptions[key], ctx, publicThis, key);
  3555. }
  3556. }
  3557. if (provideOptions) {
  3558. const provides = isFunction(provideOptions)
  3559. ? provideOptions.call(publicThis)
  3560. : provideOptions;
  3561. Reflect.ownKeys(provides).forEach(key => {
  3562. provide(key, provides[key]);
  3563. });
  3564. }
  3565. if (created) {
  3566. callHook(created, instance, "c" /* CREATED */);
  3567. }
  3568. function registerLifecycleHook(register, hook) {
  3569. if (isArray(hook)) {
  3570. hook.forEach(_hook => register(_hook.bind(publicThis)));
  3571. }
  3572. else if (hook) {
  3573. register(hook.bind(publicThis));
  3574. }
  3575. }
  3576. registerLifecycleHook(onBeforeMount, beforeMount);
  3577. registerLifecycleHook(onMounted, mounted);
  3578. registerLifecycleHook(onBeforeUpdate, beforeUpdate);
  3579. registerLifecycleHook(onUpdated, updated);
  3580. registerLifecycleHook(onActivated, activated);
  3581. registerLifecycleHook(onDeactivated, deactivated);
  3582. registerLifecycleHook(onErrorCaptured, errorCaptured);
  3583. registerLifecycleHook(onRenderTracked, renderTracked);
  3584. registerLifecycleHook(onRenderTriggered, renderTriggered);
  3585. registerLifecycleHook(onBeforeUnmount, beforeUnmount);
  3586. registerLifecycleHook(onUnmounted, unmounted);
  3587. registerLifecycleHook(onServerPrefetch, serverPrefetch);
  3588. if (isArray(expose)) {
  3589. if (expose.length) {
  3590. const exposed = instance.exposed || (instance.exposed = {});
  3591. expose.forEach(key => {
  3592. Object.defineProperty(exposed, key, {
  3593. get: () => publicThis[key],
  3594. set: val => (publicThis[key] = val)
  3595. });
  3596. });
  3597. }
  3598. else if (!instance.exposed) {
  3599. instance.exposed = {};
  3600. }
  3601. }
  3602. // options that are handled when creating the instance but also need to be
  3603. // applied from mixins
  3604. if (render && instance.render === NOOP) {
  3605. instance.render = render;
  3606. }
  3607. if (inheritAttrs != null) {
  3608. instance.inheritAttrs = inheritAttrs;
  3609. }
  3610. // asset options.
  3611. if (components)
  3612. instance.components = components;
  3613. if (directives)
  3614. instance.directives = directives;
  3615. }
  3616. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
  3617. if (isArray(injectOptions)) {
  3618. injectOptions = normalizeInject(injectOptions);
  3619. }
  3620. for (const key in injectOptions) {
  3621. const opt = injectOptions[key];
  3622. let injected;
  3623. if (isObject(opt)) {
  3624. if ('default' in opt) {
  3625. injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
  3626. }
  3627. else {
  3628. injected = inject(opt.from || key);
  3629. }
  3630. }
  3631. else {
  3632. injected = inject(opt);
  3633. }
  3634. if (isRef(injected)) {
  3635. // TODO remove the check in 3.3
  3636. if (unwrapRef) {
  3637. Object.defineProperty(ctx, key, {
  3638. enumerable: true,
  3639. configurable: true,
  3640. get: () => injected.value,
  3641. set: v => (injected.value = v)
  3642. });
  3643. }
  3644. else {
  3645. {
  3646. warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
  3647. `and no longer needs \`.value\` in the next minor release. ` +
  3648. `To opt-in to the new behavior now, ` +
  3649. `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
  3650. `temporary and will not be needed in the future.)`);
  3651. }
  3652. ctx[key] = injected;
  3653. }
  3654. }
  3655. else {
  3656. ctx[key] = injected;
  3657. }
  3658. {
  3659. checkDuplicateProperties("Inject" /* INJECT */, key);
  3660. }
  3661. }
  3662. }
  3663. function callHook(hook, instance, type) {
  3664. callWithAsyncErrorHandling(isArray(hook)
  3665. ? hook.map(h => h.bind(instance.proxy))
  3666. : hook.bind(instance.proxy), instance, type);
  3667. }
  3668. function createWatcher(raw, ctx, publicThis, key) {
  3669. const getter = key.includes('.')
  3670. ? createPathGetter(publicThis, key)
  3671. : () => publicThis[key];
  3672. if (isString(raw)) {
  3673. const handler = ctx[raw];
  3674. if (isFunction(handler)) {
  3675. watch(getter, handler);
  3676. }
  3677. else {
  3678. warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
  3679. }
  3680. }
  3681. else if (isFunction(raw)) {
  3682. watch(getter, raw.bind(publicThis));
  3683. }
  3684. else if (isObject(raw)) {
  3685. if (isArray(raw)) {
  3686. raw.forEach(r => createWatcher(r, ctx, publicThis, key));
  3687. }
  3688. else {
  3689. const handler = isFunction(raw.handler)
  3690. ? raw.handler.bind(publicThis)
  3691. : ctx[raw.handler];
  3692. if (isFunction(handler)) {
  3693. watch(getter, handler, raw);
  3694. }
  3695. else {
  3696. warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  3697. }
  3698. }
  3699. }
  3700. else {
  3701. warn$1(`Invalid watch option: "${key}"`, raw);
  3702. }
  3703. }
  3704. /**
  3705. * Resolve merged options and cache it on the component.
  3706. * This is done only once per-component since the merging does not involve
  3707. * instances.
  3708. */
  3709. function resolveMergedOptions(instance) {
  3710. const base = instance.type;
  3711. const { mixins, extends: extendsOptions } = base;
  3712. const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
  3713. const cached = cache.get(base);
  3714. let resolved;
  3715. if (cached) {
  3716. resolved = cached;
  3717. }
  3718. else if (!globalMixins.length && !mixins && !extendsOptions) {
  3719. {
  3720. resolved = base;
  3721. }
  3722. }
  3723. else {
  3724. resolved = {};
  3725. if (globalMixins.length) {
  3726. globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
  3727. }
  3728. mergeOptions(resolved, base, optionMergeStrategies);
  3729. }
  3730. cache.set(base, resolved);
  3731. return resolved;
  3732. }
  3733. function mergeOptions(to, from, strats, asMixin = false) {
  3734. const { mixins, extends: extendsOptions } = from;
  3735. if (extendsOptions) {
  3736. mergeOptions(to, extendsOptions, strats, true);
  3737. }
  3738. if (mixins) {
  3739. mixins.forEach((m) => mergeOptions(to, m, strats, true));
  3740. }
  3741. for (const key in from) {
  3742. if (asMixin && key === 'expose') {
  3743. warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
  3744. `It should only be declared in the base component itself.`);
  3745. }
  3746. else {
  3747. const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
  3748. to[key] = strat ? strat(to[key], from[key]) : from[key];
  3749. }
  3750. }
  3751. return to;
  3752. }
  3753. const internalOptionMergeStrats = {
  3754. data: mergeDataFn,
  3755. props: mergeObjectOptions,
  3756. emits: mergeObjectOptions,
  3757. // objects
  3758. methods: mergeObjectOptions,
  3759. computed: mergeObjectOptions,
  3760. // lifecycle
  3761. beforeCreate: mergeAsArray,
  3762. created: mergeAsArray,
  3763. beforeMount: mergeAsArray,
  3764. mounted: mergeAsArray,
  3765. beforeUpdate: mergeAsArray,
  3766. updated: mergeAsArray,
  3767. beforeDestroy: mergeAsArray,
  3768. beforeUnmount: mergeAsArray,
  3769. destroyed: mergeAsArray,
  3770. unmounted: mergeAsArray,
  3771. activated: mergeAsArray,
  3772. deactivated: mergeAsArray,
  3773. errorCaptured: mergeAsArray,
  3774. serverPrefetch: mergeAsArray,
  3775. // assets
  3776. components: mergeObjectOptions,
  3777. directives: mergeObjectOptions,
  3778. // watch
  3779. watch: mergeWatchOptions,
  3780. // provide / inject
  3781. provide: mergeDataFn,
  3782. inject: mergeInject
  3783. };
  3784. function mergeDataFn(to, from) {
  3785. if (!from) {
  3786. return to;
  3787. }
  3788. if (!to) {
  3789. return from;
  3790. }
  3791. return function mergedDataFn() {
  3792. return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
  3793. };
  3794. }
  3795. function mergeInject(to, from) {
  3796. return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  3797. }
  3798. function normalizeInject(raw) {
  3799. if (isArray(raw)) {
  3800. const res = {};
  3801. for (let i = 0; i < raw.length; i++) {
  3802. res[raw[i]] = raw[i];
  3803. }
  3804. return res;
  3805. }
  3806. return raw;
  3807. }
  3808. function mergeAsArray(to, from) {
  3809. return to ? [...new Set([].concat(to, from))] : from;
  3810. }
  3811. function mergeObjectOptions(to, from) {
  3812. return to ? extend(extend(Object.create(null), to), from) : from;
  3813. }
  3814. function mergeWatchOptions(to, from) {
  3815. if (!to)
  3816. return from;
  3817. if (!from)
  3818. return to;
  3819. const merged = extend(Object.create(null), to);
  3820. for (const key in from) {
  3821. merged[key] = mergeAsArray(to[key], from[key]);
  3822. }
  3823. return merged;
  3824. }
  3825. function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
  3826. isSSR = false) {
  3827. const props = {};
  3828. const attrs = {};
  3829. def(attrs, InternalObjectKey, 1);
  3830. instance.propsDefaults = Object.create(null);
  3831. setFullProps(instance, rawProps, props, attrs);
  3832. // ensure all declared prop keys are present
  3833. for (const key in instance.propsOptions[0]) {
  3834. if (!(key in props)) {
  3835. props[key] = undefined;
  3836. }
  3837. }
  3838. // validation
  3839. {
  3840. validateProps(rawProps || {}, props, instance);
  3841. }
  3842. if (isStateful) {
  3843. // stateful
  3844. instance.props = isSSR ? props : shallowReactive(props);
  3845. }
  3846. else {
  3847. if (!instance.type.props) {
  3848. // functional w/ optional props, props === attrs
  3849. instance.props = attrs;
  3850. }
  3851. else {
  3852. // functional w/ declared props
  3853. instance.props = props;
  3854. }
  3855. }
  3856. instance.attrs = attrs;
  3857. }
  3858. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  3859. const { props, attrs, vnode: { patchFlag } } = instance;
  3860. const rawCurrentProps = toRaw(props);
  3861. const [options] = instance.propsOptions;
  3862. let hasAttrsChanged = false;
  3863. if (
  3864. // always force full diff in dev
  3865. // - #1942 if hmr is enabled with sfc component
  3866. // - vite#872 non-sfc component used by sfc component
  3867. !((instance.type.__hmrId ||
  3868. (instance.parent && instance.parent.type.__hmrId))) &&
  3869. (optimized || patchFlag > 0) &&
  3870. !(patchFlag & 16 /* FULL_PROPS */)) {
  3871. if (patchFlag & 8 /* PROPS */) {
  3872. // Compiler-generated props & no keys change, just set the updated
  3873. // the props.
  3874. const propsToUpdate = instance.vnode.dynamicProps;
  3875. for (let i = 0; i < propsToUpdate.length; i++) {
  3876. let key = propsToUpdate[i];
  3877. // PROPS flag guarantees rawProps to be non-null
  3878. const value = rawProps[key];
  3879. if (options) {
  3880. // attr / props separation was done on init and will be consistent
  3881. // in this code path, so just check if attrs have it.
  3882. if (hasOwn(attrs, key)) {
  3883. if (value !== attrs[key]) {
  3884. attrs[key] = value;
  3885. hasAttrsChanged = true;
  3886. }
  3887. }
  3888. else {
  3889. const camelizedKey = camelize(key);
  3890. props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
  3891. }
  3892. }
  3893. else {
  3894. if (value !== attrs[key]) {
  3895. attrs[key] = value;
  3896. hasAttrsChanged = true;
  3897. }
  3898. }
  3899. }
  3900. }
  3901. }
  3902. else {
  3903. // full props update.
  3904. if (setFullProps(instance, rawProps, props, attrs)) {
  3905. hasAttrsChanged = true;
  3906. }
  3907. // in case of dynamic props, check if we need to delete keys from
  3908. // the props object
  3909. let kebabKey;
  3910. for (const key in rawCurrentProps) {
  3911. if (!rawProps ||
  3912. // for camelCase
  3913. (!hasOwn(rawProps, key) &&
  3914. // it's possible the original props was passed in as kebab-case
  3915. // and converted to camelCase (#955)
  3916. ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
  3917. if (options) {
  3918. if (rawPrevProps &&
  3919. // for camelCase
  3920. (rawPrevProps[key] !== undefined ||
  3921. // for kebab-case
  3922. rawPrevProps[kebabKey] !== undefined)) {
  3923. props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
  3924. }
  3925. }
  3926. else {
  3927. delete props[key];
  3928. }
  3929. }
  3930. }
  3931. // in the case of functional component w/o props declaration, props and
  3932. // attrs point to the same object so it should already have been updated.
  3933. if (attrs !== rawCurrentProps) {
  3934. for (const key in attrs) {
  3935. if (!rawProps || !hasOwn(rawProps, key)) {
  3936. delete attrs[key];
  3937. hasAttrsChanged = true;
  3938. }
  3939. }
  3940. }
  3941. }
  3942. // trigger updates for $attrs in case it's used in component slots
  3943. if (hasAttrsChanged) {
  3944. trigger(instance, "set" /* SET */, '$attrs');
  3945. }
  3946. {
  3947. validateProps(rawProps || {}, props, instance);
  3948. }
  3949. }
  3950. function setFullProps(instance, rawProps, props, attrs) {
  3951. const [options, needCastKeys] = instance.propsOptions;
  3952. let hasAttrsChanged = false;
  3953. let rawCastValues;
  3954. if (rawProps) {
  3955. for (let key in rawProps) {
  3956. // key, ref are reserved and never passed down
  3957. if (isReservedProp(key)) {
  3958. continue;
  3959. }
  3960. const value = rawProps[key];
  3961. // prop option names are camelized during normalization, so to support
  3962. // kebab -> camel conversion here we need to camelize the key.
  3963. let camelKey;
  3964. if (options && hasOwn(options, (camelKey = camelize(key)))) {
  3965. if (!needCastKeys || !needCastKeys.includes(camelKey)) {
  3966. props[camelKey] = value;
  3967. }
  3968. else {
  3969. (rawCastValues || (rawCastValues = {}))[camelKey] = value;
  3970. }
  3971. }
  3972. else if (!isEmitListener(instance.emitsOptions, key)) {
  3973. if (!(key in attrs) || value !== attrs[key]) {
  3974. attrs[key] = value;
  3975. hasAttrsChanged = true;
  3976. }
  3977. }
  3978. }
  3979. }
  3980. if (needCastKeys) {
  3981. const rawCurrentProps = toRaw(props);
  3982. const castValues = rawCastValues || EMPTY_OBJ;
  3983. for (let i = 0; i < needCastKeys.length; i++) {
  3984. const key = needCastKeys[i];
  3985. props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
  3986. }
  3987. }
  3988. return hasAttrsChanged;
  3989. }
  3990. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  3991. const opt = options[key];
  3992. if (opt != null) {
  3993. const hasDefault = hasOwn(opt, 'default');
  3994. // default values
  3995. if (hasDefault && value === undefined) {
  3996. const defaultValue = opt.default;
  3997. if (opt.type !== Function && isFunction(defaultValue)) {
  3998. const { propsDefaults } = instance;
  3999. if (key in propsDefaults) {
  4000. value = propsDefaults[key];
  4001. }
  4002. else {
  4003. setCurrentInstance(instance);
  4004. value = propsDefaults[key] = defaultValue.call(null, props);
  4005. unsetCurrentInstance();
  4006. }
  4007. }
  4008. else {
  4009. value = defaultValue;
  4010. }
  4011. }
  4012. // boolean casting
  4013. if (opt[0 /* shouldCast */]) {
  4014. if (isAbsent && !hasDefault) {
  4015. value = false;
  4016. }
  4017. else if (opt[1 /* shouldCastTrue */] &&
  4018. (value === '' || value === hyphenate(key))) {
  4019. value = true;
  4020. }
  4021. }
  4022. }
  4023. return value;
  4024. }
  4025. function normalizePropsOptions(comp, appContext, asMixin = false) {
  4026. const cache = appContext.propsCache;
  4027. const cached = cache.get(comp);
  4028. if (cached) {
  4029. return cached;
  4030. }
  4031. const raw = comp.props;
  4032. const normalized = {};
  4033. const needCastKeys = [];
  4034. // apply mixin/extends props
  4035. let hasExtends = false;
  4036. if (!isFunction(comp)) {
  4037. const extendProps = (raw) => {
  4038. hasExtends = true;
  4039. const [props, keys] = normalizePropsOptions(raw, appContext, true);
  4040. extend(normalized, props);
  4041. if (keys)
  4042. needCastKeys.push(...keys);
  4043. };
  4044. if (!asMixin && appContext.mixins.length) {
  4045. appContext.mixins.forEach(extendProps);
  4046. }
  4047. if (comp.extends) {
  4048. extendProps(comp.extends);
  4049. }
  4050. if (comp.mixins) {
  4051. comp.mixins.forEach(extendProps);
  4052. }
  4053. }
  4054. if (!raw && !hasExtends) {
  4055. cache.set(comp, EMPTY_ARR);
  4056. return EMPTY_ARR;
  4057. }
  4058. if (isArray(raw)) {
  4059. for (let i = 0; i < raw.length; i++) {
  4060. if (!isString(raw[i])) {
  4061. warn$1(`props must be strings when using array syntax.`, raw[i]);
  4062. }
  4063. const normalizedKey = camelize(raw[i]);
  4064. if (validatePropName(normalizedKey)) {
  4065. normalized[normalizedKey] = EMPTY_OBJ;
  4066. }
  4067. }
  4068. }
  4069. else if (raw) {
  4070. if (!isObject(raw)) {
  4071. warn$1(`invalid props options`, raw);
  4072. }
  4073. for (const key in raw) {
  4074. const normalizedKey = camelize(key);
  4075. if (validatePropName(normalizedKey)) {
  4076. const opt = raw[key];
  4077. const prop = (normalized[normalizedKey] =
  4078. isArray(opt) || isFunction(opt) ? { type: opt } : opt);
  4079. if (prop) {
  4080. const booleanIndex = getTypeIndex(Boolean, prop.type);
  4081. const stringIndex = getTypeIndex(String, prop.type);
  4082. prop[0 /* shouldCast */] = booleanIndex > -1;
  4083. prop[1 /* shouldCastTrue */] =
  4084. stringIndex < 0 || booleanIndex < stringIndex;
  4085. // if the prop needs boolean casting or default value
  4086. if (booleanIndex > -1 || hasOwn(prop, 'default')) {
  4087. needCastKeys.push(normalizedKey);
  4088. }
  4089. }
  4090. }
  4091. }
  4092. }
  4093. const res = [normalized, needCastKeys];
  4094. cache.set(comp, res);
  4095. return res;
  4096. }
  4097. function validatePropName(key) {
  4098. if (key[0] !== '$') {
  4099. return true;
  4100. }
  4101. else {
  4102. warn$1(`Invalid prop name: "${key}" is a reserved property.`);
  4103. }
  4104. return false;
  4105. }
  4106. // use function string name to check type constructors
  4107. // so that it works across vms / iframes.
  4108. function getType(ctor) {
  4109. const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
  4110. return match ? match[1] : ctor === null ? 'null' : '';
  4111. }
  4112. function isSameType(a, b) {
  4113. return getType(a) === getType(b);
  4114. }
  4115. function getTypeIndex(type, expectedTypes) {
  4116. if (isArray(expectedTypes)) {
  4117. return expectedTypes.findIndex(t => isSameType(t, type));
  4118. }
  4119. else if (isFunction(expectedTypes)) {
  4120. return isSameType(expectedTypes, type) ? 0 : -1;
  4121. }
  4122. return -1;
  4123. }
  4124. /**
  4125. * dev only
  4126. */
  4127. function validateProps(rawProps, props, instance) {
  4128. const resolvedValues = toRaw(props);
  4129. const options = instance.propsOptions[0];
  4130. for (const key in options) {
  4131. let opt = options[key];
  4132. if (opt == null)
  4133. continue;
  4134. validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
  4135. }
  4136. }
  4137. /**
  4138. * dev only
  4139. */
  4140. function validateProp(name, value, prop, isAbsent) {
  4141. const { type, required, validator } = prop;
  4142. // required!
  4143. if (required && isAbsent) {
  4144. warn$1('Missing required prop: "' + name + '"');
  4145. return;
  4146. }
  4147. // missing but optional
  4148. if (value == null && !prop.required) {
  4149. return;
  4150. }
  4151. // type check
  4152. if (type != null && type !== true) {
  4153. let isValid = false;
  4154. const types = isArray(type) ? type : [type];
  4155. const expectedTypes = [];
  4156. // value is valid as long as one of the specified types match
  4157. for (let i = 0; i < types.length && !isValid; i++) {
  4158. const { valid, expectedType } = assertType(value, types[i]);
  4159. expectedTypes.push(expectedType || '');
  4160. isValid = valid;
  4161. }
  4162. if (!isValid) {
  4163. warn$1(getInvalidTypeMessage(name, value, expectedTypes));
  4164. return;
  4165. }
  4166. }
  4167. // custom validator
  4168. if (validator && !validator(value)) {
  4169. warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
  4170. }
  4171. }
  4172. const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
  4173. /**
  4174. * dev only
  4175. */
  4176. function assertType(value, type) {
  4177. let valid;
  4178. const expectedType = getType(type);
  4179. if (isSimpleType(expectedType)) {
  4180. const t = typeof value;
  4181. valid = t === expectedType.toLowerCase();
  4182. // for primitive wrapper objects
  4183. if (!valid && t === 'object') {
  4184. valid = value instanceof type;
  4185. }
  4186. }
  4187. else if (expectedType === 'Object') {
  4188. valid = isObject(value);
  4189. }
  4190. else if (expectedType === 'Array') {
  4191. valid = isArray(value);
  4192. }
  4193. else if (expectedType === 'null') {
  4194. valid = value === null;
  4195. }
  4196. else {
  4197. valid = value instanceof type;
  4198. }
  4199. return {
  4200. valid,
  4201. expectedType
  4202. };
  4203. }
  4204. /**
  4205. * dev only
  4206. */
  4207. function getInvalidTypeMessage(name, value, expectedTypes) {
  4208. let message = `Invalid prop: type check failed for prop "${name}".` +
  4209. ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
  4210. const expectedType = expectedTypes[0];
  4211. const receivedType = toRawType(value);
  4212. const expectedValue = styleValue(value, expectedType);
  4213. const receivedValue = styleValue(value, receivedType);
  4214. // check if we need to specify expected value
  4215. if (expectedTypes.length === 1 &&
  4216. isExplicable(expectedType) &&
  4217. !isBoolean(expectedType, receivedType)) {
  4218. message += ` with value ${expectedValue}`;
  4219. }
  4220. message += `, got ${receivedType} `;
  4221. // check if we need to specify received value
  4222. if (isExplicable(receivedType)) {
  4223. message += `with value ${receivedValue}.`;
  4224. }
  4225. return message;
  4226. }
  4227. /**
  4228. * dev only
  4229. */
  4230. function styleValue(value, type) {
  4231. if (type === 'String') {
  4232. return `"${value}"`;
  4233. }
  4234. else if (type === 'Number') {
  4235. return `${Number(value)}`;
  4236. }
  4237. else {
  4238. return `${value}`;
  4239. }
  4240. }
  4241. /**
  4242. * dev only
  4243. */
  4244. function isExplicable(type) {
  4245. const explicitTypes = ['string', 'number', 'boolean'];
  4246. return explicitTypes.some(elem => type.toLowerCase() === elem);
  4247. }
  4248. /**
  4249. * dev only
  4250. */
  4251. function isBoolean(...args) {
  4252. return args.some(elem => elem.toLowerCase() === 'boolean');
  4253. }
  4254. const isInternalKey = (key) => key[0] === '_' || key === '$stable';
  4255. const normalizeSlotValue = (value) => isArray(value)
  4256. ? value.map(normalizeVNode)
  4257. : [normalizeVNode(value)];
  4258. const normalizeSlot = (key, rawSlot, ctx) => {
  4259. const normalized = withCtx((...args) => {
  4260. if (currentInstance) {
  4261. warn$1(`Slot "${key}" invoked outside of the render function: ` +
  4262. `this will not track dependencies used in the slot. ` +
  4263. `Invoke the slot function inside the render function instead.`);
  4264. }
  4265. return normalizeSlotValue(rawSlot(...args));
  4266. }, ctx);
  4267. normalized._c = false;
  4268. return normalized;
  4269. };
  4270. const normalizeObjectSlots = (rawSlots, slots, instance) => {
  4271. const ctx = rawSlots._ctx;
  4272. for (const key in rawSlots) {
  4273. if (isInternalKey(key))
  4274. continue;
  4275. const value = rawSlots[key];
  4276. if (isFunction(value)) {
  4277. slots[key] = normalizeSlot(key, value, ctx);
  4278. }
  4279. else if (value != null) {
  4280. {
  4281. warn$1(`Non-function value encountered for slot "${key}". ` +
  4282. `Prefer function slots for better performance.`);
  4283. }
  4284. const normalized = normalizeSlotValue(value);
  4285. slots[key] = () => normalized;
  4286. }
  4287. }
  4288. };
  4289. const normalizeVNodeSlots = (instance, children) => {
  4290. if (!isKeepAlive(instance.vnode) &&
  4291. !(false )) {
  4292. warn$1(`Non-function value encountered for default slot. ` +
  4293. `Prefer function slots for better performance.`);
  4294. }
  4295. const normalized = normalizeSlotValue(children);
  4296. instance.slots.default = () => normalized;
  4297. };
  4298. const initSlots = (instance, children) => {
  4299. if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  4300. const type = children._;
  4301. if (type) {
  4302. // users can get the shallow readonly version of the slots object through `this.$slots`,
  4303. // we should avoid the proxy object polluting the slots of the internal instance
  4304. instance.slots = toRaw(children);
  4305. // make compiler marker non-enumerable
  4306. def(children, '_', type);
  4307. }
  4308. else {
  4309. normalizeObjectSlots(children, (instance.slots = {}));
  4310. }
  4311. }
  4312. else {
  4313. instance.slots = {};
  4314. if (children) {
  4315. normalizeVNodeSlots(instance, children);
  4316. }
  4317. }
  4318. def(instance.slots, InternalObjectKey, 1);
  4319. };
  4320. const updateSlots = (instance, children, optimized) => {
  4321. const { vnode, slots } = instance;
  4322. let needDeletionCheck = true;
  4323. let deletionComparisonTarget = EMPTY_OBJ;
  4324. if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  4325. const type = children._;
  4326. if (type) {
  4327. // compiled slots.
  4328. if (isHmrUpdating) {
  4329. // Parent was HMR updated so slot content may have changed.
  4330. // force update slots and mark instance for hmr as well
  4331. extend(slots, children);
  4332. }
  4333. else if (optimized && type === 1 /* STABLE */) {
  4334. // compiled AND stable.
  4335. // no need to update, and skip stale slots removal.
  4336. needDeletionCheck = false;
  4337. }
  4338. else {
  4339. // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
  4340. // normalization.
  4341. extend(slots, children);
  4342. // #2893
  4343. // when rendering the optimized slots by manually written render function,
  4344. // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
  4345. // i.e. let the `renderSlot` create the bailed Fragment
  4346. if (!optimized && type === 1 /* STABLE */) {
  4347. delete slots._;
  4348. }
  4349. }
  4350. }
  4351. else {
  4352. needDeletionCheck = !children.$stable;
  4353. normalizeObjectSlots(children, slots);
  4354. }
  4355. deletionComparisonTarget = children;
  4356. }
  4357. else if (children) {
  4358. // non slot object children (direct value) passed to a component
  4359. normalizeVNodeSlots(instance, children);
  4360. deletionComparisonTarget = { default: 1 };
  4361. }
  4362. // delete stale slots
  4363. if (needDeletionCheck) {
  4364. for (const key in slots) {
  4365. if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
  4366. delete slots[key];
  4367. }
  4368. }
  4369. }
  4370. };
  4371. /**
  4372. Runtime helper for applying directives to a vnode. Example usage:
  4373. const comp = resolveComponent('comp')
  4374. const foo = resolveDirective('foo')
  4375. const bar = resolveDirective('bar')
  4376. return withDirectives(h(comp), [
  4377. [foo, this.x],
  4378. [bar, this.y]
  4379. ])
  4380. */
  4381. const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
  4382. function validateDirectiveName(name) {
  4383. if (isBuiltInDirective(name)) {
  4384. warn$1('Do not use built-in directive ids as custom directive id: ' + name);
  4385. }
  4386. }
  4387. /**
  4388. * Adds directives to a VNode.
  4389. */
  4390. function withDirectives(vnode, directives) {
  4391. const internalInstance = currentRenderingInstance;
  4392. if (internalInstance === null) {
  4393. warn$1(`withDirectives can only be used inside render functions.`);
  4394. return vnode;
  4395. }
  4396. const instance = internalInstance.proxy;
  4397. const bindings = vnode.dirs || (vnode.dirs = []);
  4398. for (let i = 0; i < directives.length; i++) {
  4399. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  4400. if (isFunction(dir)) {
  4401. dir = {
  4402. mounted: dir,
  4403. updated: dir
  4404. };
  4405. }
  4406. if (dir.deep) {
  4407. traverse(value);
  4408. }
  4409. bindings.push({
  4410. dir,
  4411. instance,
  4412. value,
  4413. oldValue: void 0,
  4414. arg,
  4415. modifiers
  4416. });
  4417. }
  4418. return vnode;
  4419. }
  4420. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  4421. const bindings = vnode.dirs;
  4422. const oldBindings = prevVNode && prevVNode.dirs;
  4423. for (let i = 0; i < bindings.length; i++) {
  4424. const binding = bindings[i];
  4425. if (oldBindings) {
  4426. binding.oldValue = oldBindings[i].value;
  4427. }
  4428. let hook = binding.dir[name];
  4429. if (hook) {
  4430. // disable tracking inside all lifecycle hooks
  4431. // since they can potentially be called inside effects.
  4432. pauseTracking();
  4433. callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
  4434. vnode.el,
  4435. binding,
  4436. vnode,
  4437. prevVNode
  4438. ]);
  4439. resetTracking();
  4440. }
  4441. }
  4442. }
  4443. function createAppContext() {
  4444. return {
  4445. app: null,
  4446. config: {
  4447. isNativeTag: NO,
  4448. performance: false,
  4449. globalProperties: {},
  4450. optionMergeStrategies: {},
  4451. errorHandler: undefined,
  4452. warnHandler: undefined,
  4453. compilerOptions: {}
  4454. },
  4455. mixins: [],
  4456. components: {},
  4457. directives: {},
  4458. provides: Object.create(null),
  4459. optionsCache: new WeakMap(),
  4460. propsCache: new WeakMap(),
  4461. emitsCache: new WeakMap()
  4462. };
  4463. }
  4464. let uid = 0;
  4465. function createAppAPI(render, hydrate) {
  4466. return function createApp(rootComponent, rootProps = null) {
  4467. if (rootProps != null && !isObject(rootProps)) {
  4468. warn$1(`root props passed to app.mount() must be an object.`);
  4469. rootProps = null;
  4470. }
  4471. const context = createAppContext();
  4472. const installedPlugins = new Set();
  4473. let isMounted = false;
  4474. const app = (context.app = {
  4475. _uid: uid++,
  4476. _component: rootComponent,
  4477. _props: rootProps,
  4478. _container: null,
  4479. _context: context,
  4480. _instance: null,
  4481. version,
  4482. get config() {
  4483. return context.config;
  4484. },
  4485. set config(v) {
  4486. {
  4487. warn$1(`app.config cannot be replaced. Modify individual options instead.`);
  4488. }
  4489. },
  4490. use(plugin, ...options) {
  4491. if (installedPlugins.has(plugin)) {
  4492. warn$1(`Plugin has already been applied to target app.`);
  4493. }
  4494. else if (plugin && isFunction(plugin.install)) {
  4495. installedPlugins.add(plugin);
  4496. plugin.install(app, ...options);
  4497. }
  4498. else if (isFunction(plugin)) {
  4499. installedPlugins.add(plugin);
  4500. plugin(app, ...options);
  4501. }
  4502. else {
  4503. warn$1(`A plugin must either be a function or an object with an "install" ` +
  4504. `function.`);
  4505. }
  4506. return app;
  4507. },
  4508. mixin(mixin) {
  4509. {
  4510. if (!context.mixins.includes(mixin)) {
  4511. context.mixins.push(mixin);
  4512. }
  4513. else {
  4514. warn$1('Mixin has already been applied to target app' +
  4515. (mixin.name ? `: ${mixin.name}` : ''));
  4516. }
  4517. }
  4518. return app;
  4519. },
  4520. component(name, component) {
  4521. {
  4522. validateComponentName(name, context.config);
  4523. }
  4524. if (!component) {
  4525. return context.components[name];
  4526. }
  4527. if (context.components[name]) {
  4528. warn$1(`Component "${name}" has already been registered in target app.`);
  4529. }
  4530. context.components[name] = component;
  4531. return app;
  4532. },
  4533. directive(name, directive) {
  4534. {
  4535. validateDirectiveName(name);
  4536. }
  4537. if (!directive) {
  4538. return context.directives[name];
  4539. }
  4540. if (context.directives[name]) {
  4541. warn$1(`Directive "${name}" has already been registered in target app.`);
  4542. }
  4543. context.directives[name] = directive;
  4544. return app;
  4545. },
  4546. mount(rootContainer, isHydrate, isSVG) {
  4547. if (!isMounted) {
  4548. const vnode = createVNode(rootComponent, rootProps);
  4549. // store app context on the root VNode.
  4550. // this will be set on the root instance on initial mount.
  4551. vnode.appContext = context;
  4552. // HMR root reload
  4553. {
  4554. context.reload = () => {
  4555. render(cloneVNode(vnode), rootContainer, isSVG);
  4556. };
  4557. }
  4558. if (isHydrate && hydrate) {
  4559. hydrate(vnode, rootContainer);
  4560. }
  4561. else {
  4562. render(vnode, rootContainer, isSVG);
  4563. }
  4564. isMounted = true;
  4565. app._container = rootContainer;
  4566. rootContainer.__vue_app__ = app;
  4567. {
  4568. app._instance = vnode.component;
  4569. devtoolsInitApp(app, version);
  4570. }
  4571. return getExposeProxy(vnode.component) || vnode.component.proxy;
  4572. }
  4573. else {
  4574. warn$1(`App has already been mounted.\n` +
  4575. `If you want to remount the same app, move your app creation logic ` +
  4576. `into a factory function and create fresh app instances for each ` +
  4577. `mount - e.g. \`const createMyApp = () => createApp(App)\``);
  4578. }
  4579. },
  4580. unmount() {
  4581. if (isMounted) {
  4582. render(null, app._container);
  4583. {
  4584. app._instance = null;
  4585. devtoolsUnmountApp(app);
  4586. }
  4587. delete app._container.__vue_app__;
  4588. }
  4589. else {
  4590. warn$1(`Cannot unmount an app that is not mounted.`);
  4591. }
  4592. },
  4593. provide(key, value) {
  4594. if (key in context.provides) {
  4595. warn$1(`App already provides property with key "${String(key)}". ` +
  4596. `It will be overwritten with the new value.`);
  4597. }
  4598. // TypeScript doesn't allow symbols as index type
  4599. // https://github.com/Microsoft/TypeScript/issues/24587
  4600. context.provides[key] = value;
  4601. return app;
  4602. }
  4603. });
  4604. return app;
  4605. };
  4606. }
  4607. /**
  4608. * Function for handling a template ref
  4609. */
  4610. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  4611. if (isArray(rawRef)) {
  4612. rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
  4613. return;
  4614. }
  4615. if (isAsyncWrapper(vnode) && !isUnmount) {
  4616. // when mounting async components, nothing needs to be done,
  4617. // because the template ref is forwarded to inner component
  4618. return;
  4619. }
  4620. const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
  4621. ? getExposeProxy(vnode.component) || vnode.component.proxy
  4622. : vnode.el;
  4623. const value = isUnmount ? null : refValue;
  4624. const { i: owner, r: ref } = rawRef;
  4625. if (!owner) {
  4626. warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
  4627. `A vnode with ref must be created inside the render function.`);
  4628. return;
  4629. }
  4630. const oldRef = oldRawRef && oldRawRef.r;
  4631. const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
  4632. const setupState = owner.setupState;
  4633. // dynamic ref changed. unset old ref
  4634. if (oldRef != null && oldRef !== ref) {
  4635. if (isString(oldRef)) {
  4636. refs[oldRef] = null;
  4637. if (hasOwn(setupState, oldRef)) {
  4638. setupState[oldRef] = null;
  4639. }
  4640. }
  4641. else if (isRef(oldRef)) {
  4642. oldRef.value = null;
  4643. }
  4644. }
  4645. if (isFunction(ref)) {
  4646. callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
  4647. }
  4648. else {
  4649. const _isString = isString(ref);
  4650. const _isRef = isRef(ref);
  4651. if (_isString || _isRef) {
  4652. const doSet = () => {
  4653. if (rawRef.f) {
  4654. const existing = _isString ? refs[ref] : ref.value;
  4655. if (isUnmount) {
  4656. isArray(existing) && remove(existing, refValue);
  4657. }
  4658. else {
  4659. if (!isArray(existing)) {
  4660. if (_isString) {
  4661. refs[ref] = [refValue];
  4662. }
  4663. else {
  4664. ref.value = [refValue];
  4665. if (rawRef.k)
  4666. refs[rawRef.k] = ref.value;
  4667. }
  4668. }
  4669. else if (!existing.includes(refValue)) {
  4670. existing.push(refValue);
  4671. }
  4672. }
  4673. }
  4674. else if (_isString) {
  4675. refs[ref] = value;
  4676. if (hasOwn(setupState, ref)) {
  4677. setupState[ref] = value;
  4678. }
  4679. }
  4680. else if (isRef(ref)) {
  4681. ref.value = value;
  4682. if (rawRef.k)
  4683. refs[rawRef.k] = value;
  4684. }
  4685. else {
  4686. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  4687. }
  4688. };
  4689. if (value) {
  4690. doSet.id = -1;
  4691. queuePostRenderEffect(doSet, parentSuspense);
  4692. }
  4693. else {
  4694. doSet();
  4695. }
  4696. }
  4697. else {
  4698. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  4699. }
  4700. }
  4701. }
  4702. let hasMismatch = false;
  4703. const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
  4704. const isComment = (node) => node.nodeType === 8 /* COMMENT */;
  4705. // Note: hydration is DOM-specific
  4706. // But we have to place it in core due to tight coupling with core - splitting
  4707. // it out creates a ton of unnecessary complexity.
  4708. // Hydration also depends on some renderer internal logic which needs to be
  4709. // passed in via arguments.
  4710. function createHydrationFunctions(rendererInternals) {
  4711. const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
  4712. const hydrate = (vnode, container) => {
  4713. if (!container.hasChildNodes()) {
  4714. warn$1(`Attempting to hydrate existing markup but container is empty. ` +
  4715. `Performing full mount instead.`);
  4716. patch(null, vnode, container);
  4717. flushPostFlushCbs();
  4718. return;
  4719. }
  4720. hasMismatch = false;
  4721. hydrateNode(container.firstChild, vnode, null, null, null);
  4722. flushPostFlushCbs();
  4723. if (hasMismatch && !false) {
  4724. // this error should show up in production
  4725. console.error(`Hydration completed but contains mismatches.`);
  4726. }
  4727. };
  4728. const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
  4729. const isFragmentStart = isComment(node) && node.data === '[';
  4730. const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
  4731. const { type, ref, shapeFlag } = vnode;
  4732. const domType = node.nodeType;
  4733. vnode.el = node;
  4734. let nextNode = null;
  4735. switch (type) {
  4736. case Text:
  4737. if (domType !== 3 /* TEXT */) {
  4738. nextNode = onMismatch();
  4739. }
  4740. else {
  4741. if (node.data !== vnode.children) {
  4742. hasMismatch = true;
  4743. warn$1(`Hydration text mismatch:` +
  4744. `\n- Client: ${JSON.stringify(node.data)}` +
  4745. `\n- Server: ${JSON.stringify(vnode.children)}`);
  4746. node.data = vnode.children;
  4747. }
  4748. nextNode = nextSibling(node);
  4749. }
  4750. break;
  4751. case Comment:
  4752. if (domType !== 8 /* COMMENT */ || isFragmentStart) {
  4753. nextNode = onMismatch();
  4754. }
  4755. else {
  4756. nextNode = nextSibling(node);
  4757. }
  4758. break;
  4759. case Static:
  4760. if (domType !== 1 /* ELEMENT */) {
  4761. nextNode = onMismatch();
  4762. }
  4763. else {
  4764. // determine anchor, adopt content
  4765. nextNode = node;
  4766. // if the static vnode has its content stripped during build,
  4767. // adopt it from the server-rendered HTML.
  4768. const needToAdoptContent = !vnode.children.length;
  4769. for (let i = 0; i < vnode.staticCount; i++) {
  4770. if (needToAdoptContent)
  4771. vnode.children += nextNode.outerHTML;
  4772. if (i === vnode.staticCount - 1) {
  4773. vnode.anchor = nextNode;
  4774. }
  4775. nextNode = nextSibling(nextNode);
  4776. }
  4777. return nextNode;
  4778. }
  4779. break;
  4780. case Fragment:
  4781. if (!isFragmentStart) {
  4782. nextNode = onMismatch();
  4783. }
  4784. else {
  4785. nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  4786. }
  4787. break;
  4788. default:
  4789. if (shapeFlag & 1 /* ELEMENT */) {
  4790. if (domType !== 1 /* ELEMENT */ ||
  4791. vnode.type.toLowerCase() !==
  4792. node.tagName.toLowerCase()) {
  4793. nextNode = onMismatch();
  4794. }
  4795. else {
  4796. nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  4797. }
  4798. }
  4799. else if (shapeFlag & 6 /* COMPONENT */) {
  4800. // when setting up the render effect, if the initial vnode already
  4801. // has .el set, the component will perform hydration instead of mount
  4802. // on its sub-tree.
  4803. vnode.slotScopeIds = slotScopeIds;
  4804. const container = parentNode(node);
  4805. mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
  4806. // component may be async, so in the case of fragments we cannot rely
  4807. // on component's rendered output to determine the end of the fragment
  4808. // instead, we do a lookahead to find the end anchor node.
  4809. nextNode = isFragmentStart
  4810. ? locateClosingAsyncAnchor(node)
  4811. : nextSibling(node);
  4812. // #3787
  4813. // if component is async, it may get moved / unmounted before its
  4814. // inner component is loaded, so we need to give it a placeholder
  4815. // vnode that matches its adopted DOM.
  4816. if (isAsyncWrapper(vnode)) {
  4817. let subTree;
  4818. if (isFragmentStart) {
  4819. subTree = createVNode(Fragment);
  4820. subTree.anchor = nextNode
  4821. ? nextNode.previousSibling
  4822. : container.lastChild;
  4823. }
  4824. else {
  4825. subTree =
  4826. node.nodeType === 3 ? createTextVNode('') : createVNode('div');
  4827. }
  4828. subTree.el = node;
  4829. vnode.component.subTree = subTree;
  4830. }
  4831. }
  4832. else if (shapeFlag & 64 /* TELEPORT */) {
  4833. if (domType !== 8 /* COMMENT */) {
  4834. nextNode = onMismatch();
  4835. }
  4836. else {
  4837. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
  4838. }
  4839. }
  4840. else if (shapeFlag & 128 /* SUSPENSE */) {
  4841. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
  4842. }
  4843. else {
  4844. warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
  4845. }
  4846. }
  4847. if (ref != null) {
  4848. setRef(ref, null, parentSuspense, vnode);
  4849. }
  4850. return nextNode;
  4851. };
  4852. const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  4853. optimized = optimized || !!vnode.dynamicChildren;
  4854. const { type, props, patchFlag, shapeFlag, dirs } = vnode;
  4855. // #4006 for form elements with non-string v-model value bindings
  4856. // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
  4857. const forcePatchValue = (type === 'input' && dirs) || type === 'option';
  4858. // skip props & children if this is hoisted static nodes
  4859. if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
  4860. if (dirs) {
  4861. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  4862. }
  4863. // props
  4864. if (props) {
  4865. if (forcePatchValue ||
  4866. !optimized ||
  4867. patchFlag & (16 /* FULL_PROPS */ | 32 /* HYDRATE_EVENTS */)) {
  4868. for (const key in props) {
  4869. if ((forcePatchValue && key.endsWith('value')) ||
  4870. (isOn(key) && !isReservedProp(key))) {
  4871. patchProp(el, key, null, props[key], false, undefined, parentComponent);
  4872. }
  4873. }
  4874. }
  4875. else if (props.onClick) {
  4876. // Fast path for click listeners (which is most often) to avoid
  4877. // iterating through props.
  4878. patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
  4879. }
  4880. }
  4881. // vnode / directive hooks
  4882. let vnodeHooks;
  4883. if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
  4884. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  4885. }
  4886. if (dirs) {
  4887. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  4888. }
  4889. if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
  4890. queueEffectWithSuspense(() => {
  4891. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  4892. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  4893. }, parentSuspense);
  4894. }
  4895. // children
  4896. if (shapeFlag & 16 /* ARRAY_CHILDREN */ &&
  4897. // skip if element has innerHTML / textContent
  4898. !(props && (props.innerHTML || props.textContent))) {
  4899. let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
  4900. let hasWarned = false;
  4901. while (next) {
  4902. hasMismatch = true;
  4903. if (!hasWarned) {
  4904. warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
  4905. `server rendered element contains more child nodes than client vdom.`);
  4906. hasWarned = true;
  4907. }
  4908. // The SSRed DOM contains more nodes than it should. Remove them.
  4909. const cur = next;
  4910. next = next.nextSibling;
  4911. remove(cur);
  4912. }
  4913. }
  4914. else if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  4915. if (el.textContent !== vnode.children) {
  4916. hasMismatch = true;
  4917. warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
  4918. `- Client: ${el.textContent}\n` +
  4919. `- Server: ${vnode.children}`);
  4920. el.textContent = vnode.children;
  4921. }
  4922. }
  4923. }
  4924. return el.nextSibling;
  4925. };
  4926. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  4927. optimized = optimized || !!parentVNode.dynamicChildren;
  4928. const children = parentVNode.children;
  4929. const l = children.length;
  4930. let hasWarned = false;
  4931. for (let i = 0; i < l; i++) {
  4932. const vnode = optimized
  4933. ? children[i]
  4934. : (children[i] = normalizeVNode(children[i]));
  4935. if (node) {
  4936. node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  4937. }
  4938. else if (vnode.type === Text && !vnode.children) {
  4939. continue;
  4940. }
  4941. else {
  4942. hasMismatch = true;
  4943. if (!hasWarned) {
  4944. warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
  4945. `server rendered element contains fewer child nodes than client vdom.`);
  4946. hasWarned = true;
  4947. }
  4948. // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
  4949. patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  4950. }
  4951. }
  4952. return node;
  4953. };
  4954. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  4955. const { slotScopeIds: fragmentSlotScopeIds } = vnode;
  4956. if (fragmentSlotScopeIds) {
  4957. slotScopeIds = slotScopeIds
  4958. ? slotScopeIds.concat(fragmentSlotScopeIds)
  4959. : fragmentSlotScopeIds;
  4960. }
  4961. const container = parentNode(node);
  4962. const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
  4963. if (next && isComment(next) && next.data === ']') {
  4964. return nextSibling((vnode.anchor = next));
  4965. }
  4966. else {
  4967. // fragment didn't hydrate successfully, since we didn't get a end anchor
  4968. // back. This should have led to node/children mismatch warnings.
  4969. hasMismatch = true;
  4970. // since the anchor is missing, we need to create one and insert it
  4971. insert((vnode.anchor = createComment(`]`)), container, next);
  4972. return next;
  4973. }
  4974. };
  4975. const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  4976. hasMismatch = true;
  4977. warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* TEXT */
  4978. ? `(text)`
  4979. : isComment(node) && node.data === '['
  4980. ? `(start of fragment)`
  4981. : ``);
  4982. vnode.el = null;
  4983. if (isFragment) {
  4984. // remove excessive fragment nodes
  4985. const end = locateClosingAsyncAnchor(node);
  4986. while (true) {
  4987. const next = nextSibling(node);
  4988. if (next && next !== end) {
  4989. remove(next);
  4990. }
  4991. else {
  4992. break;
  4993. }
  4994. }
  4995. }
  4996. const next = nextSibling(node);
  4997. const container = parentNode(node);
  4998. remove(node);
  4999. patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  5000. return next;
  5001. };
  5002. const locateClosingAsyncAnchor = (node) => {
  5003. let match = 0;
  5004. while (node) {
  5005. node = nextSibling(node);
  5006. if (node && isComment(node)) {
  5007. if (node.data === '[')
  5008. match++;
  5009. if (node.data === ']') {
  5010. if (match === 0) {
  5011. return nextSibling(node);
  5012. }
  5013. else {
  5014. match--;
  5015. }
  5016. }
  5017. }
  5018. }
  5019. return node;
  5020. };
  5021. return [hydrate, hydrateNode];
  5022. }
  5023. let supported;
  5024. let perf;
  5025. function startMeasure(instance, type) {
  5026. if (instance.appContext.config.performance && isSupported()) {
  5027. perf.mark(`vue-${type}-${instance.uid}`);
  5028. }
  5029. {
  5030. devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
  5031. }
  5032. }
  5033. function endMeasure(instance, type) {
  5034. if (instance.appContext.config.performance && isSupported()) {
  5035. const startTag = `vue-${type}-${instance.uid}`;
  5036. const endTag = startTag + `:end`;
  5037. perf.mark(endTag);
  5038. perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
  5039. perf.clearMarks(startTag);
  5040. perf.clearMarks(endTag);
  5041. }
  5042. {
  5043. devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
  5044. }
  5045. }
  5046. function isSupported() {
  5047. if (supported !== undefined) {
  5048. return supported;
  5049. }
  5050. /* eslint-disable no-restricted-globals */
  5051. if (typeof window !== 'undefined' && window.performance) {
  5052. supported = true;
  5053. perf = window.performance;
  5054. }
  5055. else {
  5056. supported = false;
  5057. }
  5058. /* eslint-enable no-restricted-globals */
  5059. return supported;
  5060. }
  5061. const queuePostRenderEffect = queueEffectWithSuspense
  5062. ;
  5063. /**
  5064. * The createRenderer function accepts two generic arguments:
  5065. * HostNode and HostElement, corresponding to Node and Element types in the
  5066. * host environment. For example, for runtime-dom, HostNode would be the DOM
  5067. * `Node` interface and HostElement would be the DOM `Element` interface.
  5068. *
  5069. * Custom renderers can pass in the platform specific types like this:
  5070. *
  5071. * ``` js
  5072. * const { render, createApp } = createRenderer<Node, Element>({
  5073. * patchProp,
  5074. * ...nodeOps
  5075. * })
  5076. * ```
  5077. */
  5078. function createRenderer(options) {
  5079. return baseCreateRenderer(options);
  5080. }
  5081. // Separate API for creating hydration-enabled renderer.
  5082. // Hydration logic is only used when calling this function, making it
  5083. // tree-shakable.
  5084. function createHydrationRenderer(options) {
  5085. return baseCreateRenderer(options, createHydrationFunctions);
  5086. }
  5087. // implementation
  5088. function baseCreateRenderer(options, createHydrationFns) {
  5089. const target = getGlobalThis();
  5090. target.__VUE__ = true;
  5091. {
  5092. setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
  5093. }
  5094. const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
  5095. // Note: functions inside this closure should use `const xxx = () => {}`
  5096. // style in order to prevent being inlined by minifiers.
  5097. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  5098. if (n1 === n2) {
  5099. return;
  5100. }
  5101. // patching & not same type, unmount old tree
  5102. if (n1 && !isSameVNodeType(n1, n2)) {
  5103. anchor = getNextHostNode(n1);
  5104. unmount(n1, parentComponent, parentSuspense, true);
  5105. n1 = null;
  5106. }
  5107. if (n2.patchFlag === -2 /* BAIL */) {
  5108. optimized = false;
  5109. n2.dynamicChildren = null;
  5110. }
  5111. const { type, ref, shapeFlag } = n2;
  5112. switch (type) {
  5113. case Text:
  5114. processText(n1, n2, container, anchor);
  5115. break;
  5116. case Comment:
  5117. processCommentNode(n1, n2, container, anchor);
  5118. break;
  5119. case Static:
  5120. if (n1 == null) {
  5121. mountStaticNode(n2, container, anchor, isSVG);
  5122. }
  5123. else {
  5124. patchStaticNode(n1, n2, container, isSVG);
  5125. }
  5126. break;
  5127. case Fragment:
  5128. processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5129. break;
  5130. default:
  5131. if (shapeFlag & 1 /* ELEMENT */) {
  5132. processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5133. }
  5134. else if (shapeFlag & 6 /* COMPONENT */) {
  5135. processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5136. }
  5137. else if (shapeFlag & 64 /* TELEPORT */) {
  5138. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  5139. }
  5140. else if (shapeFlag & 128 /* SUSPENSE */) {
  5141. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  5142. }
  5143. else {
  5144. warn$1('Invalid VNode type:', type, `(${typeof type})`);
  5145. }
  5146. }
  5147. // set ref
  5148. if (ref != null && parentComponent) {
  5149. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
  5150. }
  5151. };
  5152. const processText = (n1, n2, container, anchor) => {
  5153. if (n1 == null) {
  5154. hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
  5155. }
  5156. else {
  5157. const el = (n2.el = n1.el);
  5158. if (n2.children !== n1.children) {
  5159. hostSetText(el, n2.children);
  5160. }
  5161. }
  5162. };
  5163. const processCommentNode = (n1, n2, container, anchor) => {
  5164. if (n1 == null) {
  5165. hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
  5166. }
  5167. else {
  5168. // there's no support for dynamic comments
  5169. n2.el = n1.el;
  5170. }
  5171. };
  5172. const mountStaticNode = (n2, container, anchor, isSVG) => {
  5173. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
  5174. };
  5175. /**
  5176. * Dev / HMR only
  5177. */
  5178. const patchStaticNode = (n1, n2, container, isSVG) => {
  5179. // static nodes are only patched during dev for HMR
  5180. if (n2.children !== n1.children) {
  5181. const anchor = hostNextSibling(n1.anchor);
  5182. // remove existing
  5183. removeStaticNode(n1);
  5184. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
  5185. }
  5186. else {
  5187. n2.el = n1.el;
  5188. n2.anchor = n1.anchor;
  5189. }
  5190. };
  5191. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  5192. let next;
  5193. while (el && el !== anchor) {
  5194. next = hostNextSibling(el);
  5195. hostInsert(el, container, nextSibling);
  5196. el = next;
  5197. }
  5198. hostInsert(anchor, container, nextSibling);
  5199. };
  5200. const removeStaticNode = ({ el, anchor }) => {
  5201. let next;
  5202. while (el && el !== anchor) {
  5203. next = hostNextSibling(el);
  5204. hostRemove(el);
  5205. el = next;
  5206. }
  5207. hostRemove(anchor);
  5208. };
  5209. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  5210. isSVG = isSVG || n2.type === 'svg';
  5211. if (n1 == null) {
  5212. mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5213. }
  5214. else {
  5215. patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5216. }
  5217. };
  5218. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  5219. let el;
  5220. let vnodeHook;
  5221. const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
  5222. {
  5223. el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
  5224. // mount children first, since some props may rely on child content
  5225. // being already rendered, e.g. `<select value>`
  5226. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  5227. hostSetElementText(el, vnode.children);
  5228. }
  5229. else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  5230. mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
  5231. }
  5232. if (dirs) {
  5233. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  5234. }
  5235. // props
  5236. if (props) {
  5237. for (const key in props) {
  5238. if (key !== 'value' && !isReservedProp(key)) {
  5239. hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  5240. }
  5241. }
  5242. /**
  5243. * Special case for setting value on DOM elements:
  5244. * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
  5245. * - it needs to be forced (#1471)
  5246. * #2353 proposes adding another renderer option to configure this, but
  5247. * the properties affects are so finite it is worth special casing it
  5248. * here to reduce the complexity. (Special casing it also should not
  5249. * affect non-DOM renderers)
  5250. */
  5251. if ('value' in props) {
  5252. hostPatchProp(el, 'value', null, props.value);
  5253. }
  5254. if ((vnodeHook = props.onVnodeBeforeMount)) {
  5255. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  5256. }
  5257. }
  5258. // scopeId
  5259. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
  5260. }
  5261. {
  5262. Object.defineProperty(el, '__vnode', {
  5263. value: vnode,
  5264. enumerable: false
  5265. });
  5266. Object.defineProperty(el, '__vueParentComponent', {
  5267. value: parentComponent,
  5268. enumerable: false
  5269. });
  5270. }
  5271. if (dirs) {
  5272. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  5273. }
  5274. // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
  5275. // #1689 For inside suspense + suspense resolved case, just call it
  5276. const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
  5277. transition &&
  5278. !transition.persisted;
  5279. if (needCallTransitionHooks) {
  5280. transition.beforeEnter(el);
  5281. }
  5282. hostInsert(el, container, anchor);
  5283. if ((vnodeHook = props && props.onVnodeMounted) ||
  5284. needCallTransitionHooks ||
  5285. dirs) {
  5286. queuePostRenderEffect(() => {
  5287. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  5288. needCallTransitionHooks && transition.enter(el);
  5289. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  5290. }, parentSuspense);
  5291. }
  5292. };
  5293. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  5294. if (scopeId) {
  5295. hostSetScopeId(el, scopeId);
  5296. }
  5297. if (slotScopeIds) {
  5298. for (let i = 0; i < slotScopeIds.length; i++) {
  5299. hostSetScopeId(el, slotScopeIds[i]);
  5300. }
  5301. }
  5302. if (parentComponent) {
  5303. let subTree = parentComponent.subTree;
  5304. if (subTree.patchFlag > 0 &&
  5305. subTree.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
  5306. subTree =
  5307. filterSingleRoot(subTree.children) || subTree;
  5308. }
  5309. if (vnode === subTree) {
  5310. const parentVNode = parentComponent.vnode;
  5311. setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
  5312. }
  5313. }
  5314. };
  5315. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
  5316. for (let i = start; i < children.length; i++) {
  5317. const child = (children[i] = optimized
  5318. ? cloneIfMounted(children[i])
  5319. : normalizeVNode(children[i]));
  5320. patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5321. }
  5322. };
  5323. const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  5324. const el = (n2.el = n1.el);
  5325. let { patchFlag, dynamicChildren, dirs } = n2;
  5326. // #1426 take the old vnode's patch flag into account since user may clone a
  5327. // compiler-generated vnode, which de-opts to FULL_PROPS
  5328. patchFlag |= n1.patchFlag & 16 /* FULL_PROPS */;
  5329. const oldProps = n1.props || EMPTY_OBJ;
  5330. const newProps = n2.props || EMPTY_OBJ;
  5331. let vnodeHook;
  5332. // disable recurse in beforeUpdate hooks
  5333. parentComponent && toggleRecurse(parentComponent, false);
  5334. if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
  5335. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  5336. }
  5337. if (dirs) {
  5338. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
  5339. }
  5340. parentComponent && toggleRecurse(parentComponent, true);
  5341. if (isHmrUpdating) {
  5342. // HMR updated, force full diff
  5343. patchFlag = 0;
  5344. optimized = false;
  5345. dynamicChildren = null;
  5346. }
  5347. const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
  5348. if (dynamicChildren) {
  5349. patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
  5350. if (parentComponent && parentComponent.type.__hmrId) {
  5351. traverseStaticChildren(n1, n2);
  5352. }
  5353. }
  5354. else if (!optimized) {
  5355. // full diff
  5356. patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
  5357. }
  5358. if (patchFlag > 0) {
  5359. // the presence of a patchFlag means this element's render code was
  5360. // generated by the compiler and can take the fast path.
  5361. // in this path old node and new node are guaranteed to have the same shape
  5362. // (i.e. at the exact same position in the source template)
  5363. if (patchFlag & 16 /* FULL_PROPS */) {
  5364. // element props contain dynamic keys, full diff needed
  5365. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  5366. }
  5367. else {
  5368. // class
  5369. // this flag is matched when the element has dynamic class bindings.
  5370. if (patchFlag & 2 /* CLASS */) {
  5371. if (oldProps.class !== newProps.class) {
  5372. hostPatchProp(el, 'class', null, newProps.class, isSVG);
  5373. }
  5374. }
  5375. // style
  5376. // this flag is matched when the element has dynamic style bindings
  5377. if (patchFlag & 4 /* STYLE */) {
  5378. hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
  5379. }
  5380. // props
  5381. // This flag is matched when the element has dynamic prop/attr bindings
  5382. // other than class and style. The keys of dynamic prop/attrs are saved for
  5383. // faster iteration.
  5384. // Note dynamic keys like :[foo]="bar" will cause this optimization to
  5385. // bail out and go through a full diff because we need to unset the old key
  5386. if (patchFlag & 8 /* PROPS */) {
  5387. // if the flag is present then dynamicProps must be non-null
  5388. const propsToUpdate = n2.dynamicProps;
  5389. for (let i = 0; i < propsToUpdate.length; i++) {
  5390. const key = propsToUpdate[i];
  5391. const prev = oldProps[key];
  5392. const next = newProps[key];
  5393. // #1471 force patch value
  5394. if (next !== prev || key === 'value') {
  5395. hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
  5396. }
  5397. }
  5398. }
  5399. }
  5400. // text
  5401. // This flag is matched when the element has only dynamic text children.
  5402. if (patchFlag & 1 /* TEXT */) {
  5403. if (n1.children !== n2.children) {
  5404. hostSetElementText(el, n2.children);
  5405. }
  5406. }
  5407. }
  5408. else if (!optimized && dynamicChildren == null) {
  5409. // unoptimized, full diff
  5410. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  5411. }
  5412. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  5413. queuePostRenderEffect(() => {
  5414. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  5415. dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
  5416. }, parentSuspense);
  5417. }
  5418. };
  5419. // The fast path for blocks.
  5420. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
  5421. for (let i = 0; i < newChildren.length; i++) {
  5422. const oldVNode = oldChildren[i];
  5423. const newVNode = newChildren[i];
  5424. // Determine the container (parent element) for the patch.
  5425. const container =
  5426. // oldVNode may be an errored async setup() component inside Suspense
  5427. // which will not have a mounted element
  5428. oldVNode.el &&
  5429. // - In the case of a Fragment, we need to provide the actual parent
  5430. // of the Fragment itself so it can move its children.
  5431. (oldVNode.type === Fragment ||
  5432. // - In the case of different nodes, there is going to be a replacement
  5433. // which also requires the correct parent container
  5434. !isSameVNodeType(oldVNode, newVNode) ||
  5435. // - In the case of a component, it could contain anything.
  5436. oldVNode.shapeFlag & (6 /* COMPONENT */ | 64 /* TELEPORT */))
  5437. ? hostParentNode(oldVNode.el)
  5438. : // In other cases, the parent container is not actually used so we
  5439. // just pass the block element here to avoid a DOM parentNode call.
  5440. fallbackContainer;
  5441. patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
  5442. }
  5443. };
  5444. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  5445. if (oldProps !== newProps) {
  5446. for (const key in newProps) {
  5447. // empty string is not valid prop
  5448. if (isReservedProp(key))
  5449. continue;
  5450. const next = newProps[key];
  5451. const prev = oldProps[key];
  5452. // defer patching value
  5453. if (next !== prev && key !== 'value') {
  5454. hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  5455. }
  5456. }
  5457. if (oldProps !== EMPTY_OBJ) {
  5458. for (const key in oldProps) {
  5459. if (!isReservedProp(key) && !(key in newProps)) {
  5460. hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  5461. }
  5462. }
  5463. }
  5464. if ('value' in newProps) {
  5465. hostPatchProp(el, 'value', oldProps.value, newProps.value);
  5466. }
  5467. }
  5468. };
  5469. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  5470. const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
  5471. const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
  5472. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
  5473. if (isHmrUpdating) {
  5474. // HMR updated, force full diff
  5475. patchFlag = 0;
  5476. optimized = false;
  5477. dynamicChildren = null;
  5478. }
  5479. // check if this is a slot fragment with :slotted scope ids
  5480. if (fragmentSlotScopeIds) {
  5481. slotScopeIds = slotScopeIds
  5482. ? slotScopeIds.concat(fragmentSlotScopeIds)
  5483. : fragmentSlotScopeIds;
  5484. }
  5485. if (n1 == null) {
  5486. hostInsert(fragmentStartAnchor, container, anchor);
  5487. hostInsert(fragmentEndAnchor, container, anchor);
  5488. // a fragment can only have array children
  5489. // since they are either generated by the compiler, or implicitly created
  5490. // from arrays.
  5491. mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5492. }
  5493. else {
  5494. if (patchFlag > 0 &&
  5495. patchFlag & 64 /* STABLE_FRAGMENT */ &&
  5496. dynamicChildren &&
  5497. // #2715 the previous fragment could've been a BAILed one as a result
  5498. // of renderSlot() with no valid children
  5499. n1.dynamicChildren) {
  5500. // a stable fragment (template root or <template v-for>) doesn't need to
  5501. // patch children order, but it may contain dynamicChildren.
  5502. patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
  5503. if (parentComponent && parentComponent.type.__hmrId) {
  5504. traverseStaticChildren(n1, n2);
  5505. }
  5506. else if (
  5507. // #2080 if the stable fragment has a key, it's a <template v-for> that may
  5508. // get moved around. Make sure all root level vnodes inherit el.
  5509. // #2134 or if it's a component root, it may also get moved around
  5510. // as the component is being moved.
  5511. n2.key != null ||
  5512. (parentComponent && n2 === parentComponent.subTree)) {
  5513. traverseStaticChildren(n1, n2, true /* shallow */);
  5514. }
  5515. }
  5516. else {
  5517. // keyed / unkeyed, or manual fragments.
  5518. // for keyed & unkeyed, since they are compiler generated from v-for,
  5519. // each child is guaranteed to be a block so the fragment will never
  5520. // have dynamicChildren.
  5521. patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5522. }
  5523. }
  5524. };
  5525. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  5526. n2.slotScopeIds = slotScopeIds;
  5527. if (n1 == null) {
  5528. if (n2.shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  5529. parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
  5530. }
  5531. else {
  5532. mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  5533. }
  5534. }
  5535. else {
  5536. updateComponent(n1, n2, optimized);
  5537. }
  5538. };
  5539. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  5540. const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
  5541. if (instance.type.__hmrId) {
  5542. registerHMR(instance);
  5543. }
  5544. {
  5545. pushWarningContext(initialVNode);
  5546. startMeasure(instance, `mount`);
  5547. }
  5548. // inject renderer internals for keepAlive
  5549. if (isKeepAlive(initialVNode)) {
  5550. instance.ctx.renderer = internals;
  5551. }
  5552. // resolve props and slots for setup context
  5553. {
  5554. {
  5555. startMeasure(instance, `init`);
  5556. }
  5557. setupComponent(instance);
  5558. {
  5559. endMeasure(instance, `init`);
  5560. }
  5561. }
  5562. // setup() is async. This component relies on async logic to be resolved
  5563. // before proceeding
  5564. if (instance.asyncDep) {
  5565. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  5566. // Give it a placeholder if this is not hydration
  5567. // TODO handle self-defined fallback
  5568. if (!initialVNode.el) {
  5569. const placeholder = (instance.subTree = createVNode(Comment));
  5570. processCommentNode(null, placeholder, container, anchor);
  5571. }
  5572. return;
  5573. }
  5574. setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
  5575. {
  5576. popWarningContext();
  5577. endMeasure(instance, `mount`);
  5578. }
  5579. };
  5580. const updateComponent = (n1, n2, optimized) => {
  5581. const instance = (n2.component = n1.component);
  5582. if (shouldUpdateComponent(n1, n2, optimized)) {
  5583. if (instance.asyncDep &&
  5584. !instance.asyncResolved) {
  5585. // async & still pending - just update props and slots
  5586. // since the component's reactive effect for render isn't set-up yet
  5587. {
  5588. pushWarningContext(n2);
  5589. }
  5590. updateComponentPreRender(instance, n2, optimized);
  5591. {
  5592. popWarningContext();
  5593. }
  5594. return;
  5595. }
  5596. else {
  5597. // normal update
  5598. instance.next = n2;
  5599. // in case the child component is also queued, remove it to avoid
  5600. // double updating the same child component in the same flush.
  5601. invalidateJob(instance.update);
  5602. // instance.update is the reactive effect.
  5603. instance.update();
  5604. }
  5605. }
  5606. else {
  5607. // no update needed. just copy over properties
  5608. n2.component = n1.component;
  5609. n2.el = n1.el;
  5610. instance.vnode = n2;
  5611. }
  5612. };
  5613. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  5614. const componentUpdateFn = () => {
  5615. if (!instance.isMounted) {
  5616. let vnodeHook;
  5617. const { el, props } = initialVNode;
  5618. const { bm, m, parent } = instance;
  5619. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
  5620. toggleRecurse(instance, false);
  5621. // beforeMount hook
  5622. if (bm) {
  5623. invokeArrayFns(bm);
  5624. }
  5625. // onVnodeBeforeMount
  5626. if (!isAsyncWrapperVNode &&
  5627. (vnodeHook = props && props.onVnodeBeforeMount)) {
  5628. invokeVNodeHook(vnodeHook, parent, initialVNode);
  5629. }
  5630. toggleRecurse(instance, true);
  5631. if (el && hydrateNode) {
  5632. // vnode has adopted host node - perform hydration instead of mount.
  5633. const hydrateSubTree = () => {
  5634. {
  5635. startMeasure(instance, `render`);
  5636. }
  5637. instance.subTree = renderComponentRoot(instance);
  5638. {
  5639. endMeasure(instance, `render`);
  5640. }
  5641. {
  5642. startMeasure(instance, `hydrate`);
  5643. }
  5644. hydrateNode(el, instance.subTree, instance, parentSuspense, null);
  5645. {
  5646. endMeasure(instance, `hydrate`);
  5647. }
  5648. };
  5649. if (isAsyncWrapperVNode) {
  5650. initialVNode.type.__asyncLoader().then(
  5651. // note: we are moving the render call into an async callback,
  5652. // which means it won't track dependencies - but it's ok because
  5653. // a server-rendered async wrapper is already in resolved state
  5654. // and it will never need to change.
  5655. () => !instance.isUnmounted && hydrateSubTree());
  5656. }
  5657. else {
  5658. hydrateSubTree();
  5659. }
  5660. }
  5661. else {
  5662. {
  5663. startMeasure(instance, `render`);
  5664. }
  5665. const subTree = (instance.subTree = renderComponentRoot(instance));
  5666. {
  5667. endMeasure(instance, `render`);
  5668. }
  5669. {
  5670. startMeasure(instance, `patch`);
  5671. }
  5672. patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
  5673. {
  5674. endMeasure(instance, `patch`);
  5675. }
  5676. initialVNode.el = subTree.el;
  5677. }
  5678. // mounted hook
  5679. if (m) {
  5680. queuePostRenderEffect(m, parentSuspense);
  5681. }
  5682. // onVnodeMounted
  5683. if (!isAsyncWrapperVNode &&
  5684. (vnodeHook = props && props.onVnodeMounted)) {
  5685. const scopedInitialVNode = initialVNode;
  5686. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
  5687. }
  5688. // activated hook for keep-alive roots.
  5689. // #1742 activated hook must be accessed after first render
  5690. // since the hook may be injected by a child keep-alive
  5691. if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  5692. instance.a && queuePostRenderEffect(instance.a, parentSuspense);
  5693. }
  5694. instance.isMounted = true;
  5695. {
  5696. devtoolsComponentAdded(instance);
  5697. }
  5698. // #2458: deference mount-only object parameters to prevent memleaks
  5699. initialVNode = container = anchor = null;
  5700. }
  5701. else {
  5702. // updateComponent
  5703. // This is triggered by mutation of component's own state (next: null)
  5704. // OR parent calling processComponent (next: VNode)
  5705. let { next, bu, u, parent, vnode } = instance;
  5706. let originNext = next;
  5707. let vnodeHook;
  5708. {
  5709. pushWarningContext(next || instance.vnode);
  5710. }
  5711. // Disallow component effect recursion during pre-lifecycle hooks.
  5712. toggleRecurse(instance, false);
  5713. if (next) {
  5714. next.el = vnode.el;
  5715. updateComponentPreRender(instance, next, optimized);
  5716. }
  5717. else {
  5718. next = vnode;
  5719. }
  5720. // beforeUpdate hook
  5721. if (bu) {
  5722. invokeArrayFns(bu);
  5723. }
  5724. // onVnodeBeforeUpdate
  5725. if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
  5726. invokeVNodeHook(vnodeHook, parent, next, vnode);
  5727. }
  5728. toggleRecurse(instance, true);
  5729. // render
  5730. {
  5731. startMeasure(instance, `render`);
  5732. }
  5733. const nextTree = renderComponentRoot(instance);
  5734. {
  5735. endMeasure(instance, `render`);
  5736. }
  5737. const prevTree = instance.subTree;
  5738. instance.subTree = nextTree;
  5739. {
  5740. startMeasure(instance, `patch`);
  5741. }
  5742. patch(prevTree, nextTree,
  5743. // parent may have changed if it's in a teleport
  5744. hostParentNode(prevTree.el),
  5745. // anchor may have changed if it's in a fragment
  5746. getNextHostNode(prevTree), instance, parentSuspense, isSVG);
  5747. {
  5748. endMeasure(instance, `patch`);
  5749. }
  5750. next.el = nextTree.el;
  5751. if (originNext === null) {
  5752. // self-triggered update. In case of HOC, update parent component
  5753. // vnode el. HOC is indicated by parent instance's subTree pointing
  5754. // to child component's vnode
  5755. updateHOCHostEl(instance, nextTree.el);
  5756. }
  5757. // updated hook
  5758. if (u) {
  5759. queuePostRenderEffect(u, parentSuspense);
  5760. }
  5761. // onVnodeUpdated
  5762. if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
  5763. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
  5764. }
  5765. {
  5766. devtoolsComponentUpdated(instance);
  5767. }
  5768. {
  5769. popWarningContext();
  5770. }
  5771. }
  5772. };
  5773. // create reactive effect for rendering
  5774. const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
  5775. ));
  5776. const update = (instance.update = effect.run.bind(effect));
  5777. update.id = instance.uid;
  5778. // allowRecurse
  5779. // #1801, #2043 component render effects should allow recursive updates
  5780. toggleRecurse(instance, true);
  5781. {
  5782. effect.onTrack = instance.rtc
  5783. ? e => invokeArrayFns(instance.rtc, e)
  5784. : void 0;
  5785. effect.onTrigger = instance.rtg
  5786. ? e => invokeArrayFns(instance.rtg, e)
  5787. : void 0;
  5788. // @ts-ignore (for scheduler)
  5789. update.ownerInstance = instance;
  5790. }
  5791. update();
  5792. };
  5793. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  5794. nextVNode.component = instance;
  5795. const prevProps = instance.vnode.props;
  5796. instance.vnode = nextVNode;
  5797. instance.next = null;
  5798. updateProps(instance, nextVNode.props, prevProps, optimized);
  5799. updateSlots(instance, nextVNode.children, optimized);
  5800. pauseTracking();
  5801. // props update may have triggered pre-flush watchers.
  5802. // flush them before the render update.
  5803. flushPreFlushCbs(undefined, instance.update);
  5804. resetTracking();
  5805. };
  5806. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
  5807. const c1 = n1 && n1.children;
  5808. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  5809. const c2 = n2.children;
  5810. const { patchFlag, shapeFlag } = n2;
  5811. // fast path
  5812. if (patchFlag > 0) {
  5813. if (patchFlag & 128 /* KEYED_FRAGMENT */) {
  5814. // this could be either fully-keyed or mixed (some keyed some not)
  5815. // presence of patchFlag means children are guaranteed to be arrays
  5816. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5817. return;
  5818. }
  5819. else if (patchFlag & 256 /* UNKEYED_FRAGMENT */) {
  5820. // unkeyed
  5821. patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5822. return;
  5823. }
  5824. }
  5825. // children has 3 possibilities: text, array or no children.
  5826. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  5827. // text children fast path
  5828. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  5829. unmountChildren(c1, parentComponent, parentSuspense);
  5830. }
  5831. if (c2 !== c1) {
  5832. hostSetElementText(container, c2);
  5833. }
  5834. }
  5835. else {
  5836. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  5837. // prev children was array
  5838. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  5839. // two arrays, cannot assume anything, do full diff
  5840. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5841. }
  5842. else {
  5843. // no new children, just unmount old
  5844. unmountChildren(c1, parentComponent, parentSuspense, true);
  5845. }
  5846. }
  5847. else {
  5848. // prev children was text OR null
  5849. // new children is array OR null
  5850. if (prevShapeFlag & 8 /* TEXT_CHILDREN */) {
  5851. hostSetElementText(container, '');
  5852. }
  5853. // mount new if array
  5854. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  5855. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5856. }
  5857. }
  5858. }
  5859. };
  5860. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  5861. c1 = c1 || EMPTY_ARR;
  5862. c2 = c2 || EMPTY_ARR;
  5863. const oldLength = c1.length;
  5864. const newLength = c2.length;
  5865. const commonLength = Math.min(oldLength, newLength);
  5866. let i;
  5867. for (i = 0; i < commonLength; i++) {
  5868. const nextChild = (c2[i] = optimized
  5869. ? cloneIfMounted(c2[i])
  5870. : normalizeVNode(c2[i]));
  5871. patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5872. }
  5873. if (oldLength > newLength) {
  5874. // remove old
  5875. unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
  5876. }
  5877. else {
  5878. // mount new
  5879. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
  5880. }
  5881. };
  5882. // can be all-keyed or mixed
  5883. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  5884. let i = 0;
  5885. const l2 = c2.length;
  5886. let e1 = c1.length - 1; // prev ending index
  5887. let e2 = l2 - 1; // next ending index
  5888. // 1. sync from start
  5889. // (a b) c
  5890. // (a b) d e
  5891. while (i <= e1 && i <= e2) {
  5892. const n1 = c1[i];
  5893. const n2 = (c2[i] = optimized
  5894. ? cloneIfMounted(c2[i])
  5895. : normalizeVNode(c2[i]));
  5896. if (isSameVNodeType(n1, n2)) {
  5897. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5898. }
  5899. else {
  5900. break;
  5901. }
  5902. i++;
  5903. }
  5904. // 2. sync from end
  5905. // a (b c)
  5906. // d e (b c)
  5907. while (i <= e1 && i <= e2) {
  5908. const n1 = c1[e1];
  5909. const n2 = (c2[e2] = optimized
  5910. ? cloneIfMounted(c2[e2])
  5911. : normalizeVNode(c2[e2]));
  5912. if (isSameVNodeType(n1, n2)) {
  5913. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5914. }
  5915. else {
  5916. break;
  5917. }
  5918. e1--;
  5919. e2--;
  5920. }
  5921. // 3. common sequence + mount
  5922. // (a b)
  5923. // (a b) c
  5924. // i = 2, e1 = 1, e2 = 2
  5925. // (a b)
  5926. // c (a b)
  5927. // i = 0, e1 = -1, e2 = 0
  5928. if (i > e1) {
  5929. if (i <= e2) {
  5930. const nextPos = e2 + 1;
  5931. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  5932. while (i <= e2) {
  5933. patch(null, (c2[i] = optimized
  5934. ? cloneIfMounted(c2[i])
  5935. : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5936. i++;
  5937. }
  5938. }
  5939. }
  5940. // 4. common sequence + unmount
  5941. // (a b) c
  5942. // (a b)
  5943. // i = 2, e1 = 2, e2 = 1
  5944. // a (b c)
  5945. // (b c)
  5946. // i = 0, e1 = 0, e2 = -1
  5947. else if (i > e2) {
  5948. while (i <= e1) {
  5949. unmount(c1[i], parentComponent, parentSuspense, true);
  5950. i++;
  5951. }
  5952. }
  5953. // 5. unknown sequence
  5954. // [i ... e1 + 1]: a b [c d e] f g
  5955. // [i ... e2 + 1]: a b [e d c h] f g
  5956. // i = 2, e1 = 4, e2 = 5
  5957. else {
  5958. const s1 = i; // prev starting index
  5959. const s2 = i; // next starting index
  5960. // 5.1 build key:index map for newChildren
  5961. const keyToNewIndexMap = new Map();
  5962. for (i = s2; i <= e2; i++) {
  5963. const nextChild = (c2[i] = optimized
  5964. ? cloneIfMounted(c2[i])
  5965. : normalizeVNode(c2[i]));
  5966. if (nextChild.key != null) {
  5967. if (keyToNewIndexMap.has(nextChild.key)) {
  5968. warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
  5969. }
  5970. keyToNewIndexMap.set(nextChild.key, i);
  5971. }
  5972. }
  5973. // 5.2 loop through old children left to be patched and try to patch
  5974. // matching nodes & remove nodes that are no longer present
  5975. let j;
  5976. let patched = 0;
  5977. const toBePatched = e2 - s2 + 1;
  5978. let moved = false;
  5979. // used to track whether any node has moved
  5980. let maxNewIndexSoFar = 0;
  5981. // works as Map<newIndex, oldIndex>
  5982. // Note that oldIndex is offset by +1
  5983. // and oldIndex = 0 is a special value indicating the new node has
  5984. // no corresponding old node.
  5985. // used for determining longest stable subsequence
  5986. const newIndexToOldIndexMap = new Array(toBePatched);
  5987. for (i = 0; i < toBePatched; i++)
  5988. newIndexToOldIndexMap[i] = 0;
  5989. for (i = s1; i <= e1; i++) {
  5990. const prevChild = c1[i];
  5991. if (patched >= toBePatched) {
  5992. // all new children have been patched so this can only be a removal
  5993. unmount(prevChild, parentComponent, parentSuspense, true);
  5994. continue;
  5995. }
  5996. let newIndex;
  5997. if (prevChild.key != null) {
  5998. newIndex = keyToNewIndexMap.get(prevChild.key);
  5999. }
  6000. else {
  6001. // key-less node, try to locate a key-less node of the same type
  6002. for (j = s2; j <= e2; j++) {
  6003. if (newIndexToOldIndexMap[j - s2] === 0 &&
  6004. isSameVNodeType(prevChild, c2[j])) {
  6005. newIndex = j;
  6006. break;
  6007. }
  6008. }
  6009. }
  6010. if (newIndex === undefined) {
  6011. unmount(prevChild, parentComponent, parentSuspense, true);
  6012. }
  6013. else {
  6014. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  6015. if (newIndex >= maxNewIndexSoFar) {
  6016. maxNewIndexSoFar = newIndex;
  6017. }
  6018. else {
  6019. moved = true;
  6020. }
  6021. patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6022. patched++;
  6023. }
  6024. }
  6025. // 5.3 move and mount
  6026. // generate longest stable subsequence only when nodes have moved
  6027. const increasingNewIndexSequence = moved
  6028. ? getSequence(newIndexToOldIndexMap)
  6029. : EMPTY_ARR;
  6030. j = increasingNewIndexSequence.length - 1;
  6031. // looping backwards so that we can use last patched node as anchor
  6032. for (i = toBePatched - 1; i >= 0; i--) {
  6033. const nextIndex = s2 + i;
  6034. const nextChild = c2[nextIndex];
  6035. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  6036. if (newIndexToOldIndexMap[i] === 0) {
  6037. // mount new
  6038. patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6039. }
  6040. else if (moved) {
  6041. // move if:
  6042. // There is no stable subsequence (e.g. a reverse)
  6043. // OR current node is not among the stable sequence
  6044. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  6045. move(nextChild, container, anchor, 2 /* REORDER */);
  6046. }
  6047. else {
  6048. j--;
  6049. }
  6050. }
  6051. }
  6052. }
  6053. };
  6054. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  6055. const { el, type, transition, children, shapeFlag } = vnode;
  6056. if (shapeFlag & 6 /* COMPONENT */) {
  6057. move(vnode.component.subTree, container, anchor, moveType);
  6058. return;
  6059. }
  6060. if (shapeFlag & 128 /* SUSPENSE */) {
  6061. vnode.suspense.move(container, anchor, moveType);
  6062. return;
  6063. }
  6064. if (shapeFlag & 64 /* TELEPORT */) {
  6065. type.move(vnode, container, anchor, internals);
  6066. return;
  6067. }
  6068. if (type === Fragment) {
  6069. hostInsert(el, container, anchor);
  6070. for (let i = 0; i < children.length; i++) {
  6071. move(children[i], container, anchor, moveType);
  6072. }
  6073. hostInsert(vnode.anchor, container, anchor);
  6074. return;
  6075. }
  6076. if (type === Static) {
  6077. moveStaticNode(vnode, container, anchor);
  6078. return;
  6079. }
  6080. // single nodes
  6081. const needTransition = moveType !== 2 /* REORDER */ &&
  6082. shapeFlag & 1 /* ELEMENT */ &&
  6083. transition;
  6084. if (needTransition) {
  6085. if (moveType === 0 /* ENTER */) {
  6086. transition.beforeEnter(el);
  6087. hostInsert(el, container, anchor);
  6088. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  6089. }
  6090. else {
  6091. const { leave, delayLeave, afterLeave } = transition;
  6092. const remove = () => hostInsert(el, container, anchor);
  6093. const performLeave = () => {
  6094. leave(el, () => {
  6095. remove();
  6096. afterLeave && afterLeave();
  6097. });
  6098. };
  6099. if (delayLeave) {
  6100. delayLeave(el, remove, performLeave);
  6101. }
  6102. else {
  6103. performLeave();
  6104. }
  6105. }
  6106. }
  6107. else {
  6108. hostInsert(el, container, anchor);
  6109. }
  6110. };
  6111. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  6112. const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
  6113. // unset ref
  6114. if (ref != null) {
  6115. setRef(ref, null, parentSuspense, vnode, true);
  6116. }
  6117. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  6118. parentComponent.ctx.deactivate(vnode);
  6119. return;
  6120. }
  6121. const shouldInvokeDirs = shapeFlag & 1 /* ELEMENT */ && dirs;
  6122. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
  6123. let vnodeHook;
  6124. if (shouldInvokeVnodeHook &&
  6125. (vnodeHook = props && props.onVnodeBeforeUnmount)) {
  6126. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6127. }
  6128. if (shapeFlag & 6 /* COMPONENT */) {
  6129. unmountComponent(vnode.component, parentSuspense, doRemove);
  6130. }
  6131. else {
  6132. if (shapeFlag & 128 /* SUSPENSE */) {
  6133. vnode.suspense.unmount(parentSuspense, doRemove);
  6134. return;
  6135. }
  6136. if (shouldInvokeDirs) {
  6137. invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
  6138. }
  6139. if (shapeFlag & 64 /* TELEPORT */) {
  6140. vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
  6141. }
  6142. else if (dynamicChildren &&
  6143. // #1153: fast path should not be taken for non-stable (v-for) fragments
  6144. (type !== Fragment ||
  6145. (patchFlag > 0 && patchFlag & 64 /* STABLE_FRAGMENT */))) {
  6146. // fast path for block nodes: only need to unmount dynamic children.
  6147. unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
  6148. }
  6149. else if ((type === Fragment &&
  6150. patchFlag &
  6151. (128 /* KEYED_FRAGMENT */ | 256 /* UNKEYED_FRAGMENT */)) ||
  6152. (!optimized && shapeFlag & 16 /* ARRAY_CHILDREN */)) {
  6153. unmountChildren(children, parentComponent, parentSuspense);
  6154. }
  6155. if (doRemove) {
  6156. remove(vnode);
  6157. }
  6158. }
  6159. if ((shouldInvokeVnodeHook &&
  6160. (vnodeHook = props && props.onVnodeUnmounted)) ||
  6161. shouldInvokeDirs) {
  6162. queuePostRenderEffect(() => {
  6163. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6164. shouldInvokeDirs &&
  6165. invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
  6166. }, parentSuspense);
  6167. }
  6168. };
  6169. const remove = vnode => {
  6170. const { type, el, anchor, transition } = vnode;
  6171. if (type === Fragment) {
  6172. removeFragment(el, anchor);
  6173. return;
  6174. }
  6175. if (type === Static) {
  6176. removeStaticNode(vnode);
  6177. return;
  6178. }
  6179. const performRemove = () => {
  6180. hostRemove(el);
  6181. if (transition && !transition.persisted && transition.afterLeave) {
  6182. transition.afterLeave();
  6183. }
  6184. };
  6185. if (vnode.shapeFlag & 1 /* ELEMENT */ &&
  6186. transition &&
  6187. !transition.persisted) {
  6188. const { leave, delayLeave } = transition;
  6189. const performLeave = () => leave(el, performRemove);
  6190. if (delayLeave) {
  6191. delayLeave(vnode.el, performRemove, performLeave);
  6192. }
  6193. else {
  6194. performLeave();
  6195. }
  6196. }
  6197. else {
  6198. performRemove();
  6199. }
  6200. };
  6201. const removeFragment = (cur, end) => {
  6202. // For fragments, directly remove all contained DOM nodes.
  6203. // (fragment child nodes cannot have transition)
  6204. let next;
  6205. while (cur !== end) {
  6206. next = hostNextSibling(cur);
  6207. hostRemove(cur);
  6208. cur = next;
  6209. }
  6210. hostRemove(end);
  6211. };
  6212. const unmountComponent = (instance, parentSuspense, doRemove) => {
  6213. if (instance.type.__hmrId) {
  6214. unregisterHMR(instance);
  6215. }
  6216. const { bum, scope, update, subTree, um } = instance;
  6217. // beforeUnmount hook
  6218. if (bum) {
  6219. invokeArrayFns(bum);
  6220. }
  6221. // stop effects in component scope
  6222. scope.stop();
  6223. // update may be null if a component is unmounted before its async
  6224. // setup has resolved.
  6225. if (update) {
  6226. // so that scheduler will no longer invoke it
  6227. update.active = false;
  6228. unmount(subTree, instance, parentSuspense, doRemove);
  6229. }
  6230. // unmounted hook
  6231. if (um) {
  6232. queuePostRenderEffect(um, parentSuspense);
  6233. }
  6234. queuePostRenderEffect(() => {
  6235. instance.isUnmounted = true;
  6236. }, parentSuspense);
  6237. // A component with async dep inside a pending suspense is unmounted before
  6238. // its async dep resolves. This should remove the dep from the suspense, and
  6239. // cause the suspense to resolve immediately if that was the last dep.
  6240. if (parentSuspense &&
  6241. parentSuspense.pendingBranch &&
  6242. !parentSuspense.isUnmounted &&
  6243. instance.asyncDep &&
  6244. !instance.asyncResolved &&
  6245. instance.suspenseId === parentSuspense.pendingId) {
  6246. parentSuspense.deps--;
  6247. if (parentSuspense.deps === 0) {
  6248. parentSuspense.resolve();
  6249. }
  6250. }
  6251. {
  6252. devtoolsComponentRemoved(instance);
  6253. }
  6254. };
  6255. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  6256. for (let i = start; i < children.length; i++) {
  6257. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  6258. }
  6259. };
  6260. const getNextHostNode = vnode => {
  6261. if (vnode.shapeFlag & 6 /* COMPONENT */) {
  6262. return getNextHostNode(vnode.component.subTree);
  6263. }
  6264. if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  6265. return vnode.suspense.next();
  6266. }
  6267. return hostNextSibling((vnode.anchor || vnode.el));
  6268. };
  6269. const render = (vnode, container, isSVG) => {
  6270. if (vnode == null) {
  6271. if (container._vnode) {
  6272. unmount(container._vnode, null, null, true);
  6273. }
  6274. }
  6275. else {
  6276. patch(container._vnode || null, vnode, container, null, null, null, isSVG);
  6277. }
  6278. flushPostFlushCbs();
  6279. container._vnode = vnode;
  6280. };
  6281. const internals = {
  6282. p: patch,
  6283. um: unmount,
  6284. m: move,
  6285. r: remove,
  6286. mt: mountComponent,
  6287. mc: mountChildren,
  6288. pc: patchChildren,
  6289. pbc: patchBlockChildren,
  6290. n: getNextHostNode,
  6291. o: options
  6292. };
  6293. let hydrate;
  6294. let hydrateNode;
  6295. if (createHydrationFns) {
  6296. [hydrate, hydrateNode] = createHydrationFns(internals);
  6297. }
  6298. return {
  6299. render,
  6300. hydrate,
  6301. createApp: createAppAPI(render, hydrate)
  6302. };
  6303. }
  6304. function toggleRecurse({ effect, update }, allowed) {
  6305. effect.allowRecurse = update.allowRecurse = allowed;
  6306. }
  6307. /**
  6308. * #1156
  6309. * When a component is HMR-enabled, we need to make sure that all static nodes
  6310. * inside a block also inherit the DOM element from the previous tree so that
  6311. * HMR updates (which are full updates) can retrieve the element for patching.
  6312. *
  6313. * #2080
  6314. * Inside keyed `template` fragment static children, if a fragment is moved,
  6315. * the children will always be moved. Therefore, in order to ensure correct move
  6316. * position, el should be inherited from previous nodes.
  6317. */
  6318. function traverseStaticChildren(n1, n2, shallow = false) {
  6319. const ch1 = n1.children;
  6320. const ch2 = n2.children;
  6321. if (isArray(ch1) && isArray(ch2)) {
  6322. for (let i = 0; i < ch1.length; i++) {
  6323. // this is only called in the optimized path so array children are
  6324. // guaranteed to be vnodes
  6325. const c1 = ch1[i];
  6326. let c2 = ch2[i];
  6327. if (c2.shapeFlag & 1 /* ELEMENT */ && !c2.dynamicChildren) {
  6328. if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* HYDRATE_EVENTS */) {
  6329. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  6330. c2.el = c1.el;
  6331. }
  6332. if (!shallow)
  6333. traverseStaticChildren(c1, c2);
  6334. }
  6335. // also inherit for comment nodes, but not placeholders (e.g. v-if which
  6336. // would have received .el during block patch)
  6337. if (c2.type === Comment && !c2.el) {
  6338. c2.el = c1.el;
  6339. }
  6340. }
  6341. }
  6342. }
  6343. // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
  6344. function getSequence(arr) {
  6345. const p = arr.slice();
  6346. const result = [0];
  6347. let i, j, u, v, c;
  6348. const len = arr.length;
  6349. for (i = 0; i < len; i++) {
  6350. const arrI = arr[i];
  6351. if (arrI !== 0) {
  6352. j = result[result.length - 1];
  6353. if (arr[j] < arrI) {
  6354. p[i] = j;
  6355. result.push(i);
  6356. continue;
  6357. }
  6358. u = 0;
  6359. v = result.length - 1;
  6360. while (u < v) {
  6361. c = (u + v) >> 1;
  6362. if (arr[result[c]] < arrI) {
  6363. u = c + 1;
  6364. }
  6365. else {
  6366. v = c;
  6367. }
  6368. }
  6369. if (arrI < arr[result[u]]) {
  6370. if (u > 0) {
  6371. p[i] = result[u - 1];
  6372. }
  6373. result[u] = i;
  6374. }
  6375. }
  6376. }
  6377. u = result.length;
  6378. v = result[u - 1];
  6379. while (u-- > 0) {
  6380. result[u] = v;
  6381. v = p[v];
  6382. }
  6383. return result;
  6384. }
  6385. const isTeleport = (type) => type.__isTeleport;
  6386. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
  6387. const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
  6388. const resolveTarget = (props, select) => {
  6389. const targetSelector = props && props.to;
  6390. if (isString(targetSelector)) {
  6391. if (!select) {
  6392. warn$1(`Current renderer does not support string target for Teleports. ` +
  6393. `(missing querySelector renderer option)`);
  6394. return null;
  6395. }
  6396. else {
  6397. const target = select(targetSelector);
  6398. if (!target) {
  6399. warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
  6400. `Note the target element must exist before the component is mounted - ` +
  6401. `i.e. the target cannot be rendered by the component itself, and ` +
  6402. `ideally should be outside of the entire Vue component tree.`);
  6403. }
  6404. return target;
  6405. }
  6406. }
  6407. else {
  6408. if (!targetSelector && !isTeleportDisabled(props)) {
  6409. warn$1(`Invalid Teleport target: ${targetSelector}`);
  6410. }
  6411. return targetSelector;
  6412. }
  6413. };
  6414. const TeleportImpl = {
  6415. __isTeleport: true,
  6416. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
  6417. const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
  6418. const disabled = isTeleportDisabled(n2.props);
  6419. let { shapeFlag, children, dynamicChildren } = n2;
  6420. // #3302
  6421. // HMR updated, force full diff
  6422. if (isHmrUpdating) {
  6423. optimized = false;
  6424. dynamicChildren = null;
  6425. }
  6426. if (n1 == null) {
  6427. // insert anchors in the main view
  6428. const placeholder = (n2.el = createComment('teleport start')
  6429. );
  6430. const mainAnchor = (n2.anchor = createComment('teleport end')
  6431. );
  6432. insert(placeholder, container, anchor);
  6433. insert(mainAnchor, container, anchor);
  6434. const target = (n2.target = resolveTarget(n2.props, querySelector));
  6435. const targetAnchor = (n2.targetAnchor = createText(''));
  6436. if (target) {
  6437. insert(targetAnchor, target);
  6438. // #2652 we could be teleporting from a non-SVG tree into an SVG tree
  6439. isSVG = isSVG || isTargetSVG(target);
  6440. }
  6441. else if (!disabled) {
  6442. warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
  6443. }
  6444. const mount = (container, anchor) => {
  6445. // Teleport *always* has Array children. This is enforced in both the
  6446. // compiler and vnode children normalization.
  6447. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  6448. mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6449. }
  6450. };
  6451. if (disabled) {
  6452. mount(container, mainAnchor);
  6453. }
  6454. else if (target) {
  6455. mount(target, targetAnchor);
  6456. }
  6457. }
  6458. else {
  6459. // update content
  6460. n2.el = n1.el;
  6461. const mainAnchor = (n2.anchor = n1.anchor);
  6462. const target = (n2.target = n1.target);
  6463. const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
  6464. const wasDisabled = isTeleportDisabled(n1.props);
  6465. const currentContainer = wasDisabled ? container : target;
  6466. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  6467. isSVG = isSVG || isTargetSVG(target);
  6468. if (dynamicChildren) {
  6469. // fast path when the teleport happens to be a block root
  6470. patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
  6471. // even in block tree mode we need to make sure all root-level nodes
  6472. // in the teleport inherit previous DOM references so that they can
  6473. // be moved in future patches.
  6474. traverseStaticChildren(n1, n2, true);
  6475. }
  6476. else if (!optimized) {
  6477. patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
  6478. }
  6479. if (disabled) {
  6480. if (!wasDisabled) {
  6481. // enabled -> disabled
  6482. // move into main container
  6483. moveTeleport(n2, container, mainAnchor, internals, 1 /* TOGGLE */);
  6484. }
  6485. }
  6486. else {
  6487. // target changed
  6488. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  6489. const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
  6490. if (nextTarget) {
  6491. moveTeleport(n2, nextTarget, null, internals, 0 /* TARGET_CHANGE */);
  6492. }
  6493. else {
  6494. warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
  6495. }
  6496. }
  6497. else if (wasDisabled) {
  6498. // disabled -> enabled
  6499. // move into teleport target
  6500. moveTeleport(n2, target, targetAnchor, internals, 1 /* TOGGLE */);
  6501. }
  6502. }
  6503. }
  6504. },
  6505. remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
  6506. const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
  6507. if (target) {
  6508. hostRemove(targetAnchor);
  6509. }
  6510. // an unmounted teleport should always remove its children if not disabled
  6511. if (doRemove || !isTeleportDisabled(props)) {
  6512. hostRemove(anchor);
  6513. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  6514. for (let i = 0; i < children.length; i++) {
  6515. const child = children[i];
  6516. unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
  6517. }
  6518. }
  6519. }
  6520. },
  6521. move: moveTeleport,
  6522. hydrate: hydrateTeleport
  6523. };
  6524. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
  6525. // move target anchor if this is a target change.
  6526. if (moveType === 0 /* TARGET_CHANGE */) {
  6527. insert(vnode.targetAnchor, container, parentAnchor);
  6528. }
  6529. const { el, anchor, shapeFlag, children, props } = vnode;
  6530. const isReorder = moveType === 2 /* REORDER */;
  6531. // move main view anchor if this is a re-order.
  6532. if (isReorder) {
  6533. insert(el, container, parentAnchor);
  6534. }
  6535. // if this is a re-order and teleport is enabled (content is in target)
  6536. // do not move children. So the opposite is: only move children if this
  6537. // is not a reorder, or the teleport is disabled
  6538. if (!isReorder || isTeleportDisabled(props)) {
  6539. // Teleport has either Array children or no children.
  6540. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  6541. for (let i = 0; i < children.length; i++) {
  6542. move(children[i], container, parentAnchor, 2 /* REORDER */);
  6543. }
  6544. }
  6545. }
  6546. // move main view anchor if this is a re-order.
  6547. if (isReorder) {
  6548. insert(anchor, container, parentAnchor);
  6549. }
  6550. }
  6551. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
  6552. const target = (vnode.target = resolveTarget(vnode.props, querySelector));
  6553. if (target) {
  6554. // if multiple teleports rendered to the same target element, we need to
  6555. // pick up from where the last teleport finished instead of the first node
  6556. const targetNode = target._lpa || target.firstChild;
  6557. if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {
  6558. if (isTeleportDisabled(vnode.props)) {
  6559. vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
  6560. vnode.targetAnchor = targetNode;
  6561. }
  6562. else {
  6563. vnode.anchor = nextSibling(node);
  6564. vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
  6565. }
  6566. target._lpa =
  6567. vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  6568. }
  6569. }
  6570. return vnode.anchor && nextSibling(vnode.anchor);
  6571. }
  6572. // Force-casted public typing for h and TSX props inference
  6573. const Teleport = TeleportImpl;
  6574. const COMPONENTS = 'components';
  6575. const DIRECTIVES = 'directives';
  6576. /**
  6577. * @private
  6578. */
  6579. function resolveComponent(name, maybeSelfReference) {
  6580. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
  6581. }
  6582. const NULL_DYNAMIC_COMPONENT = Symbol();
  6583. /**
  6584. * @private
  6585. */
  6586. function resolveDynamicComponent(component) {
  6587. if (isString(component)) {
  6588. return resolveAsset(COMPONENTS, component, false) || component;
  6589. }
  6590. else {
  6591. // invalid types will fallthrough to createVNode and raise warning
  6592. return (component || NULL_DYNAMIC_COMPONENT);
  6593. }
  6594. }
  6595. /**
  6596. * @private
  6597. */
  6598. function resolveDirective(name) {
  6599. return resolveAsset(DIRECTIVES, name);
  6600. }
  6601. // implementation
  6602. function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
  6603. const instance = currentRenderingInstance || currentInstance;
  6604. if (instance) {
  6605. const Component = instance.type;
  6606. // explicit self name has highest priority
  6607. if (type === COMPONENTS) {
  6608. const selfName = getComponentName(Component);
  6609. if (selfName &&
  6610. (selfName === name ||
  6611. selfName === camelize(name) ||
  6612. selfName === capitalize(camelize(name)))) {
  6613. return Component;
  6614. }
  6615. }
  6616. const res =
  6617. // local registration
  6618. // check instance[type] first which is resolved for options API
  6619. resolve(instance[type] || Component[type], name) ||
  6620. // global registration
  6621. resolve(instance.appContext[type], name);
  6622. if (!res && maybeSelfReference) {
  6623. // fallback to implicit self-reference
  6624. return Component;
  6625. }
  6626. if (warnMissing && !res) {
  6627. const extra = type === COMPONENTS
  6628. ? `\nIf this is a native custom element, make sure to exclude it from ` +
  6629. `component resolution via compilerOptions.isCustomElement.`
  6630. : ``;
  6631. warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
  6632. }
  6633. return res;
  6634. }
  6635. else {
  6636. warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
  6637. `can only be used in render() or setup().`);
  6638. }
  6639. }
  6640. function resolve(registry, name) {
  6641. return (registry &&
  6642. (registry[name] ||
  6643. registry[camelize(name)] ||
  6644. registry[capitalize(camelize(name))]));
  6645. }
  6646. const Fragment = Symbol('Fragment' );
  6647. const Text = Symbol('Text' );
  6648. const Comment = Symbol('Comment' );
  6649. const Static = Symbol('Static' );
  6650. // Since v-if and v-for are the two possible ways node structure can dynamically
  6651. // change, once we consider v-if branches and each v-for fragment a block, we
  6652. // can divide a template into nested blocks, and within each block the node
  6653. // structure would be stable. This allows us to skip most children diffing
  6654. // and only worry about the dynamic nodes (indicated by patch flags).
  6655. const blockStack = [];
  6656. let currentBlock = null;
  6657. /**
  6658. * Open a block.
  6659. * This must be called before `createBlock`. It cannot be part of `createBlock`
  6660. * because the children of the block are evaluated before `createBlock` itself
  6661. * is called. The generated code typically looks like this:
  6662. *
  6663. * ```js
  6664. * function render() {
  6665. * return (openBlock(),createBlock('div', null, [...]))
  6666. * }
  6667. * ```
  6668. * disableTracking is true when creating a v-for fragment block, since a v-for
  6669. * fragment always diffs its children.
  6670. *
  6671. * @private
  6672. */
  6673. function openBlock(disableTracking = false) {
  6674. blockStack.push((currentBlock = disableTracking ? null : []));
  6675. }
  6676. function closeBlock() {
  6677. blockStack.pop();
  6678. currentBlock = blockStack[blockStack.length - 1] || null;
  6679. }
  6680. // Whether we should be tracking dynamic child nodes inside a block.
  6681. // Only tracks when this value is > 0
  6682. // We are not using a simple boolean because this value may need to be
  6683. // incremented/decremented by nested usage of v-once (see below)
  6684. let isBlockTreeEnabled = 1;
  6685. /**
  6686. * Block tracking sometimes needs to be disabled, for example during the
  6687. * creation of a tree that needs to be cached by v-once. The compiler generates
  6688. * code like this:
  6689. *
  6690. * ``` js
  6691. * _cache[1] || (
  6692. * setBlockTracking(-1),
  6693. * _cache[1] = createVNode(...),
  6694. * setBlockTracking(1),
  6695. * _cache[1]
  6696. * )
  6697. * ```
  6698. *
  6699. * @private
  6700. */
  6701. function setBlockTracking(value) {
  6702. isBlockTreeEnabled += value;
  6703. }
  6704. function setupBlock(vnode) {
  6705. // save current block children on the block vnode
  6706. vnode.dynamicChildren =
  6707. isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
  6708. // close block
  6709. closeBlock();
  6710. // a block is always going to be patched, so track it as a child of its
  6711. // parent block
  6712. if (isBlockTreeEnabled > 0 && currentBlock) {
  6713. currentBlock.push(vnode);
  6714. }
  6715. return vnode;
  6716. }
  6717. /**
  6718. * @private
  6719. */
  6720. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  6721. return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true /* isBlock */));
  6722. }
  6723. /**
  6724. * Create a block root vnode. Takes the same exact arguments as `createVNode`.
  6725. * A block root keeps track of dynamic nodes within the block in the
  6726. * `dynamicChildren` array.
  6727. *
  6728. * @private
  6729. */
  6730. function createBlock(type, props, children, patchFlag, dynamicProps) {
  6731. return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */));
  6732. }
  6733. function isVNode(value) {
  6734. return value ? value.__v_isVNode === true : false;
  6735. }
  6736. function isSameVNodeType(n1, n2) {
  6737. if (n2.shapeFlag & 6 /* COMPONENT */ &&
  6738. hmrDirtyComponents.has(n2.type)) {
  6739. // HMR only: if the component has been hot-updated, force a reload.
  6740. return false;
  6741. }
  6742. return n1.type === n2.type && n1.key === n2.key;
  6743. }
  6744. let vnodeArgsTransformer;
  6745. /**
  6746. * Internal API for registering an arguments transform for createVNode
  6747. * used for creating stubs in the test-utils
  6748. * It is *internal* but needs to be exposed for test-utils to pick up proper
  6749. * typings
  6750. */
  6751. function transformVNodeArgs(transformer) {
  6752. vnodeArgsTransformer = transformer;
  6753. }
  6754. const createVNodeWithArgsTransform = (...args) => {
  6755. return _createVNode(...(vnodeArgsTransformer
  6756. ? vnodeArgsTransformer(args, currentRenderingInstance)
  6757. : args));
  6758. };
  6759. const InternalObjectKey = `__vInternal`;
  6760. const normalizeKey = ({ key }) => key != null ? key : null;
  6761. const normalizeRef = ({ ref, ref_key, ref_for }) => {
  6762. return (ref != null
  6763. ? isString(ref) || isRef(ref) || isFunction(ref)
  6764. ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
  6765. : ref
  6766. : null);
  6767. };
  6768. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
  6769. const vnode = {
  6770. __v_isVNode: true,
  6771. __v_skip: true,
  6772. type,
  6773. props,
  6774. key: props && normalizeKey(props),
  6775. ref: props && normalizeRef(props),
  6776. scopeId: currentScopeId,
  6777. slotScopeIds: null,
  6778. children,
  6779. component: null,
  6780. suspense: null,
  6781. ssContent: null,
  6782. ssFallback: null,
  6783. dirs: null,
  6784. transition: null,
  6785. el: null,
  6786. anchor: null,
  6787. target: null,
  6788. targetAnchor: null,
  6789. staticCount: 0,
  6790. shapeFlag,
  6791. patchFlag,
  6792. dynamicProps,
  6793. dynamicChildren: null,
  6794. appContext: null
  6795. };
  6796. if (needFullChildrenNormalization) {
  6797. normalizeChildren(vnode, children);
  6798. // normalize suspense children
  6799. if (shapeFlag & 128 /* SUSPENSE */) {
  6800. type.normalize(vnode);
  6801. }
  6802. }
  6803. else if (children) {
  6804. // compiled element vnode - if children is passed, only possible types are
  6805. // string or Array.
  6806. vnode.shapeFlag |= isString(children)
  6807. ? 8 /* TEXT_CHILDREN */
  6808. : 16 /* ARRAY_CHILDREN */;
  6809. }
  6810. // validate key
  6811. if (vnode.key !== vnode.key) {
  6812. warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  6813. }
  6814. // track vnode for block tree
  6815. if (isBlockTreeEnabled > 0 &&
  6816. // avoid a block node from tracking itself
  6817. !isBlockNode &&
  6818. // has current parent block
  6819. currentBlock &&
  6820. // presence of a patch flag indicates this node needs patching on updates.
  6821. // component nodes also should always be patched, because even if the
  6822. // component doesn't need to update, it needs to persist the instance on to
  6823. // the next vnode so that it can be properly unmounted later.
  6824. (vnode.patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) &&
  6825. // the EVENTS flag is only for hydration and if it is the only flag, the
  6826. // vnode should not be considered dynamic due to handler caching.
  6827. vnode.patchFlag !== 32 /* HYDRATE_EVENTS */) {
  6828. currentBlock.push(vnode);
  6829. }
  6830. return vnode;
  6831. }
  6832. const createVNode = (createVNodeWithArgsTransform );
  6833. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  6834. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  6835. if (!type) {
  6836. warn$1(`Invalid vnode type when creating vnode: ${type}.`);
  6837. }
  6838. type = Comment;
  6839. }
  6840. if (isVNode(type)) {
  6841. // createVNode receiving an existing vnode. This happens in cases like
  6842. // <component :is="vnode"/>
  6843. // #2078 make sure to merge refs during the clone instead of overwriting it
  6844. const cloned = cloneVNode(type, props, true /* mergeRef: true */);
  6845. if (children) {
  6846. normalizeChildren(cloned, children);
  6847. }
  6848. return cloned;
  6849. }
  6850. // class component normalization.
  6851. if (isClassComponent(type)) {
  6852. type = type.__vccOpts;
  6853. }
  6854. // class & style normalization.
  6855. if (props) {
  6856. // for reactive or proxy objects, we need to clone it to enable mutation.
  6857. props = guardReactiveProps(props);
  6858. let { class: klass, style } = props;
  6859. if (klass && !isString(klass)) {
  6860. props.class = normalizeClass(klass);
  6861. }
  6862. if (isObject(style)) {
  6863. // reactive state objects need to be cloned since they are likely to be
  6864. // mutated
  6865. if (isProxy(style) && !isArray(style)) {
  6866. style = extend({}, style);
  6867. }
  6868. props.style = normalizeStyle(style);
  6869. }
  6870. }
  6871. // encode the vnode type information into a bitmap
  6872. const shapeFlag = isString(type)
  6873. ? 1 /* ELEMENT */
  6874. : isSuspense(type)
  6875. ? 128 /* SUSPENSE */
  6876. : isTeleport(type)
  6877. ? 64 /* TELEPORT */
  6878. : isObject(type)
  6879. ? 4 /* STATEFUL_COMPONENT */
  6880. : isFunction(type)
  6881. ? 2 /* FUNCTIONAL_COMPONENT */
  6882. : 0;
  6883. if (shapeFlag & 4 /* STATEFUL_COMPONENT */ && isProxy(type)) {
  6884. type = toRaw(type);
  6885. warn$1(`Vue received a Component which was made a reactive object. This can ` +
  6886. `lead to unnecessary performance overhead, and should be avoided by ` +
  6887. `marking the component with \`markRaw\` or using \`shallowRef\` ` +
  6888. `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
  6889. }
  6890. return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
  6891. }
  6892. function guardReactiveProps(props) {
  6893. if (!props)
  6894. return null;
  6895. return isProxy(props) || InternalObjectKey in props
  6896. ? extend({}, props)
  6897. : props;
  6898. }
  6899. function cloneVNode(vnode, extraProps, mergeRef = false) {
  6900. // This is intentionally NOT using spread or extend to avoid the runtime
  6901. // key enumeration cost.
  6902. const { props, ref, patchFlag, children } = vnode;
  6903. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  6904. const cloned = {
  6905. __v_isVNode: true,
  6906. __v_skip: true,
  6907. type: vnode.type,
  6908. props: mergedProps,
  6909. key: mergedProps && normalizeKey(mergedProps),
  6910. ref: extraProps && extraProps.ref
  6911. ? // #2078 in the case of <component :is="vnode" ref="extra"/>
  6912. // if the vnode itself already has a ref, cloneVNode will need to merge
  6913. // the refs so the single vnode can be set on multiple refs
  6914. mergeRef && ref
  6915. ? isArray(ref)
  6916. ? ref.concat(normalizeRef(extraProps))
  6917. : [ref, normalizeRef(extraProps)]
  6918. : normalizeRef(extraProps)
  6919. : ref,
  6920. scopeId: vnode.scopeId,
  6921. slotScopeIds: vnode.slotScopeIds,
  6922. children: patchFlag === -1 /* HOISTED */ && isArray(children)
  6923. ? children.map(deepCloneVNode)
  6924. : children,
  6925. target: vnode.target,
  6926. targetAnchor: vnode.targetAnchor,
  6927. staticCount: vnode.staticCount,
  6928. shapeFlag: vnode.shapeFlag,
  6929. // if the vnode is cloned with extra props, we can no longer assume its
  6930. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  6931. // note: perserve flag for fragments since they use the flag for children
  6932. // fast paths only.
  6933. patchFlag: extraProps && vnode.type !== Fragment
  6934. ? patchFlag === -1 // hoisted node
  6935. ? 16 /* FULL_PROPS */
  6936. : patchFlag | 16 /* FULL_PROPS */
  6937. : patchFlag,
  6938. dynamicProps: vnode.dynamicProps,
  6939. dynamicChildren: vnode.dynamicChildren,
  6940. appContext: vnode.appContext,
  6941. dirs: vnode.dirs,
  6942. transition: vnode.transition,
  6943. // These should technically only be non-null on mounted VNodes. However,
  6944. // they *should* be copied for kept-alive vnodes. So we just always copy
  6945. // them since them being non-null during a mount doesn't affect the logic as
  6946. // they will simply be overwritten.
  6947. component: vnode.component,
  6948. suspense: vnode.suspense,
  6949. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  6950. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  6951. el: vnode.el,
  6952. anchor: vnode.anchor
  6953. };
  6954. return cloned;
  6955. }
  6956. /**
  6957. * Dev only, for HMR of hoisted vnodes reused in v-for
  6958. * https://github.com/vitejs/vite/issues/2022
  6959. */
  6960. function deepCloneVNode(vnode) {
  6961. const cloned = cloneVNode(vnode);
  6962. if (isArray(vnode.children)) {
  6963. cloned.children = vnode.children.map(deepCloneVNode);
  6964. }
  6965. return cloned;
  6966. }
  6967. /**
  6968. * @private
  6969. */
  6970. function createTextVNode(text = ' ', flag = 0) {
  6971. return createVNode(Text, null, text, flag);
  6972. }
  6973. /**
  6974. * @private
  6975. */
  6976. function createStaticVNode(content, numberOfNodes) {
  6977. // A static vnode can contain multiple stringified elements, and the number
  6978. // of elements is necessary for hydration.
  6979. const vnode = createVNode(Static, null, content);
  6980. vnode.staticCount = numberOfNodes;
  6981. return vnode;
  6982. }
  6983. /**
  6984. * @private
  6985. */
  6986. function createCommentVNode(text = '',
  6987. // when used as the v-else branch, the comment node must be created as a
  6988. // block to ensure correct updates.
  6989. asBlock = false) {
  6990. return asBlock
  6991. ? (openBlock(), createBlock(Comment, null, text))
  6992. : createVNode(Comment, null, text);
  6993. }
  6994. function normalizeVNode(child) {
  6995. if (child == null || typeof child === 'boolean') {
  6996. // empty placeholder
  6997. return createVNode(Comment);
  6998. }
  6999. else if (isArray(child)) {
  7000. // fragment
  7001. return createVNode(Fragment, null,
  7002. // #3666, avoid reference pollution when reusing vnode
  7003. child.slice());
  7004. }
  7005. else if (typeof child === 'object') {
  7006. // already vnode, this should be the most common since compiled templates
  7007. // always produce all-vnode children arrays
  7008. return cloneIfMounted(child);
  7009. }
  7010. else {
  7011. // strings and numbers
  7012. return createVNode(Text, null, String(child));
  7013. }
  7014. }
  7015. // optimized normalization for template-compiled render fns
  7016. function cloneIfMounted(child) {
  7017. return child.el === null || child.memo ? child : cloneVNode(child);
  7018. }
  7019. function normalizeChildren(vnode, children) {
  7020. let type = 0;
  7021. const { shapeFlag } = vnode;
  7022. if (children == null) {
  7023. children = null;
  7024. }
  7025. else if (isArray(children)) {
  7026. type = 16 /* ARRAY_CHILDREN */;
  7027. }
  7028. else if (typeof children === 'object') {
  7029. if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
  7030. // Normalize slot to plain children for plain element and Teleport
  7031. const slot = children.default;
  7032. if (slot) {
  7033. // _c marker is added by withCtx() indicating this is a compiled slot
  7034. slot._c && (slot._d = false);
  7035. normalizeChildren(vnode, slot());
  7036. slot._c && (slot._d = true);
  7037. }
  7038. return;
  7039. }
  7040. else {
  7041. type = 32 /* SLOTS_CHILDREN */;
  7042. const slotFlag = children._;
  7043. if (!slotFlag && !(InternalObjectKey in children)) {
  7044. children._ctx = currentRenderingInstance;
  7045. }
  7046. else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
  7047. // a child component receives forwarded slots from the parent.
  7048. // its slot type is determined by its parent's slot type.
  7049. if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
  7050. children._ = 1 /* STABLE */;
  7051. }
  7052. else {
  7053. children._ = 2 /* DYNAMIC */;
  7054. vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
  7055. }
  7056. }
  7057. }
  7058. }
  7059. else if (isFunction(children)) {
  7060. children = { default: children, _ctx: currentRenderingInstance };
  7061. type = 32 /* SLOTS_CHILDREN */;
  7062. }
  7063. else {
  7064. children = String(children);
  7065. // force teleport children to array so it can be moved around
  7066. if (shapeFlag & 64 /* TELEPORT */) {
  7067. type = 16 /* ARRAY_CHILDREN */;
  7068. children = [createTextVNode(children)];
  7069. }
  7070. else {
  7071. type = 8 /* TEXT_CHILDREN */;
  7072. }
  7073. }
  7074. vnode.children = children;
  7075. vnode.shapeFlag |= type;
  7076. }
  7077. function mergeProps(...args) {
  7078. const ret = {};
  7079. for (let i = 0; i < args.length; i++) {
  7080. const toMerge = args[i];
  7081. for (const key in toMerge) {
  7082. if (key === 'class') {
  7083. if (ret.class !== toMerge.class) {
  7084. ret.class = normalizeClass([ret.class, toMerge.class]);
  7085. }
  7086. }
  7087. else if (key === 'style') {
  7088. ret.style = normalizeStyle([ret.style, toMerge.style]);
  7089. }
  7090. else if (isOn(key)) {
  7091. const existing = ret[key];
  7092. const incoming = toMerge[key];
  7093. if (existing !== incoming &&
  7094. !(isArray(existing) && existing.includes(incoming))) {
  7095. ret[key] = existing
  7096. ? [].concat(existing, incoming)
  7097. : incoming;
  7098. }
  7099. }
  7100. else if (key !== '') {
  7101. ret[key] = toMerge[key];
  7102. }
  7103. }
  7104. }
  7105. return ret;
  7106. }
  7107. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  7108. callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
  7109. vnode,
  7110. prevVNode
  7111. ]);
  7112. }
  7113. /**
  7114. * Actual implementation
  7115. */
  7116. function renderList(source, renderItem, cache, index) {
  7117. let ret;
  7118. const cached = (cache && cache[index]);
  7119. if (isArray(source) || isString(source)) {
  7120. ret = new Array(source.length);
  7121. for (let i = 0, l = source.length; i < l; i++) {
  7122. ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
  7123. }
  7124. }
  7125. else if (typeof source === 'number') {
  7126. if (!Number.isInteger(source)) {
  7127. warn$1(`The v-for range expect an integer value but got ${source}.`);
  7128. return [];
  7129. }
  7130. ret = new Array(source);
  7131. for (let i = 0; i < source; i++) {
  7132. ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
  7133. }
  7134. }
  7135. else if (isObject(source)) {
  7136. if (source[Symbol.iterator]) {
  7137. ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
  7138. }
  7139. else {
  7140. const keys = Object.keys(source);
  7141. ret = new Array(keys.length);
  7142. for (let i = 0, l = keys.length; i < l; i++) {
  7143. const key = keys[i];
  7144. ret[i] = renderItem(source[key], key, i, cached && cached[i]);
  7145. }
  7146. }
  7147. }
  7148. else {
  7149. ret = [];
  7150. }
  7151. if (cache) {
  7152. cache[index] = ret;
  7153. }
  7154. return ret;
  7155. }
  7156. /**
  7157. * Compiler runtime helper for creating dynamic slots object
  7158. * @private
  7159. */
  7160. function createSlots(slots, dynamicSlots) {
  7161. for (let i = 0; i < dynamicSlots.length; i++) {
  7162. const slot = dynamicSlots[i];
  7163. // array of dynamic slot generated by <template v-for="..." #[...]>
  7164. if (isArray(slot)) {
  7165. for (let j = 0; j < slot.length; j++) {
  7166. slots[slot[j].name] = slot[j].fn;
  7167. }
  7168. }
  7169. else if (slot) {
  7170. // conditional single slot generated by <template v-if="..." #foo>
  7171. slots[slot.name] = slot.fn;
  7172. }
  7173. }
  7174. return slots;
  7175. }
  7176. /**
  7177. * Compiler runtime helper for rendering `<slot/>`
  7178. * @private
  7179. */
  7180. function renderSlot(slots, name, props = {},
  7181. // this is not a user-facing function, so the fallback is always generated by
  7182. // the compiler and guaranteed to be a function returning an array
  7183. fallback, noSlotted) {
  7184. if (currentRenderingInstance.isCE) {
  7185. return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
  7186. }
  7187. let slot = slots[name];
  7188. if (slot && slot.length > 1) {
  7189. warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
  7190. `function. You need to mark this component with $dynamic-slots in the ` +
  7191. `parent template.`);
  7192. slot = () => [];
  7193. }
  7194. // a compiled slot disables block tracking by default to avoid manual
  7195. // invocation interfering with template-based block tracking, but in
  7196. // `renderSlot` we can be sure that it's template-based so we can force
  7197. // enable it.
  7198. if (slot && slot._c) {
  7199. slot._d = false;
  7200. }
  7201. openBlock();
  7202. const validSlotContent = slot && ensureValidVNode(slot(props));
  7203. const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
  7204. ? 64 /* STABLE_FRAGMENT */
  7205. : -2 /* BAIL */);
  7206. if (!noSlotted && rendered.scopeId) {
  7207. rendered.slotScopeIds = [rendered.scopeId + '-s'];
  7208. }
  7209. if (slot && slot._c) {
  7210. slot._d = true;
  7211. }
  7212. return rendered;
  7213. }
  7214. function ensureValidVNode(vnodes) {
  7215. return vnodes.some(child => {
  7216. if (!isVNode(child))
  7217. return true;
  7218. if (child.type === Comment)
  7219. return false;
  7220. if (child.type === Fragment &&
  7221. !ensureValidVNode(child.children))
  7222. return false;
  7223. return true;
  7224. })
  7225. ? vnodes
  7226. : null;
  7227. }
  7228. /**
  7229. * For prefixing keys in v-on="obj" with "on"
  7230. * @private
  7231. */
  7232. function toHandlers(obj) {
  7233. const ret = {};
  7234. if (!isObject(obj)) {
  7235. warn$1(`v-on with no argument expects an object value.`);
  7236. return ret;
  7237. }
  7238. for (const key in obj) {
  7239. ret[toHandlerKey(key)] = obj[key];
  7240. }
  7241. return ret;
  7242. }
  7243. /**
  7244. * #2437 In Vue 3, functional components do not have a public instance proxy but
  7245. * they exist in the internal parent chain. For code that relies on traversing
  7246. * public $parent chains, skip functional ones and go to the parent instead.
  7247. */
  7248. const getPublicInstance = (i) => {
  7249. if (!i)
  7250. return null;
  7251. if (isStatefulComponent(i))
  7252. return getExposeProxy(i) || i.proxy;
  7253. return getPublicInstance(i.parent);
  7254. };
  7255. const publicPropertiesMap = extend(Object.create(null), {
  7256. $: i => i,
  7257. $el: i => i.vnode.el,
  7258. $data: i => i.data,
  7259. $props: i => (shallowReadonly(i.props) ),
  7260. $attrs: i => (shallowReadonly(i.attrs) ),
  7261. $slots: i => (shallowReadonly(i.slots) ),
  7262. $refs: i => (shallowReadonly(i.refs) ),
  7263. $parent: i => getPublicInstance(i.parent),
  7264. $root: i => getPublicInstance(i.root),
  7265. $emit: i => i.emit,
  7266. $options: i => (resolveMergedOptions(i) ),
  7267. $forceUpdate: i => () => queueJob(i.update),
  7268. $nextTick: i => nextTick.bind(i.proxy),
  7269. $watch: i => (instanceWatch.bind(i) )
  7270. });
  7271. const PublicInstanceProxyHandlers = {
  7272. get({ _: instance }, key) {
  7273. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  7274. // for internal formatters to know that this is a Vue instance
  7275. if (key === '__isVue') {
  7276. return true;
  7277. }
  7278. // prioritize <script setup> bindings during dev.
  7279. // this allows even properties that start with _ or $ to be used - so that
  7280. // it aligns with the production behavior where the render fn is inlined and
  7281. // indeed has access to all declared variables.
  7282. if (setupState !== EMPTY_OBJ &&
  7283. setupState.__isScriptSetup &&
  7284. hasOwn(setupState, key)) {
  7285. return setupState[key];
  7286. }
  7287. // data / props / ctx
  7288. // This getter gets called for every property access on the render context
  7289. // during render and is a major hotspot. The most expensive part of this
  7290. // is the multiple hasOwn() calls. It's much faster to do a simple property
  7291. // access on a plain object, so we use an accessCache object (with null
  7292. // prototype) to memoize what access type a key corresponds to.
  7293. let normalizedProps;
  7294. if (key[0] !== '$') {
  7295. const n = accessCache[key];
  7296. if (n !== undefined) {
  7297. switch (n) {
  7298. case 1 /* SETUP */:
  7299. return setupState[key];
  7300. case 2 /* DATA */:
  7301. return data[key];
  7302. case 4 /* CONTEXT */:
  7303. return ctx[key];
  7304. case 3 /* PROPS */:
  7305. return props[key];
  7306. // default: just fallthrough
  7307. }
  7308. }
  7309. else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
  7310. accessCache[key] = 1 /* SETUP */;
  7311. return setupState[key];
  7312. }
  7313. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  7314. accessCache[key] = 2 /* DATA */;
  7315. return data[key];
  7316. }
  7317. else if (
  7318. // only cache other properties when instance has declared (thus stable)
  7319. // props
  7320. (normalizedProps = instance.propsOptions[0]) &&
  7321. hasOwn(normalizedProps, key)) {
  7322. accessCache[key] = 3 /* PROPS */;
  7323. return props[key];
  7324. }
  7325. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  7326. accessCache[key] = 4 /* CONTEXT */;
  7327. return ctx[key];
  7328. }
  7329. else if (shouldCacheAccess) {
  7330. accessCache[key] = 0 /* OTHER */;
  7331. }
  7332. }
  7333. const publicGetter = publicPropertiesMap[key];
  7334. let cssModule, globalProperties;
  7335. // public $xxx properties
  7336. if (publicGetter) {
  7337. if (key === '$attrs') {
  7338. track(instance, "get" /* GET */, key);
  7339. markAttrsAccessed();
  7340. }
  7341. return publicGetter(instance);
  7342. }
  7343. else if (
  7344. // css module (injected by vue-loader)
  7345. (cssModule = type.__cssModules) &&
  7346. (cssModule = cssModule[key])) {
  7347. return cssModule;
  7348. }
  7349. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  7350. // user may set custom properties to `this` that start with `$`
  7351. accessCache[key] = 4 /* CONTEXT */;
  7352. return ctx[key];
  7353. }
  7354. else if (
  7355. // global properties
  7356. ((globalProperties = appContext.config.globalProperties),
  7357. hasOwn(globalProperties, key))) {
  7358. {
  7359. return globalProperties[key];
  7360. }
  7361. }
  7362. else if (currentRenderingInstance &&
  7363. (!isString(key) ||
  7364. // #1091 avoid internal isRef/isVNode checks on component instance leading
  7365. // to infinite warning loop
  7366. key.indexOf('__v') !== 0)) {
  7367. if (data !== EMPTY_OBJ &&
  7368. (key[0] === '$' || key[0] === '_') &&
  7369. hasOwn(data, key)) {
  7370. warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
  7371. `character ("$" or "_") and is not proxied on the render context.`);
  7372. }
  7373. else if (instance === currentRenderingInstance) {
  7374. warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
  7375. `but is not defined on instance.`);
  7376. }
  7377. }
  7378. },
  7379. set({ _: instance }, key, value) {
  7380. const { data, setupState, ctx } = instance;
  7381. if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
  7382. setupState[key] = value;
  7383. }
  7384. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  7385. data[key] = value;
  7386. }
  7387. else if (hasOwn(instance.props, key)) {
  7388. warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
  7389. return false;
  7390. }
  7391. if (key[0] === '$' && key.slice(1) in instance) {
  7392. warn$1(`Attempting to mutate public property "${key}". ` +
  7393. `Properties starting with $ are reserved and readonly.`, instance);
  7394. return false;
  7395. }
  7396. else {
  7397. if (key in instance.appContext.config.globalProperties) {
  7398. Object.defineProperty(ctx, key, {
  7399. enumerable: true,
  7400. configurable: true,
  7401. value
  7402. });
  7403. }
  7404. else {
  7405. ctx[key] = value;
  7406. }
  7407. }
  7408. return true;
  7409. },
  7410. has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
  7411. let normalizedProps;
  7412. return (!!accessCache[key] ||
  7413. (data !== EMPTY_OBJ && hasOwn(data, key)) ||
  7414. (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
  7415. ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
  7416. hasOwn(ctx, key) ||
  7417. hasOwn(publicPropertiesMap, key) ||
  7418. hasOwn(appContext.config.globalProperties, key));
  7419. }
  7420. };
  7421. {
  7422. PublicInstanceProxyHandlers.ownKeys = (target) => {
  7423. warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
  7424. `The keys will be empty in production mode to avoid performance overhead.`);
  7425. return Reflect.ownKeys(target);
  7426. };
  7427. }
  7428. const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
  7429. get(target, key) {
  7430. // fast path for unscopables when using `with` block
  7431. if (key === Symbol.unscopables) {
  7432. return;
  7433. }
  7434. return PublicInstanceProxyHandlers.get(target, key, target);
  7435. },
  7436. has(_, key) {
  7437. const has = key[0] !== '_' && !isGloballyWhitelisted(key);
  7438. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  7439. warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
  7440. }
  7441. return has;
  7442. }
  7443. });
  7444. // dev only
  7445. // In dev mode, the proxy target exposes the same properties as seen on `this`
  7446. // for easier console inspection. In prod mode it will be an empty object so
  7447. // these properties definitions can be skipped.
  7448. function createDevRenderContext(instance) {
  7449. const target = {};
  7450. // expose internal instance for proxy handlers
  7451. Object.defineProperty(target, `_`, {
  7452. configurable: true,
  7453. enumerable: false,
  7454. get: () => instance
  7455. });
  7456. // expose public properties
  7457. Object.keys(publicPropertiesMap).forEach(key => {
  7458. Object.defineProperty(target, key, {
  7459. configurable: true,
  7460. enumerable: false,
  7461. get: () => publicPropertiesMap[key](instance),
  7462. // intercepted by the proxy so no need for implementation,
  7463. // but needed to prevent set errors
  7464. set: NOOP
  7465. });
  7466. });
  7467. return target;
  7468. }
  7469. // dev only
  7470. function exposePropsOnRenderContext(instance) {
  7471. const { ctx, propsOptions: [propsOptions] } = instance;
  7472. if (propsOptions) {
  7473. Object.keys(propsOptions).forEach(key => {
  7474. Object.defineProperty(ctx, key, {
  7475. enumerable: true,
  7476. configurable: true,
  7477. get: () => instance.props[key],
  7478. set: NOOP
  7479. });
  7480. });
  7481. }
  7482. }
  7483. // dev only
  7484. function exposeSetupStateOnRenderContext(instance) {
  7485. const { ctx, setupState } = instance;
  7486. Object.keys(toRaw(setupState)).forEach(key => {
  7487. if (!setupState.__isScriptSetup) {
  7488. if (key[0] === '$' || key[0] === '_') {
  7489. warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
  7490. `which are reserved prefixes for Vue internals.`);
  7491. return;
  7492. }
  7493. Object.defineProperty(ctx, key, {
  7494. enumerable: true,
  7495. configurable: true,
  7496. get: () => setupState[key],
  7497. set: NOOP
  7498. });
  7499. }
  7500. });
  7501. }
  7502. const emptyAppContext = createAppContext();
  7503. let uid$1 = 0;
  7504. function createComponentInstance(vnode, parent, suspense) {
  7505. const type = vnode.type;
  7506. // inherit parent app context - or - if root, adopt from root vnode
  7507. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  7508. const instance = {
  7509. uid: uid$1++,
  7510. vnode,
  7511. type,
  7512. parent,
  7513. appContext,
  7514. root: null,
  7515. next: null,
  7516. subTree: null,
  7517. effect: null,
  7518. update: null,
  7519. scope: new EffectScope(true /* detached */),
  7520. render: null,
  7521. proxy: null,
  7522. exposed: null,
  7523. exposeProxy: null,
  7524. withProxy: null,
  7525. provides: parent ? parent.provides : Object.create(appContext.provides),
  7526. accessCache: null,
  7527. renderCache: [],
  7528. // local resovled assets
  7529. components: null,
  7530. directives: null,
  7531. // resolved props and emits options
  7532. propsOptions: normalizePropsOptions(type, appContext),
  7533. emitsOptions: normalizeEmitsOptions(type, appContext),
  7534. // emit
  7535. emit: null,
  7536. emitted: null,
  7537. // props default value
  7538. propsDefaults: EMPTY_OBJ,
  7539. // inheritAttrs
  7540. inheritAttrs: type.inheritAttrs,
  7541. // state
  7542. ctx: EMPTY_OBJ,
  7543. data: EMPTY_OBJ,
  7544. props: EMPTY_OBJ,
  7545. attrs: EMPTY_OBJ,
  7546. slots: EMPTY_OBJ,
  7547. refs: EMPTY_OBJ,
  7548. setupState: EMPTY_OBJ,
  7549. setupContext: null,
  7550. // suspense related
  7551. suspense,
  7552. suspenseId: suspense ? suspense.pendingId : 0,
  7553. asyncDep: null,
  7554. asyncResolved: false,
  7555. // lifecycle hooks
  7556. // not using enums here because it results in computed properties
  7557. isMounted: false,
  7558. isUnmounted: false,
  7559. isDeactivated: false,
  7560. bc: null,
  7561. c: null,
  7562. bm: null,
  7563. m: null,
  7564. bu: null,
  7565. u: null,
  7566. um: null,
  7567. bum: null,
  7568. da: null,
  7569. a: null,
  7570. rtg: null,
  7571. rtc: null,
  7572. ec: null,
  7573. sp: null
  7574. };
  7575. {
  7576. instance.ctx = createDevRenderContext(instance);
  7577. }
  7578. instance.root = parent ? parent.root : instance;
  7579. instance.emit = emit$1.bind(null, instance);
  7580. // apply custom element special handling
  7581. if (vnode.ce) {
  7582. vnode.ce(instance);
  7583. }
  7584. return instance;
  7585. }
  7586. let currentInstance = null;
  7587. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  7588. const setCurrentInstance = (instance) => {
  7589. currentInstance = instance;
  7590. instance.scope.on();
  7591. };
  7592. const unsetCurrentInstance = () => {
  7593. currentInstance && currentInstance.scope.off();
  7594. currentInstance = null;
  7595. };
  7596. const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');
  7597. function validateComponentName(name, config) {
  7598. const appIsNativeTag = config.isNativeTag || NO;
  7599. if (isBuiltInTag(name) || appIsNativeTag(name)) {
  7600. warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
  7601. }
  7602. }
  7603. function isStatefulComponent(instance) {
  7604. return instance.vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */;
  7605. }
  7606. let isInSSRComponentSetup = false;
  7607. function setupComponent(instance, isSSR = false) {
  7608. isInSSRComponentSetup = isSSR;
  7609. const { props, children } = instance.vnode;
  7610. const isStateful = isStatefulComponent(instance);
  7611. initProps(instance, props, isStateful, isSSR);
  7612. initSlots(instance, children);
  7613. const setupResult = isStateful
  7614. ? setupStatefulComponent(instance, isSSR)
  7615. : undefined;
  7616. isInSSRComponentSetup = false;
  7617. return setupResult;
  7618. }
  7619. function setupStatefulComponent(instance, isSSR) {
  7620. const Component = instance.type;
  7621. {
  7622. if (Component.name) {
  7623. validateComponentName(Component.name, instance.appContext.config);
  7624. }
  7625. if (Component.components) {
  7626. const names = Object.keys(Component.components);
  7627. for (let i = 0; i < names.length; i++) {
  7628. validateComponentName(names[i], instance.appContext.config);
  7629. }
  7630. }
  7631. if (Component.directives) {
  7632. const names = Object.keys(Component.directives);
  7633. for (let i = 0; i < names.length; i++) {
  7634. validateDirectiveName(names[i]);
  7635. }
  7636. }
  7637. if (Component.compilerOptions && isRuntimeOnly()) {
  7638. warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
  7639. `includes the runtime compiler. Since you are using a runtime-only ` +
  7640. `build, the options should be passed via your build tool config instead.`);
  7641. }
  7642. }
  7643. // 0. create render proxy property access cache
  7644. instance.accessCache = Object.create(null);
  7645. // 1. create public instance / render proxy
  7646. // also mark it raw so it's never observed
  7647. instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
  7648. {
  7649. exposePropsOnRenderContext(instance);
  7650. }
  7651. // 2. call setup()
  7652. const { setup } = Component;
  7653. if (setup) {
  7654. const setupContext = (instance.setupContext =
  7655. setup.length > 1 ? createSetupContext(instance) : null);
  7656. setCurrentInstance(instance);
  7657. pauseTracking();
  7658. const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [shallowReadonly(instance.props) , setupContext]);
  7659. resetTracking();
  7660. unsetCurrentInstance();
  7661. if (isPromise(setupResult)) {
  7662. setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
  7663. if (isSSR) {
  7664. // return the promise so server-renderer can wait on it
  7665. return setupResult
  7666. .then((resolvedResult) => {
  7667. handleSetupResult(instance, resolvedResult, isSSR);
  7668. })
  7669. .catch(e => {
  7670. handleError(e, instance, 0 /* SETUP_FUNCTION */);
  7671. });
  7672. }
  7673. else {
  7674. // async setup returned Promise.
  7675. // bail here and wait for re-entry.
  7676. instance.asyncDep = setupResult;
  7677. }
  7678. }
  7679. else {
  7680. handleSetupResult(instance, setupResult, isSSR);
  7681. }
  7682. }
  7683. else {
  7684. finishComponentSetup(instance, isSSR);
  7685. }
  7686. }
  7687. function handleSetupResult(instance, setupResult, isSSR) {
  7688. if (isFunction(setupResult)) {
  7689. // setup returned an inline render function
  7690. {
  7691. instance.render = setupResult;
  7692. }
  7693. }
  7694. else if (isObject(setupResult)) {
  7695. if (isVNode(setupResult)) {
  7696. warn$1(`setup() should not return VNodes directly - ` +
  7697. `return a render function instead.`);
  7698. }
  7699. // setup returned bindings.
  7700. // assuming a render function compiled from template is present.
  7701. {
  7702. instance.devtoolsRawSetupState = setupResult;
  7703. }
  7704. instance.setupState = proxyRefs(setupResult);
  7705. {
  7706. exposeSetupStateOnRenderContext(instance);
  7707. }
  7708. }
  7709. else if (setupResult !== undefined) {
  7710. warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  7711. }
  7712. finishComponentSetup(instance, isSSR);
  7713. }
  7714. let compile;
  7715. let installWithProxy;
  7716. /**
  7717. * For runtime-dom to register the compiler.
  7718. * Note the exported method uses any to avoid d.ts relying on the compiler types.
  7719. */
  7720. function registerRuntimeCompiler(_compile) {
  7721. compile = _compile;
  7722. installWithProxy = i => {
  7723. if (i.render._rc) {
  7724. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  7725. }
  7726. };
  7727. }
  7728. // dev only
  7729. const isRuntimeOnly = () => !compile;
  7730. function finishComponentSetup(instance, isSSR, skipOptions) {
  7731. const Component = instance.type;
  7732. // template / render function normalization
  7733. // could be already set when returned from setup()
  7734. if (!instance.render) {
  7735. // only do on-the-fly compile if not in SSR - SSR on-the-fly compliation
  7736. // is done by server-renderer
  7737. if (!isSSR && compile && !Component.render) {
  7738. const template = Component.template;
  7739. if (template) {
  7740. {
  7741. startMeasure(instance, `compile`);
  7742. }
  7743. const { isCustomElement, compilerOptions } = instance.appContext.config;
  7744. const { delimiters, compilerOptions: componentCompilerOptions } = Component;
  7745. const finalCompilerOptions = extend(extend({
  7746. isCustomElement,
  7747. delimiters
  7748. }, compilerOptions), componentCompilerOptions);
  7749. Component.render = compile(template, finalCompilerOptions);
  7750. {
  7751. endMeasure(instance, `compile`);
  7752. }
  7753. }
  7754. }
  7755. instance.render = (Component.render || NOOP);
  7756. // for runtime-compiled render functions using `with` blocks, the render
  7757. // proxy used needs a different `has` handler which is more performant and
  7758. // also only allows a whitelist of globals to fallthrough.
  7759. if (installWithProxy) {
  7760. installWithProxy(instance);
  7761. }
  7762. }
  7763. // support for 2.x options
  7764. {
  7765. setCurrentInstance(instance);
  7766. pauseTracking();
  7767. applyOptions(instance);
  7768. resetTracking();
  7769. unsetCurrentInstance();
  7770. }
  7771. // warn missing template/render
  7772. // the runtime compilation of template in SSR is done by server-render
  7773. if (!Component.render && instance.render === NOOP && !isSSR) {
  7774. /* istanbul ignore if */
  7775. if (!compile && Component.template) {
  7776. warn$1(`Component provided template option but ` +
  7777. `runtime compilation is not supported in this build of Vue.` +
  7778. (` Use "vue.global.js" instead.`
  7779. ) /* should not happen */);
  7780. }
  7781. else {
  7782. warn$1(`Component is missing template or render function.`);
  7783. }
  7784. }
  7785. }
  7786. function createAttrsProxy(instance) {
  7787. return new Proxy(instance.attrs, {
  7788. get(target, key) {
  7789. markAttrsAccessed();
  7790. track(instance, "get" /* GET */, '$attrs');
  7791. return target[key];
  7792. },
  7793. set() {
  7794. warn$1(`setupContext.attrs is readonly.`);
  7795. return false;
  7796. },
  7797. deleteProperty() {
  7798. warn$1(`setupContext.attrs is readonly.`);
  7799. return false;
  7800. }
  7801. }
  7802. );
  7803. }
  7804. function createSetupContext(instance) {
  7805. const expose = exposed => {
  7806. if (instance.exposed) {
  7807. warn$1(`expose() should be called only once per setup().`);
  7808. }
  7809. instance.exposed = exposed || {};
  7810. };
  7811. let attrs;
  7812. {
  7813. // We use getters in dev in case libs like test-utils overwrite instance
  7814. // properties (overwrites should not be done in prod)
  7815. return Object.freeze({
  7816. get attrs() {
  7817. return attrs || (attrs = createAttrsProxy(instance));
  7818. },
  7819. get slots() {
  7820. return shallowReadonly(instance.slots);
  7821. },
  7822. get emit() {
  7823. return (event, ...args) => instance.emit(event, ...args);
  7824. },
  7825. expose
  7826. });
  7827. }
  7828. }
  7829. function getExposeProxy(instance) {
  7830. if (instance.exposed) {
  7831. return (instance.exposeProxy ||
  7832. (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  7833. get(target, key) {
  7834. if (key in target) {
  7835. return target[key];
  7836. }
  7837. else if (key in publicPropertiesMap) {
  7838. return publicPropertiesMap[key](instance);
  7839. }
  7840. }
  7841. })));
  7842. }
  7843. }
  7844. const classifyRE = /(?:^|[-_])(\w)/g;
  7845. const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  7846. function getComponentName(Component) {
  7847. return isFunction(Component)
  7848. ? Component.displayName || Component.name
  7849. : Component.name;
  7850. }
  7851. /* istanbul ignore next */
  7852. function formatComponentName(instance, Component, isRoot = false) {
  7853. let name = getComponentName(Component);
  7854. if (!name && Component.__file) {
  7855. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  7856. if (match) {
  7857. name = match[1];
  7858. }
  7859. }
  7860. if (!name && instance && instance.parent) {
  7861. // try to infer the name based on reverse resolution
  7862. const inferFromRegistry = (registry) => {
  7863. for (const key in registry) {
  7864. if (registry[key] === Component) {
  7865. return key;
  7866. }
  7867. }
  7868. };
  7869. name =
  7870. inferFromRegistry(instance.components ||
  7871. instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
  7872. }
  7873. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  7874. }
  7875. function isClassComponent(value) {
  7876. return isFunction(value) && '__vccOpts' in value;
  7877. }
  7878. const stack = [];
  7879. function pushWarningContext(vnode) {
  7880. stack.push(vnode);
  7881. }
  7882. function popWarningContext() {
  7883. stack.pop();
  7884. }
  7885. function warn$1(msg, ...args) {
  7886. // avoid props formatting or warn handler tracking deps that might be mutated
  7887. // during patch, leading to infinite recursion.
  7888. pauseTracking();
  7889. const instance = stack.length ? stack[stack.length - 1].component : null;
  7890. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  7891. const trace = getComponentTrace();
  7892. if (appWarnHandler) {
  7893. callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [
  7894. msg + args.join(''),
  7895. instance && instance.proxy,
  7896. trace
  7897. .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
  7898. .join('\n'),
  7899. trace
  7900. ]);
  7901. }
  7902. else {
  7903. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  7904. /* istanbul ignore if */
  7905. if (trace.length &&
  7906. // avoid spamming console during tests
  7907. !false) {
  7908. warnArgs.push(`\n`, ...formatTrace(trace));
  7909. }
  7910. console.warn(...warnArgs);
  7911. }
  7912. resetTracking();
  7913. }
  7914. function getComponentTrace() {
  7915. let currentVNode = stack[stack.length - 1];
  7916. if (!currentVNode) {
  7917. return [];
  7918. }
  7919. // we can't just use the stack because it will be incomplete during updates
  7920. // that did not start from the root. Re-construct the parent chain using
  7921. // instance parent pointers.
  7922. const normalizedStack = [];
  7923. while (currentVNode) {
  7924. const last = normalizedStack[0];
  7925. if (last && last.vnode === currentVNode) {
  7926. last.recurseCount++;
  7927. }
  7928. else {
  7929. normalizedStack.push({
  7930. vnode: currentVNode,
  7931. recurseCount: 0
  7932. });
  7933. }
  7934. const parentInstance = currentVNode.component && currentVNode.component.parent;
  7935. currentVNode = parentInstance && parentInstance.vnode;
  7936. }
  7937. return normalizedStack;
  7938. }
  7939. /* istanbul ignore next */
  7940. function formatTrace(trace) {
  7941. const logs = [];
  7942. trace.forEach((entry, i) => {
  7943. logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
  7944. });
  7945. return logs;
  7946. }
  7947. function formatTraceEntry({ vnode, recurseCount }) {
  7948. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  7949. const isRoot = vnode.component ? vnode.component.parent == null : false;
  7950. const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
  7951. const close = `>` + postfix;
  7952. return vnode.props
  7953. ? [open, ...formatProps(vnode.props), close]
  7954. : [open + close];
  7955. }
  7956. /* istanbul ignore next */
  7957. function formatProps(props) {
  7958. const res = [];
  7959. const keys = Object.keys(props);
  7960. keys.slice(0, 3).forEach(key => {
  7961. res.push(...formatProp(key, props[key]));
  7962. });
  7963. if (keys.length > 3) {
  7964. res.push(` ...`);
  7965. }
  7966. return res;
  7967. }
  7968. /* istanbul ignore next */
  7969. function formatProp(key, value, raw) {
  7970. if (isString(value)) {
  7971. value = JSON.stringify(value);
  7972. return raw ? value : [`${key}=${value}`];
  7973. }
  7974. else if (typeof value === 'number' ||
  7975. typeof value === 'boolean' ||
  7976. value == null) {
  7977. return raw ? value : [`${key}=${value}`];
  7978. }
  7979. else if (isRef(value)) {
  7980. value = formatProp(key, toRaw(value.value), true);
  7981. return raw ? value : [`${key}=Ref<`, value, `>`];
  7982. }
  7983. else if (isFunction(value)) {
  7984. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  7985. }
  7986. else {
  7987. value = toRaw(value);
  7988. return raw ? value : [`${key}=`, value];
  7989. }
  7990. }
  7991. const ErrorTypeStrings = {
  7992. ["sp" /* SERVER_PREFETCH */]: 'serverPrefetch hook',
  7993. ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
  7994. ["c" /* CREATED */]: 'created hook',
  7995. ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
  7996. ["m" /* MOUNTED */]: 'mounted hook',
  7997. ["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook',
  7998. ["u" /* UPDATED */]: 'updated',
  7999. ["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook',
  8000. ["um" /* UNMOUNTED */]: 'unmounted hook',
  8001. ["a" /* ACTIVATED */]: 'activated hook',
  8002. ["da" /* DEACTIVATED */]: 'deactivated hook',
  8003. ["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook',
  8004. ["rtc" /* RENDER_TRACKED */]: 'renderTracked hook',
  8005. ["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook',
  8006. [0 /* SETUP_FUNCTION */]: 'setup function',
  8007. [1 /* RENDER_FUNCTION */]: 'render function',
  8008. [2 /* WATCH_GETTER */]: 'watcher getter',
  8009. [3 /* WATCH_CALLBACK */]: 'watcher callback',
  8010. [4 /* WATCH_CLEANUP */]: 'watcher cleanup function',
  8011. [5 /* NATIVE_EVENT_HANDLER */]: 'native event handler',
  8012. [6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler',
  8013. [7 /* VNODE_HOOK */]: 'vnode hook',
  8014. [8 /* DIRECTIVE_HOOK */]: 'directive hook',
  8015. [9 /* TRANSITION_HOOK */]: 'transition hook',
  8016. [10 /* APP_ERROR_HANDLER */]: 'app errorHandler',
  8017. [11 /* APP_WARN_HANDLER */]: 'app warnHandler',
  8018. [12 /* FUNCTION_REF */]: 'ref function',
  8019. [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
  8020. [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
  8021. 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next'
  8022. };
  8023. function callWithErrorHandling(fn, instance, type, args) {
  8024. let res;
  8025. try {
  8026. res = args ? fn(...args) : fn();
  8027. }
  8028. catch (err) {
  8029. handleError(err, instance, type);
  8030. }
  8031. return res;
  8032. }
  8033. function callWithAsyncErrorHandling(fn, instance, type, args) {
  8034. if (isFunction(fn)) {
  8035. const res = callWithErrorHandling(fn, instance, type, args);
  8036. if (res && isPromise(res)) {
  8037. res.catch(err => {
  8038. handleError(err, instance, type);
  8039. });
  8040. }
  8041. return res;
  8042. }
  8043. const values = [];
  8044. for (let i = 0; i < fn.length; i++) {
  8045. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  8046. }
  8047. return values;
  8048. }
  8049. function handleError(err, instance, type, throwInDev = true) {
  8050. const contextVNode = instance ? instance.vnode : null;
  8051. if (instance) {
  8052. let cur = instance.parent;
  8053. // the exposed instance is the render proxy to keep it consistent with 2.x
  8054. const exposedInstance = instance.proxy;
  8055. // in production the hook receives only the error code
  8056. const errorInfo = ErrorTypeStrings[type] ;
  8057. while (cur) {
  8058. const errorCapturedHooks = cur.ec;
  8059. if (errorCapturedHooks) {
  8060. for (let i = 0; i < errorCapturedHooks.length; i++) {
  8061. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  8062. return;
  8063. }
  8064. }
  8065. }
  8066. cur = cur.parent;
  8067. }
  8068. // app-level handling
  8069. const appErrorHandler = instance.appContext.config.errorHandler;
  8070. if (appErrorHandler) {
  8071. callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
  8072. return;
  8073. }
  8074. }
  8075. logError(err, type, contextVNode, throwInDev);
  8076. }
  8077. function logError(err, type, contextVNode, throwInDev = true) {
  8078. {
  8079. const info = ErrorTypeStrings[type];
  8080. if (contextVNode) {
  8081. pushWarningContext(contextVNode);
  8082. }
  8083. warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  8084. if (contextVNode) {
  8085. popWarningContext();
  8086. }
  8087. // crash in dev by default so it's more noticeable
  8088. if (throwInDev) {
  8089. throw err;
  8090. }
  8091. else {
  8092. console.error(err);
  8093. }
  8094. }
  8095. }
  8096. let isFlushing = false;
  8097. let isFlushPending = false;
  8098. const queue = [];
  8099. let flushIndex = 0;
  8100. const pendingPreFlushCbs = [];
  8101. let activePreFlushCbs = null;
  8102. let preFlushIndex = 0;
  8103. const pendingPostFlushCbs = [];
  8104. let activePostFlushCbs = null;
  8105. let postFlushIndex = 0;
  8106. const resolvedPromise = Promise.resolve();
  8107. let currentFlushPromise = null;
  8108. let currentPreFlushParentJob = null;
  8109. const RECURSION_LIMIT = 100;
  8110. function nextTick(fn) {
  8111. const p = currentFlushPromise || resolvedPromise;
  8112. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  8113. }
  8114. // #2768
  8115. // Use binary-search to find a suitable position in the queue,
  8116. // so that the queue maintains the increasing order of job's id,
  8117. // which can prevent the job from being skipped and also can avoid repeated patching.
  8118. function findInsertionIndex(id) {
  8119. // the start index should be `flushIndex + 1`
  8120. let start = flushIndex + 1;
  8121. let end = queue.length;
  8122. while (start < end) {
  8123. const middle = (start + end) >>> 1;
  8124. const middleJobId = getId(queue[middle]);
  8125. middleJobId < id ? (start = middle + 1) : (end = middle);
  8126. }
  8127. return start;
  8128. }
  8129. function queueJob(job) {
  8130. // the dedupe search uses the startIndex argument of Array.includes()
  8131. // by default the search index includes the current job that is being run
  8132. // so it cannot recursively trigger itself again.
  8133. // if the job is a watch() callback, the search will start with a +1 index to
  8134. // allow it recursively trigger itself - it is the user's responsibility to
  8135. // ensure it doesn't end up in an infinite loop.
  8136. if ((!queue.length ||
  8137. !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) &&
  8138. job !== currentPreFlushParentJob) {
  8139. if (job.id == null) {
  8140. queue.push(job);
  8141. }
  8142. else {
  8143. queue.splice(findInsertionIndex(job.id), 0, job);
  8144. }
  8145. queueFlush();
  8146. }
  8147. }
  8148. function queueFlush() {
  8149. if (!isFlushing && !isFlushPending) {
  8150. isFlushPending = true;
  8151. currentFlushPromise = resolvedPromise.then(flushJobs);
  8152. }
  8153. }
  8154. function invalidateJob(job) {
  8155. const i = queue.indexOf(job);
  8156. if (i > flushIndex) {
  8157. queue.splice(i, 1);
  8158. }
  8159. }
  8160. function queueCb(cb, activeQueue, pendingQueue, index) {
  8161. if (!isArray(cb)) {
  8162. if (!activeQueue ||
  8163. !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
  8164. pendingQueue.push(cb);
  8165. }
  8166. }
  8167. else {
  8168. // if cb is an array, it is a component lifecycle hook which can only be
  8169. // triggered by a job, which is already deduped in the main queue, so
  8170. // we can skip duplicate check here to improve perf
  8171. pendingQueue.push(...cb);
  8172. }
  8173. queueFlush();
  8174. }
  8175. function queuePreFlushCb(cb) {
  8176. queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
  8177. }
  8178. function queuePostFlushCb(cb) {
  8179. queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
  8180. }
  8181. function flushPreFlushCbs(seen, parentJob = null) {
  8182. if (pendingPreFlushCbs.length) {
  8183. currentPreFlushParentJob = parentJob;
  8184. activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
  8185. pendingPreFlushCbs.length = 0;
  8186. {
  8187. seen = seen || new Map();
  8188. }
  8189. for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
  8190. if (checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex])) {
  8191. continue;
  8192. }
  8193. activePreFlushCbs[preFlushIndex]();
  8194. }
  8195. activePreFlushCbs = null;
  8196. preFlushIndex = 0;
  8197. currentPreFlushParentJob = null;
  8198. // recursively flush until it drains
  8199. flushPreFlushCbs(seen, parentJob);
  8200. }
  8201. }
  8202. function flushPostFlushCbs(seen) {
  8203. if (pendingPostFlushCbs.length) {
  8204. const deduped = [...new Set(pendingPostFlushCbs)];
  8205. pendingPostFlushCbs.length = 0;
  8206. // #1947 already has active queue, nested flushPostFlushCbs call
  8207. if (activePostFlushCbs) {
  8208. activePostFlushCbs.push(...deduped);
  8209. return;
  8210. }
  8211. activePostFlushCbs = deduped;
  8212. {
  8213. seen = seen || new Map();
  8214. }
  8215. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  8216. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  8217. if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
  8218. continue;
  8219. }
  8220. activePostFlushCbs[postFlushIndex]();
  8221. }
  8222. activePostFlushCbs = null;
  8223. postFlushIndex = 0;
  8224. }
  8225. }
  8226. const getId = (job) => job.id == null ? Infinity : job.id;
  8227. function flushJobs(seen) {
  8228. isFlushPending = false;
  8229. isFlushing = true;
  8230. {
  8231. seen = seen || new Map();
  8232. }
  8233. flushPreFlushCbs(seen);
  8234. // Sort queue before flush.
  8235. // This ensures that:
  8236. // 1. Components are updated from parent to child. (because parent is always
  8237. // created before the child so its render effect will have smaller
  8238. // priority number)
  8239. // 2. If a component is unmounted during a parent component's update,
  8240. // its update can be skipped.
  8241. queue.sort((a, b) => getId(a) - getId(b));
  8242. // conditional usage of checkRecursiveUpdate must be determined out of
  8243. // try ... catch block since Rollup by default de-optimizes treeshaking
  8244. // inside try-catch. This can leave all warning code unshaked. Although
  8245. // they would get eventually shaken by a minifier like terser, some minifiers
  8246. // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
  8247. const check = (job) => checkRecursiveUpdates(seen, job)
  8248. ;
  8249. try {
  8250. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  8251. const job = queue[flushIndex];
  8252. if (job && job.active !== false) {
  8253. if (true && check(job)) {
  8254. continue;
  8255. }
  8256. // console.log(`running:`, job.id)
  8257. callWithErrorHandling(job, null, 14 /* SCHEDULER */);
  8258. }
  8259. }
  8260. }
  8261. finally {
  8262. flushIndex = 0;
  8263. queue.length = 0;
  8264. flushPostFlushCbs(seen);
  8265. isFlushing = false;
  8266. currentFlushPromise = null;
  8267. // some postFlushCb queued jobs!
  8268. // keep flushing until it drains.
  8269. if (queue.length ||
  8270. pendingPreFlushCbs.length ||
  8271. pendingPostFlushCbs.length) {
  8272. flushJobs(seen);
  8273. }
  8274. }
  8275. }
  8276. function checkRecursiveUpdates(seen, fn) {
  8277. if (!seen.has(fn)) {
  8278. seen.set(fn, 1);
  8279. }
  8280. else {
  8281. const count = seen.get(fn);
  8282. if (count > RECURSION_LIMIT) {
  8283. const instance = fn.ownerInstance;
  8284. const componentName = instance && getComponentName(instance.type);
  8285. warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
  8286. `This means you have a reactive effect that is mutating its own ` +
  8287. `dependencies and thus recursively triggering itself. Possible sources ` +
  8288. `include component template, render function, updated hook or ` +
  8289. `watcher source function.`);
  8290. return true;
  8291. }
  8292. else {
  8293. seen.set(fn, count + 1);
  8294. }
  8295. }
  8296. }
  8297. // Simple effect.
  8298. function watchEffect(effect, options) {
  8299. return doWatch(effect, null, options);
  8300. }
  8301. function watchPostEffect(effect, options) {
  8302. return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
  8303. ));
  8304. }
  8305. function watchSyncEffect(effect, options) {
  8306. return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
  8307. ));
  8308. }
  8309. // initial value for watchers to trigger on undefined initial values
  8310. const INITIAL_WATCHER_VALUE = {};
  8311. // implementation
  8312. function watch(source, cb, options) {
  8313. if (!isFunction(cb)) {
  8314. warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  8315. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  8316. `supports \`watch(source, cb, options?) signature.`);
  8317. }
  8318. return doWatch(source, cb, options);
  8319. }
  8320. function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
  8321. if (!cb) {
  8322. if (immediate !== undefined) {
  8323. warn$1(`watch() "immediate" option is only respected when using the ` +
  8324. `watch(source, callback, options?) signature.`);
  8325. }
  8326. if (deep !== undefined) {
  8327. warn$1(`watch() "deep" option is only respected when using the ` +
  8328. `watch(source, callback, options?) signature.`);
  8329. }
  8330. }
  8331. const warnInvalidSource = (s) => {
  8332. warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
  8333. `a reactive object, or an array of these types.`);
  8334. };
  8335. const instance = currentInstance;
  8336. let getter;
  8337. let forceTrigger = false;
  8338. let isMultiSource = false;
  8339. if (isRef(source)) {
  8340. getter = () => source.value;
  8341. forceTrigger = !!source._shallow;
  8342. }
  8343. else if (isReactive(source)) {
  8344. getter = () => source;
  8345. deep = true;
  8346. }
  8347. else if (isArray(source)) {
  8348. isMultiSource = true;
  8349. forceTrigger = source.some(isReactive);
  8350. getter = () => source.map(s => {
  8351. if (isRef(s)) {
  8352. return s.value;
  8353. }
  8354. else if (isReactive(s)) {
  8355. return traverse(s);
  8356. }
  8357. else if (isFunction(s)) {
  8358. return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */);
  8359. }
  8360. else {
  8361. warnInvalidSource(s);
  8362. }
  8363. });
  8364. }
  8365. else if (isFunction(source)) {
  8366. if (cb) {
  8367. // getter with cb
  8368. getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */);
  8369. }
  8370. else {
  8371. // no cb -> simple effect
  8372. getter = () => {
  8373. if (instance && instance.isUnmounted) {
  8374. return;
  8375. }
  8376. if (cleanup) {
  8377. cleanup();
  8378. }
  8379. return callWithAsyncErrorHandling(source, instance, 3 /* WATCH_CALLBACK */, [onInvalidate]);
  8380. };
  8381. }
  8382. }
  8383. else {
  8384. getter = NOOP;
  8385. warnInvalidSource(source);
  8386. }
  8387. if (cb && deep) {
  8388. const baseGetter = getter;
  8389. getter = () => traverse(baseGetter());
  8390. }
  8391. let cleanup;
  8392. let onInvalidate = (fn) => {
  8393. cleanup = effect.onStop = () => {
  8394. callWithErrorHandling(fn, instance, 4 /* WATCH_CLEANUP */);
  8395. };
  8396. };
  8397. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  8398. const job = () => {
  8399. if (!effect.active) {
  8400. return;
  8401. }
  8402. if (cb) {
  8403. // watch(source, cb)
  8404. const newValue = effect.run();
  8405. if (deep ||
  8406. forceTrigger ||
  8407. (isMultiSource
  8408. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  8409. : hasChanged(newValue, oldValue)) ||
  8410. (false )) {
  8411. // cleanup before running cb again
  8412. if (cleanup) {
  8413. cleanup();
  8414. }
  8415. callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [
  8416. newValue,
  8417. // pass undefined as the old value when it's changed for the first time
  8418. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  8419. onInvalidate
  8420. ]);
  8421. oldValue = newValue;
  8422. }
  8423. }
  8424. else {
  8425. // watchEffect
  8426. effect.run();
  8427. }
  8428. };
  8429. // important: mark the job as a watcher callback so that scheduler knows
  8430. // it is allowed to self-trigger (#1727)
  8431. job.allowRecurse = !!cb;
  8432. let scheduler;
  8433. if (flush === 'sync') {
  8434. scheduler = job; // the scheduler function gets called directly
  8435. }
  8436. else if (flush === 'post') {
  8437. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  8438. }
  8439. else {
  8440. // default: 'pre'
  8441. scheduler = () => {
  8442. if (!instance || instance.isMounted) {
  8443. queuePreFlushCb(job);
  8444. }
  8445. else {
  8446. // with 'pre' option, the first call must happen before
  8447. // the component is mounted so it is called synchronously.
  8448. job();
  8449. }
  8450. };
  8451. }
  8452. const effect = new ReactiveEffect(getter, scheduler);
  8453. {
  8454. effect.onTrack = onTrack;
  8455. effect.onTrigger = onTrigger;
  8456. }
  8457. // initial run
  8458. if (cb) {
  8459. if (immediate) {
  8460. job();
  8461. }
  8462. else {
  8463. oldValue = effect.run();
  8464. }
  8465. }
  8466. else if (flush === 'post') {
  8467. queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
  8468. }
  8469. else {
  8470. effect.run();
  8471. }
  8472. return () => {
  8473. effect.stop();
  8474. if (instance && instance.scope) {
  8475. remove(instance.scope.effects, effect);
  8476. }
  8477. };
  8478. }
  8479. // this.$watch
  8480. function instanceWatch(source, value, options) {
  8481. const publicThis = this.proxy;
  8482. const getter = isString(source)
  8483. ? source.includes('.')
  8484. ? createPathGetter(publicThis, source)
  8485. : () => publicThis[source]
  8486. : source.bind(publicThis, publicThis);
  8487. let cb;
  8488. if (isFunction(value)) {
  8489. cb = value;
  8490. }
  8491. else {
  8492. cb = value.handler;
  8493. options = value;
  8494. }
  8495. const cur = currentInstance;
  8496. setCurrentInstance(this);
  8497. const res = doWatch(getter, cb.bind(publicThis), options);
  8498. if (cur) {
  8499. setCurrentInstance(cur);
  8500. }
  8501. else {
  8502. unsetCurrentInstance();
  8503. }
  8504. return res;
  8505. }
  8506. function createPathGetter(ctx, path) {
  8507. const segments = path.split('.');
  8508. return () => {
  8509. let cur = ctx;
  8510. for (let i = 0; i < segments.length && cur; i++) {
  8511. cur = cur[segments[i]];
  8512. }
  8513. return cur;
  8514. };
  8515. }
  8516. function traverse(value, seen) {
  8517. if (!isObject(value) || value["__v_skip" /* SKIP */]) {
  8518. return value;
  8519. }
  8520. seen = seen || new Set();
  8521. if (seen.has(value)) {
  8522. return value;
  8523. }
  8524. seen.add(value);
  8525. if (isRef(value)) {
  8526. traverse(value.value, seen);
  8527. }
  8528. else if (isArray(value)) {
  8529. for (let i = 0; i < value.length; i++) {
  8530. traverse(value[i], seen);
  8531. }
  8532. }
  8533. else if (isSet(value) || isMap(value)) {
  8534. value.forEach((v) => {
  8535. traverse(v, seen);
  8536. });
  8537. }
  8538. else if (isPlainObject(value)) {
  8539. for (const key in value) {
  8540. traverse(value[key], seen);
  8541. }
  8542. }
  8543. return value;
  8544. }
  8545. // dev only
  8546. const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
  8547. `<script setup> of a single file component. Its arguments should be ` +
  8548. `compiled away and passing it at runtime has no effect.`);
  8549. // implementation
  8550. function defineProps() {
  8551. {
  8552. warnRuntimeUsage(`defineProps`);
  8553. }
  8554. return null;
  8555. }
  8556. // implementation
  8557. function defineEmits() {
  8558. {
  8559. warnRuntimeUsage(`defineEmits`);
  8560. }
  8561. return null;
  8562. }
  8563. /**
  8564. * Vue `<script setup>` compiler macro for declaring a component's exposed
  8565. * instance properties when it is accessed by a parent component via template
  8566. * refs.
  8567. *
  8568. * `<script setup>` components are closed by default - i.e. varaibles inside
  8569. * the `<script setup>` scope is not exposed to parent unless explicitly exposed
  8570. * via `defineExpose`.
  8571. *
  8572. * This is only usable inside `<script setup>`, is compiled away in the
  8573. * output and should **not** be actually called at runtime.
  8574. */
  8575. function defineExpose(exposed) {
  8576. {
  8577. warnRuntimeUsage(`defineExpose`);
  8578. }
  8579. }
  8580. /**
  8581. * Vue `<script setup>` compiler macro for providing props default values when
  8582. * using type-based `defineProps` declaration.
  8583. *
  8584. * Example usage:
  8585. * ```ts
  8586. * withDefaults(defineProps<{
  8587. * size?: number
  8588. * labels?: string[]
  8589. * }>(), {
  8590. * size: 3,
  8591. * labels: () => ['default label']
  8592. * })
  8593. * ```
  8594. *
  8595. * This is only usable inside `<script setup>`, is compiled away in the output
  8596. * and should **not** be actually called at runtime.
  8597. */
  8598. function withDefaults(props, defaults) {
  8599. {
  8600. warnRuntimeUsage(`withDefaults`);
  8601. }
  8602. return null;
  8603. }
  8604. function useSlots() {
  8605. return getContext().slots;
  8606. }
  8607. function useAttrs() {
  8608. return getContext().attrs;
  8609. }
  8610. function getContext() {
  8611. const i = getCurrentInstance();
  8612. if (!i) {
  8613. warn$1(`useContext() called without active instance.`);
  8614. }
  8615. return i.setupContext || (i.setupContext = createSetupContext(i));
  8616. }
  8617. /**
  8618. * Runtime helper for merging default declarations. Imported by compiled code
  8619. * only.
  8620. * @internal
  8621. */
  8622. function mergeDefaults(raw, defaults) {
  8623. const props = isArray(raw)
  8624. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  8625. : raw;
  8626. for (const key in defaults) {
  8627. const opt = props[key];
  8628. if (opt) {
  8629. if (isArray(opt) || isFunction(opt)) {
  8630. props[key] = { type: opt, default: defaults[key] };
  8631. }
  8632. else {
  8633. opt.default = defaults[key];
  8634. }
  8635. }
  8636. else if (opt === null) {
  8637. props[key] = { default: defaults[key] };
  8638. }
  8639. else {
  8640. warn$1(`props default key "${key}" has no corresponding declaration.`);
  8641. }
  8642. }
  8643. return props;
  8644. }
  8645. /**
  8646. * Used to create a proxy for the rest element when destructuring props with
  8647. * defineProps().
  8648. * @internal
  8649. */
  8650. function createPropsRestProxy(props, excludedKeys) {
  8651. const ret = {};
  8652. for (const key in props) {
  8653. if (!excludedKeys.includes(key)) {
  8654. Object.defineProperty(ret, key, {
  8655. enumerable: true,
  8656. get: () => props[key]
  8657. });
  8658. }
  8659. }
  8660. return ret;
  8661. }
  8662. /**
  8663. * `<script setup>` helper for persisting the current instance context over
  8664. * async/await flows.
  8665. *
  8666. * `@vue/compiler-sfc` converts the following:
  8667. *
  8668. * ```ts
  8669. * const x = await foo()
  8670. * ```
  8671. *
  8672. * into:
  8673. *
  8674. * ```ts
  8675. * let __temp, __restore
  8676. * const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
  8677. * ```
  8678. * @internal
  8679. */
  8680. function withAsyncContext(getAwaitable) {
  8681. const ctx = getCurrentInstance();
  8682. if (!ctx) {
  8683. warn$1(`withAsyncContext called without active current instance. ` +
  8684. `This is likely a bug.`);
  8685. }
  8686. let awaitable = getAwaitable();
  8687. unsetCurrentInstance();
  8688. if (isPromise(awaitable)) {
  8689. awaitable = awaitable.catch(e => {
  8690. setCurrentInstance(ctx);
  8691. throw e;
  8692. });
  8693. }
  8694. return [awaitable, () => setCurrentInstance(ctx)];
  8695. }
  8696. // Actual implementation
  8697. function h(type, propsOrChildren, children) {
  8698. const l = arguments.length;
  8699. if (l === 2) {
  8700. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  8701. // single vnode without props
  8702. if (isVNode(propsOrChildren)) {
  8703. return createVNode(type, null, [propsOrChildren]);
  8704. }
  8705. // props without children
  8706. return createVNode(type, propsOrChildren);
  8707. }
  8708. else {
  8709. // omit props
  8710. return createVNode(type, null, propsOrChildren);
  8711. }
  8712. }
  8713. else {
  8714. if (l > 3) {
  8715. children = Array.prototype.slice.call(arguments, 2);
  8716. }
  8717. else if (l === 3 && isVNode(children)) {
  8718. children = [children];
  8719. }
  8720. return createVNode(type, propsOrChildren, children);
  8721. }
  8722. }
  8723. const ssrContextKey = Symbol(`ssrContext` );
  8724. const useSSRContext = () => {
  8725. {
  8726. warn$1(`useSSRContext() is not supported in the global build.`);
  8727. }
  8728. };
  8729. function initCustomFormatter() {
  8730. /* eslint-disable no-restricted-globals */
  8731. if (typeof window === 'undefined') {
  8732. return;
  8733. }
  8734. const vueStyle = { style: 'color:#3ba776' };
  8735. const numberStyle = { style: 'color:#0b1bc9' };
  8736. const stringStyle = { style: 'color:#b62e24' };
  8737. const keywordStyle = { style: 'color:#9d288c' };
  8738. // custom formatter for Chrome
  8739. // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
  8740. const formatter = {
  8741. header(obj) {
  8742. // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
  8743. if (!isObject(obj)) {
  8744. return null;
  8745. }
  8746. if (obj.__isVue) {
  8747. return ['div', vueStyle, `VueInstance`];
  8748. }
  8749. else if (isRef(obj)) {
  8750. return [
  8751. 'div',
  8752. {},
  8753. ['span', vueStyle, genRefFlag(obj)],
  8754. '<',
  8755. formatValue(obj.value),
  8756. `>`
  8757. ];
  8758. }
  8759. else if (isReactive(obj)) {
  8760. return [
  8761. 'div',
  8762. {},
  8763. ['span', vueStyle, 'Reactive'],
  8764. '<',
  8765. formatValue(obj),
  8766. `>${isReadonly(obj) ? ` (readonly)` : ``}`
  8767. ];
  8768. }
  8769. else if (isReadonly(obj)) {
  8770. return [
  8771. 'div',
  8772. {},
  8773. ['span', vueStyle, 'Readonly'],
  8774. '<',
  8775. formatValue(obj),
  8776. '>'
  8777. ];
  8778. }
  8779. return null;
  8780. },
  8781. hasBody(obj) {
  8782. return obj && obj.__isVue;
  8783. },
  8784. body(obj) {
  8785. if (obj && obj.__isVue) {
  8786. return [
  8787. 'div',
  8788. {},
  8789. ...formatInstance(obj.$)
  8790. ];
  8791. }
  8792. }
  8793. };
  8794. function formatInstance(instance) {
  8795. const blocks = [];
  8796. if (instance.type.props && instance.props) {
  8797. blocks.push(createInstanceBlock('props', toRaw(instance.props)));
  8798. }
  8799. if (instance.setupState !== EMPTY_OBJ) {
  8800. blocks.push(createInstanceBlock('setup', instance.setupState));
  8801. }
  8802. if (instance.data !== EMPTY_OBJ) {
  8803. blocks.push(createInstanceBlock('data', toRaw(instance.data)));
  8804. }
  8805. const computed = extractKeys(instance, 'computed');
  8806. if (computed) {
  8807. blocks.push(createInstanceBlock('computed', computed));
  8808. }
  8809. const injected = extractKeys(instance, 'inject');
  8810. if (injected) {
  8811. blocks.push(createInstanceBlock('injected', injected));
  8812. }
  8813. blocks.push([
  8814. 'div',
  8815. {},
  8816. [
  8817. 'span',
  8818. {
  8819. style: keywordStyle.style + ';opacity:0.66'
  8820. },
  8821. '$ (internal): '
  8822. ],
  8823. ['object', { object: instance }]
  8824. ]);
  8825. return blocks;
  8826. }
  8827. function createInstanceBlock(type, target) {
  8828. target = extend({}, target);
  8829. if (!Object.keys(target).length) {
  8830. return ['span', {}];
  8831. }
  8832. return [
  8833. 'div',
  8834. { style: 'line-height:1.25em;margin-bottom:0.6em' },
  8835. [
  8836. 'div',
  8837. {
  8838. style: 'color:#476582'
  8839. },
  8840. type
  8841. ],
  8842. [
  8843. 'div',
  8844. {
  8845. style: 'padding-left:1.25em'
  8846. },
  8847. ...Object.keys(target).map(key => {
  8848. return [
  8849. 'div',
  8850. {},
  8851. ['span', keywordStyle, key + ': '],
  8852. formatValue(target[key], false)
  8853. ];
  8854. })
  8855. ]
  8856. ];
  8857. }
  8858. function formatValue(v, asRaw = true) {
  8859. if (typeof v === 'number') {
  8860. return ['span', numberStyle, v];
  8861. }
  8862. else if (typeof v === 'string') {
  8863. return ['span', stringStyle, JSON.stringify(v)];
  8864. }
  8865. else if (typeof v === 'boolean') {
  8866. return ['span', keywordStyle, v];
  8867. }
  8868. else if (isObject(v)) {
  8869. return ['object', { object: asRaw ? toRaw(v) : v }];
  8870. }
  8871. else {
  8872. return ['span', stringStyle, String(v)];
  8873. }
  8874. }
  8875. function extractKeys(instance, type) {
  8876. const Comp = instance.type;
  8877. if (isFunction(Comp)) {
  8878. return;
  8879. }
  8880. const extracted = {};
  8881. for (const key in instance.ctx) {
  8882. if (isKeyOfType(Comp, key, type)) {
  8883. extracted[key] = instance.ctx[key];
  8884. }
  8885. }
  8886. return extracted;
  8887. }
  8888. function isKeyOfType(Comp, key, type) {
  8889. const opts = Comp[type];
  8890. if ((isArray(opts) && opts.includes(key)) ||
  8891. (isObject(opts) && key in opts)) {
  8892. return true;
  8893. }
  8894. if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
  8895. return true;
  8896. }
  8897. if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
  8898. return true;
  8899. }
  8900. }
  8901. function genRefFlag(v) {
  8902. if (v._shallow) {
  8903. return `ShallowRef`;
  8904. }
  8905. if (v.effect) {
  8906. return `ComputedRef`;
  8907. }
  8908. return `Ref`;
  8909. }
  8910. if (window.devtoolsFormatters) {
  8911. window.devtoolsFormatters.push(formatter);
  8912. }
  8913. else {
  8914. window.devtoolsFormatters = [formatter];
  8915. }
  8916. }
  8917. function withMemo(memo, render, cache, index) {
  8918. const cached = cache[index];
  8919. if (cached && isMemoSame(cached, memo)) {
  8920. return cached;
  8921. }
  8922. const ret = render();
  8923. // shallow clone
  8924. ret.memo = memo.slice();
  8925. return (cache[index] = ret);
  8926. }
  8927. function isMemoSame(cached, memo) {
  8928. const prev = cached.memo;
  8929. if (prev.length != memo.length) {
  8930. return false;
  8931. }
  8932. for (let i = 0; i < prev.length; i++) {
  8933. if (prev[i] !== memo[i]) {
  8934. return false;
  8935. }
  8936. }
  8937. // make sure to let parent block track it when returning cached
  8938. if (isBlockTreeEnabled > 0 && currentBlock) {
  8939. currentBlock.push(cached);
  8940. }
  8941. return true;
  8942. }
  8943. // Core API ------------------------------------------------------------------
  8944. const version = "3.2.25";
  8945. /**
  8946. * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
  8947. * @internal
  8948. */
  8949. const ssrUtils = (null);
  8950. /**
  8951. * @internal only exposed in compat builds
  8952. */
  8953. const resolveFilter = null;
  8954. /**
  8955. * @internal only exposed in compat builds.
  8956. */
  8957. const compatUtils = (null);
  8958. const svgNS = 'http://www.w3.org/2000/svg';
  8959. const doc = (typeof document !== 'undefined' ? document : null);
  8960. const staticTemplateCache = new Map();
  8961. const nodeOps = {
  8962. insert: (child, parent, anchor) => {
  8963. parent.insertBefore(child, anchor || null);
  8964. },
  8965. remove: child => {
  8966. const parent = child.parentNode;
  8967. if (parent) {
  8968. parent.removeChild(child);
  8969. }
  8970. },
  8971. createElement: (tag, isSVG, is, props) => {
  8972. const el = isSVG
  8973. ? doc.createElementNS(svgNS, tag)
  8974. : doc.createElement(tag, is ? { is } : undefined);
  8975. if (tag === 'select' && props && props.multiple != null) {
  8976. el.setAttribute('multiple', props.multiple);
  8977. }
  8978. return el;
  8979. },
  8980. createText: text => doc.createTextNode(text),
  8981. createComment: text => doc.createComment(text),
  8982. setText: (node, text) => {
  8983. node.nodeValue = text;
  8984. },
  8985. setElementText: (el, text) => {
  8986. el.textContent = text;
  8987. },
  8988. parentNode: node => node.parentNode,
  8989. nextSibling: node => node.nextSibling,
  8990. querySelector: selector => doc.querySelector(selector),
  8991. setScopeId(el, id) {
  8992. el.setAttribute(id, '');
  8993. },
  8994. cloneNode(el) {
  8995. const cloned = el.cloneNode(true);
  8996. // #3072
  8997. // - in `patchDOMProp`, we store the actual value in the `el._value` property.
  8998. // - normally, elements using `:value` bindings will not be hoisted, but if
  8999. // the bound value is a constant, e.g. `:value="true"` - they do get
  9000. // hoisted.
  9001. // - in production, hoisted nodes are cloned when subsequent inserts, but
  9002. // cloneNode() does not copy the custom property we attached.
  9003. // - This may need to account for other custom DOM properties we attach to
  9004. // elements in addition to `_value` in the future.
  9005. if (`_value` in el) {
  9006. cloned._value = el._value;
  9007. }
  9008. return cloned;
  9009. },
  9010. // __UNSAFE__
  9011. // Reason: innerHTML.
  9012. // Static content here can only come from compiled templates.
  9013. // As long as the user only uses trusted templates, this is safe.
  9014. insertStaticContent(content, parent, anchor, isSVG) {
  9015. // <parent> before | first ... last | anchor </parent>
  9016. const before = anchor ? anchor.previousSibling : parent.lastChild;
  9017. let template = staticTemplateCache.get(content);
  9018. if (!template) {
  9019. const t = doc.createElement('template');
  9020. t.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
  9021. template = t.content;
  9022. if (isSVG) {
  9023. // remove outer svg wrapper
  9024. const wrapper = template.firstChild;
  9025. while (wrapper.firstChild) {
  9026. template.appendChild(wrapper.firstChild);
  9027. }
  9028. template.removeChild(wrapper);
  9029. }
  9030. staticTemplateCache.set(content, template);
  9031. }
  9032. parent.insertBefore(template.cloneNode(true), anchor);
  9033. return [
  9034. // first
  9035. before ? before.nextSibling : parent.firstChild,
  9036. // last
  9037. anchor ? anchor.previousSibling : parent.lastChild
  9038. ];
  9039. }
  9040. };
  9041. // compiler should normalize class + :class bindings on the same element
  9042. // into a single binding ['staticClass', dynamic]
  9043. function patchClass(el, value, isSVG) {
  9044. // directly setting className should be faster than setAttribute in theory
  9045. // if this is an element during a transition, take the temporary transition
  9046. // classes into account.
  9047. const transitionClasses = el._vtc;
  9048. if (transitionClasses) {
  9049. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
  9050. }
  9051. if (value == null) {
  9052. el.removeAttribute('class');
  9053. }
  9054. else if (isSVG) {
  9055. el.setAttribute('class', value);
  9056. }
  9057. else {
  9058. el.className = value;
  9059. }
  9060. }
  9061. function patchStyle(el, prev, next) {
  9062. const style = el.style;
  9063. const isCssString = isString(next);
  9064. if (next && !isCssString) {
  9065. for (const key in next) {
  9066. setStyle(style, key, next[key]);
  9067. }
  9068. if (prev && !isString(prev)) {
  9069. for (const key in prev) {
  9070. if (next[key] == null) {
  9071. setStyle(style, key, '');
  9072. }
  9073. }
  9074. }
  9075. }
  9076. else {
  9077. const currentDisplay = style.display;
  9078. if (isCssString) {
  9079. if (prev !== next) {
  9080. style.cssText = next;
  9081. }
  9082. }
  9083. else if (prev) {
  9084. el.removeAttribute('style');
  9085. }
  9086. // indicates that the `display` of the element is controlled by `v-show`,
  9087. // so we always keep the current `display` value regardless of the `style`
  9088. // value, thus handing over control to `v-show`.
  9089. if ('_vod' in el) {
  9090. style.display = currentDisplay;
  9091. }
  9092. }
  9093. }
  9094. const importantRE = /\s*!important$/;
  9095. function setStyle(style, name, val) {
  9096. if (isArray(val)) {
  9097. val.forEach(v => setStyle(style, name, v));
  9098. }
  9099. else {
  9100. if (name.startsWith('--')) {
  9101. // custom property definition
  9102. style.setProperty(name, val);
  9103. }
  9104. else {
  9105. const prefixed = autoPrefix(style, name);
  9106. if (importantRE.test(val)) {
  9107. // !important
  9108. style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
  9109. }
  9110. else {
  9111. style[prefixed] = val;
  9112. }
  9113. }
  9114. }
  9115. }
  9116. const prefixes = ['Webkit', 'Moz', 'ms'];
  9117. const prefixCache = {};
  9118. function autoPrefix(style, rawName) {
  9119. const cached = prefixCache[rawName];
  9120. if (cached) {
  9121. return cached;
  9122. }
  9123. let name = camelize(rawName);
  9124. if (name !== 'filter' && name in style) {
  9125. return (prefixCache[rawName] = name);
  9126. }
  9127. name = capitalize(name);
  9128. for (let i = 0; i < prefixes.length; i++) {
  9129. const prefixed = prefixes[i] + name;
  9130. if (prefixed in style) {
  9131. return (prefixCache[rawName] = prefixed);
  9132. }
  9133. }
  9134. return rawName;
  9135. }
  9136. const xlinkNS = 'http://www.w3.org/1999/xlink';
  9137. function patchAttr(el, key, value, isSVG, instance) {
  9138. if (isSVG && key.startsWith('xlink:')) {
  9139. if (value == null) {
  9140. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  9141. }
  9142. else {
  9143. el.setAttributeNS(xlinkNS, key, value);
  9144. }
  9145. }
  9146. else {
  9147. // note we are only checking boolean attributes that don't have a
  9148. // corresponding dom prop of the same name here.
  9149. const isBoolean = isSpecialBooleanAttr(key);
  9150. if (value == null || (isBoolean && !includeBooleanAttr(value))) {
  9151. el.removeAttribute(key);
  9152. }
  9153. else {
  9154. el.setAttribute(key, isBoolean ? '' : value);
  9155. }
  9156. }
  9157. }
  9158. // __UNSAFE__
  9159. // functions. The user is responsible for using them with only trusted content.
  9160. function patchDOMProp(el, key, value,
  9161. // the following args are passed only due to potential innerHTML/textContent
  9162. // overriding existing VNodes, in which case the old tree must be properly
  9163. // unmounted.
  9164. prevChildren, parentComponent, parentSuspense, unmountChildren) {
  9165. if (key === 'innerHTML' || key === 'textContent') {
  9166. if (prevChildren) {
  9167. unmountChildren(prevChildren, parentComponent, parentSuspense);
  9168. }
  9169. el[key] = value == null ? '' : value;
  9170. return;
  9171. }
  9172. if (key === 'value' &&
  9173. el.tagName !== 'PROGRESS' &&
  9174. // custom elements may use _value internally
  9175. !el.tagName.includes('-')) {
  9176. // store value as _value as well since
  9177. // non-string values will be stringified.
  9178. el._value = value;
  9179. const newValue = value == null ? '' : value;
  9180. if (el.value !== newValue ||
  9181. // #4956: always set for OPTION elements because its value falls back to
  9182. // textContent if no value attribute is present. And setting .value for
  9183. // OPTION has no side effect
  9184. el.tagName === 'OPTION') {
  9185. el.value = newValue;
  9186. }
  9187. if (value == null) {
  9188. el.removeAttribute(key);
  9189. }
  9190. return;
  9191. }
  9192. if (value === '' || value == null) {
  9193. const type = typeof el[key];
  9194. if (type === 'boolean') {
  9195. // e.g. <select multiple> compiles to { multiple: '' }
  9196. el[key] = includeBooleanAttr(value);
  9197. return;
  9198. }
  9199. else if (value == null && type === 'string') {
  9200. // e.g. <div :id="null">
  9201. el[key] = '';
  9202. el.removeAttribute(key);
  9203. return;
  9204. }
  9205. else if (type === 'number') {
  9206. // e.g. <img :width="null">
  9207. // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
  9208. try {
  9209. el[key] = 0;
  9210. }
  9211. catch (_a) { }
  9212. el.removeAttribute(key);
  9213. return;
  9214. }
  9215. }
  9216. // some properties perform value validation and throw
  9217. try {
  9218. el[key] = value;
  9219. }
  9220. catch (e) {
  9221. {
  9222. warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
  9223. `value ${value} is invalid.`, e);
  9224. }
  9225. }
  9226. }
  9227. // Async edge case fix requires storing an event listener's attach timestamp.
  9228. let _getNow = Date.now;
  9229. let skipTimestampCheck = false;
  9230. if (typeof window !== 'undefined') {
  9231. // Determine what event timestamp the browser is using. Annoyingly, the
  9232. // timestamp can either be hi-res (relative to page load) or low-res
  9233. // (relative to UNIX epoch), so in order to compare time we have to use the
  9234. // same timestamp type when saving the flush timestamp.
  9235. if (_getNow() > document.createEvent('Event').timeStamp) {
  9236. // if the low-res timestamp which is bigger than the event timestamp
  9237. // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
  9238. // and we need to use the hi-res version for event listeners as well.
  9239. _getNow = () => performance.now();
  9240. }
  9241. // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
  9242. // and does not fire microtasks in between event propagation, so safe to exclude.
  9243. const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
  9244. skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
  9245. }
  9246. // To avoid the overhead of repeatedly calling performance.now(), we cache
  9247. // and use the same timestamp for all event listeners attached in the same tick.
  9248. let cachedNow = 0;
  9249. const p = Promise.resolve();
  9250. const reset = () => {
  9251. cachedNow = 0;
  9252. };
  9253. const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
  9254. function addEventListener(el, event, handler, options) {
  9255. el.addEventListener(event, handler, options);
  9256. }
  9257. function removeEventListener(el, event, handler, options) {
  9258. el.removeEventListener(event, handler, options);
  9259. }
  9260. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  9261. // vei = vue event invokers
  9262. const invokers = el._vei || (el._vei = {});
  9263. const existingInvoker = invokers[rawName];
  9264. if (nextValue && existingInvoker) {
  9265. // patch
  9266. existingInvoker.value = nextValue;
  9267. }
  9268. else {
  9269. const [name, options] = parseName(rawName);
  9270. if (nextValue) {
  9271. // add
  9272. const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
  9273. addEventListener(el, name, invoker, options);
  9274. }
  9275. else if (existingInvoker) {
  9276. // remove
  9277. removeEventListener(el, name, existingInvoker, options);
  9278. invokers[rawName] = undefined;
  9279. }
  9280. }
  9281. }
  9282. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  9283. function parseName(name) {
  9284. let options;
  9285. if (optionsModifierRE.test(name)) {
  9286. options = {};
  9287. let m;
  9288. while ((m = name.match(optionsModifierRE))) {
  9289. name = name.slice(0, name.length - m[0].length);
  9290. options[m[0].toLowerCase()] = true;
  9291. }
  9292. }
  9293. return [hyphenate(name.slice(2)), options];
  9294. }
  9295. function createInvoker(initialValue, instance) {
  9296. const invoker = (e) => {
  9297. // async edge case #6566: inner click event triggers patch, event handler
  9298. // attached to outer element during patch, and triggered again. This
  9299. // happens because browsers fire microtask ticks between event propagation.
  9300. // the solution is simple: we save the timestamp when a handler is attached,
  9301. // and the handler would only fire if the event passed to it was fired
  9302. // AFTER it was attached.
  9303. const timeStamp = e.timeStamp || _getNow();
  9304. if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
  9305. callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, [e]);
  9306. }
  9307. };
  9308. invoker.value = initialValue;
  9309. invoker.attached = getNow();
  9310. return invoker;
  9311. }
  9312. function patchStopImmediatePropagation(e, value) {
  9313. if (isArray(value)) {
  9314. const originalStop = e.stopImmediatePropagation;
  9315. e.stopImmediatePropagation = () => {
  9316. originalStop.call(e);
  9317. e._stopped = true;
  9318. };
  9319. return value.map(fn => (e) => !e._stopped && fn(e));
  9320. }
  9321. else {
  9322. return value;
  9323. }
  9324. }
  9325. const nativeOnRE = /^on[a-z]/;
  9326. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  9327. if (key === 'class') {
  9328. patchClass(el, nextValue, isSVG);
  9329. }
  9330. else if (key === 'style') {
  9331. patchStyle(el, prevValue, nextValue);
  9332. }
  9333. else if (isOn(key)) {
  9334. // ignore v-model listeners
  9335. if (!isModelListener(key)) {
  9336. patchEvent(el, key, prevValue, nextValue, parentComponent);
  9337. }
  9338. }
  9339. else if (key[0] === '.'
  9340. ? ((key = key.slice(1)), true)
  9341. : key[0] === '^'
  9342. ? ((key = key.slice(1)), false)
  9343. : shouldSetAsProp(el, key, nextValue, isSVG)) {
  9344. patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
  9345. }
  9346. else {
  9347. // special case for <input v-model type="checkbox"> with
  9348. // :true-value & :false-value
  9349. // store value as dom properties since non-string values will be
  9350. // stringified.
  9351. if (key === 'true-value') {
  9352. el._trueValue = nextValue;
  9353. }
  9354. else if (key === 'false-value') {
  9355. el._falseValue = nextValue;
  9356. }
  9357. patchAttr(el, key, nextValue, isSVG);
  9358. }
  9359. };
  9360. function shouldSetAsProp(el, key, value, isSVG) {
  9361. if (isSVG) {
  9362. // most keys must be set as attribute on svg elements to work
  9363. // ...except innerHTML & textContent
  9364. if (key === 'innerHTML' || key === 'textContent') {
  9365. return true;
  9366. }
  9367. // or native onclick with function values
  9368. if (key in el && nativeOnRE.test(key) && isFunction(value)) {
  9369. return true;
  9370. }
  9371. return false;
  9372. }
  9373. // spellcheck and draggable are numerated attrs, however their
  9374. // corresponding DOM properties are actually booleans - this leads to
  9375. // setting it with a string "false" value leading it to be coerced to
  9376. // `true`, so we need to always treat them as attributes.
  9377. // Note that `contentEditable` doesn't have this problem: its DOM
  9378. // property is also enumerated string values.
  9379. if (key === 'spellcheck' || key === 'draggable') {
  9380. return false;
  9381. }
  9382. // #1787, #2840 form property on form elements is readonly and must be set as
  9383. // attribute.
  9384. if (key === 'form') {
  9385. return false;
  9386. }
  9387. // #1526 <input list> must be set as attribute
  9388. if (key === 'list' && el.tagName === 'INPUT') {
  9389. return false;
  9390. }
  9391. // #2766 <textarea type> must be set as attribute
  9392. if (key === 'type' && el.tagName === 'TEXTAREA') {
  9393. return false;
  9394. }
  9395. // native onclick with string value, must be set as attribute
  9396. if (nativeOnRE.test(key) && isString(value)) {
  9397. return false;
  9398. }
  9399. return key in el;
  9400. }
  9401. function defineCustomElement(options, hydate) {
  9402. const Comp = defineComponent(options);
  9403. class VueCustomElement extends VueElement {
  9404. constructor(initialProps) {
  9405. super(Comp, initialProps, hydate);
  9406. }
  9407. }
  9408. VueCustomElement.def = Comp;
  9409. return VueCustomElement;
  9410. }
  9411. const defineSSRCustomElement = ((options) => {
  9412. // @ts-ignore
  9413. return defineCustomElement(options, hydrate);
  9414. });
  9415. const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
  9416. });
  9417. class VueElement extends BaseClass {
  9418. constructor(_def, _props = {}, hydrate) {
  9419. super();
  9420. this._def = _def;
  9421. this._props = _props;
  9422. /**
  9423. * @internal
  9424. */
  9425. this._instance = null;
  9426. this._connected = false;
  9427. this._resolved = false;
  9428. this._numberProps = null;
  9429. if (this.shadowRoot && hydrate) {
  9430. hydrate(this._createVNode(), this.shadowRoot);
  9431. }
  9432. else {
  9433. if (this.shadowRoot) {
  9434. warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
  9435. `defined as hydratable. Use \`defineSSRCustomElement\`.`);
  9436. }
  9437. this.attachShadow({ mode: 'open' });
  9438. }
  9439. }
  9440. connectedCallback() {
  9441. this._connected = true;
  9442. if (!this._instance) {
  9443. this._resolveDef();
  9444. }
  9445. }
  9446. disconnectedCallback() {
  9447. this._connected = false;
  9448. nextTick(() => {
  9449. if (!this._connected) {
  9450. render(null, this.shadowRoot);
  9451. this._instance = null;
  9452. }
  9453. });
  9454. }
  9455. /**
  9456. * resolve inner component definition (handle possible async component)
  9457. */
  9458. _resolveDef() {
  9459. if (this._resolved) {
  9460. return;
  9461. }
  9462. this._resolved = true;
  9463. // set initial attrs
  9464. for (let i = 0; i < this.attributes.length; i++) {
  9465. this._setAttr(this.attributes[i].name);
  9466. }
  9467. // watch future attr changes
  9468. new MutationObserver(mutations => {
  9469. for (const m of mutations) {
  9470. this._setAttr(m.attributeName);
  9471. }
  9472. }).observe(this, { attributes: true });
  9473. const resolve = (def) => {
  9474. const { props, styles } = def;
  9475. const hasOptions = !isArray(props);
  9476. const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
  9477. // cast Number-type props set before resolve
  9478. let numberProps;
  9479. if (hasOptions) {
  9480. for (const key in this._props) {
  9481. const opt = props[key];
  9482. if (opt === Number || (opt && opt.type === Number)) {
  9483. this._props[key] = toNumber(this._props[key]);
  9484. (numberProps || (numberProps = Object.create(null)))[key] = true;
  9485. }
  9486. }
  9487. }
  9488. this._numberProps = numberProps;
  9489. // check if there are props set pre-upgrade or connect
  9490. for (const key of Object.keys(this)) {
  9491. if (key[0] !== '_') {
  9492. this._setProp(key, this[key], true, false);
  9493. }
  9494. }
  9495. // defining getter/setters on prototype
  9496. for (const key of rawKeys.map(camelize)) {
  9497. Object.defineProperty(this, key, {
  9498. get() {
  9499. return this._getProp(key);
  9500. },
  9501. set(val) {
  9502. this._setProp(key, val);
  9503. }
  9504. });
  9505. }
  9506. // apply CSS
  9507. this._applyStyles(styles);
  9508. // initial render
  9509. this._update();
  9510. };
  9511. const asyncDef = this._def.__asyncLoader;
  9512. if (asyncDef) {
  9513. asyncDef().then(resolve);
  9514. }
  9515. else {
  9516. resolve(this._def);
  9517. }
  9518. }
  9519. _setAttr(key) {
  9520. let value = this.getAttribute(key);
  9521. if (this._numberProps && this._numberProps[key]) {
  9522. value = toNumber(value);
  9523. }
  9524. this._setProp(camelize(key), value, false);
  9525. }
  9526. /**
  9527. * @internal
  9528. */
  9529. _getProp(key) {
  9530. return this._props[key];
  9531. }
  9532. /**
  9533. * @internal
  9534. */
  9535. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  9536. if (val !== this._props[key]) {
  9537. this._props[key] = val;
  9538. if (shouldUpdate && this._instance) {
  9539. this._update();
  9540. }
  9541. // reflect
  9542. if (shouldReflect) {
  9543. if (val === true) {
  9544. this.setAttribute(hyphenate(key), '');
  9545. }
  9546. else if (typeof val === 'string' || typeof val === 'number') {
  9547. this.setAttribute(hyphenate(key), val + '');
  9548. }
  9549. else if (!val) {
  9550. this.removeAttribute(hyphenate(key));
  9551. }
  9552. }
  9553. }
  9554. }
  9555. _update() {
  9556. render(this._createVNode(), this.shadowRoot);
  9557. }
  9558. _createVNode() {
  9559. const vnode = createVNode(this._def, extend({}, this._props));
  9560. if (!this._instance) {
  9561. vnode.ce = instance => {
  9562. this._instance = instance;
  9563. instance.isCE = true;
  9564. // HMR
  9565. {
  9566. instance.ceReload = newStyles => {
  9567. // always reset styles
  9568. if (this._styles) {
  9569. this._styles.forEach(s => this.shadowRoot.removeChild(s));
  9570. this._styles.length = 0;
  9571. }
  9572. this._applyStyles(newStyles);
  9573. // if this is an async component, ceReload is called from the inner
  9574. // component so no need to reload the async wrapper
  9575. if (!this._def.__asyncLoader) {
  9576. // reload
  9577. this._instance = null;
  9578. this._update();
  9579. }
  9580. };
  9581. }
  9582. // intercept emit
  9583. instance.emit = (event, ...args) => {
  9584. this.dispatchEvent(new CustomEvent(event, {
  9585. detail: args
  9586. }));
  9587. };
  9588. // locate nearest Vue custom element parent for provide/inject
  9589. let parent = this;
  9590. while ((parent =
  9591. parent && (parent.parentNode || parent.host))) {
  9592. if (parent instanceof VueElement) {
  9593. instance.parent = parent._instance;
  9594. break;
  9595. }
  9596. }
  9597. };
  9598. }
  9599. return vnode;
  9600. }
  9601. _applyStyles(styles) {
  9602. if (styles) {
  9603. styles.forEach(css => {
  9604. const s = document.createElement('style');
  9605. s.textContent = css;
  9606. this.shadowRoot.appendChild(s);
  9607. // record for HMR
  9608. {
  9609. (this._styles || (this._styles = [])).push(s);
  9610. }
  9611. });
  9612. }
  9613. }
  9614. }
  9615. function useCssModule(name = '$style') {
  9616. /* istanbul ignore else */
  9617. {
  9618. {
  9619. warn$1(`useCssModule() is not supported in the global build.`);
  9620. }
  9621. return EMPTY_OBJ;
  9622. }
  9623. }
  9624. /**
  9625. * Runtime helper for SFC's CSS variable injection feature.
  9626. * @private
  9627. */
  9628. function useCssVars(getter) {
  9629. const instance = getCurrentInstance();
  9630. /* istanbul ignore next */
  9631. if (!instance) {
  9632. warn$1(`useCssVars is called without current active component instance.`);
  9633. return;
  9634. }
  9635. const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
  9636. watchPostEffect(setVars);
  9637. onMounted(() => {
  9638. const ob = new MutationObserver(setVars);
  9639. ob.observe(instance.subTree.el.parentNode, { childList: true });
  9640. onUnmounted(() => ob.disconnect());
  9641. });
  9642. }
  9643. function setVarsOnVNode(vnode, vars) {
  9644. if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  9645. const suspense = vnode.suspense;
  9646. vnode = suspense.activeBranch;
  9647. if (suspense.pendingBranch && !suspense.isHydrating) {
  9648. suspense.effects.push(() => {
  9649. setVarsOnVNode(suspense.activeBranch, vars);
  9650. });
  9651. }
  9652. }
  9653. // drill down HOCs until it's a non-component vnode
  9654. while (vnode.component) {
  9655. vnode = vnode.component.subTree;
  9656. }
  9657. if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
  9658. setVarsOnNode(vnode.el, vars);
  9659. }
  9660. else if (vnode.type === Fragment) {
  9661. vnode.children.forEach(c => setVarsOnVNode(c, vars));
  9662. }
  9663. else if (vnode.type === Static) {
  9664. let { el, anchor } = vnode;
  9665. while (el) {
  9666. setVarsOnNode(el, vars);
  9667. if (el === anchor)
  9668. break;
  9669. el = el.nextSibling;
  9670. }
  9671. }
  9672. }
  9673. function setVarsOnNode(el, vars) {
  9674. if (el.nodeType === 1) {
  9675. const style = el.style;
  9676. for (const key in vars) {
  9677. style.setProperty(`--${key}`, vars[key]);
  9678. }
  9679. }
  9680. }
  9681. const TRANSITION = 'transition';
  9682. const ANIMATION = 'animation';
  9683. // DOM Transition is a higher-order-component based on the platform-agnostic
  9684. // base Transition component, with DOM-specific logic.
  9685. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
  9686. Transition.displayName = 'Transition';
  9687. const DOMTransitionPropsValidators = {
  9688. name: String,
  9689. type: String,
  9690. css: {
  9691. type: Boolean,
  9692. default: true
  9693. },
  9694. duration: [String, Number, Object],
  9695. enterFromClass: String,
  9696. enterActiveClass: String,
  9697. enterToClass: String,
  9698. appearFromClass: String,
  9699. appearActiveClass: String,
  9700. appearToClass: String,
  9701. leaveFromClass: String,
  9702. leaveActiveClass: String,
  9703. leaveToClass: String
  9704. };
  9705. const TransitionPropsValidators = (Transition.props =
  9706. /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
  9707. /**
  9708. * #3227 Incoming hooks may be merged into arrays when wrapping Transition
  9709. * with custom HOCs.
  9710. */
  9711. const callHook$1 = (hook, args = []) => {
  9712. if (isArray(hook)) {
  9713. hook.forEach(h => h(...args));
  9714. }
  9715. else if (hook) {
  9716. hook(...args);
  9717. }
  9718. };
  9719. /**
  9720. * Check if a hook expects a callback (2nd arg), which means the user
  9721. * intends to explicitly control the end of the transition.
  9722. */
  9723. const hasExplicitCallback = (hook) => {
  9724. return hook
  9725. ? isArray(hook)
  9726. ? hook.some(h => h.length > 1)
  9727. : hook.length > 1
  9728. : false;
  9729. };
  9730. function resolveTransitionProps(rawProps) {
  9731. const baseProps = {};
  9732. for (const key in rawProps) {
  9733. if (!(key in DOMTransitionPropsValidators)) {
  9734. baseProps[key] = rawProps[key];
  9735. }
  9736. }
  9737. if (rawProps.css === false) {
  9738. return baseProps;
  9739. }
  9740. const { name = 'v', type, 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;
  9741. const durations = normalizeDuration(duration);
  9742. const enterDuration = durations && durations[0];
  9743. const leaveDuration = durations && durations[1];
  9744. const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
  9745. const finishEnter = (el, isAppear, done) => {
  9746. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9747. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  9748. done && done();
  9749. };
  9750. const finishLeave = (el, done) => {
  9751. removeTransitionClass(el, leaveToClass);
  9752. removeTransitionClass(el, leaveActiveClass);
  9753. done && done();
  9754. };
  9755. const makeEnterHook = (isAppear) => {
  9756. return (el, done) => {
  9757. const hook = isAppear ? onAppear : onEnter;
  9758. const resolve = () => finishEnter(el, isAppear, done);
  9759. callHook$1(hook, [el, resolve]);
  9760. nextFrame(() => {
  9761. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  9762. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9763. if (!hasExplicitCallback(hook)) {
  9764. whenTransitionEnds(el, type, enterDuration, resolve);
  9765. }
  9766. });
  9767. };
  9768. };
  9769. return extend(baseProps, {
  9770. onBeforeEnter(el) {
  9771. callHook$1(onBeforeEnter, [el]);
  9772. addTransitionClass(el, enterFromClass);
  9773. addTransitionClass(el, enterActiveClass);
  9774. },
  9775. onBeforeAppear(el) {
  9776. callHook$1(onBeforeAppear, [el]);
  9777. addTransitionClass(el, appearFromClass);
  9778. addTransitionClass(el, appearActiveClass);
  9779. },
  9780. onEnter: makeEnterHook(false),
  9781. onAppear: makeEnterHook(true),
  9782. onLeave(el, done) {
  9783. const resolve = () => finishLeave(el, done);
  9784. addTransitionClass(el, leaveFromClass);
  9785. // force reflow so *-leave-from classes immediately take effect (#2593)
  9786. forceReflow();
  9787. addTransitionClass(el, leaveActiveClass);
  9788. nextFrame(() => {
  9789. removeTransitionClass(el, leaveFromClass);
  9790. addTransitionClass(el, leaveToClass);
  9791. if (!hasExplicitCallback(onLeave)) {
  9792. whenTransitionEnds(el, type, leaveDuration, resolve);
  9793. }
  9794. });
  9795. callHook$1(onLeave, [el, resolve]);
  9796. },
  9797. onEnterCancelled(el) {
  9798. finishEnter(el, false);
  9799. callHook$1(onEnterCancelled, [el]);
  9800. },
  9801. onAppearCancelled(el) {
  9802. finishEnter(el, true);
  9803. callHook$1(onAppearCancelled, [el]);
  9804. },
  9805. onLeaveCancelled(el) {
  9806. finishLeave(el);
  9807. callHook$1(onLeaveCancelled, [el]);
  9808. }
  9809. });
  9810. }
  9811. function normalizeDuration(duration) {
  9812. if (duration == null) {
  9813. return null;
  9814. }
  9815. else if (isObject(duration)) {
  9816. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  9817. }
  9818. else {
  9819. const n = NumberOf(duration);
  9820. return [n, n];
  9821. }
  9822. }
  9823. function NumberOf(val) {
  9824. const res = toNumber(val);
  9825. validateDuration(res);
  9826. return res;
  9827. }
  9828. function validateDuration(val) {
  9829. if (typeof val !== 'number') {
  9830. warn$1(`<transition> explicit duration is not a valid number - ` +
  9831. `got ${JSON.stringify(val)}.`);
  9832. }
  9833. else if (isNaN(val)) {
  9834. warn$1(`<transition> explicit duration is NaN - ` +
  9835. 'the duration expression might be incorrect.');
  9836. }
  9837. }
  9838. function addTransitionClass(el, cls) {
  9839. cls.split(/\s+/).forEach(c => c && el.classList.add(c));
  9840. (el._vtc ||
  9841. (el._vtc = new Set())).add(cls);
  9842. }
  9843. function removeTransitionClass(el, cls) {
  9844. cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
  9845. const { _vtc } = el;
  9846. if (_vtc) {
  9847. _vtc.delete(cls);
  9848. if (!_vtc.size) {
  9849. el._vtc = undefined;
  9850. }
  9851. }
  9852. }
  9853. function nextFrame(cb) {
  9854. requestAnimationFrame(() => {
  9855. requestAnimationFrame(cb);
  9856. });
  9857. }
  9858. let endId = 0;
  9859. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  9860. const id = (el._endId = ++endId);
  9861. const resolveIfNotStale = () => {
  9862. if (id === el._endId) {
  9863. resolve();
  9864. }
  9865. };
  9866. if (explicitTimeout) {
  9867. return setTimeout(resolveIfNotStale, explicitTimeout);
  9868. }
  9869. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  9870. if (!type) {
  9871. return resolve();
  9872. }
  9873. const endEvent = type + 'end';
  9874. let ended = 0;
  9875. const end = () => {
  9876. el.removeEventListener(endEvent, onEnd);
  9877. resolveIfNotStale();
  9878. };
  9879. const onEnd = (e) => {
  9880. if (e.target === el && ++ended >= propCount) {
  9881. end();
  9882. }
  9883. };
  9884. setTimeout(() => {
  9885. if (ended < propCount) {
  9886. end();
  9887. }
  9888. }, timeout + 1);
  9889. el.addEventListener(endEvent, onEnd);
  9890. }
  9891. function getTransitionInfo(el, expectedType) {
  9892. const styles = window.getComputedStyle(el);
  9893. // JSDOM may return undefined for transition properties
  9894. const getStyleProperties = (key) => (styles[key] || '').split(', ');
  9895. const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
  9896. const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
  9897. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  9898. const animationDelays = getStyleProperties(ANIMATION + 'Delay');
  9899. const animationDurations = getStyleProperties(ANIMATION + 'Duration');
  9900. const animationTimeout = getTimeout(animationDelays, animationDurations);
  9901. let type = null;
  9902. let timeout = 0;
  9903. let propCount = 0;
  9904. /* istanbul ignore if */
  9905. if (expectedType === TRANSITION) {
  9906. if (transitionTimeout > 0) {
  9907. type = TRANSITION;
  9908. timeout = transitionTimeout;
  9909. propCount = transitionDurations.length;
  9910. }
  9911. }
  9912. else if (expectedType === ANIMATION) {
  9913. if (animationTimeout > 0) {
  9914. type = ANIMATION;
  9915. timeout = animationTimeout;
  9916. propCount = animationDurations.length;
  9917. }
  9918. }
  9919. else {
  9920. timeout = Math.max(transitionTimeout, animationTimeout);
  9921. type =
  9922. timeout > 0
  9923. ? transitionTimeout > animationTimeout
  9924. ? TRANSITION
  9925. : ANIMATION
  9926. : null;
  9927. propCount = type
  9928. ? type === TRANSITION
  9929. ? transitionDurations.length
  9930. : animationDurations.length
  9931. : 0;
  9932. }
  9933. const hasTransform = type === TRANSITION &&
  9934. /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
  9935. return {
  9936. type,
  9937. timeout,
  9938. propCount,
  9939. hasTransform
  9940. };
  9941. }
  9942. function getTimeout(delays, durations) {
  9943. while (delays.length < durations.length) {
  9944. delays = delays.concat(delays);
  9945. }
  9946. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  9947. }
  9948. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer
  9949. // numbers in a locale-dependent way, using a comma instead of a dot.
  9950. // If comma is not replaced with a dot, the input will be rounded down
  9951. // (i.e. acting as a floor function) causing unexpected behaviors
  9952. function toMs(s) {
  9953. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  9954. }
  9955. // synchronously force layout to put elements into a certain state
  9956. function forceReflow() {
  9957. return document.body.offsetHeight;
  9958. }
  9959. const positionMap = new WeakMap();
  9960. const newPositionMap = new WeakMap();
  9961. const TransitionGroupImpl = {
  9962. name: 'TransitionGroup',
  9963. props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
  9964. tag: String,
  9965. moveClass: String
  9966. }),
  9967. setup(props, { slots }) {
  9968. const instance = getCurrentInstance();
  9969. const state = useTransitionState();
  9970. let prevChildren;
  9971. let children;
  9972. onUpdated(() => {
  9973. // children is guaranteed to exist after initial render
  9974. if (!prevChildren.length) {
  9975. return;
  9976. }
  9977. const moveClass = props.moveClass || `${props.name || 'v'}-move`;
  9978. if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
  9979. return;
  9980. }
  9981. // we divide the work into three loops to avoid mixing DOM reads and writes
  9982. // in each iteration - which helps prevent layout thrashing.
  9983. prevChildren.forEach(callPendingCbs);
  9984. prevChildren.forEach(recordPosition);
  9985. const movedChildren = prevChildren.filter(applyTranslation);
  9986. // force reflow to put everything in position
  9987. forceReflow();
  9988. movedChildren.forEach(c => {
  9989. const el = c.el;
  9990. const style = el.style;
  9991. addTransitionClass(el, moveClass);
  9992. style.transform = style.webkitTransform = style.transitionDuration = '';
  9993. const cb = (el._moveCb = (e) => {
  9994. if (e && e.target !== el) {
  9995. return;
  9996. }
  9997. if (!e || /transform$/.test(e.propertyName)) {
  9998. el.removeEventListener('transitionend', cb);
  9999. el._moveCb = null;
  10000. removeTransitionClass(el, moveClass);
  10001. }
  10002. });
  10003. el.addEventListener('transitionend', cb);
  10004. });
  10005. });
  10006. return () => {
  10007. const rawProps = toRaw(props);
  10008. const cssTransitionProps = resolveTransitionProps(rawProps);
  10009. let tag = rawProps.tag || Fragment;
  10010. prevChildren = children;
  10011. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  10012. for (let i = 0; i < children.length; i++) {
  10013. const child = children[i];
  10014. if (child.key != null) {
  10015. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10016. }
  10017. else {
  10018. warn$1(`<TransitionGroup> children must be keyed.`);
  10019. }
  10020. }
  10021. if (prevChildren) {
  10022. for (let i = 0; i < prevChildren.length; i++) {
  10023. const child = prevChildren[i];
  10024. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10025. positionMap.set(child, child.el.getBoundingClientRect());
  10026. }
  10027. }
  10028. return createVNode(tag, null, children);
  10029. };
  10030. }
  10031. };
  10032. const TransitionGroup = TransitionGroupImpl;
  10033. function callPendingCbs(c) {
  10034. const el = c.el;
  10035. if (el._moveCb) {
  10036. el._moveCb();
  10037. }
  10038. if (el._enterCb) {
  10039. el._enterCb();
  10040. }
  10041. }
  10042. function recordPosition(c) {
  10043. newPositionMap.set(c, c.el.getBoundingClientRect());
  10044. }
  10045. function applyTranslation(c) {
  10046. const oldPos = positionMap.get(c);
  10047. const newPos = newPositionMap.get(c);
  10048. const dx = oldPos.left - newPos.left;
  10049. const dy = oldPos.top - newPos.top;
  10050. if (dx || dy) {
  10051. const s = c.el.style;
  10052. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  10053. s.transitionDuration = '0s';
  10054. return c;
  10055. }
  10056. }
  10057. function hasCSSTransform(el, root, moveClass) {
  10058. // Detect whether an element with the move class applied has
  10059. // CSS transitions. Since the element may be inside an entering
  10060. // transition at this very moment, we make a clone of it and remove
  10061. // all other transition classes applied to ensure only the move class
  10062. // is applied.
  10063. const clone = el.cloneNode();
  10064. if (el._vtc) {
  10065. el._vtc.forEach(cls => {
  10066. cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
  10067. });
  10068. }
  10069. moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
  10070. clone.style.display = 'none';
  10071. const container = (root.nodeType === 1 ? root : root.parentNode);
  10072. container.appendChild(clone);
  10073. const { hasTransform } = getTransitionInfo(clone);
  10074. container.removeChild(clone);
  10075. return hasTransform;
  10076. }
  10077. const getModelAssigner = (vnode) => {
  10078. const fn = vnode.props['onUpdate:modelValue'];
  10079. return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
  10080. };
  10081. function onCompositionStart(e) {
  10082. e.target.composing = true;
  10083. }
  10084. function onCompositionEnd(e) {
  10085. const target = e.target;
  10086. if (target.composing) {
  10087. target.composing = false;
  10088. trigger$1(target, 'input');
  10089. }
  10090. }
  10091. function trigger$1(el, type) {
  10092. const e = document.createEvent('HTMLEvents');
  10093. e.initEvent(type, true, true);
  10094. el.dispatchEvent(e);
  10095. }
  10096. // We are exporting the v-model runtime directly as vnode hooks so that it can
  10097. // be tree-shaken in case v-model is never used.
  10098. const vModelText = {
  10099. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  10100. el._assign = getModelAssigner(vnode);
  10101. const castToNumber = number || (vnode.props && vnode.props.type === 'number');
  10102. addEventListener(el, lazy ? 'change' : 'input', e => {
  10103. if (e.target.composing)
  10104. return;
  10105. let domValue = el.value;
  10106. if (trim) {
  10107. domValue = domValue.trim();
  10108. }
  10109. else if (castToNumber) {
  10110. domValue = toNumber(domValue);
  10111. }
  10112. el._assign(domValue);
  10113. });
  10114. if (trim) {
  10115. addEventListener(el, 'change', () => {
  10116. el.value = el.value.trim();
  10117. });
  10118. }
  10119. if (!lazy) {
  10120. addEventListener(el, 'compositionstart', onCompositionStart);
  10121. addEventListener(el, 'compositionend', onCompositionEnd);
  10122. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  10123. // switching focus before confirming composition choice
  10124. // this also fixes the issue where some browsers e.g. iOS Chrome
  10125. // fires "change" instead of "input" on autocomplete.
  10126. addEventListener(el, 'change', onCompositionEnd);
  10127. }
  10128. },
  10129. // set value on mounted so it's after min/max for type="range"
  10130. mounted(el, { value }) {
  10131. el.value = value == null ? '' : value;
  10132. },
  10133. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  10134. el._assign = getModelAssigner(vnode);
  10135. // avoid clearing unresolved text. #2302
  10136. if (el.composing)
  10137. return;
  10138. if (document.activeElement === el) {
  10139. if (lazy) {
  10140. return;
  10141. }
  10142. if (trim && el.value.trim() === value) {
  10143. return;
  10144. }
  10145. if ((number || el.type === 'number') && toNumber(el.value) === value) {
  10146. return;
  10147. }
  10148. }
  10149. const newValue = value == null ? '' : value;
  10150. if (el.value !== newValue) {
  10151. el.value = newValue;
  10152. }
  10153. }
  10154. };
  10155. const vModelCheckbox = {
  10156. // #4096 array checkboxes need to be deep traversed
  10157. deep: true,
  10158. created(el, _, vnode) {
  10159. el._assign = getModelAssigner(vnode);
  10160. addEventListener(el, 'change', () => {
  10161. const modelValue = el._modelValue;
  10162. const elementValue = getValue(el);
  10163. const checked = el.checked;
  10164. const assign = el._assign;
  10165. if (isArray(modelValue)) {
  10166. const index = looseIndexOf(modelValue, elementValue);
  10167. const found = index !== -1;
  10168. if (checked && !found) {
  10169. assign(modelValue.concat(elementValue));
  10170. }
  10171. else if (!checked && found) {
  10172. const filtered = [...modelValue];
  10173. filtered.splice(index, 1);
  10174. assign(filtered);
  10175. }
  10176. }
  10177. else if (isSet(modelValue)) {
  10178. const cloned = new Set(modelValue);
  10179. if (checked) {
  10180. cloned.add(elementValue);
  10181. }
  10182. else {
  10183. cloned.delete(elementValue);
  10184. }
  10185. assign(cloned);
  10186. }
  10187. else {
  10188. assign(getCheckboxValue(el, checked));
  10189. }
  10190. });
  10191. },
  10192. // set initial checked on mount to wait for true-value/false-value
  10193. mounted: setChecked,
  10194. beforeUpdate(el, binding, vnode) {
  10195. el._assign = getModelAssigner(vnode);
  10196. setChecked(el, binding, vnode);
  10197. }
  10198. };
  10199. function setChecked(el, { value, oldValue }, vnode) {
  10200. el._modelValue = value;
  10201. if (isArray(value)) {
  10202. el.checked = looseIndexOf(value, vnode.props.value) > -1;
  10203. }
  10204. else if (isSet(value)) {
  10205. el.checked = value.has(vnode.props.value);
  10206. }
  10207. else if (value !== oldValue) {
  10208. el.checked = looseEqual(value, getCheckboxValue(el, true));
  10209. }
  10210. }
  10211. const vModelRadio = {
  10212. created(el, { value }, vnode) {
  10213. el.checked = looseEqual(value, vnode.props.value);
  10214. el._assign = getModelAssigner(vnode);
  10215. addEventListener(el, 'change', () => {
  10216. el._assign(getValue(el));
  10217. });
  10218. },
  10219. beforeUpdate(el, { value, oldValue }, vnode) {
  10220. el._assign = getModelAssigner(vnode);
  10221. if (value !== oldValue) {
  10222. el.checked = looseEqual(value, vnode.props.value);
  10223. }
  10224. }
  10225. };
  10226. const vModelSelect = {
  10227. // <select multiple> value need to be deep traversed
  10228. deep: true,
  10229. created(el, { value, modifiers: { number } }, vnode) {
  10230. const isSetModel = isSet(value);
  10231. addEventListener(el, 'change', () => {
  10232. const selectedVal = Array.prototype.filter
  10233. .call(el.options, (o) => o.selected)
  10234. .map((o) => number ? toNumber(getValue(o)) : getValue(o));
  10235. el._assign(el.multiple
  10236. ? isSetModel
  10237. ? new Set(selectedVal)
  10238. : selectedVal
  10239. : selectedVal[0]);
  10240. });
  10241. el._assign = getModelAssigner(vnode);
  10242. },
  10243. // set value in mounted & updated because <select> relies on its children
  10244. // <option>s.
  10245. mounted(el, { value }) {
  10246. setSelected(el, value);
  10247. },
  10248. beforeUpdate(el, _binding, vnode) {
  10249. el._assign = getModelAssigner(vnode);
  10250. },
  10251. updated(el, { value }) {
  10252. setSelected(el, value);
  10253. }
  10254. };
  10255. function setSelected(el, value) {
  10256. const isMultiple = el.multiple;
  10257. if (isMultiple && !isArray(value) && !isSet(value)) {
  10258. warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
  10259. `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
  10260. return;
  10261. }
  10262. for (let i = 0, l = el.options.length; i < l; i++) {
  10263. const option = el.options[i];
  10264. const optionValue = getValue(option);
  10265. if (isMultiple) {
  10266. if (isArray(value)) {
  10267. option.selected = looseIndexOf(value, optionValue) > -1;
  10268. }
  10269. else {
  10270. option.selected = value.has(optionValue);
  10271. }
  10272. }
  10273. else {
  10274. if (looseEqual(getValue(option), value)) {
  10275. if (el.selectedIndex !== i)
  10276. el.selectedIndex = i;
  10277. return;
  10278. }
  10279. }
  10280. }
  10281. if (!isMultiple && el.selectedIndex !== -1) {
  10282. el.selectedIndex = -1;
  10283. }
  10284. }
  10285. // retrieve raw value set via :value bindings
  10286. function getValue(el) {
  10287. return '_value' in el ? el._value : el.value;
  10288. }
  10289. // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
  10290. function getCheckboxValue(el, checked) {
  10291. const key = checked ? '_trueValue' : '_falseValue';
  10292. return key in el ? el[key] : checked;
  10293. }
  10294. const vModelDynamic = {
  10295. created(el, binding, vnode) {
  10296. callModelHook(el, binding, vnode, null, 'created');
  10297. },
  10298. mounted(el, binding, vnode) {
  10299. callModelHook(el, binding, vnode, null, 'mounted');
  10300. },
  10301. beforeUpdate(el, binding, vnode, prevVNode) {
  10302. callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
  10303. },
  10304. updated(el, binding, vnode, prevVNode) {
  10305. callModelHook(el, binding, vnode, prevVNode, 'updated');
  10306. }
  10307. };
  10308. function callModelHook(el, binding, vnode, prevVNode, hook) {
  10309. let modelToUse;
  10310. switch (el.tagName) {
  10311. case 'SELECT':
  10312. modelToUse = vModelSelect;
  10313. break;
  10314. case 'TEXTAREA':
  10315. modelToUse = vModelText;
  10316. break;
  10317. default:
  10318. switch (vnode.props && vnode.props.type) {
  10319. case 'checkbox':
  10320. modelToUse = vModelCheckbox;
  10321. break;
  10322. case 'radio':
  10323. modelToUse = vModelRadio;
  10324. break;
  10325. default:
  10326. modelToUse = vModelText;
  10327. }
  10328. }
  10329. const fn = modelToUse[hook];
  10330. fn && fn(el, binding, vnode, prevVNode);
  10331. }
  10332. const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
  10333. const modifierGuards = {
  10334. stop: e => e.stopPropagation(),
  10335. prevent: e => e.preventDefault(),
  10336. self: e => e.target !== e.currentTarget,
  10337. ctrl: e => !e.ctrlKey,
  10338. shift: e => !e.shiftKey,
  10339. alt: e => !e.altKey,
  10340. meta: e => !e.metaKey,
  10341. left: e => 'button' in e && e.button !== 0,
  10342. middle: e => 'button' in e && e.button !== 1,
  10343. right: e => 'button' in e && e.button !== 2,
  10344. exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
  10345. };
  10346. /**
  10347. * @private
  10348. */
  10349. const withModifiers = (fn, modifiers) => {
  10350. return (event, ...args) => {
  10351. for (let i = 0; i < modifiers.length; i++) {
  10352. const guard = modifierGuards[modifiers[i]];
  10353. if (guard && guard(event, modifiers))
  10354. return;
  10355. }
  10356. return fn(event, ...args);
  10357. };
  10358. };
  10359. // Kept for 2.x compat.
  10360. // Note: IE11 compat for `spacebar` and `del` is removed for now.
  10361. const keyNames = {
  10362. esc: 'escape',
  10363. space: ' ',
  10364. up: 'arrow-up',
  10365. left: 'arrow-left',
  10366. right: 'arrow-right',
  10367. down: 'arrow-down',
  10368. delete: 'backspace'
  10369. };
  10370. /**
  10371. * @private
  10372. */
  10373. const withKeys = (fn, modifiers) => {
  10374. return (event) => {
  10375. if (!('key' in event)) {
  10376. return;
  10377. }
  10378. const eventKey = hyphenate(event.key);
  10379. if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
  10380. return fn(event);
  10381. }
  10382. };
  10383. };
  10384. const vShow = {
  10385. beforeMount(el, { value }, { transition }) {
  10386. el._vod = el.style.display === 'none' ? '' : el.style.display;
  10387. if (transition && value) {
  10388. transition.beforeEnter(el);
  10389. }
  10390. else {
  10391. setDisplay(el, value);
  10392. }
  10393. },
  10394. mounted(el, { value }, { transition }) {
  10395. if (transition && value) {
  10396. transition.enter(el);
  10397. }
  10398. },
  10399. updated(el, { value, oldValue }, { transition }) {
  10400. if (!value === !oldValue)
  10401. return;
  10402. if (transition) {
  10403. if (value) {
  10404. transition.beforeEnter(el);
  10405. setDisplay(el, true);
  10406. transition.enter(el);
  10407. }
  10408. else {
  10409. transition.leave(el, () => {
  10410. setDisplay(el, false);
  10411. });
  10412. }
  10413. }
  10414. else {
  10415. setDisplay(el, value);
  10416. }
  10417. },
  10418. beforeUnmount(el, { value }) {
  10419. setDisplay(el, value);
  10420. }
  10421. };
  10422. function setDisplay(el, value) {
  10423. el.style.display = value ? el._vod : 'none';
  10424. }
  10425. const rendererOptions = extend({ patchProp }, nodeOps);
  10426. // lazy create the renderer - this makes core renderer logic tree-shakable
  10427. // in case the user only imports reactivity utilities from Vue.
  10428. let renderer;
  10429. let enabledHydration = false;
  10430. function ensureRenderer() {
  10431. return (renderer ||
  10432. (renderer = createRenderer(rendererOptions)));
  10433. }
  10434. function ensureHydrationRenderer() {
  10435. renderer = enabledHydration
  10436. ? renderer
  10437. : createHydrationRenderer(rendererOptions);
  10438. enabledHydration = true;
  10439. return renderer;
  10440. }
  10441. // use explicit type casts here to avoid import() calls in rolled-up d.ts
  10442. const render = ((...args) => {
  10443. ensureRenderer().render(...args);
  10444. });
  10445. const hydrate = ((...args) => {
  10446. ensureHydrationRenderer().hydrate(...args);
  10447. });
  10448. const createApp = ((...args) => {
  10449. const app = ensureRenderer().createApp(...args);
  10450. {
  10451. injectNativeTagCheck(app);
  10452. injectCompilerOptionsCheck(app);
  10453. }
  10454. const { mount } = app;
  10455. app.mount = (containerOrSelector) => {
  10456. const container = normalizeContainer(containerOrSelector);
  10457. if (!container)
  10458. return;
  10459. const component = app._component;
  10460. if (!isFunction(component) && !component.render && !component.template) {
  10461. // __UNSAFE__
  10462. // Reason: potential execution of JS expressions in in-DOM template.
  10463. // The user must make sure the in-DOM template is trusted. If it's
  10464. // rendered by the server, the template should not contain any user data.
  10465. component.template = container.innerHTML;
  10466. }
  10467. // clear content before mounting
  10468. container.innerHTML = '';
  10469. const proxy = mount(container, false, container instanceof SVGElement);
  10470. if (container instanceof Element) {
  10471. container.removeAttribute('v-cloak');
  10472. container.setAttribute('data-v-app', '');
  10473. }
  10474. return proxy;
  10475. };
  10476. return app;
  10477. });
  10478. const createSSRApp = ((...args) => {
  10479. const app = ensureHydrationRenderer().createApp(...args);
  10480. {
  10481. injectNativeTagCheck(app);
  10482. injectCompilerOptionsCheck(app);
  10483. }
  10484. const { mount } = app;
  10485. app.mount = (containerOrSelector) => {
  10486. const container = normalizeContainer(containerOrSelector);
  10487. if (container) {
  10488. return mount(container, true, container instanceof SVGElement);
  10489. }
  10490. };
  10491. return app;
  10492. });
  10493. function injectNativeTagCheck(app) {
  10494. // Inject `isNativeTag`
  10495. // this is used for component name validation (dev only)
  10496. Object.defineProperty(app.config, 'isNativeTag', {
  10497. value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  10498. writable: false
  10499. });
  10500. }
  10501. // dev only
  10502. function injectCompilerOptionsCheck(app) {
  10503. if (isRuntimeOnly()) {
  10504. const isCustomElement = app.config.isCustomElement;
  10505. Object.defineProperty(app.config, 'isCustomElement', {
  10506. get() {
  10507. return isCustomElement;
  10508. },
  10509. set() {
  10510. warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
  10511. `\`compilerOptions.isCustomElement\` instead.`);
  10512. }
  10513. });
  10514. const compilerOptions = app.config.compilerOptions;
  10515. const msg = `The \`compilerOptions\` config option is only respected when using ` +
  10516. `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
  10517. `Since you are using the runtime-only build, \`compilerOptions\` ` +
  10518. `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
  10519. `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
  10520. `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
  10521. `- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom`;
  10522. Object.defineProperty(app.config, 'compilerOptions', {
  10523. get() {
  10524. warn$1(msg);
  10525. return compilerOptions;
  10526. },
  10527. set() {
  10528. warn$1(msg);
  10529. }
  10530. });
  10531. }
  10532. }
  10533. function normalizeContainer(container) {
  10534. if (isString(container)) {
  10535. const res = document.querySelector(container);
  10536. if (!res) {
  10537. warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
  10538. }
  10539. return res;
  10540. }
  10541. if (window.ShadowRoot &&
  10542. container instanceof window.ShadowRoot &&
  10543. container.mode === 'closed') {
  10544. warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
  10545. }
  10546. return container;
  10547. }
  10548. /**
  10549. * @internal
  10550. */
  10551. const initDirectivesForSSR = NOOP;
  10552. function initDev() {
  10553. {
  10554. {
  10555. console.info(`You are running a development build of Vue.\n` +
  10556. `Make sure to use the production build (*.prod.js) when deploying for production.`);
  10557. }
  10558. initCustomFormatter();
  10559. }
  10560. }
  10561. // This entry exports the runtime only, and is built as
  10562. {
  10563. initDev();
  10564. }
  10565. const compile$1 = () => {
  10566. {
  10567. warn$1(`Runtime compilation is not supported in this build of Vue.` +
  10568. (` Use "vue.global.js" instead.`
  10569. ) /* should not happen */);
  10570. }
  10571. };
  10572. exports.BaseTransition = BaseTransition;
  10573. exports.Comment = Comment;
  10574. exports.EffectScope = EffectScope;
  10575. exports.Fragment = Fragment;
  10576. exports.KeepAlive = KeepAlive;
  10577. exports.ReactiveEffect = ReactiveEffect;
  10578. exports.Static = Static;
  10579. exports.Suspense = Suspense;
  10580. exports.Teleport = Teleport;
  10581. exports.Text = Text;
  10582. exports.Transition = Transition;
  10583. exports.TransitionGroup = TransitionGroup;
  10584. exports.VueElement = VueElement;
  10585. exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
  10586. exports.callWithErrorHandling = callWithErrorHandling;
  10587. exports.camelize = camelize;
  10588. exports.capitalize = capitalize;
  10589. exports.cloneVNode = cloneVNode;
  10590. exports.compatUtils = compatUtils;
  10591. exports.compile = compile$1;
  10592. exports.computed = computed;
  10593. exports.createApp = createApp;
  10594. exports.createBlock = createBlock;
  10595. exports.createCommentVNode = createCommentVNode;
  10596. exports.createElementBlock = createElementBlock;
  10597. exports.createElementVNode = createBaseVNode;
  10598. exports.createHydrationRenderer = createHydrationRenderer;
  10599. exports.createPropsRestProxy = createPropsRestProxy;
  10600. exports.createRenderer = createRenderer;
  10601. exports.createSSRApp = createSSRApp;
  10602. exports.createSlots = createSlots;
  10603. exports.createStaticVNode = createStaticVNode;
  10604. exports.createTextVNode = createTextVNode;
  10605. exports.createVNode = createVNode;
  10606. exports.customRef = customRef;
  10607. exports.defineAsyncComponent = defineAsyncComponent;
  10608. exports.defineComponent = defineComponent;
  10609. exports.defineCustomElement = defineCustomElement;
  10610. exports.defineEmits = defineEmits;
  10611. exports.defineExpose = defineExpose;
  10612. exports.defineProps = defineProps;
  10613. exports.defineSSRCustomElement = defineSSRCustomElement;
  10614. exports.effect = effect;
  10615. exports.effectScope = effectScope;
  10616. exports.getCurrentInstance = getCurrentInstance;
  10617. exports.getCurrentScope = getCurrentScope;
  10618. exports.getTransitionRawChildren = getTransitionRawChildren;
  10619. exports.guardReactiveProps = guardReactiveProps;
  10620. exports.h = h;
  10621. exports.handleError = handleError;
  10622. exports.hydrate = hydrate;
  10623. exports.initCustomFormatter = initCustomFormatter;
  10624. exports.initDirectivesForSSR = initDirectivesForSSR;
  10625. exports.inject = inject;
  10626. exports.isMemoSame = isMemoSame;
  10627. exports.isProxy = isProxy;
  10628. exports.isReactive = isReactive;
  10629. exports.isReadonly = isReadonly;
  10630. exports.isRef = isRef;
  10631. exports.isRuntimeOnly = isRuntimeOnly;
  10632. exports.isVNode = isVNode;
  10633. exports.markRaw = markRaw;
  10634. exports.mergeDefaults = mergeDefaults;
  10635. exports.mergeProps = mergeProps;
  10636. exports.nextTick = nextTick;
  10637. exports.normalizeClass = normalizeClass;
  10638. exports.normalizeProps = normalizeProps;
  10639. exports.normalizeStyle = normalizeStyle;
  10640. exports.onActivated = onActivated;
  10641. exports.onBeforeMount = onBeforeMount;
  10642. exports.onBeforeUnmount = onBeforeUnmount;
  10643. exports.onBeforeUpdate = onBeforeUpdate;
  10644. exports.onDeactivated = onDeactivated;
  10645. exports.onErrorCaptured = onErrorCaptured;
  10646. exports.onMounted = onMounted;
  10647. exports.onRenderTracked = onRenderTracked;
  10648. exports.onRenderTriggered = onRenderTriggered;
  10649. exports.onScopeDispose = onScopeDispose;
  10650. exports.onServerPrefetch = onServerPrefetch;
  10651. exports.onUnmounted = onUnmounted;
  10652. exports.onUpdated = onUpdated;
  10653. exports.openBlock = openBlock;
  10654. exports.popScopeId = popScopeId;
  10655. exports.provide = provide;
  10656. exports.proxyRefs = proxyRefs;
  10657. exports.pushScopeId = pushScopeId;
  10658. exports.queuePostFlushCb = queuePostFlushCb;
  10659. exports.reactive = reactive;
  10660. exports.readonly = readonly;
  10661. exports.ref = ref;
  10662. exports.registerRuntimeCompiler = registerRuntimeCompiler;
  10663. exports.render = render;
  10664. exports.renderList = renderList;
  10665. exports.renderSlot = renderSlot;
  10666. exports.resolveComponent = resolveComponent;
  10667. exports.resolveDirective = resolveDirective;
  10668. exports.resolveDynamicComponent = resolveDynamicComponent;
  10669. exports.resolveFilter = resolveFilter;
  10670. exports.resolveTransitionHooks = resolveTransitionHooks;
  10671. exports.setBlockTracking = setBlockTracking;
  10672. exports.setDevtoolsHook = setDevtoolsHook;
  10673. exports.setTransitionHooks = setTransitionHooks;
  10674. exports.shallowReactive = shallowReactive;
  10675. exports.shallowReadonly = shallowReadonly;
  10676. exports.shallowRef = shallowRef;
  10677. exports.ssrContextKey = ssrContextKey;
  10678. exports.ssrUtils = ssrUtils;
  10679. exports.stop = stop;
  10680. exports.toDisplayString = toDisplayString;
  10681. exports.toHandlerKey = toHandlerKey;
  10682. exports.toHandlers = toHandlers;
  10683. exports.toRaw = toRaw;
  10684. exports.toRef = toRef;
  10685. exports.toRefs = toRefs;
  10686. exports.transformVNodeArgs = transformVNodeArgs;
  10687. exports.triggerRef = triggerRef;
  10688. exports.unref = unref;
  10689. exports.useAttrs = useAttrs;
  10690. exports.useCssModule = useCssModule;
  10691. exports.useCssVars = useCssVars;
  10692. exports.useSSRContext = useSSRContext;
  10693. exports.useSlots = useSlots;
  10694. exports.useTransitionState = useTransitionState;
  10695. exports.vModelCheckbox = vModelCheckbox;
  10696. exports.vModelDynamic = vModelDynamic;
  10697. exports.vModelRadio = vModelRadio;
  10698. exports.vModelSelect = vModelSelect;
  10699. exports.vModelText = vModelText;
  10700. exports.vShow = vShow;
  10701. exports.version = version;
  10702. exports.warn = warn$1;
  10703. exports.watch = watch;
  10704. exports.watchEffect = watchEffect;
  10705. exports.watchPostEffect = watchPostEffect;
  10706. exports.watchSyncEffect = watchSyncEffect;
  10707. exports.withAsyncContext = withAsyncContext;
  10708. exports.withCtx = withCtx;
  10709. exports.withDefaults = withDefaults;
  10710. exports.withDirectives = withDirectives;
  10711. exports.withKeys = withKeys;
  10712. exports.withMemo = withMemo;
  10713. exports.withModifiers = withModifiers;
  10714. exports.withScopeId = withScopeId;
  10715. Object.defineProperty(exports, '__esModule', { value: true });
  10716. return exports;
  10717. }({}));