runtime-dom.global.js 422 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077
  1. var VueRuntimeDOM = (function (exports) {
  2. 'use strict';
  3. /**
  4. * Make a map and return a function for checking if a key
  5. * is in that map.
  6. * IMPORTANT: all calls of this function must be prefixed with
  7. * \/\*#\_\_PURE\_\_\*\/
  8. * So that rollup can tree-shake them if necessary.
  9. */
  10. function makeMap(str, expectsLowerCase) {
  11. const map = Object.create(null);
  12. const list = str.split(',');
  13. for (let i = 0; i < list.length; i++) {
  14. map[list[i]] = true;
  15. }
  16. return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
  17. }
  18. const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
  19. 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
  20. 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
  21. const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
  22. function normalizeStyle(value) {
  23. if (isArray(value)) {
  24. const res = {};
  25. for (let i = 0; i < value.length; i++) {
  26. const item = value[i];
  27. const normalized = isString(item)
  28. ? parseStringStyle(item)
  29. : normalizeStyle(item);
  30. if (normalized) {
  31. for (const key in normalized) {
  32. res[key] = normalized[key];
  33. }
  34. }
  35. }
  36. return res;
  37. }
  38. else if (isString(value)) {
  39. return value;
  40. }
  41. else if (isObject(value)) {
  42. return value;
  43. }
  44. }
  45. const listDelimiterRE = /;(?![^(]*\))/g;
  46. const propertyDelimiterRE = /:([^]+)/;
  47. const styleCommentRE = /\/\*.*?\*\//gs;
  48. function parseStringStyle(cssText) {
  49. const ret = {};
  50. cssText
  51. .replace(styleCommentRE, '')
  52. .split(listDelimiterRE)
  53. .forEach(item => {
  54. if (item) {
  55. const tmp = item.split(propertyDelimiterRE);
  56. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  57. }
  58. });
  59. return ret;
  60. }
  61. function normalizeClass(value) {
  62. let res = '';
  63. if (isString(value)) {
  64. res = value;
  65. }
  66. else if (isArray(value)) {
  67. for (let i = 0; i < value.length; i++) {
  68. const normalized = normalizeClass(value[i]);
  69. if (normalized) {
  70. res += normalized + ' ';
  71. }
  72. }
  73. }
  74. else if (isObject(value)) {
  75. for (const name in value) {
  76. if (value[name]) {
  77. res += name + ' ';
  78. }
  79. }
  80. }
  81. return res.trim();
  82. }
  83. function normalizeProps(props) {
  84. if (!props)
  85. return null;
  86. let { class: klass, style } = props;
  87. if (klass && !isString(klass)) {
  88. props.class = normalizeClass(klass);
  89. }
  90. if (style) {
  91. props.style = normalizeStyle(style);
  92. }
  93. return props;
  94. }
  95. // These tag configs are shared between compiler-dom and runtime-dom, so they
  96. // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
  97. const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
  98. 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
  99. 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
  100. 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
  101. 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
  102. 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
  103. 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
  104. 'option,output,progress,select,textarea,details,dialog,menu,' +
  105. 'summary,template,blockquote,iframe,tfoot';
  106. // https://developer.mozilla.org/en-US/docs/Web/SVG/Element
  107. const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
  108. 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
  109. 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
  110. 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
  111. 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
  112. 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
  113. 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
  114. 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
  115. 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
  116. 'text,textPath,title,tspan,unknown,use,view';
  117. /**
  118. * Compiler only.
  119. * Do NOT use in runtime code paths unless behind `true` flag.
  120. */
  121. const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
  122. /**
  123. * Compiler only.
  124. * Do NOT use in runtime code paths unless behind `true` flag.
  125. */
  126. const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
  127. /**
  128. * On the client we only need to offer special cases for boolean attributes that
  129. * have different names from their corresponding dom properties:
  130. * - itemscope -> N/A
  131. * - allowfullscreen -> allowFullscreen
  132. * - formnovalidate -> formNoValidate
  133. * - ismap -> isMap
  134. * - nomodule -> noModule
  135. * - novalidate -> noValidate
  136. * - readonly -> readOnly
  137. */
  138. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  139. const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
  140. /**
  141. * Boolean attributes should be included if the value is truthy or ''.
  142. * e.g. `<select multiple>` compiles to `{ multiple: '' }`
  143. */
  144. function includeBooleanAttr(value) {
  145. return !!value || value === '';
  146. }
  147. function looseCompareArrays(a, b) {
  148. if (a.length !== b.length)
  149. return false;
  150. let equal = true;
  151. for (let i = 0; equal && i < a.length; i++) {
  152. equal = looseEqual(a[i], b[i]);
  153. }
  154. return equal;
  155. }
  156. function looseEqual(a, b) {
  157. if (a === b)
  158. return true;
  159. let aValidType = isDate(a);
  160. let bValidType = isDate(b);
  161. if (aValidType || bValidType) {
  162. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  163. }
  164. aValidType = isSymbol(a);
  165. bValidType = isSymbol(b);
  166. if (aValidType || bValidType) {
  167. return a === b;
  168. }
  169. aValidType = isArray(a);
  170. bValidType = isArray(b);
  171. if (aValidType || bValidType) {
  172. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  173. }
  174. aValidType = isObject(a);
  175. bValidType = isObject(b);
  176. if (aValidType || bValidType) {
  177. /* istanbul ignore if: this if will probably never be called */
  178. if (!aValidType || !bValidType) {
  179. return false;
  180. }
  181. const aKeysCount = Object.keys(a).length;
  182. const bKeysCount = Object.keys(b).length;
  183. if (aKeysCount !== bKeysCount) {
  184. return false;
  185. }
  186. for (const key in a) {
  187. const aHasKey = a.hasOwnProperty(key);
  188. const bHasKey = b.hasOwnProperty(key);
  189. if ((aHasKey && !bHasKey) ||
  190. (!aHasKey && bHasKey) ||
  191. !looseEqual(a[key], b[key])) {
  192. return false;
  193. }
  194. }
  195. }
  196. return String(a) === String(b);
  197. }
  198. function looseIndexOf(arr, val) {
  199. return arr.findIndex(item => looseEqual(item, val));
  200. }
  201. /**
  202. * For converting {{ interpolation }} values to displayed strings.
  203. * @private
  204. */
  205. const toDisplayString = (val) => {
  206. return isString(val)
  207. ? val
  208. : val == null
  209. ? ''
  210. : isArray(val) ||
  211. (isObject(val) &&
  212. (val.toString === objectToString || !isFunction(val.toString)))
  213. ? JSON.stringify(val, replacer, 2)
  214. : String(val);
  215. };
  216. const replacer = (_key, val) => {
  217. // can't use isRef here since @vue/shared has no deps
  218. if (val && val.__v_isRef) {
  219. return replacer(_key, val.value);
  220. }
  221. else if (isMap(val)) {
  222. return {
  223. [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
  224. entries[`${key} =>`] = val;
  225. return entries;
  226. }, {})
  227. };
  228. }
  229. else if (isSet(val)) {
  230. return {
  231. [`Set(${val.size})`]: [...val.values()]
  232. };
  233. }
  234. else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  235. return String(val);
  236. }
  237. return val;
  238. };
  239. const EMPTY_OBJ = Object.freeze({})
  240. ;
  241. const EMPTY_ARR = Object.freeze([]) ;
  242. const NOOP = () => { };
  243. /**
  244. * Always return false.
  245. */
  246. const NO = () => false;
  247. const onRE = /^on[^a-z]/;
  248. const isOn = (key) => onRE.test(key);
  249. const isModelListener = (key) => key.startsWith('onUpdate:');
  250. const extend = Object.assign;
  251. const remove = (arr, el) => {
  252. const i = arr.indexOf(el);
  253. if (i > -1) {
  254. arr.splice(i, 1);
  255. }
  256. };
  257. const hasOwnProperty = Object.prototype.hasOwnProperty;
  258. const hasOwn = (val, key) => hasOwnProperty.call(val, key);
  259. const isArray = Array.isArray;
  260. const isMap = (val) => toTypeString(val) === '[object Map]';
  261. const isSet = (val) => toTypeString(val) === '[object Set]';
  262. const isDate = (val) => toTypeString(val) === '[object Date]';
  263. const isFunction = (val) => typeof val === 'function';
  264. const isString = (val) => typeof val === 'string';
  265. const isSymbol = (val) => typeof val === 'symbol';
  266. const isObject = (val) => val !== null && typeof val === 'object';
  267. const isPromise = (val) => {
  268. return isObject(val) && isFunction(val.then) && isFunction(val.catch);
  269. };
  270. const objectToString = Object.prototype.toString;
  271. const toTypeString = (value) => objectToString.call(value);
  272. const toRawType = (value) => {
  273. // extract "RawType" from strings like "[object RawType]"
  274. return toTypeString(value).slice(8, -1);
  275. };
  276. const isPlainObject = (val) => toTypeString(val) === '[object Object]';
  277. const isIntegerKey = (key) => isString(key) &&
  278. key !== 'NaN' &&
  279. key[0] !== '-' &&
  280. '' + parseInt(key, 10) === key;
  281. const isReservedProp = /*#__PURE__*/ makeMap(
  282. // the leading comma is intentional so empty string "" is also included
  283. ',key,ref,ref_for,ref_key,' +
  284. 'onVnodeBeforeMount,onVnodeMounted,' +
  285. 'onVnodeBeforeUpdate,onVnodeUpdated,' +
  286. 'onVnodeBeforeUnmount,onVnodeUnmounted');
  287. const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
  288. const cacheStringFunction = (fn) => {
  289. const cache = Object.create(null);
  290. return ((str) => {
  291. const hit = cache[str];
  292. return hit || (cache[str] = fn(str));
  293. });
  294. };
  295. const camelizeRE = /-(\w)/g;
  296. /**
  297. * @private
  298. */
  299. const camelize = cacheStringFunction((str) => {
  300. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  301. });
  302. const hyphenateRE = /\B([A-Z])/g;
  303. /**
  304. * @private
  305. */
  306. const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
  307. /**
  308. * @private
  309. */
  310. const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
  311. /**
  312. * @private
  313. */
  314. const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
  315. // compare whether a value has changed, accounting for NaN.
  316. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  317. const invokeArrayFns = (fns, arg) => {
  318. for (let i = 0; i < fns.length; i++) {
  319. fns[i](arg);
  320. }
  321. };
  322. const def = (obj, key, value) => {
  323. Object.defineProperty(obj, key, {
  324. configurable: true,
  325. enumerable: false,
  326. value
  327. });
  328. };
  329. const toNumber = (val) => {
  330. const n = parseFloat(val);
  331. return isNaN(n) ? val : n;
  332. };
  333. let _globalThis;
  334. const getGlobalThis = () => {
  335. return (_globalThis ||
  336. (_globalThis =
  337. typeof globalThis !== 'undefined'
  338. ? globalThis
  339. : typeof self !== 'undefined'
  340. ? self
  341. : typeof window !== 'undefined'
  342. ? window
  343. : typeof global !== 'undefined'
  344. ? global
  345. : {}));
  346. };
  347. function warn(msg, ...args) {
  348. console.warn(`[Vue warn] ${msg}`, ...args);
  349. }
  350. let activeEffectScope;
  351. class EffectScope {
  352. constructor(detached = false) {
  353. this.detached = detached;
  354. /**
  355. * @internal
  356. */
  357. this.active = true;
  358. /**
  359. * @internal
  360. */
  361. this.effects = [];
  362. /**
  363. * @internal
  364. */
  365. this.cleanups = [];
  366. this.parent = activeEffectScope;
  367. if (!detached && activeEffectScope) {
  368. this.index =
  369. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  370. }
  371. }
  372. run(fn) {
  373. if (this.active) {
  374. const currentEffectScope = activeEffectScope;
  375. try {
  376. activeEffectScope = this;
  377. return fn();
  378. }
  379. finally {
  380. activeEffectScope = currentEffectScope;
  381. }
  382. }
  383. else {
  384. warn(`cannot run an inactive effect scope.`);
  385. }
  386. }
  387. /**
  388. * This should only be called on non-detached scopes
  389. * @internal
  390. */
  391. on() {
  392. activeEffectScope = this;
  393. }
  394. /**
  395. * This should only be called on non-detached scopes
  396. * @internal
  397. */
  398. off() {
  399. activeEffectScope = this.parent;
  400. }
  401. stop(fromParent) {
  402. if (this.active) {
  403. let i, l;
  404. for (i = 0, l = this.effects.length; i < l; i++) {
  405. this.effects[i].stop();
  406. }
  407. for (i = 0, l = this.cleanups.length; i < l; i++) {
  408. this.cleanups[i]();
  409. }
  410. if (this.scopes) {
  411. for (i = 0, l = this.scopes.length; i < l; i++) {
  412. this.scopes[i].stop(true);
  413. }
  414. }
  415. // nested scope, dereference from parent to avoid memory leaks
  416. if (!this.detached && this.parent && !fromParent) {
  417. // optimized O(1) removal
  418. const last = this.parent.scopes.pop();
  419. if (last && last !== this) {
  420. this.parent.scopes[this.index] = last;
  421. last.index = this.index;
  422. }
  423. }
  424. this.parent = undefined;
  425. this.active = false;
  426. }
  427. }
  428. }
  429. function effectScope(detached) {
  430. return new EffectScope(detached);
  431. }
  432. function recordEffectScope(effect, scope = activeEffectScope) {
  433. if (scope && scope.active) {
  434. scope.effects.push(effect);
  435. }
  436. }
  437. function getCurrentScope() {
  438. return activeEffectScope;
  439. }
  440. function onScopeDispose(fn) {
  441. if (activeEffectScope) {
  442. activeEffectScope.cleanups.push(fn);
  443. }
  444. else {
  445. warn(`onScopeDispose() is called when there is no active effect scope` +
  446. ` to be associated with.`);
  447. }
  448. }
  449. const createDep = (effects) => {
  450. const dep = new Set(effects);
  451. dep.w = 0;
  452. dep.n = 0;
  453. return dep;
  454. };
  455. const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
  456. const newTracked = (dep) => (dep.n & trackOpBit) > 0;
  457. const initDepMarkers = ({ deps }) => {
  458. if (deps.length) {
  459. for (let i = 0; i < deps.length; i++) {
  460. deps[i].w |= trackOpBit; // set was tracked
  461. }
  462. }
  463. };
  464. const finalizeDepMarkers = (effect) => {
  465. const { deps } = effect;
  466. if (deps.length) {
  467. let ptr = 0;
  468. for (let i = 0; i < deps.length; i++) {
  469. const dep = deps[i];
  470. if (wasTracked(dep) && !newTracked(dep)) {
  471. dep.delete(effect);
  472. }
  473. else {
  474. deps[ptr++] = dep;
  475. }
  476. // clear bits
  477. dep.w &= ~trackOpBit;
  478. dep.n &= ~trackOpBit;
  479. }
  480. deps.length = ptr;
  481. }
  482. };
  483. const targetMap = new WeakMap();
  484. // The number of effects currently being tracked recursively.
  485. let effectTrackDepth = 0;
  486. let trackOpBit = 1;
  487. /**
  488. * The bitwise track markers support at most 30 levels of recursion.
  489. * This value is chosen to enable modern JS engines to use a SMI on all platforms.
  490. * When recursion depth is greater, fall back to using a full cleanup.
  491. */
  492. const maxMarkerBits = 30;
  493. let activeEffect;
  494. const ITERATE_KEY = Symbol('iterate' );
  495. const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
  496. class ReactiveEffect {
  497. constructor(fn, scheduler = null, scope) {
  498. this.fn = fn;
  499. this.scheduler = scheduler;
  500. this.active = true;
  501. this.deps = [];
  502. this.parent = undefined;
  503. recordEffectScope(this, scope);
  504. }
  505. run() {
  506. if (!this.active) {
  507. return this.fn();
  508. }
  509. let parent = activeEffect;
  510. let lastShouldTrack = shouldTrack;
  511. while (parent) {
  512. if (parent === this) {
  513. return;
  514. }
  515. parent = parent.parent;
  516. }
  517. try {
  518. this.parent = activeEffect;
  519. activeEffect = this;
  520. shouldTrack = true;
  521. trackOpBit = 1 << ++effectTrackDepth;
  522. if (effectTrackDepth <= maxMarkerBits) {
  523. initDepMarkers(this);
  524. }
  525. else {
  526. cleanupEffect(this);
  527. }
  528. return this.fn();
  529. }
  530. finally {
  531. if (effectTrackDepth <= maxMarkerBits) {
  532. finalizeDepMarkers(this);
  533. }
  534. trackOpBit = 1 << --effectTrackDepth;
  535. activeEffect = this.parent;
  536. shouldTrack = lastShouldTrack;
  537. this.parent = undefined;
  538. if (this.deferStop) {
  539. this.stop();
  540. }
  541. }
  542. }
  543. stop() {
  544. // stopped while running itself - defer the cleanup
  545. if (activeEffect === this) {
  546. this.deferStop = true;
  547. }
  548. else if (this.active) {
  549. cleanupEffect(this);
  550. if (this.onStop) {
  551. this.onStop();
  552. }
  553. this.active = false;
  554. }
  555. }
  556. }
  557. function cleanupEffect(effect) {
  558. const { deps } = effect;
  559. if (deps.length) {
  560. for (let i = 0; i < deps.length; i++) {
  561. deps[i].delete(effect);
  562. }
  563. deps.length = 0;
  564. }
  565. }
  566. function effect(fn, options) {
  567. if (fn.effect) {
  568. fn = fn.effect.fn;
  569. }
  570. const _effect = new ReactiveEffect(fn);
  571. if (options) {
  572. extend(_effect, options);
  573. if (options.scope)
  574. recordEffectScope(_effect, options.scope);
  575. }
  576. if (!options || !options.lazy) {
  577. _effect.run();
  578. }
  579. const runner = _effect.run.bind(_effect);
  580. runner.effect = _effect;
  581. return runner;
  582. }
  583. function stop(runner) {
  584. runner.effect.stop();
  585. }
  586. let shouldTrack = true;
  587. const trackStack = [];
  588. function pauseTracking() {
  589. trackStack.push(shouldTrack);
  590. shouldTrack = false;
  591. }
  592. function resetTracking() {
  593. const last = trackStack.pop();
  594. shouldTrack = last === undefined ? true : last;
  595. }
  596. function track(target, type, key) {
  597. if (shouldTrack && activeEffect) {
  598. let depsMap = targetMap.get(target);
  599. if (!depsMap) {
  600. targetMap.set(target, (depsMap = new Map()));
  601. }
  602. let dep = depsMap.get(key);
  603. if (!dep) {
  604. depsMap.set(key, (dep = createDep()));
  605. }
  606. const eventInfo = { effect: activeEffect, target, type, key }
  607. ;
  608. trackEffects(dep, eventInfo);
  609. }
  610. }
  611. function trackEffects(dep, debuggerEventExtraInfo) {
  612. let shouldTrack = false;
  613. if (effectTrackDepth <= maxMarkerBits) {
  614. if (!newTracked(dep)) {
  615. dep.n |= trackOpBit; // set newly tracked
  616. shouldTrack = !wasTracked(dep);
  617. }
  618. }
  619. else {
  620. // Full cleanup mode.
  621. shouldTrack = !dep.has(activeEffect);
  622. }
  623. if (shouldTrack) {
  624. dep.add(activeEffect);
  625. activeEffect.deps.push(dep);
  626. if (activeEffect.onTrack) {
  627. activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
  628. }
  629. }
  630. }
  631. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  632. const depsMap = targetMap.get(target);
  633. if (!depsMap) {
  634. // never been tracked
  635. return;
  636. }
  637. let deps = [];
  638. if (type === "clear" /* TriggerOpTypes.CLEAR */) {
  639. // collection being cleared
  640. // trigger all effects for target
  641. deps = [...depsMap.values()];
  642. }
  643. else if (key === 'length' && isArray(target)) {
  644. const newLength = toNumber(newValue);
  645. depsMap.forEach((dep, key) => {
  646. if (key === 'length' || key >= newLength) {
  647. deps.push(dep);
  648. }
  649. });
  650. }
  651. else {
  652. // schedule runs for SET | ADD | DELETE
  653. if (key !== void 0) {
  654. deps.push(depsMap.get(key));
  655. }
  656. // also run for iteration key on ADD | DELETE | Map.SET
  657. switch (type) {
  658. case "add" /* TriggerOpTypes.ADD */:
  659. if (!isArray(target)) {
  660. deps.push(depsMap.get(ITERATE_KEY));
  661. if (isMap(target)) {
  662. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  663. }
  664. }
  665. else if (isIntegerKey(key)) {
  666. // new index added to array -> length changes
  667. deps.push(depsMap.get('length'));
  668. }
  669. break;
  670. case "delete" /* TriggerOpTypes.DELETE */:
  671. if (!isArray(target)) {
  672. deps.push(depsMap.get(ITERATE_KEY));
  673. if (isMap(target)) {
  674. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  675. }
  676. }
  677. break;
  678. case "set" /* TriggerOpTypes.SET */:
  679. if (isMap(target)) {
  680. deps.push(depsMap.get(ITERATE_KEY));
  681. }
  682. break;
  683. }
  684. }
  685. const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
  686. ;
  687. if (deps.length === 1) {
  688. if (deps[0]) {
  689. {
  690. triggerEffects(deps[0], eventInfo);
  691. }
  692. }
  693. }
  694. else {
  695. const effects = [];
  696. for (const dep of deps) {
  697. if (dep) {
  698. effects.push(...dep);
  699. }
  700. }
  701. {
  702. triggerEffects(createDep(effects), eventInfo);
  703. }
  704. }
  705. }
  706. function triggerEffects(dep, debuggerEventExtraInfo) {
  707. // spread into array for stabilization
  708. const effects = isArray(dep) ? dep : [...dep];
  709. for (const effect of effects) {
  710. if (effect.computed) {
  711. triggerEffect(effect, debuggerEventExtraInfo);
  712. }
  713. }
  714. for (const effect of effects) {
  715. if (!effect.computed) {
  716. triggerEffect(effect, debuggerEventExtraInfo);
  717. }
  718. }
  719. }
  720. function triggerEffect(effect, debuggerEventExtraInfo) {
  721. if (effect !== activeEffect || effect.allowRecurse) {
  722. if (effect.onTrigger) {
  723. effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
  724. }
  725. if (effect.scheduler) {
  726. effect.scheduler();
  727. }
  728. else {
  729. effect.run();
  730. }
  731. }
  732. }
  733. const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
  734. const builtInSymbols = new Set(
  735. /*#__PURE__*/
  736. Object.getOwnPropertyNames(Symbol)
  737. // ios10.x Object.getOwnPropertyNames(Symbol) can enumerate 'arguments' and 'caller'
  738. // but accessing them on Symbol leads to TypeError because Symbol is a strict mode
  739. // function
  740. .filter(key => key !== 'arguments' && key !== 'caller')
  741. .map(key => Symbol[key])
  742. .filter(isSymbol));
  743. const get = /*#__PURE__*/ createGetter();
  744. const shallowGet = /*#__PURE__*/ createGetter(false, true);
  745. const readonlyGet = /*#__PURE__*/ createGetter(true);
  746. const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
  747. const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
  748. function createArrayInstrumentations() {
  749. const instrumentations = {};
  750. ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
  751. instrumentations[key] = function (...args) {
  752. const arr = toRaw(this);
  753. for (let i = 0, l = this.length; i < l; i++) {
  754. track(arr, "get" /* TrackOpTypes.GET */, i + '');
  755. }
  756. // we run the method using the original args first (which may be reactive)
  757. const res = arr[key](...args);
  758. if (res === -1 || res === false) {
  759. // if that didn't work, run it again using raw values.
  760. return arr[key](...args.map(toRaw));
  761. }
  762. else {
  763. return res;
  764. }
  765. };
  766. });
  767. ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
  768. instrumentations[key] = function (...args) {
  769. pauseTracking();
  770. const res = toRaw(this)[key].apply(this, args);
  771. resetTracking();
  772. return res;
  773. };
  774. });
  775. return instrumentations;
  776. }
  777. function createGetter(isReadonly = false, shallow = false) {
  778. return function get(target, key, receiver) {
  779. if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
  780. return !isReadonly;
  781. }
  782. else if (key === "__v_isReadonly" /* ReactiveFlags.IS_READONLY */) {
  783. return isReadonly;
  784. }
  785. else if (key === "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */) {
  786. return shallow;
  787. }
  788. else if (key === "__v_raw" /* ReactiveFlags.RAW */ &&
  789. receiver ===
  790. (isReadonly
  791. ? shallow
  792. ? shallowReadonlyMap
  793. : readonlyMap
  794. : shallow
  795. ? shallowReactiveMap
  796. : reactiveMap).get(target)) {
  797. return target;
  798. }
  799. const targetIsArray = isArray(target);
  800. if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
  801. return Reflect.get(arrayInstrumentations, key, receiver);
  802. }
  803. const res = Reflect.get(target, key, receiver);
  804. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  805. return res;
  806. }
  807. if (!isReadonly) {
  808. track(target, "get" /* TrackOpTypes.GET */, key);
  809. }
  810. if (shallow) {
  811. return res;
  812. }
  813. if (isRef(res)) {
  814. // ref unwrapping - skip unwrap for Array + integer key.
  815. return targetIsArray && isIntegerKey(key) ? res : res.value;
  816. }
  817. if (isObject(res)) {
  818. // Convert returned value into a proxy as well. we do the isObject check
  819. // here to avoid invalid value warning. Also need to lazy access readonly
  820. // and reactive here to avoid circular dependency.
  821. return isReadonly ? readonly(res) : reactive(res);
  822. }
  823. return res;
  824. };
  825. }
  826. const set = /*#__PURE__*/ createSetter();
  827. const shallowSet = /*#__PURE__*/ createSetter(true);
  828. function createSetter(shallow = false) {
  829. return function set(target, key, value, receiver) {
  830. let oldValue = target[key];
  831. if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
  832. return false;
  833. }
  834. if (!shallow) {
  835. if (!isShallow(value) && !isReadonly(value)) {
  836. oldValue = toRaw(oldValue);
  837. value = toRaw(value);
  838. }
  839. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  840. oldValue.value = value;
  841. return true;
  842. }
  843. }
  844. const hadKey = isArray(target) && isIntegerKey(key)
  845. ? Number(key) < target.length
  846. : hasOwn(target, key);
  847. const result = Reflect.set(target, key, value, receiver);
  848. // don't trigger if target is something up in the prototype chain of original
  849. if (target === toRaw(receiver)) {
  850. if (!hadKey) {
  851. trigger(target, "add" /* TriggerOpTypes.ADD */, key, value);
  852. }
  853. else if (hasChanged(value, oldValue)) {
  854. trigger(target, "set" /* TriggerOpTypes.SET */, key, value, oldValue);
  855. }
  856. }
  857. return result;
  858. };
  859. }
  860. function deleteProperty(target, key) {
  861. const hadKey = hasOwn(target, key);
  862. const oldValue = target[key];
  863. const result = Reflect.deleteProperty(target, key);
  864. if (result && hadKey) {
  865. trigger(target, "delete" /* TriggerOpTypes.DELETE */, key, undefined, oldValue);
  866. }
  867. return result;
  868. }
  869. function has(target, key) {
  870. const result = Reflect.has(target, key);
  871. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  872. track(target, "has" /* TrackOpTypes.HAS */, key);
  873. }
  874. return result;
  875. }
  876. function ownKeys(target) {
  877. track(target, "iterate" /* TrackOpTypes.ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
  878. return Reflect.ownKeys(target);
  879. }
  880. const mutableHandlers = {
  881. get,
  882. set,
  883. deleteProperty,
  884. has,
  885. ownKeys
  886. };
  887. const readonlyHandlers = {
  888. get: readonlyGet,
  889. set(target, key) {
  890. {
  891. warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
  892. }
  893. return true;
  894. },
  895. deleteProperty(target, key) {
  896. {
  897. warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
  898. }
  899. return true;
  900. }
  901. };
  902. const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
  903. get: shallowGet,
  904. set: shallowSet
  905. });
  906. // Props handlers are special in the sense that it should not unwrap top-level
  907. // refs (in order to allow refs to be explicitly passed down), but should
  908. // retain the reactivity of the normal readonly object.
  909. const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
  910. get: shallowReadonlyGet
  911. });
  912. const toShallow = (value) => value;
  913. const getProto = (v) => Reflect.getPrototypeOf(v);
  914. function get$1(target, key, isReadonly = false, isShallow = false) {
  915. // #1772: readonly(reactive(Map)) should return readonly + reactive version
  916. // of the value
  917. target = target["__v_raw" /* ReactiveFlags.RAW */];
  918. const rawTarget = toRaw(target);
  919. const rawKey = toRaw(key);
  920. if (!isReadonly) {
  921. if (key !== rawKey) {
  922. track(rawTarget, "get" /* TrackOpTypes.GET */, key);
  923. }
  924. track(rawTarget, "get" /* TrackOpTypes.GET */, rawKey);
  925. }
  926. const { has } = getProto(rawTarget);
  927. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  928. if (has.call(rawTarget, key)) {
  929. return wrap(target.get(key));
  930. }
  931. else if (has.call(rawTarget, rawKey)) {
  932. return wrap(target.get(rawKey));
  933. }
  934. else if (target !== rawTarget) {
  935. // #3602 readonly(reactive(Map))
  936. // ensure that the nested reactive `Map` can do tracking for itself
  937. target.get(key);
  938. }
  939. }
  940. function has$1(key, isReadonly = false) {
  941. const target = this["__v_raw" /* ReactiveFlags.RAW */];
  942. const rawTarget = toRaw(target);
  943. const rawKey = toRaw(key);
  944. if (!isReadonly) {
  945. if (key !== rawKey) {
  946. track(rawTarget, "has" /* TrackOpTypes.HAS */, key);
  947. }
  948. track(rawTarget, "has" /* TrackOpTypes.HAS */, rawKey);
  949. }
  950. return key === rawKey
  951. ? target.has(key)
  952. : target.has(key) || target.has(rawKey);
  953. }
  954. function size(target, isReadonly = false) {
  955. target = target["__v_raw" /* ReactiveFlags.RAW */];
  956. !isReadonly && track(toRaw(target), "iterate" /* TrackOpTypes.ITERATE */, ITERATE_KEY);
  957. return Reflect.get(target, 'size', target);
  958. }
  959. function add(value) {
  960. value = toRaw(value);
  961. const target = toRaw(this);
  962. const proto = getProto(target);
  963. const hadKey = proto.has.call(target, value);
  964. if (!hadKey) {
  965. target.add(value);
  966. trigger(target, "add" /* TriggerOpTypes.ADD */, value, value);
  967. }
  968. return this;
  969. }
  970. function set$1(key, value) {
  971. value = toRaw(value);
  972. const target = toRaw(this);
  973. const { has, get } = getProto(target);
  974. let hadKey = has.call(target, key);
  975. if (!hadKey) {
  976. key = toRaw(key);
  977. hadKey = has.call(target, key);
  978. }
  979. else {
  980. checkIdentityKeys(target, has, key);
  981. }
  982. const oldValue = get.call(target, key);
  983. target.set(key, value);
  984. if (!hadKey) {
  985. trigger(target, "add" /* TriggerOpTypes.ADD */, key, value);
  986. }
  987. else if (hasChanged(value, oldValue)) {
  988. trigger(target, "set" /* TriggerOpTypes.SET */, key, value, oldValue);
  989. }
  990. return this;
  991. }
  992. function deleteEntry(key) {
  993. const target = toRaw(this);
  994. const { has, get } = getProto(target);
  995. let hadKey = has.call(target, key);
  996. if (!hadKey) {
  997. key = toRaw(key);
  998. hadKey = has.call(target, key);
  999. }
  1000. else {
  1001. checkIdentityKeys(target, has, key);
  1002. }
  1003. const oldValue = get ? get.call(target, key) : undefined;
  1004. // forward the operation before queueing reactions
  1005. const result = target.delete(key);
  1006. if (hadKey) {
  1007. trigger(target, "delete" /* TriggerOpTypes.DELETE */, key, undefined, oldValue);
  1008. }
  1009. return result;
  1010. }
  1011. function clear() {
  1012. const target = toRaw(this);
  1013. const hadItems = target.size !== 0;
  1014. const oldTarget = isMap(target)
  1015. ? new Map(target)
  1016. : new Set(target)
  1017. ;
  1018. // forward the operation before queueing reactions
  1019. const result = target.clear();
  1020. if (hadItems) {
  1021. trigger(target, "clear" /* TriggerOpTypes.CLEAR */, undefined, undefined, oldTarget);
  1022. }
  1023. return result;
  1024. }
  1025. function createForEach(isReadonly, isShallow) {
  1026. return function forEach(callback, thisArg) {
  1027. const observed = this;
  1028. const target = observed["__v_raw" /* ReactiveFlags.RAW */];
  1029. const rawTarget = toRaw(target);
  1030. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1031. !isReadonly && track(rawTarget, "iterate" /* TrackOpTypes.ITERATE */, ITERATE_KEY);
  1032. return target.forEach((value, key) => {
  1033. // important: make sure the callback is
  1034. // 1. invoked with the reactive map as `this` and 3rd arg
  1035. // 2. the value received should be a corresponding reactive/readonly.
  1036. return callback.call(thisArg, wrap(value), wrap(key), observed);
  1037. });
  1038. };
  1039. }
  1040. function createIterableMethod(method, isReadonly, isShallow) {
  1041. return function (...args) {
  1042. const target = this["__v_raw" /* ReactiveFlags.RAW */];
  1043. const rawTarget = toRaw(target);
  1044. const targetIsMap = isMap(rawTarget);
  1045. const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
  1046. const isKeyOnly = method === 'keys' && targetIsMap;
  1047. const innerIterator = target[method](...args);
  1048. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1049. !isReadonly &&
  1050. track(rawTarget, "iterate" /* TrackOpTypes.ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
  1051. // return a wrapped iterator which returns observed versions of the
  1052. // values emitted from the real iterator
  1053. return {
  1054. // iterator protocol
  1055. next() {
  1056. const { value, done } = innerIterator.next();
  1057. return done
  1058. ? { value, done }
  1059. : {
  1060. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1061. done
  1062. };
  1063. },
  1064. // iterable protocol
  1065. [Symbol.iterator]() {
  1066. return this;
  1067. }
  1068. };
  1069. };
  1070. }
  1071. function createReadonlyMethod(type) {
  1072. return function (...args) {
  1073. {
  1074. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1075. console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
  1076. }
  1077. return type === "delete" /* TriggerOpTypes.DELETE */ ? false : this;
  1078. };
  1079. }
  1080. function createInstrumentations() {
  1081. const mutableInstrumentations = {
  1082. get(key) {
  1083. return get$1(this, key);
  1084. },
  1085. get size() {
  1086. return size(this);
  1087. },
  1088. has: has$1,
  1089. add,
  1090. set: set$1,
  1091. delete: deleteEntry,
  1092. clear,
  1093. forEach: createForEach(false, false)
  1094. };
  1095. const shallowInstrumentations = {
  1096. get(key) {
  1097. return get$1(this, key, false, true);
  1098. },
  1099. get size() {
  1100. return size(this);
  1101. },
  1102. has: has$1,
  1103. add,
  1104. set: set$1,
  1105. delete: deleteEntry,
  1106. clear,
  1107. forEach: createForEach(false, true)
  1108. };
  1109. const readonlyInstrumentations = {
  1110. get(key) {
  1111. return get$1(this, key, true);
  1112. },
  1113. get size() {
  1114. return size(this, true);
  1115. },
  1116. has(key) {
  1117. return has$1.call(this, key, true);
  1118. },
  1119. add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
  1120. set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
  1121. delete: createReadonlyMethod("delete" /* TriggerOpTypes.DELETE */),
  1122. clear: createReadonlyMethod("clear" /* TriggerOpTypes.CLEAR */),
  1123. forEach: createForEach(true, false)
  1124. };
  1125. const shallowReadonlyInstrumentations = {
  1126. get(key) {
  1127. return get$1(this, key, true, true);
  1128. },
  1129. get size() {
  1130. return size(this, true);
  1131. },
  1132. has(key) {
  1133. return has$1.call(this, key, true);
  1134. },
  1135. add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
  1136. set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
  1137. delete: createReadonlyMethod("delete" /* TriggerOpTypes.DELETE */),
  1138. clear: createReadonlyMethod("clear" /* TriggerOpTypes.CLEAR */),
  1139. forEach: createForEach(true, true)
  1140. };
  1141. const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
  1142. iteratorMethods.forEach(method => {
  1143. mutableInstrumentations[method] = createIterableMethod(method, false, false);
  1144. readonlyInstrumentations[method] = createIterableMethod(method, true, false);
  1145. shallowInstrumentations[method] = createIterableMethod(method, false, true);
  1146. shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
  1147. });
  1148. return [
  1149. mutableInstrumentations,
  1150. readonlyInstrumentations,
  1151. shallowInstrumentations,
  1152. shallowReadonlyInstrumentations
  1153. ];
  1154. }
  1155. const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
  1156. function createInstrumentationGetter(isReadonly, shallow) {
  1157. const instrumentations = shallow
  1158. ? isReadonly
  1159. ? shallowReadonlyInstrumentations
  1160. : shallowInstrumentations
  1161. : isReadonly
  1162. ? readonlyInstrumentations
  1163. : mutableInstrumentations;
  1164. return (target, key, receiver) => {
  1165. if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
  1166. return !isReadonly;
  1167. }
  1168. else if (key === "__v_isReadonly" /* ReactiveFlags.IS_READONLY */) {
  1169. return isReadonly;
  1170. }
  1171. else if (key === "__v_raw" /* ReactiveFlags.RAW */) {
  1172. return target;
  1173. }
  1174. return Reflect.get(hasOwn(instrumentations, key) && key in target
  1175. ? instrumentations
  1176. : target, key, receiver);
  1177. };
  1178. }
  1179. const mutableCollectionHandlers = {
  1180. get: /*#__PURE__*/ createInstrumentationGetter(false, false)
  1181. };
  1182. const shallowCollectionHandlers = {
  1183. get: /*#__PURE__*/ createInstrumentationGetter(false, true)
  1184. };
  1185. const readonlyCollectionHandlers = {
  1186. get: /*#__PURE__*/ createInstrumentationGetter(true, false)
  1187. };
  1188. const shallowReadonlyCollectionHandlers = {
  1189. get: /*#__PURE__*/ createInstrumentationGetter(true, true)
  1190. };
  1191. function checkIdentityKeys(target, has, key) {
  1192. const rawKey = toRaw(key);
  1193. if (rawKey !== key && has.call(target, rawKey)) {
  1194. const type = toRawType(target);
  1195. console.warn(`Reactive ${type} contains both the raw and reactive ` +
  1196. `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
  1197. `which can lead to inconsistencies. ` +
  1198. `Avoid differentiating between the raw and reactive versions ` +
  1199. `of an object and only use the reactive version if possible.`);
  1200. }
  1201. }
  1202. const reactiveMap = new WeakMap();
  1203. const shallowReactiveMap = new WeakMap();
  1204. const readonlyMap = new WeakMap();
  1205. const shallowReadonlyMap = new WeakMap();
  1206. function targetTypeMap(rawType) {
  1207. switch (rawType) {
  1208. case 'Object':
  1209. case 'Array':
  1210. return 1 /* TargetType.COMMON */;
  1211. case 'Map':
  1212. case 'Set':
  1213. case 'WeakMap':
  1214. case 'WeakSet':
  1215. return 2 /* TargetType.COLLECTION */;
  1216. default:
  1217. return 0 /* TargetType.INVALID */;
  1218. }
  1219. }
  1220. function getTargetType(value) {
  1221. return value["__v_skip" /* ReactiveFlags.SKIP */] || !Object.isExtensible(value)
  1222. ? 0 /* TargetType.INVALID */
  1223. : targetTypeMap(toRawType(value));
  1224. }
  1225. function reactive(target) {
  1226. // if trying to observe a readonly proxy, return the readonly version.
  1227. if (isReadonly(target)) {
  1228. return target;
  1229. }
  1230. return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
  1231. }
  1232. /**
  1233. * Return a shallowly-reactive copy of the original object, where only the root
  1234. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1235. * root level).
  1236. */
  1237. function shallowReactive(target) {
  1238. return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
  1239. }
  1240. /**
  1241. * Creates a readonly copy of the original object. Note the returned copy is not
  1242. * made reactive, but `readonly` can be called on an already reactive object.
  1243. */
  1244. function readonly(target) {
  1245. return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
  1246. }
  1247. /**
  1248. * Returns a reactive-copy of the original object, where only the root level
  1249. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1250. * returned properties.
  1251. * This is used for creating the props proxy object for stateful components.
  1252. */
  1253. function shallowReadonly(target) {
  1254. return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
  1255. }
  1256. function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
  1257. if (!isObject(target)) {
  1258. {
  1259. console.warn(`value cannot be made reactive: ${String(target)}`);
  1260. }
  1261. return target;
  1262. }
  1263. // target is already a Proxy, return it.
  1264. // exception: calling readonly() on a reactive object
  1265. if (target["__v_raw" /* ReactiveFlags.RAW */] &&
  1266. !(isReadonly && target["__v_isReactive" /* ReactiveFlags.IS_REACTIVE */])) {
  1267. return target;
  1268. }
  1269. // target already has corresponding Proxy
  1270. const existingProxy = proxyMap.get(target);
  1271. if (existingProxy) {
  1272. return existingProxy;
  1273. }
  1274. // only specific value types can be observed.
  1275. const targetType = getTargetType(target);
  1276. if (targetType === 0 /* TargetType.INVALID */) {
  1277. return target;
  1278. }
  1279. const proxy = new Proxy(target, targetType === 2 /* TargetType.COLLECTION */ ? collectionHandlers : baseHandlers);
  1280. proxyMap.set(target, proxy);
  1281. return proxy;
  1282. }
  1283. function isReactive(value) {
  1284. if (isReadonly(value)) {
  1285. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  1286. }
  1287. return !!(value && value["__v_isReactive" /* ReactiveFlags.IS_REACTIVE */]);
  1288. }
  1289. function isReadonly(value) {
  1290. return !!(value && value["__v_isReadonly" /* ReactiveFlags.IS_READONLY */]);
  1291. }
  1292. function isShallow(value) {
  1293. return !!(value && value["__v_isShallow" /* ReactiveFlags.IS_SHALLOW */]);
  1294. }
  1295. function isProxy(value) {
  1296. return isReactive(value) || isReadonly(value);
  1297. }
  1298. function toRaw(observed) {
  1299. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  1300. return raw ? toRaw(raw) : observed;
  1301. }
  1302. function markRaw(value) {
  1303. def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
  1304. return value;
  1305. }
  1306. const toReactive = (value) => isObject(value) ? reactive(value) : value;
  1307. const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  1308. function trackRefValue(ref) {
  1309. if (shouldTrack && activeEffect) {
  1310. ref = toRaw(ref);
  1311. {
  1312. trackEffects(ref.dep || (ref.dep = createDep()), {
  1313. target: ref,
  1314. type: "get" /* TrackOpTypes.GET */,
  1315. key: 'value'
  1316. });
  1317. }
  1318. }
  1319. }
  1320. function triggerRefValue(ref, newVal) {
  1321. ref = toRaw(ref);
  1322. if (ref.dep) {
  1323. {
  1324. triggerEffects(ref.dep, {
  1325. target: ref,
  1326. type: "set" /* TriggerOpTypes.SET */,
  1327. key: 'value',
  1328. newValue: newVal
  1329. });
  1330. }
  1331. }
  1332. }
  1333. function isRef(r) {
  1334. return !!(r && r.__v_isRef === true);
  1335. }
  1336. function ref(value) {
  1337. return createRef(value, false);
  1338. }
  1339. function shallowRef(value) {
  1340. return createRef(value, true);
  1341. }
  1342. function createRef(rawValue, shallow) {
  1343. if (isRef(rawValue)) {
  1344. return rawValue;
  1345. }
  1346. return new RefImpl(rawValue, shallow);
  1347. }
  1348. class RefImpl {
  1349. constructor(value, __v_isShallow) {
  1350. this.__v_isShallow = __v_isShallow;
  1351. this.dep = undefined;
  1352. this.__v_isRef = true;
  1353. this._rawValue = __v_isShallow ? value : toRaw(value);
  1354. this._value = __v_isShallow ? value : toReactive(value);
  1355. }
  1356. get value() {
  1357. trackRefValue(this);
  1358. return this._value;
  1359. }
  1360. set value(newVal) {
  1361. const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
  1362. newVal = useDirectValue ? newVal : toRaw(newVal);
  1363. if (hasChanged(newVal, this._rawValue)) {
  1364. this._rawValue = newVal;
  1365. this._value = useDirectValue ? newVal : toReactive(newVal);
  1366. triggerRefValue(this, newVal);
  1367. }
  1368. }
  1369. }
  1370. function triggerRef(ref) {
  1371. triggerRefValue(ref, ref.value );
  1372. }
  1373. function unref(ref) {
  1374. return isRef(ref) ? ref.value : ref;
  1375. }
  1376. const shallowUnwrapHandlers = {
  1377. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1378. set: (target, key, value, receiver) => {
  1379. const oldValue = target[key];
  1380. if (isRef(oldValue) && !isRef(value)) {
  1381. oldValue.value = value;
  1382. return true;
  1383. }
  1384. else {
  1385. return Reflect.set(target, key, value, receiver);
  1386. }
  1387. }
  1388. };
  1389. function proxyRefs(objectWithRefs) {
  1390. return isReactive(objectWithRefs)
  1391. ? objectWithRefs
  1392. : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1393. }
  1394. class CustomRefImpl {
  1395. constructor(factory) {
  1396. this.dep = undefined;
  1397. this.__v_isRef = true;
  1398. const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
  1399. this._get = get;
  1400. this._set = set;
  1401. }
  1402. get value() {
  1403. return this._get();
  1404. }
  1405. set value(newVal) {
  1406. this._set(newVal);
  1407. }
  1408. }
  1409. function customRef(factory) {
  1410. return new CustomRefImpl(factory);
  1411. }
  1412. function toRefs(object) {
  1413. if (!isProxy(object)) {
  1414. console.warn(`toRefs() expects a reactive object but received a plain one.`);
  1415. }
  1416. const ret = isArray(object) ? new Array(object.length) : {};
  1417. for (const key in object) {
  1418. ret[key] = toRef(object, key);
  1419. }
  1420. return ret;
  1421. }
  1422. class ObjectRefImpl {
  1423. constructor(_object, _key, _defaultValue) {
  1424. this._object = _object;
  1425. this._key = _key;
  1426. this._defaultValue = _defaultValue;
  1427. this.__v_isRef = true;
  1428. }
  1429. get value() {
  1430. const val = this._object[this._key];
  1431. return val === undefined ? this._defaultValue : val;
  1432. }
  1433. set value(newVal) {
  1434. this._object[this._key] = newVal;
  1435. }
  1436. }
  1437. function toRef(object, key, defaultValue) {
  1438. const val = object[key];
  1439. return isRef(val)
  1440. ? val
  1441. : new ObjectRefImpl(object, key, defaultValue);
  1442. }
  1443. var _a;
  1444. class ComputedRefImpl {
  1445. constructor(getter, _setter, isReadonly, isSSR) {
  1446. this._setter = _setter;
  1447. this.dep = undefined;
  1448. this.__v_isRef = true;
  1449. this[_a] = false;
  1450. this._dirty = true;
  1451. this.effect = new ReactiveEffect(getter, () => {
  1452. if (!this._dirty) {
  1453. this._dirty = true;
  1454. triggerRefValue(this);
  1455. }
  1456. });
  1457. this.effect.computed = this;
  1458. this.effect.active = this._cacheable = !isSSR;
  1459. this["__v_isReadonly" /* ReactiveFlags.IS_READONLY */] = isReadonly;
  1460. }
  1461. get value() {
  1462. // the computed ref may get wrapped by other proxies e.g. readonly() #3376
  1463. const self = toRaw(this);
  1464. trackRefValue(self);
  1465. if (self._dirty || !self._cacheable) {
  1466. self._dirty = false;
  1467. self._value = self.effect.run();
  1468. }
  1469. return self._value;
  1470. }
  1471. set value(newValue) {
  1472. this._setter(newValue);
  1473. }
  1474. }
  1475. _a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
  1476. function computed(getterOrOptions, debugOptions, isSSR = false) {
  1477. let getter;
  1478. let setter;
  1479. const onlyGetter = isFunction(getterOrOptions);
  1480. if (onlyGetter) {
  1481. getter = getterOrOptions;
  1482. setter = () => {
  1483. console.warn('Write operation failed: computed value is readonly');
  1484. }
  1485. ;
  1486. }
  1487. else {
  1488. getter = getterOrOptions.get;
  1489. setter = getterOrOptions.set;
  1490. }
  1491. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
  1492. if (debugOptions && !isSSR) {
  1493. cRef.effect.onTrack = debugOptions.onTrack;
  1494. cRef.effect.onTrigger = debugOptions.onTrigger;
  1495. }
  1496. return cRef;
  1497. }
  1498. const stack = [];
  1499. function pushWarningContext(vnode) {
  1500. stack.push(vnode);
  1501. }
  1502. function popWarningContext() {
  1503. stack.pop();
  1504. }
  1505. function warn$1(msg, ...args) {
  1506. // avoid props formatting or warn handler tracking deps that might be mutated
  1507. // during patch, leading to infinite recursion.
  1508. pauseTracking();
  1509. const instance = stack.length ? stack[stack.length - 1].component : null;
  1510. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  1511. const trace = getComponentTrace();
  1512. if (appWarnHandler) {
  1513. callWithErrorHandling(appWarnHandler, instance, 11 /* ErrorCodes.APP_WARN_HANDLER */, [
  1514. msg + args.join(''),
  1515. instance && instance.proxy,
  1516. trace
  1517. .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
  1518. .join('\n'),
  1519. trace
  1520. ]);
  1521. }
  1522. else {
  1523. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  1524. /* istanbul ignore if */
  1525. if (trace.length &&
  1526. // avoid spamming console during tests
  1527. !false) {
  1528. warnArgs.push(`\n`, ...formatTrace(trace));
  1529. }
  1530. console.warn(...warnArgs);
  1531. }
  1532. resetTracking();
  1533. }
  1534. function getComponentTrace() {
  1535. let currentVNode = stack[stack.length - 1];
  1536. if (!currentVNode) {
  1537. return [];
  1538. }
  1539. // we can't just use the stack because it will be incomplete during updates
  1540. // that did not start from the root. Re-construct the parent chain using
  1541. // instance parent pointers.
  1542. const normalizedStack = [];
  1543. while (currentVNode) {
  1544. const last = normalizedStack[0];
  1545. if (last && last.vnode === currentVNode) {
  1546. last.recurseCount++;
  1547. }
  1548. else {
  1549. normalizedStack.push({
  1550. vnode: currentVNode,
  1551. recurseCount: 0
  1552. });
  1553. }
  1554. const parentInstance = currentVNode.component && currentVNode.component.parent;
  1555. currentVNode = parentInstance && parentInstance.vnode;
  1556. }
  1557. return normalizedStack;
  1558. }
  1559. /* istanbul ignore next */
  1560. function formatTrace(trace) {
  1561. const logs = [];
  1562. trace.forEach((entry, i) => {
  1563. logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
  1564. });
  1565. return logs;
  1566. }
  1567. function formatTraceEntry({ vnode, recurseCount }) {
  1568. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  1569. const isRoot = vnode.component ? vnode.component.parent == null : false;
  1570. const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
  1571. const close = `>` + postfix;
  1572. return vnode.props
  1573. ? [open, ...formatProps(vnode.props), close]
  1574. : [open + close];
  1575. }
  1576. /* istanbul ignore next */
  1577. function formatProps(props) {
  1578. const res = [];
  1579. const keys = Object.keys(props);
  1580. keys.slice(0, 3).forEach(key => {
  1581. res.push(...formatProp(key, props[key]));
  1582. });
  1583. if (keys.length > 3) {
  1584. res.push(` ...`);
  1585. }
  1586. return res;
  1587. }
  1588. /* istanbul ignore next */
  1589. function formatProp(key, value, raw) {
  1590. if (isString(value)) {
  1591. value = JSON.stringify(value);
  1592. return raw ? value : [`${key}=${value}`];
  1593. }
  1594. else if (typeof value === 'number' ||
  1595. typeof value === 'boolean' ||
  1596. value == null) {
  1597. return raw ? value : [`${key}=${value}`];
  1598. }
  1599. else if (isRef(value)) {
  1600. value = formatProp(key, toRaw(value.value), true);
  1601. return raw ? value : [`${key}=Ref<`, value, `>`];
  1602. }
  1603. else if (isFunction(value)) {
  1604. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  1605. }
  1606. else {
  1607. value = toRaw(value);
  1608. return raw ? value : [`${key}=`, value];
  1609. }
  1610. }
  1611. const ErrorTypeStrings = {
  1612. ["sp" /* LifecycleHooks.SERVER_PREFETCH */]: 'serverPrefetch hook',
  1613. ["bc" /* LifecycleHooks.BEFORE_CREATE */]: 'beforeCreate hook',
  1614. ["c" /* LifecycleHooks.CREATED */]: 'created hook',
  1615. ["bm" /* LifecycleHooks.BEFORE_MOUNT */]: 'beforeMount hook',
  1616. ["m" /* LifecycleHooks.MOUNTED */]: 'mounted hook',
  1617. ["bu" /* LifecycleHooks.BEFORE_UPDATE */]: 'beforeUpdate hook',
  1618. ["u" /* LifecycleHooks.UPDATED */]: 'updated',
  1619. ["bum" /* LifecycleHooks.BEFORE_UNMOUNT */]: 'beforeUnmount hook',
  1620. ["um" /* LifecycleHooks.UNMOUNTED */]: 'unmounted hook',
  1621. ["a" /* LifecycleHooks.ACTIVATED */]: 'activated hook',
  1622. ["da" /* LifecycleHooks.DEACTIVATED */]: 'deactivated hook',
  1623. ["ec" /* LifecycleHooks.ERROR_CAPTURED */]: 'errorCaptured hook',
  1624. ["rtc" /* LifecycleHooks.RENDER_TRACKED */]: 'renderTracked hook',
  1625. ["rtg" /* LifecycleHooks.RENDER_TRIGGERED */]: 'renderTriggered hook',
  1626. [0 /* ErrorCodes.SETUP_FUNCTION */]: 'setup function',
  1627. [1 /* ErrorCodes.RENDER_FUNCTION */]: 'render function',
  1628. [2 /* ErrorCodes.WATCH_GETTER */]: 'watcher getter',
  1629. [3 /* ErrorCodes.WATCH_CALLBACK */]: 'watcher callback',
  1630. [4 /* ErrorCodes.WATCH_CLEANUP */]: 'watcher cleanup function',
  1631. [5 /* ErrorCodes.NATIVE_EVENT_HANDLER */]: 'native event handler',
  1632. [6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */]: 'component event handler',
  1633. [7 /* ErrorCodes.VNODE_HOOK */]: 'vnode hook',
  1634. [8 /* ErrorCodes.DIRECTIVE_HOOK */]: 'directive hook',
  1635. [9 /* ErrorCodes.TRANSITION_HOOK */]: 'transition hook',
  1636. [10 /* ErrorCodes.APP_ERROR_HANDLER */]: 'app errorHandler',
  1637. [11 /* ErrorCodes.APP_WARN_HANDLER */]: 'app warnHandler',
  1638. [12 /* ErrorCodes.FUNCTION_REF */]: 'ref function',
  1639. [13 /* ErrorCodes.ASYNC_COMPONENT_LOADER */]: 'async component loader',
  1640. [14 /* ErrorCodes.SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
  1641. 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
  1642. };
  1643. function callWithErrorHandling(fn, instance, type, args) {
  1644. let res;
  1645. try {
  1646. res = args ? fn(...args) : fn();
  1647. }
  1648. catch (err) {
  1649. handleError(err, instance, type);
  1650. }
  1651. return res;
  1652. }
  1653. function callWithAsyncErrorHandling(fn, instance, type, args) {
  1654. if (isFunction(fn)) {
  1655. const res = callWithErrorHandling(fn, instance, type, args);
  1656. if (res && isPromise(res)) {
  1657. res.catch(err => {
  1658. handleError(err, instance, type);
  1659. });
  1660. }
  1661. return res;
  1662. }
  1663. const values = [];
  1664. for (let i = 0; i < fn.length; i++) {
  1665. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  1666. }
  1667. return values;
  1668. }
  1669. function handleError(err, instance, type, throwInDev = true) {
  1670. const contextVNode = instance ? instance.vnode : null;
  1671. if (instance) {
  1672. let cur = instance.parent;
  1673. // the exposed instance is the render proxy to keep it consistent with 2.x
  1674. const exposedInstance = instance.proxy;
  1675. // in production the hook receives only the error code
  1676. const errorInfo = ErrorTypeStrings[type] ;
  1677. while (cur) {
  1678. const errorCapturedHooks = cur.ec;
  1679. if (errorCapturedHooks) {
  1680. for (let i = 0; i < errorCapturedHooks.length; i++) {
  1681. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  1682. return;
  1683. }
  1684. }
  1685. }
  1686. cur = cur.parent;
  1687. }
  1688. // app-level handling
  1689. const appErrorHandler = instance.appContext.config.errorHandler;
  1690. if (appErrorHandler) {
  1691. callWithErrorHandling(appErrorHandler, null, 10 /* ErrorCodes.APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
  1692. return;
  1693. }
  1694. }
  1695. logError(err, type, contextVNode, throwInDev);
  1696. }
  1697. function logError(err, type, contextVNode, throwInDev = true) {
  1698. {
  1699. const info = ErrorTypeStrings[type];
  1700. if (contextVNode) {
  1701. pushWarningContext(contextVNode);
  1702. }
  1703. warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  1704. if (contextVNode) {
  1705. popWarningContext();
  1706. }
  1707. // crash in dev by default so it's more noticeable
  1708. if (throwInDev) {
  1709. throw err;
  1710. }
  1711. else {
  1712. console.error(err);
  1713. }
  1714. }
  1715. }
  1716. let isFlushing = false;
  1717. let isFlushPending = false;
  1718. const queue = [];
  1719. let flushIndex = 0;
  1720. const pendingPostFlushCbs = [];
  1721. let activePostFlushCbs = null;
  1722. let postFlushIndex = 0;
  1723. const resolvedPromise = /*#__PURE__*/ Promise.resolve();
  1724. let currentFlushPromise = null;
  1725. const RECURSION_LIMIT = 100;
  1726. function nextTick(fn) {
  1727. const p = currentFlushPromise || resolvedPromise;
  1728. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  1729. }
  1730. // #2768
  1731. // Use binary-search to find a suitable position in the queue,
  1732. // so that the queue maintains the increasing order of job's id,
  1733. // which can prevent the job from being skipped and also can avoid repeated patching.
  1734. function findInsertionIndex(id) {
  1735. // the start index should be `flushIndex + 1`
  1736. let start = flushIndex + 1;
  1737. let end = queue.length;
  1738. while (start < end) {
  1739. const middle = (start + end) >>> 1;
  1740. const middleJobId = getId(queue[middle]);
  1741. middleJobId < id ? (start = middle + 1) : (end = middle);
  1742. }
  1743. return start;
  1744. }
  1745. function queueJob(job) {
  1746. // the dedupe search uses the startIndex argument of Array.includes()
  1747. // by default the search index includes the current job that is being run
  1748. // so it cannot recursively trigger itself again.
  1749. // if the job is a watch() callback, the search will start with a +1 index to
  1750. // allow it recursively trigger itself - it is the user's responsibility to
  1751. // ensure it doesn't end up in an infinite loop.
  1752. if (!queue.length ||
  1753. !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) {
  1754. if (job.id == null) {
  1755. queue.push(job);
  1756. }
  1757. else {
  1758. queue.splice(findInsertionIndex(job.id), 0, job);
  1759. }
  1760. queueFlush();
  1761. }
  1762. }
  1763. function queueFlush() {
  1764. if (!isFlushing && !isFlushPending) {
  1765. isFlushPending = true;
  1766. currentFlushPromise = resolvedPromise.then(flushJobs);
  1767. }
  1768. }
  1769. function invalidateJob(job) {
  1770. const i = queue.indexOf(job);
  1771. if (i > flushIndex) {
  1772. queue.splice(i, 1);
  1773. }
  1774. }
  1775. function queuePostFlushCb(cb) {
  1776. if (!isArray(cb)) {
  1777. if (!activePostFlushCbs ||
  1778. !activePostFlushCbs.includes(cb, cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex)) {
  1779. pendingPostFlushCbs.push(cb);
  1780. }
  1781. }
  1782. else {
  1783. // if cb is an array, it is a component lifecycle hook which can only be
  1784. // triggered by a job, which is already deduped in the main queue, so
  1785. // we can skip duplicate check here to improve perf
  1786. pendingPostFlushCbs.push(...cb);
  1787. }
  1788. queueFlush();
  1789. }
  1790. function flushPreFlushCbs(seen,
  1791. // if currently flushing, skip the current job itself
  1792. i = isFlushing ? flushIndex + 1 : 0) {
  1793. {
  1794. seen = seen || new Map();
  1795. }
  1796. for (; i < queue.length; i++) {
  1797. const cb = queue[i];
  1798. if (cb && cb.pre) {
  1799. if (checkRecursiveUpdates(seen, cb)) {
  1800. continue;
  1801. }
  1802. queue.splice(i, 1);
  1803. i--;
  1804. cb();
  1805. }
  1806. }
  1807. }
  1808. function flushPostFlushCbs(seen) {
  1809. if (pendingPostFlushCbs.length) {
  1810. const deduped = [...new Set(pendingPostFlushCbs)];
  1811. pendingPostFlushCbs.length = 0;
  1812. // #1947 already has active queue, nested flushPostFlushCbs call
  1813. if (activePostFlushCbs) {
  1814. activePostFlushCbs.push(...deduped);
  1815. return;
  1816. }
  1817. activePostFlushCbs = deduped;
  1818. {
  1819. seen = seen || new Map();
  1820. }
  1821. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  1822. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  1823. if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
  1824. continue;
  1825. }
  1826. activePostFlushCbs[postFlushIndex]();
  1827. }
  1828. activePostFlushCbs = null;
  1829. postFlushIndex = 0;
  1830. }
  1831. }
  1832. const getId = (job) => job.id == null ? Infinity : job.id;
  1833. const comparator = (a, b) => {
  1834. const diff = getId(a) - getId(b);
  1835. if (diff === 0) {
  1836. if (a.pre && !b.pre)
  1837. return -1;
  1838. if (b.pre && !a.pre)
  1839. return 1;
  1840. }
  1841. return diff;
  1842. };
  1843. function flushJobs(seen) {
  1844. isFlushPending = false;
  1845. isFlushing = true;
  1846. {
  1847. seen = seen || new Map();
  1848. }
  1849. // Sort queue before flush.
  1850. // This ensures that:
  1851. // 1. Components are updated from parent to child. (because parent is always
  1852. // created before the child so its render effect will have smaller
  1853. // priority number)
  1854. // 2. If a component is unmounted during a parent component's update,
  1855. // its update can be skipped.
  1856. queue.sort(comparator);
  1857. // conditional usage of checkRecursiveUpdate must be determined out of
  1858. // try ... catch block since Rollup by default de-optimizes treeshaking
  1859. // inside try-catch. This can leave all warning code unshaked. Although
  1860. // they would get eventually shaken by a minifier like terser, some minifiers
  1861. // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
  1862. const check = (job) => checkRecursiveUpdates(seen, job)
  1863. ;
  1864. try {
  1865. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  1866. const job = queue[flushIndex];
  1867. if (job && job.active !== false) {
  1868. if (true && check(job)) {
  1869. continue;
  1870. }
  1871. // console.log(`running:`, job.id)
  1872. callWithErrorHandling(job, null, 14 /* ErrorCodes.SCHEDULER */);
  1873. }
  1874. }
  1875. }
  1876. finally {
  1877. flushIndex = 0;
  1878. queue.length = 0;
  1879. flushPostFlushCbs(seen);
  1880. isFlushing = false;
  1881. currentFlushPromise = null;
  1882. // some postFlushCb queued jobs!
  1883. // keep flushing until it drains.
  1884. if (queue.length || pendingPostFlushCbs.length) {
  1885. flushJobs(seen);
  1886. }
  1887. }
  1888. }
  1889. function checkRecursiveUpdates(seen, fn) {
  1890. if (!seen.has(fn)) {
  1891. seen.set(fn, 1);
  1892. }
  1893. else {
  1894. const count = seen.get(fn);
  1895. if (count > RECURSION_LIMIT) {
  1896. const instance = fn.ownerInstance;
  1897. const componentName = instance && getComponentName(instance.type);
  1898. warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
  1899. `This means you have a reactive effect that is mutating its own ` +
  1900. `dependencies and thus recursively triggering itself. Possible sources ` +
  1901. `include component template, render function, updated hook or ` +
  1902. `watcher source function.`);
  1903. return true;
  1904. }
  1905. else {
  1906. seen.set(fn, count + 1);
  1907. }
  1908. }
  1909. }
  1910. /* eslint-disable no-restricted-globals */
  1911. let isHmrUpdating = false;
  1912. const hmrDirtyComponents = new Set();
  1913. // Expose the HMR runtime on the global object
  1914. // This makes it entirely tree-shakable without polluting the exports and makes
  1915. // it easier to be used in toolings like vue-loader
  1916. // Note: for a component to be eligible for HMR it also needs the __hmrId option
  1917. // to be set so that its instances can be registered / removed.
  1918. {
  1919. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  1920. createRecord: tryWrap(createRecord),
  1921. rerender: tryWrap(rerender),
  1922. reload: tryWrap(reload)
  1923. };
  1924. }
  1925. const map = new Map();
  1926. function registerHMR(instance) {
  1927. const id = instance.type.__hmrId;
  1928. let record = map.get(id);
  1929. if (!record) {
  1930. createRecord(id, instance.type);
  1931. record = map.get(id);
  1932. }
  1933. record.instances.add(instance);
  1934. }
  1935. function unregisterHMR(instance) {
  1936. map.get(instance.type.__hmrId).instances.delete(instance);
  1937. }
  1938. function createRecord(id, initialDef) {
  1939. if (map.has(id)) {
  1940. return false;
  1941. }
  1942. map.set(id, {
  1943. initialDef: normalizeClassComponent(initialDef),
  1944. instances: new Set()
  1945. });
  1946. return true;
  1947. }
  1948. function normalizeClassComponent(component) {
  1949. return isClassComponent(component) ? component.__vccOpts : component;
  1950. }
  1951. function rerender(id, newRender) {
  1952. const record = map.get(id);
  1953. if (!record) {
  1954. return;
  1955. }
  1956. // update initial record (for not-yet-rendered component)
  1957. record.initialDef.render = newRender;
  1958. [...record.instances].forEach(instance => {
  1959. if (newRender) {
  1960. instance.render = newRender;
  1961. normalizeClassComponent(instance.type).render = newRender;
  1962. }
  1963. instance.renderCache = [];
  1964. // this flag forces child components with slot content to update
  1965. isHmrUpdating = true;
  1966. instance.update();
  1967. isHmrUpdating = false;
  1968. });
  1969. }
  1970. function reload(id, newComp) {
  1971. const record = map.get(id);
  1972. if (!record)
  1973. return;
  1974. newComp = normalizeClassComponent(newComp);
  1975. // update initial def (for not-yet-rendered components)
  1976. updateComponentDef(record.initialDef, newComp);
  1977. // create a snapshot which avoids the set being mutated during updates
  1978. const instances = [...record.instances];
  1979. for (const instance of instances) {
  1980. const oldComp = normalizeClassComponent(instance.type);
  1981. if (!hmrDirtyComponents.has(oldComp)) {
  1982. // 1. Update existing comp definition to match new one
  1983. if (oldComp !== record.initialDef) {
  1984. updateComponentDef(oldComp, newComp);
  1985. }
  1986. // 2. mark definition dirty. This forces the renderer to replace the
  1987. // component on patch.
  1988. hmrDirtyComponents.add(oldComp);
  1989. }
  1990. // 3. invalidate options resolution cache
  1991. instance.appContext.optionsCache.delete(instance.type);
  1992. // 4. actually update
  1993. if (instance.ceReload) {
  1994. // custom element
  1995. hmrDirtyComponents.add(oldComp);
  1996. instance.ceReload(newComp.styles);
  1997. hmrDirtyComponents.delete(oldComp);
  1998. }
  1999. else if (instance.parent) {
  2000. // 4. Force the parent instance to re-render. This will cause all updated
  2001. // components to be unmounted and re-mounted. Queue the update so that we
  2002. // don't end up forcing the same parent to re-render multiple times.
  2003. queueJob(instance.parent.update);
  2004. }
  2005. else if (instance.appContext.reload) {
  2006. // root instance mounted via createApp() has a reload method
  2007. instance.appContext.reload();
  2008. }
  2009. else if (typeof window !== 'undefined') {
  2010. // root instance inside tree created via raw render(). Force reload.
  2011. window.location.reload();
  2012. }
  2013. else {
  2014. console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
  2015. }
  2016. }
  2017. // 5. make sure to cleanup dirty hmr components after update
  2018. queuePostFlushCb(() => {
  2019. for (const instance of instances) {
  2020. hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
  2021. }
  2022. });
  2023. }
  2024. function updateComponentDef(oldComp, newComp) {
  2025. extend(oldComp, newComp);
  2026. for (const key in oldComp) {
  2027. if (key !== '__file' && !(key in newComp)) {
  2028. delete oldComp[key];
  2029. }
  2030. }
  2031. }
  2032. function tryWrap(fn) {
  2033. return (id, arg) => {
  2034. try {
  2035. return fn(id, arg);
  2036. }
  2037. catch (e) {
  2038. console.error(e);
  2039. console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
  2040. `Full reload required.`);
  2041. }
  2042. };
  2043. }
  2044. let buffer = [];
  2045. let devtoolsNotInstalled = false;
  2046. function emit(event, ...args) {
  2047. if (exports.devtools) {
  2048. exports.devtools.emit(event, ...args);
  2049. }
  2050. else if (!devtoolsNotInstalled) {
  2051. buffer.push({ event, args });
  2052. }
  2053. }
  2054. function setDevtoolsHook(hook, target) {
  2055. var _a, _b;
  2056. exports.devtools = hook;
  2057. if (exports.devtools) {
  2058. exports.devtools.enabled = true;
  2059. buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
  2060. buffer = [];
  2061. }
  2062. else if (
  2063. // handle late devtools injection - only do this if we are in an actual
  2064. // browser environment to avoid the timer handle stalling test runner exit
  2065. // (#4815)
  2066. typeof window !== 'undefined' &&
  2067. // some envs mock window but not fully
  2068. window.HTMLElement &&
  2069. // also exclude jsdom
  2070. !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
  2071. const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
  2072. target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
  2073. replay.push((newHook) => {
  2074. setDevtoolsHook(newHook, target);
  2075. });
  2076. // clear buffer after 3s - the user probably doesn't have devtools installed
  2077. // at all, and keeping the buffer will cause memory leaks (#4738)
  2078. setTimeout(() => {
  2079. if (!exports.devtools) {
  2080. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  2081. devtoolsNotInstalled = true;
  2082. buffer = [];
  2083. }
  2084. }, 3000);
  2085. }
  2086. else {
  2087. // non-browser env, assume not installed
  2088. devtoolsNotInstalled = true;
  2089. buffer = [];
  2090. }
  2091. }
  2092. function devtoolsInitApp(app, version) {
  2093. emit("app:init" /* DevtoolsHooks.APP_INIT */, app, version, {
  2094. Fragment,
  2095. Text,
  2096. Comment,
  2097. Static
  2098. });
  2099. }
  2100. function devtoolsUnmountApp(app) {
  2101. emit("app:unmount" /* DevtoolsHooks.APP_UNMOUNT */, app);
  2102. }
  2103. const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* DevtoolsHooks.COMPONENT_ADDED */);
  2104. const devtoolsComponentUpdated =
  2105. /*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* DevtoolsHooks.COMPONENT_UPDATED */);
  2106. const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* DevtoolsHooks.COMPONENT_REMOVED */);
  2107. const devtoolsComponentRemoved = (component) => {
  2108. if (exports.devtools &&
  2109. typeof exports.devtools.cleanupBuffer === 'function' &&
  2110. // remove the component if it wasn't buffered
  2111. !exports.devtools.cleanupBuffer(component)) {
  2112. _devtoolsComponentRemoved(component);
  2113. }
  2114. };
  2115. function createDevtoolsComponentHook(hook) {
  2116. return (component) => {
  2117. emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
  2118. };
  2119. }
  2120. const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* DevtoolsHooks.PERFORMANCE_START */);
  2121. const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* DevtoolsHooks.PERFORMANCE_END */);
  2122. function createDevtoolsPerformanceHook(hook) {
  2123. return (component, type, time) => {
  2124. emit(hook, component.appContext.app, component.uid, component, type, time);
  2125. };
  2126. }
  2127. function devtoolsComponentEmit(component, event, params) {
  2128. emit("component:emit" /* DevtoolsHooks.COMPONENT_EMIT */, component.appContext.app, component, event, params);
  2129. }
  2130. function emit$1(instance, event, ...rawArgs) {
  2131. if (instance.isUnmounted)
  2132. return;
  2133. const props = instance.vnode.props || EMPTY_OBJ;
  2134. {
  2135. const { emitsOptions, propsOptions: [propsOptions] } = instance;
  2136. if (emitsOptions) {
  2137. if (!(event in emitsOptions) &&
  2138. !(false )) {
  2139. if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
  2140. warn$1(`Component emitted event "${event}" but it is neither declared in ` +
  2141. `the emits option nor as an "${toHandlerKey(event)}" prop.`);
  2142. }
  2143. }
  2144. else {
  2145. const validator = emitsOptions[event];
  2146. if (isFunction(validator)) {
  2147. const isValid = validator(...rawArgs);
  2148. if (!isValid) {
  2149. warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
  2150. }
  2151. }
  2152. }
  2153. }
  2154. }
  2155. let args = rawArgs;
  2156. const isModelListener = event.startsWith('update:');
  2157. // for v-model update:xxx events, apply modifiers on args
  2158. const modelArg = isModelListener && event.slice(7);
  2159. if (modelArg && modelArg in props) {
  2160. const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
  2161. const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
  2162. if (trim) {
  2163. args = rawArgs.map(a => (isString(a) ? a.trim() : a));
  2164. }
  2165. if (number) {
  2166. args = rawArgs.map(toNumber);
  2167. }
  2168. }
  2169. {
  2170. devtoolsComponentEmit(instance, event, args);
  2171. }
  2172. {
  2173. const lowerCaseEvent = event.toLowerCase();
  2174. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  2175. warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
  2176. `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
  2177. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2178. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2179. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2180. }
  2181. }
  2182. let handlerName;
  2183. let handler = props[(handlerName = toHandlerKey(event))] ||
  2184. // also try camelCase event handler (#2249)
  2185. props[(handlerName = toHandlerKey(camelize(event)))];
  2186. // for v-model update:xxx events, also trigger kebab-case equivalent
  2187. // for props passed via kebab-case
  2188. if (!handler && isModelListener) {
  2189. handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
  2190. }
  2191. if (handler) {
  2192. callWithAsyncErrorHandling(handler, instance, 6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */, args);
  2193. }
  2194. const onceHandler = props[handlerName + `Once`];
  2195. if (onceHandler) {
  2196. if (!instance.emitted) {
  2197. instance.emitted = {};
  2198. }
  2199. else if (instance.emitted[handlerName]) {
  2200. return;
  2201. }
  2202. instance.emitted[handlerName] = true;
  2203. callWithAsyncErrorHandling(onceHandler, instance, 6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */, args);
  2204. }
  2205. }
  2206. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  2207. const cache = appContext.emitsCache;
  2208. const cached = cache.get(comp);
  2209. if (cached !== undefined) {
  2210. return cached;
  2211. }
  2212. const raw = comp.emits;
  2213. let normalized = {};
  2214. // apply mixin/extends props
  2215. let hasExtends = false;
  2216. if (!isFunction(comp)) {
  2217. const extendEmits = (raw) => {
  2218. const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
  2219. if (normalizedFromExtend) {
  2220. hasExtends = true;
  2221. extend(normalized, normalizedFromExtend);
  2222. }
  2223. };
  2224. if (!asMixin && appContext.mixins.length) {
  2225. appContext.mixins.forEach(extendEmits);
  2226. }
  2227. if (comp.extends) {
  2228. extendEmits(comp.extends);
  2229. }
  2230. if (comp.mixins) {
  2231. comp.mixins.forEach(extendEmits);
  2232. }
  2233. }
  2234. if (!raw && !hasExtends) {
  2235. if (isObject(comp)) {
  2236. cache.set(comp, null);
  2237. }
  2238. return null;
  2239. }
  2240. if (isArray(raw)) {
  2241. raw.forEach(key => (normalized[key] = null));
  2242. }
  2243. else {
  2244. extend(normalized, raw);
  2245. }
  2246. if (isObject(comp)) {
  2247. cache.set(comp, normalized);
  2248. }
  2249. return normalized;
  2250. }
  2251. // Check if an incoming prop key is a declared emit event listener.
  2252. // e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
  2253. // both considered matched listeners.
  2254. function isEmitListener(options, key) {
  2255. if (!options || !isOn(key)) {
  2256. return false;
  2257. }
  2258. key = key.slice(2).replace(/Once$/, '');
  2259. return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
  2260. hasOwn(options, hyphenate(key)) ||
  2261. hasOwn(options, key));
  2262. }
  2263. /**
  2264. * mark the current rendering instance for asset resolution (e.g.
  2265. * resolveComponent, resolveDirective) during render
  2266. */
  2267. let currentRenderingInstance = null;
  2268. let currentScopeId = null;
  2269. /**
  2270. * Note: rendering calls maybe nested. The function returns the parent rendering
  2271. * instance if present, which should be restored after the render is done:
  2272. *
  2273. * ```js
  2274. * const prev = setCurrentRenderingInstance(i)
  2275. * // ...render
  2276. * setCurrentRenderingInstance(prev)
  2277. * ```
  2278. */
  2279. function setCurrentRenderingInstance(instance) {
  2280. const prev = currentRenderingInstance;
  2281. currentRenderingInstance = instance;
  2282. currentScopeId = (instance && instance.type.__scopeId) || null;
  2283. return prev;
  2284. }
  2285. /**
  2286. * Set scope id when creating hoisted vnodes.
  2287. * @private compiler helper
  2288. */
  2289. function pushScopeId(id) {
  2290. currentScopeId = id;
  2291. }
  2292. /**
  2293. * Technically we no longer need this after 3.0.8 but we need to keep the same
  2294. * API for backwards compat w/ code generated by compilers.
  2295. * @private
  2296. */
  2297. function popScopeId() {
  2298. currentScopeId = null;
  2299. }
  2300. /**
  2301. * Only for backwards compat
  2302. * @private
  2303. */
  2304. const withScopeId = (_id) => withCtx;
  2305. /**
  2306. * Wrap a slot function to memoize current rendering instance
  2307. * @private compiler helper
  2308. */
  2309. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only
  2310. ) {
  2311. if (!ctx)
  2312. return fn;
  2313. // already normalized
  2314. if (fn._n) {
  2315. return fn;
  2316. }
  2317. const renderFnWithContext = (...args) => {
  2318. // If a user calls a compiled slot inside a template expression (#1745), it
  2319. // can mess up block tracking, so by default we disable block tracking and
  2320. // force bail out when invoking a compiled slot (indicated by the ._d flag).
  2321. // This isn't necessary if rendering a compiled `<slot>`, so we flip the
  2322. // ._d flag off when invoking the wrapped fn inside `renderSlot`.
  2323. if (renderFnWithContext._d) {
  2324. setBlockTracking(-1);
  2325. }
  2326. const prevInstance = setCurrentRenderingInstance(ctx);
  2327. let res;
  2328. try {
  2329. res = fn(...args);
  2330. }
  2331. finally {
  2332. setCurrentRenderingInstance(prevInstance);
  2333. if (renderFnWithContext._d) {
  2334. setBlockTracking(1);
  2335. }
  2336. }
  2337. {
  2338. devtoolsComponentUpdated(ctx);
  2339. }
  2340. return res;
  2341. };
  2342. // mark normalized to avoid duplicated wrapping
  2343. renderFnWithContext._n = true;
  2344. // mark this as compiled by default
  2345. // this is used in vnode.ts -> normalizeChildren() to set the slot
  2346. // rendering flag.
  2347. renderFnWithContext._c = true;
  2348. // disable block tracking by default
  2349. renderFnWithContext._d = true;
  2350. return renderFnWithContext;
  2351. }
  2352. /**
  2353. * dev only flag to track whether $attrs was used during render.
  2354. * If $attrs was used during render then the warning for failed attrs
  2355. * fallthrough can be suppressed.
  2356. */
  2357. let accessedAttrs = false;
  2358. function markAttrsAccessed() {
  2359. accessedAttrs = true;
  2360. }
  2361. function renderComponentRoot(instance) {
  2362. const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
  2363. let result;
  2364. let fallthroughAttrs;
  2365. const prev = setCurrentRenderingInstance(instance);
  2366. {
  2367. accessedAttrs = false;
  2368. }
  2369. try {
  2370. if (vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */) {
  2371. // withProxy is a proxy with a different `has` trap only for
  2372. // runtime-compiled render functions using `with` block.
  2373. const proxyToUse = withProxy || proxy;
  2374. result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
  2375. fallthroughAttrs = attrs;
  2376. }
  2377. else {
  2378. // functional
  2379. const render = Component;
  2380. // in dev, mark attrs accessed if optional props (attrs === props)
  2381. if (true && attrs === props) {
  2382. markAttrsAccessed();
  2383. }
  2384. result = normalizeVNode(render.length > 1
  2385. ? render(props, true
  2386. ? {
  2387. get attrs() {
  2388. markAttrsAccessed();
  2389. return attrs;
  2390. },
  2391. slots,
  2392. emit
  2393. }
  2394. : { attrs, slots, emit })
  2395. : render(props, null /* we know it doesn't need it */));
  2396. fallthroughAttrs = Component.props
  2397. ? attrs
  2398. : getFunctionalFallthrough(attrs);
  2399. }
  2400. }
  2401. catch (err) {
  2402. blockStack.length = 0;
  2403. handleError(err, instance, 1 /* ErrorCodes.RENDER_FUNCTION */);
  2404. result = createVNode(Comment);
  2405. }
  2406. // attr merging
  2407. // in dev mode, comments are preserved, and it's possible for a template
  2408. // to have comments along side the root element which makes it a fragment
  2409. let root = result;
  2410. let setRoot = undefined;
  2411. if (result.patchFlag > 0 &&
  2412. result.patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */) {
  2413. [root, setRoot] = getChildRoot(result);
  2414. }
  2415. if (fallthroughAttrs && inheritAttrs !== false) {
  2416. const keys = Object.keys(fallthroughAttrs);
  2417. const { shapeFlag } = root;
  2418. if (keys.length) {
  2419. if (shapeFlag & (1 /* ShapeFlags.ELEMENT */ | 6 /* ShapeFlags.COMPONENT */)) {
  2420. if (propsOptions && keys.some(isModelListener)) {
  2421. // If a v-model listener (onUpdate:xxx) has a corresponding declared
  2422. // prop, it indicates this component expects to handle v-model and
  2423. // it should not fallthrough.
  2424. // related: #1543, #1643, #1989
  2425. fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
  2426. }
  2427. root = cloneVNode(root, fallthroughAttrs);
  2428. }
  2429. else if (!accessedAttrs && root.type !== Comment) {
  2430. const allAttrs = Object.keys(attrs);
  2431. const eventAttrs = [];
  2432. const extraAttrs = [];
  2433. for (let i = 0, l = allAttrs.length; i < l; i++) {
  2434. const key = allAttrs[i];
  2435. if (isOn(key)) {
  2436. // ignore v-model handlers when they fail to fallthrough
  2437. if (!isModelListener(key)) {
  2438. // remove `on`, lowercase first letter to reflect event casing
  2439. // accurately
  2440. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  2441. }
  2442. }
  2443. else {
  2444. extraAttrs.push(key);
  2445. }
  2446. }
  2447. if (extraAttrs.length) {
  2448. warn$1(`Extraneous non-props attributes (` +
  2449. `${extraAttrs.join(', ')}) ` +
  2450. `were passed to component but could not be automatically inherited ` +
  2451. `because component renders fragment or text root nodes.`);
  2452. }
  2453. if (eventAttrs.length) {
  2454. warn$1(`Extraneous non-emits event listeners (` +
  2455. `${eventAttrs.join(', ')}) ` +
  2456. `were passed to component but could not be automatically inherited ` +
  2457. `because component renders fragment or text root nodes. ` +
  2458. `If the listener is intended to be a component custom event listener only, ` +
  2459. `declare it using the "emits" option.`);
  2460. }
  2461. }
  2462. }
  2463. }
  2464. // inherit directives
  2465. if (vnode.dirs) {
  2466. if (!isElementRoot(root)) {
  2467. warn$1(`Runtime directive used on component with non-element root node. ` +
  2468. `The directives will not function as intended.`);
  2469. }
  2470. // clone before mutating since the root may be a hoisted vnode
  2471. root = cloneVNode(root);
  2472. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  2473. }
  2474. // inherit transition data
  2475. if (vnode.transition) {
  2476. if (!isElementRoot(root)) {
  2477. warn$1(`Component inside <Transition> renders non-element root node ` +
  2478. `that cannot be animated.`);
  2479. }
  2480. root.transition = vnode.transition;
  2481. }
  2482. if (setRoot) {
  2483. setRoot(root);
  2484. }
  2485. else {
  2486. result = root;
  2487. }
  2488. setCurrentRenderingInstance(prev);
  2489. return result;
  2490. }
  2491. /**
  2492. * dev only
  2493. * In dev mode, template root level comments are rendered, which turns the
  2494. * template into a fragment root, but we need to locate the single element
  2495. * root for attrs and scope id processing.
  2496. */
  2497. const getChildRoot = (vnode) => {
  2498. const rawChildren = vnode.children;
  2499. const dynamicChildren = vnode.dynamicChildren;
  2500. const childRoot = filterSingleRoot(rawChildren);
  2501. if (!childRoot) {
  2502. return [vnode, undefined];
  2503. }
  2504. const index = rawChildren.indexOf(childRoot);
  2505. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  2506. const setRoot = (updatedRoot) => {
  2507. rawChildren[index] = updatedRoot;
  2508. if (dynamicChildren) {
  2509. if (dynamicIndex > -1) {
  2510. dynamicChildren[dynamicIndex] = updatedRoot;
  2511. }
  2512. else if (updatedRoot.patchFlag > 0) {
  2513. vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
  2514. }
  2515. }
  2516. };
  2517. return [normalizeVNode(childRoot), setRoot];
  2518. };
  2519. function filterSingleRoot(children) {
  2520. let singleRoot;
  2521. for (let i = 0; i < children.length; i++) {
  2522. const child = children[i];
  2523. if (isVNode(child)) {
  2524. // ignore user comment
  2525. if (child.type !== Comment || child.children === 'v-if') {
  2526. if (singleRoot) {
  2527. // has more than 1 non-comment child, return now
  2528. return;
  2529. }
  2530. else {
  2531. singleRoot = child;
  2532. }
  2533. }
  2534. }
  2535. else {
  2536. return;
  2537. }
  2538. }
  2539. return singleRoot;
  2540. }
  2541. const getFunctionalFallthrough = (attrs) => {
  2542. let res;
  2543. for (const key in attrs) {
  2544. if (key === 'class' || key === 'style' || isOn(key)) {
  2545. (res || (res = {}))[key] = attrs[key];
  2546. }
  2547. }
  2548. return res;
  2549. };
  2550. const filterModelListeners = (attrs, props) => {
  2551. const res = {};
  2552. for (const key in attrs) {
  2553. if (!isModelListener(key) || !(key.slice(9) in props)) {
  2554. res[key] = attrs[key];
  2555. }
  2556. }
  2557. return res;
  2558. };
  2559. const isElementRoot = (vnode) => {
  2560. return (vnode.shapeFlag & (6 /* ShapeFlags.COMPONENT */ | 1 /* ShapeFlags.ELEMENT */) ||
  2561. vnode.type === Comment // potential v-if branch switch
  2562. );
  2563. };
  2564. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  2565. const { props: prevProps, children: prevChildren, component } = prevVNode;
  2566. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  2567. const emits = component.emitsOptions;
  2568. // Parent component's render function was hot-updated. Since this may have
  2569. // caused the child component's slots content to have changed, we need to
  2570. // force the child to update as well.
  2571. if ((prevChildren || nextChildren) && isHmrUpdating) {
  2572. return true;
  2573. }
  2574. // force child update for runtime directive or transition on component vnode.
  2575. if (nextVNode.dirs || nextVNode.transition) {
  2576. return true;
  2577. }
  2578. if (optimized && patchFlag >= 0) {
  2579. if (patchFlag & 1024 /* PatchFlags.DYNAMIC_SLOTS */) {
  2580. // slot content that references values that might have changed,
  2581. // e.g. in a v-for
  2582. return true;
  2583. }
  2584. if (patchFlag & 16 /* PatchFlags.FULL_PROPS */) {
  2585. if (!prevProps) {
  2586. return !!nextProps;
  2587. }
  2588. // presence of this flag indicates props are always non-null
  2589. return hasPropsChanged(prevProps, nextProps, emits);
  2590. }
  2591. else if (patchFlag & 8 /* PatchFlags.PROPS */) {
  2592. const dynamicProps = nextVNode.dynamicProps;
  2593. for (let i = 0; i < dynamicProps.length; i++) {
  2594. const key = dynamicProps[i];
  2595. if (nextProps[key] !== prevProps[key] &&
  2596. !isEmitListener(emits, key)) {
  2597. return true;
  2598. }
  2599. }
  2600. }
  2601. }
  2602. else {
  2603. // this path is only taken by manually written render functions
  2604. // so presence of any children leads to a forced update
  2605. if (prevChildren || nextChildren) {
  2606. if (!nextChildren || !nextChildren.$stable) {
  2607. return true;
  2608. }
  2609. }
  2610. if (prevProps === nextProps) {
  2611. return false;
  2612. }
  2613. if (!prevProps) {
  2614. return !!nextProps;
  2615. }
  2616. if (!nextProps) {
  2617. return true;
  2618. }
  2619. return hasPropsChanged(prevProps, nextProps, emits);
  2620. }
  2621. return false;
  2622. }
  2623. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2624. const nextKeys = Object.keys(nextProps);
  2625. if (nextKeys.length !== Object.keys(prevProps).length) {
  2626. return true;
  2627. }
  2628. for (let i = 0; i < nextKeys.length; i++) {
  2629. const key = nextKeys[i];
  2630. if (nextProps[key] !== prevProps[key] &&
  2631. !isEmitListener(emitsOptions, key)) {
  2632. return true;
  2633. }
  2634. }
  2635. return false;
  2636. }
  2637. function updateHOCHostEl({ vnode, parent }, el // HostNode
  2638. ) {
  2639. while (parent && parent.subTree === vnode) {
  2640. (vnode = parent.vnode).el = el;
  2641. parent = parent.parent;
  2642. }
  2643. }
  2644. const isSuspense = (type) => type.__isSuspense;
  2645. // Suspense exposes a component-like API, and is treated like a component
  2646. // in the compiler, but internally it's a special built-in type that hooks
  2647. // directly into the renderer.
  2648. const SuspenseImpl = {
  2649. name: 'Suspense',
  2650. // In order to make Suspense tree-shakable, we need to avoid importing it
  2651. // directly in the renderer. The renderer checks for the __isSuspense flag
  2652. // on a vnode's type and calls the `process` method, passing in renderer
  2653. // internals.
  2654. __isSuspense: true,
  2655. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
  2656. // platform-specific impl passed from renderer
  2657. rendererInternals) {
  2658. if (n1 == null) {
  2659. mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
  2660. }
  2661. else {
  2662. patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
  2663. }
  2664. },
  2665. hydrate: hydrateSuspense,
  2666. create: createSuspenseBoundary,
  2667. normalize: normalizeSuspenseChildren
  2668. };
  2669. // Force-casted public typing for h and TSX props inference
  2670. const Suspense = (SuspenseImpl
  2671. );
  2672. function triggerEvent(vnode, name) {
  2673. const eventListener = vnode.props && vnode.props[name];
  2674. if (isFunction(eventListener)) {
  2675. eventListener();
  2676. }
  2677. }
  2678. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2679. const { p: patch, o: { createElement } } = rendererInternals;
  2680. const hiddenContainer = createElement('div');
  2681. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
  2682. // start mounting the content subtree in an off-dom container
  2683. patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
  2684. // now check if we have encountered any async deps
  2685. if (suspense.deps > 0) {
  2686. // has async
  2687. // invoke @fallback event
  2688. triggerEvent(vnode, 'onPending');
  2689. triggerEvent(vnode, 'onFallback');
  2690. // mount the fallback tree
  2691. patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2692. isSVG, slotScopeIds);
  2693. setActiveBranch(suspense, vnode.ssFallback);
  2694. }
  2695. else {
  2696. // Suspense has no async deps. Just resolve.
  2697. suspense.resolve();
  2698. }
  2699. }
  2700. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
  2701. const suspense = (n2.suspense = n1.suspense);
  2702. suspense.vnode = n2;
  2703. n2.el = n1.el;
  2704. const newBranch = n2.ssContent;
  2705. const newFallback = n2.ssFallback;
  2706. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  2707. if (pendingBranch) {
  2708. suspense.pendingBranch = newBranch;
  2709. if (isSameVNodeType(newBranch, pendingBranch)) {
  2710. // same root type but content may have changed.
  2711. patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2712. if (suspense.deps <= 0) {
  2713. suspense.resolve();
  2714. }
  2715. else if (isInFallback) {
  2716. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2717. isSVG, slotScopeIds, optimized);
  2718. setActiveBranch(suspense, newFallback);
  2719. }
  2720. }
  2721. else {
  2722. // toggled before pending tree is resolved
  2723. suspense.pendingId++;
  2724. if (isHydrating) {
  2725. // if toggled before hydration is finished, the current DOM tree is
  2726. // no longer valid. set it as the active branch so it will be unmounted
  2727. // when resolved
  2728. suspense.isHydrating = false;
  2729. suspense.activeBranch = pendingBranch;
  2730. }
  2731. else {
  2732. unmount(pendingBranch, parentComponent, suspense);
  2733. }
  2734. // increment pending ID. this is used to invalidate async callbacks
  2735. // reset suspense state
  2736. suspense.deps = 0;
  2737. // discard effects from pending branch
  2738. suspense.effects.length = 0;
  2739. // discard previous container
  2740. suspense.hiddenContainer = createElement('div');
  2741. if (isInFallback) {
  2742. // already in fallback state
  2743. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2744. if (suspense.deps <= 0) {
  2745. suspense.resolve();
  2746. }
  2747. else {
  2748. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2749. isSVG, slotScopeIds, optimized);
  2750. setActiveBranch(suspense, newFallback);
  2751. }
  2752. }
  2753. else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2754. // toggled "back" to current active branch
  2755. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2756. // force resolve
  2757. suspense.resolve(true);
  2758. }
  2759. else {
  2760. // switched to a 3rd branch
  2761. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2762. if (suspense.deps <= 0) {
  2763. suspense.resolve();
  2764. }
  2765. }
  2766. }
  2767. }
  2768. else {
  2769. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2770. // root did not change, just normal patch
  2771. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2772. setActiveBranch(suspense, newBranch);
  2773. }
  2774. else {
  2775. // root node toggled
  2776. // invoke @pending event
  2777. triggerEvent(n2, 'onPending');
  2778. // mount pending branch in off-dom container
  2779. suspense.pendingBranch = newBranch;
  2780. suspense.pendingId++;
  2781. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2782. if (suspense.deps <= 0) {
  2783. // incoming branch has no async deps, resolve now.
  2784. suspense.resolve();
  2785. }
  2786. else {
  2787. const { timeout, pendingId } = suspense;
  2788. if (timeout > 0) {
  2789. setTimeout(() => {
  2790. if (suspense.pendingId === pendingId) {
  2791. suspense.fallback(newFallback);
  2792. }
  2793. }, timeout);
  2794. }
  2795. else if (timeout === 0) {
  2796. suspense.fallback(newFallback);
  2797. }
  2798. }
  2799. }
  2800. }
  2801. }
  2802. let hasWarned = false;
  2803. function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
  2804. /* istanbul ignore if */
  2805. if (!hasWarned) {
  2806. hasWarned = true;
  2807. // @ts-ignore `console.info` cannot be null error
  2808. console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
  2809. }
  2810. const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
  2811. const timeout = toNumber(vnode.props && vnode.props.timeout);
  2812. const suspense = {
  2813. vnode,
  2814. parent,
  2815. parentComponent,
  2816. isSVG,
  2817. container,
  2818. hiddenContainer,
  2819. anchor,
  2820. deps: 0,
  2821. pendingId: 0,
  2822. timeout: typeof timeout === 'number' ? timeout : -1,
  2823. activeBranch: null,
  2824. pendingBranch: null,
  2825. isInFallback: true,
  2826. isHydrating,
  2827. isUnmounted: false,
  2828. effects: [],
  2829. resolve(resume = false) {
  2830. {
  2831. if (!resume && !suspense.pendingBranch) {
  2832. throw new Error(`suspense.resolve() is called without a pending branch.`);
  2833. }
  2834. if (suspense.isUnmounted) {
  2835. throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
  2836. }
  2837. }
  2838. const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
  2839. if (suspense.isHydrating) {
  2840. suspense.isHydrating = false;
  2841. }
  2842. else if (!resume) {
  2843. const delayEnter = activeBranch &&
  2844. pendingBranch.transition &&
  2845. pendingBranch.transition.mode === 'out-in';
  2846. if (delayEnter) {
  2847. activeBranch.transition.afterLeave = () => {
  2848. if (pendingId === suspense.pendingId) {
  2849. move(pendingBranch, container, anchor, 0 /* MoveType.ENTER */);
  2850. }
  2851. };
  2852. }
  2853. // this is initial anchor on mount
  2854. let { anchor } = suspense;
  2855. // unmount current active tree
  2856. if (activeBranch) {
  2857. // if the fallback tree was mounted, it may have been moved
  2858. // as part of a parent suspense. get the latest anchor for insertion
  2859. anchor = next(activeBranch);
  2860. unmount(activeBranch, parentComponent, suspense, true);
  2861. }
  2862. if (!delayEnter) {
  2863. // move content from off-dom container to actual container
  2864. move(pendingBranch, container, anchor, 0 /* MoveType.ENTER */);
  2865. }
  2866. }
  2867. setActiveBranch(suspense, pendingBranch);
  2868. suspense.pendingBranch = null;
  2869. suspense.isInFallback = false;
  2870. // flush buffered effects
  2871. // check if there is a pending parent suspense
  2872. let parent = suspense.parent;
  2873. let hasUnresolvedAncestor = false;
  2874. while (parent) {
  2875. if (parent.pendingBranch) {
  2876. // found a pending parent suspense, merge buffered post jobs
  2877. // into that parent
  2878. parent.effects.push(...effects);
  2879. hasUnresolvedAncestor = true;
  2880. break;
  2881. }
  2882. parent = parent.parent;
  2883. }
  2884. // no pending parent suspense, flush all jobs
  2885. if (!hasUnresolvedAncestor) {
  2886. queuePostFlushCb(effects);
  2887. }
  2888. suspense.effects = [];
  2889. // invoke @resolve event
  2890. triggerEvent(vnode, 'onResolve');
  2891. },
  2892. fallback(fallbackVNode) {
  2893. if (!suspense.pendingBranch) {
  2894. return;
  2895. }
  2896. const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
  2897. // invoke @fallback event
  2898. triggerEvent(vnode, 'onFallback');
  2899. const anchor = next(activeBranch);
  2900. const mountFallback = () => {
  2901. if (!suspense.isInFallback) {
  2902. return;
  2903. }
  2904. // mount the fallback tree
  2905. patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2906. isSVG, slotScopeIds, optimized);
  2907. setActiveBranch(suspense, fallbackVNode);
  2908. };
  2909. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
  2910. if (delayEnter) {
  2911. activeBranch.transition.afterLeave = mountFallback;
  2912. }
  2913. suspense.isInFallback = true;
  2914. // unmount current active branch
  2915. unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
  2916. true // shouldRemove
  2917. );
  2918. if (!delayEnter) {
  2919. mountFallback();
  2920. }
  2921. },
  2922. move(container, anchor, type) {
  2923. suspense.activeBranch &&
  2924. move(suspense.activeBranch, container, anchor, type);
  2925. suspense.container = container;
  2926. },
  2927. next() {
  2928. return suspense.activeBranch && next(suspense.activeBranch);
  2929. },
  2930. registerDep(instance, setupRenderEffect) {
  2931. const isInPendingSuspense = !!suspense.pendingBranch;
  2932. if (isInPendingSuspense) {
  2933. suspense.deps++;
  2934. }
  2935. const hydratedEl = instance.vnode.el;
  2936. instance
  2937. .asyncDep.catch(err => {
  2938. handleError(err, instance, 0 /* ErrorCodes.SETUP_FUNCTION */);
  2939. })
  2940. .then(asyncSetupResult => {
  2941. // retry when the setup() promise resolves.
  2942. // component may have been unmounted before resolve.
  2943. if (instance.isUnmounted ||
  2944. suspense.isUnmounted ||
  2945. suspense.pendingId !== instance.suspenseId) {
  2946. return;
  2947. }
  2948. // retry from this component
  2949. instance.asyncResolved = true;
  2950. const { vnode } = instance;
  2951. {
  2952. pushWarningContext(vnode);
  2953. }
  2954. handleSetupResult(instance, asyncSetupResult, false);
  2955. if (hydratedEl) {
  2956. // vnode may have been replaced if an update happened before the
  2957. // async dep is resolved.
  2958. vnode.el = hydratedEl;
  2959. }
  2960. const placeholder = !hydratedEl && instance.subTree.el;
  2961. setupRenderEffect(instance, vnode,
  2962. // component may have been moved before resolve.
  2963. // if this is not a hydration, instance.subTree will be the comment
  2964. // placeholder.
  2965. parentNode(hydratedEl || instance.subTree.el),
  2966. // anchor will not be used if this is hydration, so only need to
  2967. // consider the comment placeholder case.
  2968. hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
  2969. if (placeholder) {
  2970. remove(placeholder);
  2971. }
  2972. updateHOCHostEl(instance, vnode.el);
  2973. {
  2974. popWarningContext();
  2975. }
  2976. // only decrease deps count if suspense is not already resolved
  2977. if (isInPendingSuspense && --suspense.deps === 0) {
  2978. suspense.resolve();
  2979. }
  2980. });
  2981. },
  2982. unmount(parentSuspense, doRemove) {
  2983. suspense.isUnmounted = true;
  2984. if (suspense.activeBranch) {
  2985. unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
  2986. }
  2987. if (suspense.pendingBranch) {
  2988. unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
  2989. }
  2990. }
  2991. };
  2992. return suspense;
  2993. }
  2994. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  2995. /* eslint-disable no-restricted-globals */
  2996. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true /* hydrating */));
  2997. // there are two possible scenarios for server-rendered suspense:
  2998. // - success: ssr content should be fully resolved
  2999. // - failure: ssr content should be the fallback branch.
  3000. // however, on the client we don't really know if it has failed or not
  3001. // attempt to hydrate the DOM assuming it has succeeded, but we still
  3002. // need to construct a suspense boundary first
  3003. const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
  3004. if (suspense.deps === 0) {
  3005. suspense.resolve();
  3006. }
  3007. return result;
  3008. /* eslint-enable no-restricted-globals */
  3009. }
  3010. function normalizeSuspenseChildren(vnode) {
  3011. const { shapeFlag, children } = vnode;
  3012. const isSlotChildren = shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */;
  3013. vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
  3014. vnode.ssFallback = isSlotChildren
  3015. ? normalizeSuspenseSlot(children.fallback)
  3016. : createVNode(Comment);
  3017. }
  3018. function normalizeSuspenseSlot(s) {
  3019. let block;
  3020. if (isFunction(s)) {
  3021. const trackBlock = isBlockTreeEnabled && s._c;
  3022. if (trackBlock) {
  3023. // disableTracking: false
  3024. // allow block tracking for compiled slots
  3025. // (see ./componentRenderContext.ts)
  3026. s._d = false;
  3027. openBlock();
  3028. }
  3029. s = s();
  3030. if (trackBlock) {
  3031. s._d = true;
  3032. block = currentBlock;
  3033. closeBlock();
  3034. }
  3035. }
  3036. if (isArray(s)) {
  3037. const singleChild = filterSingleRoot(s);
  3038. if (!singleChild) {
  3039. warn$1(`<Suspense> slots expect a single root node.`);
  3040. }
  3041. s = singleChild;
  3042. }
  3043. s = normalizeVNode(s);
  3044. if (block && !s.dynamicChildren) {
  3045. s.dynamicChildren = block.filter(c => c !== s);
  3046. }
  3047. return s;
  3048. }
  3049. function queueEffectWithSuspense(fn, suspense) {
  3050. if (suspense && suspense.pendingBranch) {
  3051. if (isArray(fn)) {
  3052. suspense.effects.push(...fn);
  3053. }
  3054. else {
  3055. suspense.effects.push(fn);
  3056. }
  3057. }
  3058. else {
  3059. queuePostFlushCb(fn);
  3060. }
  3061. }
  3062. function setActiveBranch(suspense, branch) {
  3063. suspense.activeBranch = branch;
  3064. const { vnode, parentComponent } = suspense;
  3065. const el = (vnode.el = branch.el);
  3066. // in case suspense is the root node of a component,
  3067. // recursively update the HOC el
  3068. if (parentComponent && parentComponent.subTree === vnode) {
  3069. parentComponent.vnode.el = el;
  3070. updateHOCHostEl(parentComponent, el);
  3071. }
  3072. }
  3073. function provide(key, value) {
  3074. if (!currentInstance) {
  3075. {
  3076. warn$1(`provide() can only be used inside setup().`);
  3077. }
  3078. }
  3079. else {
  3080. let provides = currentInstance.provides;
  3081. // by default an instance inherits its parent's provides object
  3082. // but when it needs to provide values of its own, it creates its
  3083. // own provides object using parent provides object as prototype.
  3084. // this way in `inject` we can simply look up injections from direct
  3085. // parent and let the prototype chain do the work.
  3086. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  3087. if (parentProvides === provides) {
  3088. provides = currentInstance.provides = Object.create(parentProvides);
  3089. }
  3090. // TS doesn't allow symbol as index type
  3091. provides[key] = value;
  3092. }
  3093. }
  3094. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3095. // fallback to `currentRenderingInstance` so that this can be called in
  3096. // a functional component
  3097. const instance = currentInstance || currentRenderingInstance;
  3098. if (instance) {
  3099. // #2400
  3100. // to support `app.use` plugins,
  3101. // fallback to appContext's `provides` if the instance is at root
  3102. const provides = instance.parent == null
  3103. ? instance.vnode.appContext && instance.vnode.appContext.provides
  3104. : instance.parent.provides;
  3105. if (provides && key in provides) {
  3106. // TS doesn't allow symbol as index type
  3107. return provides[key];
  3108. }
  3109. else if (arguments.length > 1) {
  3110. return treatDefaultAsFactory && isFunction(defaultValue)
  3111. ? defaultValue.call(instance.proxy)
  3112. : defaultValue;
  3113. }
  3114. else {
  3115. warn$1(`injection "${String(key)}" not found.`);
  3116. }
  3117. }
  3118. else {
  3119. warn$1(`inject() can only be used inside setup() or functional components.`);
  3120. }
  3121. }
  3122. // Simple effect.
  3123. function watchEffect(effect, options) {
  3124. return doWatch(effect, null, options);
  3125. }
  3126. function watchPostEffect(effect, options) {
  3127. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3128. }
  3129. function watchSyncEffect(effect, options) {
  3130. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3131. }
  3132. // initial value for watchers to trigger on undefined initial values
  3133. const INITIAL_WATCHER_VALUE = {};
  3134. // implementation
  3135. function watch(source, cb, options) {
  3136. if (!isFunction(cb)) {
  3137. warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3138. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3139. `supports \`watch(source, cb, options?) signature.`);
  3140. }
  3141. return doWatch(source, cb, options);
  3142. }
  3143. function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
  3144. if (!cb) {
  3145. if (immediate !== undefined) {
  3146. warn$1(`watch() "immediate" option is only respected when using the ` +
  3147. `watch(source, callback, options?) signature.`);
  3148. }
  3149. if (deep !== undefined) {
  3150. warn$1(`watch() "deep" option is only respected when using the ` +
  3151. `watch(source, callback, options?) signature.`);
  3152. }
  3153. }
  3154. const warnInvalidSource = (s) => {
  3155. warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
  3156. `a reactive object, or an array of these types.`);
  3157. };
  3158. const instance = currentInstance;
  3159. let getter;
  3160. let forceTrigger = false;
  3161. let isMultiSource = false;
  3162. if (isRef(source)) {
  3163. getter = () => source.value;
  3164. forceTrigger = isShallow(source);
  3165. }
  3166. else if (isReactive(source)) {
  3167. getter = () => source;
  3168. deep = true;
  3169. }
  3170. else if (isArray(source)) {
  3171. isMultiSource = true;
  3172. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3173. getter = () => source.map(s => {
  3174. if (isRef(s)) {
  3175. return s.value;
  3176. }
  3177. else if (isReactive(s)) {
  3178. return traverse(s);
  3179. }
  3180. else if (isFunction(s)) {
  3181. return callWithErrorHandling(s, instance, 2 /* ErrorCodes.WATCH_GETTER */);
  3182. }
  3183. else {
  3184. warnInvalidSource(s);
  3185. }
  3186. });
  3187. }
  3188. else if (isFunction(source)) {
  3189. if (cb) {
  3190. // getter with cb
  3191. getter = () => callWithErrorHandling(source, instance, 2 /* ErrorCodes.WATCH_GETTER */);
  3192. }
  3193. else {
  3194. // no cb -> simple effect
  3195. getter = () => {
  3196. if (instance && instance.isUnmounted) {
  3197. return;
  3198. }
  3199. if (cleanup) {
  3200. cleanup();
  3201. }
  3202. return callWithAsyncErrorHandling(source, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [onCleanup]);
  3203. };
  3204. }
  3205. }
  3206. else {
  3207. getter = NOOP;
  3208. warnInvalidSource(source);
  3209. }
  3210. if (cb && deep) {
  3211. const baseGetter = getter;
  3212. getter = () => traverse(baseGetter());
  3213. }
  3214. let cleanup;
  3215. let onCleanup = (fn) => {
  3216. cleanup = effect.onStop = () => {
  3217. callWithErrorHandling(fn, instance, 4 /* ErrorCodes.WATCH_CLEANUP */);
  3218. };
  3219. };
  3220. let oldValue = isMultiSource
  3221. ? new Array(source.length).fill(INITIAL_WATCHER_VALUE)
  3222. : INITIAL_WATCHER_VALUE;
  3223. const job = () => {
  3224. if (!effect.active) {
  3225. return;
  3226. }
  3227. if (cb) {
  3228. // watch(source, cb)
  3229. const newValue = effect.run();
  3230. if (deep ||
  3231. forceTrigger ||
  3232. (isMultiSource
  3233. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3234. : hasChanged(newValue, oldValue)) ||
  3235. (false )) {
  3236. // cleanup before running cb again
  3237. if (cleanup) {
  3238. cleanup();
  3239. }
  3240. callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
  3241. newValue,
  3242. // pass undefined as the old value when it's changed for the first time
  3243. oldValue === INITIAL_WATCHER_VALUE
  3244. ? undefined
  3245. : (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
  3246. ? []
  3247. : oldValue,
  3248. onCleanup
  3249. ]);
  3250. oldValue = newValue;
  3251. }
  3252. }
  3253. else {
  3254. // watchEffect
  3255. effect.run();
  3256. }
  3257. };
  3258. // important: mark the job as a watcher callback so that scheduler knows
  3259. // it is allowed to self-trigger (#1727)
  3260. job.allowRecurse = !!cb;
  3261. let scheduler;
  3262. if (flush === 'sync') {
  3263. scheduler = job; // the scheduler function gets called directly
  3264. }
  3265. else if (flush === 'post') {
  3266. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  3267. }
  3268. else {
  3269. // default: 'pre'
  3270. job.pre = true;
  3271. if (instance)
  3272. job.id = instance.uid;
  3273. scheduler = () => queueJob(job);
  3274. }
  3275. const effect = new ReactiveEffect(getter, scheduler);
  3276. {
  3277. effect.onTrack = onTrack;
  3278. effect.onTrigger = onTrigger;
  3279. }
  3280. // initial run
  3281. if (cb) {
  3282. if (immediate) {
  3283. job();
  3284. }
  3285. else {
  3286. oldValue = effect.run();
  3287. }
  3288. }
  3289. else if (flush === 'post') {
  3290. queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
  3291. }
  3292. else {
  3293. effect.run();
  3294. }
  3295. const unwatch = () => {
  3296. effect.stop();
  3297. if (instance && instance.scope) {
  3298. remove(instance.scope.effects, effect);
  3299. }
  3300. };
  3301. return unwatch;
  3302. }
  3303. // this.$watch
  3304. function instanceWatch(source, value, options) {
  3305. const publicThis = this.proxy;
  3306. const getter = isString(source)
  3307. ? source.includes('.')
  3308. ? createPathGetter(publicThis, source)
  3309. : () => publicThis[source]
  3310. : source.bind(publicThis, publicThis);
  3311. let cb;
  3312. if (isFunction(value)) {
  3313. cb = value;
  3314. }
  3315. else {
  3316. cb = value.handler;
  3317. options = value;
  3318. }
  3319. const cur = currentInstance;
  3320. setCurrentInstance(this);
  3321. const res = doWatch(getter, cb.bind(publicThis), options);
  3322. if (cur) {
  3323. setCurrentInstance(cur);
  3324. }
  3325. else {
  3326. unsetCurrentInstance();
  3327. }
  3328. return res;
  3329. }
  3330. function createPathGetter(ctx, path) {
  3331. const segments = path.split('.');
  3332. return () => {
  3333. let cur = ctx;
  3334. for (let i = 0; i < segments.length && cur; i++) {
  3335. cur = cur[segments[i]];
  3336. }
  3337. return cur;
  3338. };
  3339. }
  3340. function traverse(value, seen) {
  3341. if (!isObject(value) || value["__v_skip" /* ReactiveFlags.SKIP */]) {
  3342. return value;
  3343. }
  3344. seen = seen || new Set();
  3345. if (seen.has(value)) {
  3346. return value;
  3347. }
  3348. seen.add(value);
  3349. if (isRef(value)) {
  3350. traverse(value.value, seen);
  3351. }
  3352. else if (isArray(value)) {
  3353. for (let i = 0; i < value.length; i++) {
  3354. traverse(value[i], seen);
  3355. }
  3356. }
  3357. else if (isSet(value) || isMap(value)) {
  3358. value.forEach((v) => {
  3359. traverse(v, seen);
  3360. });
  3361. }
  3362. else if (isPlainObject(value)) {
  3363. for (const key in value) {
  3364. traverse(value[key], seen);
  3365. }
  3366. }
  3367. return value;
  3368. }
  3369. function useTransitionState() {
  3370. const state = {
  3371. isMounted: false,
  3372. isLeaving: false,
  3373. isUnmounting: false,
  3374. leavingVNodes: new Map()
  3375. };
  3376. onMounted(() => {
  3377. state.isMounted = true;
  3378. });
  3379. onBeforeUnmount(() => {
  3380. state.isUnmounting = true;
  3381. });
  3382. return state;
  3383. }
  3384. const TransitionHookValidator = [Function, Array];
  3385. const BaseTransitionImpl = {
  3386. name: `BaseTransition`,
  3387. props: {
  3388. mode: String,
  3389. appear: Boolean,
  3390. persisted: Boolean,
  3391. // enter
  3392. onBeforeEnter: TransitionHookValidator,
  3393. onEnter: TransitionHookValidator,
  3394. onAfterEnter: TransitionHookValidator,
  3395. onEnterCancelled: TransitionHookValidator,
  3396. // leave
  3397. onBeforeLeave: TransitionHookValidator,
  3398. onLeave: TransitionHookValidator,
  3399. onAfterLeave: TransitionHookValidator,
  3400. onLeaveCancelled: TransitionHookValidator,
  3401. // appear
  3402. onBeforeAppear: TransitionHookValidator,
  3403. onAppear: TransitionHookValidator,
  3404. onAfterAppear: TransitionHookValidator,
  3405. onAppearCancelled: TransitionHookValidator
  3406. },
  3407. setup(props, { slots }) {
  3408. const instance = getCurrentInstance();
  3409. const state = useTransitionState();
  3410. let prevTransitionKey;
  3411. return () => {
  3412. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  3413. if (!children || !children.length) {
  3414. return;
  3415. }
  3416. let child = children[0];
  3417. if (children.length > 1) {
  3418. let hasFound = false;
  3419. // locate first non-comment child
  3420. for (const c of children) {
  3421. if (c.type !== Comment) {
  3422. if (hasFound) {
  3423. // warn more than one non-comment child
  3424. warn$1('<transition> can only be used on a single element or component. ' +
  3425. 'Use <transition-group> for lists.');
  3426. break;
  3427. }
  3428. child = c;
  3429. hasFound = true;
  3430. }
  3431. }
  3432. }
  3433. // there's no need to track reactivity for these props so use the raw
  3434. // props for a bit better perf
  3435. const rawProps = toRaw(props);
  3436. const { mode } = rawProps;
  3437. // check mode
  3438. if (mode &&
  3439. mode !== 'in-out' &&
  3440. mode !== 'out-in' &&
  3441. mode !== 'default') {
  3442. warn$1(`invalid <transition> mode: ${mode}`);
  3443. }
  3444. if (state.isLeaving) {
  3445. return emptyPlaceholder(child);
  3446. }
  3447. // in the case of <transition><keep-alive/></transition>, we need to
  3448. // compare the type of the kept-alive children.
  3449. const innerChild = getKeepAliveChild(child);
  3450. if (!innerChild) {
  3451. return emptyPlaceholder(child);
  3452. }
  3453. const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
  3454. setTransitionHooks(innerChild, enterHooks);
  3455. const oldChild = instance.subTree;
  3456. const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  3457. let transitionKeyChanged = false;
  3458. const { getTransitionKey } = innerChild.type;
  3459. if (getTransitionKey) {
  3460. const key = getTransitionKey();
  3461. if (prevTransitionKey === undefined) {
  3462. prevTransitionKey = key;
  3463. }
  3464. else if (key !== prevTransitionKey) {
  3465. prevTransitionKey = key;
  3466. transitionKeyChanged = true;
  3467. }
  3468. }
  3469. // handle mode
  3470. if (oldInnerChild &&
  3471. oldInnerChild.type !== Comment &&
  3472. (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  3473. const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
  3474. // update old tree's hooks in case of dynamic transition
  3475. setTransitionHooks(oldInnerChild, leavingHooks);
  3476. // switching between different views
  3477. if (mode === 'out-in') {
  3478. state.isLeaving = true;
  3479. // return placeholder node and queue update when leave finishes
  3480. leavingHooks.afterLeave = () => {
  3481. state.isLeaving = false;
  3482. // #6835
  3483. // it also needs to be updated when active is undefined
  3484. if (instance.update.active !== false) {
  3485. instance.update();
  3486. }
  3487. };
  3488. return emptyPlaceholder(child);
  3489. }
  3490. else if (mode === 'in-out' && innerChild.type !== Comment) {
  3491. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  3492. const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
  3493. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  3494. // early removal callback
  3495. el._leaveCb = () => {
  3496. earlyRemove();
  3497. el._leaveCb = undefined;
  3498. delete enterHooks.delayedLeave;
  3499. };
  3500. enterHooks.delayedLeave = delayedLeave;
  3501. };
  3502. }
  3503. }
  3504. return child;
  3505. };
  3506. }
  3507. };
  3508. // export the public type for h/tsx inference
  3509. // also to avoid inline import() in generated d.ts files
  3510. const BaseTransition = BaseTransitionImpl;
  3511. function getLeavingNodesForType(state, vnode) {
  3512. const { leavingVNodes } = state;
  3513. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  3514. if (!leavingVNodesCache) {
  3515. leavingVNodesCache = Object.create(null);
  3516. leavingVNodes.set(vnode.type, leavingVNodesCache);
  3517. }
  3518. return leavingVNodesCache;
  3519. }
  3520. // The transition hooks are attached to the vnode as vnode.transition
  3521. // and will be called at appropriate timing in the renderer.
  3522. function resolveTransitionHooks(vnode, props, state, instance) {
  3523. const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
  3524. const key = String(vnode.key);
  3525. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  3526. const callHook = (hook, args) => {
  3527. hook &&
  3528. callWithAsyncErrorHandling(hook, instance, 9 /* ErrorCodes.TRANSITION_HOOK */, args);
  3529. };
  3530. const callAsyncHook = (hook, args) => {
  3531. const done = args[1];
  3532. callHook(hook, args);
  3533. if (isArray(hook)) {
  3534. if (hook.every(hook => hook.length <= 1))
  3535. done();
  3536. }
  3537. else if (hook.length <= 1) {
  3538. done();
  3539. }
  3540. };
  3541. const hooks = {
  3542. mode,
  3543. persisted,
  3544. beforeEnter(el) {
  3545. let hook = onBeforeEnter;
  3546. if (!state.isMounted) {
  3547. if (appear) {
  3548. hook = onBeforeAppear || onBeforeEnter;
  3549. }
  3550. else {
  3551. return;
  3552. }
  3553. }
  3554. // for same element (v-show)
  3555. if (el._leaveCb) {
  3556. el._leaveCb(true /* cancelled */);
  3557. }
  3558. // for toggled element with same key (v-if)
  3559. const leavingVNode = leavingVNodesCache[key];
  3560. if (leavingVNode &&
  3561. isSameVNodeType(vnode, leavingVNode) &&
  3562. leavingVNode.el._leaveCb) {
  3563. // force early removal (not cancelled)
  3564. leavingVNode.el._leaveCb();
  3565. }
  3566. callHook(hook, [el]);
  3567. },
  3568. enter(el) {
  3569. let hook = onEnter;
  3570. let afterHook = onAfterEnter;
  3571. let cancelHook = onEnterCancelled;
  3572. if (!state.isMounted) {
  3573. if (appear) {
  3574. hook = onAppear || onEnter;
  3575. afterHook = onAfterAppear || onAfterEnter;
  3576. cancelHook = onAppearCancelled || onEnterCancelled;
  3577. }
  3578. else {
  3579. return;
  3580. }
  3581. }
  3582. let called = false;
  3583. const done = (el._enterCb = (cancelled) => {
  3584. if (called)
  3585. return;
  3586. called = true;
  3587. if (cancelled) {
  3588. callHook(cancelHook, [el]);
  3589. }
  3590. else {
  3591. callHook(afterHook, [el]);
  3592. }
  3593. if (hooks.delayedLeave) {
  3594. hooks.delayedLeave();
  3595. }
  3596. el._enterCb = undefined;
  3597. });
  3598. if (hook) {
  3599. callAsyncHook(hook, [el, done]);
  3600. }
  3601. else {
  3602. done();
  3603. }
  3604. },
  3605. leave(el, remove) {
  3606. const key = String(vnode.key);
  3607. if (el._enterCb) {
  3608. el._enterCb(true /* cancelled */);
  3609. }
  3610. if (state.isUnmounting) {
  3611. return remove();
  3612. }
  3613. callHook(onBeforeLeave, [el]);
  3614. let called = false;
  3615. const done = (el._leaveCb = (cancelled) => {
  3616. if (called)
  3617. return;
  3618. called = true;
  3619. remove();
  3620. if (cancelled) {
  3621. callHook(onLeaveCancelled, [el]);
  3622. }
  3623. else {
  3624. callHook(onAfterLeave, [el]);
  3625. }
  3626. el._leaveCb = undefined;
  3627. if (leavingVNodesCache[key] === vnode) {
  3628. delete leavingVNodesCache[key];
  3629. }
  3630. });
  3631. leavingVNodesCache[key] = vnode;
  3632. if (onLeave) {
  3633. callAsyncHook(onLeave, [el, done]);
  3634. }
  3635. else {
  3636. done();
  3637. }
  3638. },
  3639. clone(vnode) {
  3640. return resolveTransitionHooks(vnode, props, state, instance);
  3641. }
  3642. };
  3643. return hooks;
  3644. }
  3645. // the placeholder really only handles one special case: KeepAlive
  3646. // in the case of a KeepAlive in a leave phase we need to return a KeepAlive
  3647. // placeholder with empty content to avoid the KeepAlive instance from being
  3648. // unmounted.
  3649. function emptyPlaceholder(vnode) {
  3650. if (isKeepAlive(vnode)) {
  3651. vnode = cloneVNode(vnode);
  3652. vnode.children = null;
  3653. return vnode;
  3654. }
  3655. }
  3656. function getKeepAliveChild(vnode) {
  3657. return isKeepAlive(vnode)
  3658. ? vnode.children
  3659. ? vnode.children[0]
  3660. : undefined
  3661. : vnode;
  3662. }
  3663. function setTransitionHooks(vnode, hooks) {
  3664. if (vnode.shapeFlag & 6 /* ShapeFlags.COMPONENT */ && vnode.component) {
  3665. setTransitionHooks(vnode.component.subTree, hooks);
  3666. }
  3667. else if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  3668. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  3669. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  3670. }
  3671. else {
  3672. vnode.transition = hooks;
  3673. }
  3674. }
  3675. function getTransitionRawChildren(children, keepComment = false, parentKey) {
  3676. let ret = [];
  3677. let keyedFragmentCount = 0;
  3678. for (let i = 0; i < children.length; i++) {
  3679. let child = children[i];
  3680. // #5360 inherit parent key in case of <template v-for>
  3681. const key = parentKey == null
  3682. ? child.key
  3683. : String(parentKey) + String(child.key != null ? child.key : i);
  3684. // handle fragment children case, e.g. v-for
  3685. if (child.type === Fragment) {
  3686. if (child.patchFlag & 128 /* PatchFlags.KEYED_FRAGMENT */)
  3687. keyedFragmentCount++;
  3688. ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
  3689. }
  3690. // comment placeholders should be skipped, e.g. v-if
  3691. else if (keepComment || child.type !== Comment) {
  3692. ret.push(key != null ? cloneVNode(child, { key }) : child);
  3693. }
  3694. }
  3695. // #1126 if a transition children list contains multiple sub fragments, these
  3696. // fragments will be merged into a flat children array. Since each v-for
  3697. // fragment may contain different static bindings inside, we need to de-op
  3698. // these children to force full diffs to ensure correct behavior.
  3699. if (keyedFragmentCount > 1) {
  3700. for (let i = 0; i < ret.length; i++) {
  3701. ret[i].patchFlag = -2 /* PatchFlags.BAIL */;
  3702. }
  3703. }
  3704. return ret;
  3705. }
  3706. // implementation, close to no-op
  3707. function defineComponent(options) {
  3708. return isFunction(options) ? { setup: options, name: options.name } : options;
  3709. }
  3710. const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
  3711. function defineAsyncComponent(source) {
  3712. if (isFunction(source)) {
  3713. source = { loader: source };
  3714. }
  3715. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3716. suspensible = true, onError: userOnError } = source;
  3717. let pendingRequest = null;
  3718. let resolvedComp;
  3719. let retries = 0;
  3720. const retry = () => {
  3721. retries++;
  3722. pendingRequest = null;
  3723. return load();
  3724. };
  3725. const load = () => {
  3726. let thisRequest;
  3727. return (pendingRequest ||
  3728. (thisRequest = pendingRequest =
  3729. loader()
  3730. .catch(err => {
  3731. err = err instanceof Error ? err : new Error(String(err));
  3732. if (userOnError) {
  3733. return new Promise((resolve, reject) => {
  3734. const userRetry = () => resolve(retry());
  3735. const userFail = () => reject(err);
  3736. userOnError(err, userRetry, userFail, retries + 1);
  3737. });
  3738. }
  3739. else {
  3740. throw err;
  3741. }
  3742. })
  3743. .then((comp) => {
  3744. if (thisRequest !== pendingRequest && pendingRequest) {
  3745. return pendingRequest;
  3746. }
  3747. if (!comp) {
  3748. warn$1(`Async component loader resolved to undefined. ` +
  3749. `If you are using retry(), make sure to return its return value.`);
  3750. }
  3751. // interop module default
  3752. if (comp &&
  3753. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3754. comp = comp.default;
  3755. }
  3756. if (comp && !isObject(comp) && !isFunction(comp)) {
  3757. throw new Error(`Invalid async component load result: ${comp}`);
  3758. }
  3759. resolvedComp = comp;
  3760. return comp;
  3761. })));
  3762. };
  3763. return defineComponent({
  3764. name: 'AsyncComponentWrapper',
  3765. __asyncLoader: load,
  3766. get __asyncResolved() {
  3767. return resolvedComp;
  3768. },
  3769. setup() {
  3770. const instance = currentInstance;
  3771. // already resolved
  3772. if (resolvedComp) {
  3773. return () => createInnerComp(resolvedComp, instance);
  3774. }
  3775. const onError = (err) => {
  3776. pendingRequest = null;
  3777. handleError(err, instance, 13 /* ErrorCodes.ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
  3778. };
  3779. // suspense-controlled or SSR.
  3780. if ((suspensible && instance.suspense) ||
  3781. (false )) {
  3782. return load()
  3783. .then(comp => {
  3784. return () => createInnerComp(comp, instance);
  3785. })
  3786. .catch(err => {
  3787. onError(err);
  3788. return () => errorComponent
  3789. ? createVNode(errorComponent, {
  3790. error: err
  3791. })
  3792. : null;
  3793. });
  3794. }
  3795. const loaded = ref(false);
  3796. const error = ref();
  3797. const delayed = ref(!!delay);
  3798. if (delay) {
  3799. setTimeout(() => {
  3800. delayed.value = false;
  3801. }, delay);
  3802. }
  3803. if (timeout != null) {
  3804. setTimeout(() => {
  3805. if (!loaded.value && !error.value) {
  3806. const err = new Error(`Async component timed out after ${timeout}ms.`);
  3807. onError(err);
  3808. error.value = err;
  3809. }
  3810. }, timeout);
  3811. }
  3812. load()
  3813. .then(() => {
  3814. loaded.value = true;
  3815. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  3816. // parent is keep-alive, force update so the loaded component's
  3817. // name is taken into account
  3818. queueJob(instance.parent.update);
  3819. }
  3820. })
  3821. .catch(err => {
  3822. onError(err);
  3823. error.value = err;
  3824. });
  3825. return () => {
  3826. if (loaded.value && resolvedComp) {
  3827. return createInnerComp(resolvedComp, instance);
  3828. }
  3829. else if (error.value && errorComponent) {
  3830. return createVNode(errorComponent, {
  3831. error: error.value
  3832. });
  3833. }
  3834. else if (loadingComponent && !delayed.value) {
  3835. return createVNode(loadingComponent);
  3836. }
  3837. };
  3838. }
  3839. });
  3840. }
  3841. function createInnerComp(comp, parent) {
  3842. const { ref, props, children, ce } = parent.vnode;
  3843. const vnode = createVNode(comp, props, children);
  3844. // ensure inner component inherits the async wrapper's ref owner
  3845. vnode.ref = ref;
  3846. // pass the custom element callback on to the inner comp
  3847. // and remove it from the async wrapper
  3848. vnode.ce = ce;
  3849. delete parent.vnode.ce;
  3850. return vnode;
  3851. }
  3852. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  3853. const KeepAliveImpl = {
  3854. name: `KeepAlive`,
  3855. // Marker for special handling inside the renderer. We are not using a ===
  3856. // check directly on KeepAlive in the renderer, because importing it directly
  3857. // would prevent it from being tree-shaken.
  3858. __isKeepAlive: true,
  3859. props: {
  3860. include: [String, RegExp, Array],
  3861. exclude: [String, RegExp, Array],
  3862. max: [String, Number]
  3863. },
  3864. setup(props, { slots }) {
  3865. const instance = getCurrentInstance();
  3866. // KeepAlive communicates with the instantiated renderer via the
  3867. // ctx where the renderer passes in its internals,
  3868. // and the KeepAlive instance exposes activate/deactivate implementations.
  3869. // The whole point of this is to avoid importing KeepAlive directly in the
  3870. // renderer to facilitate tree-shaking.
  3871. const sharedContext = instance.ctx;
  3872. const cache = new Map();
  3873. const keys = new Set();
  3874. let current = null;
  3875. {
  3876. instance.__v_cache = cache;
  3877. }
  3878. const parentSuspense = instance.suspense;
  3879. const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
  3880. const storageContainer = createElement('div');
  3881. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  3882. const instance = vnode.component;
  3883. move(vnode, container, anchor, 0 /* MoveType.ENTER */, parentSuspense);
  3884. // in case props have changed
  3885. patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
  3886. queuePostRenderEffect(() => {
  3887. instance.isDeactivated = false;
  3888. if (instance.a) {
  3889. invokeArrayFns(instance.a);
  3890. }
  3891. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  3892. if (vnodeHook) {
  3893. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3894. }
  3895. }, parentSuspense);
  3896. {
  3897. // Update components tree
  3898. devtoolsComponentAdded(instance);
  3899. }
  3900. };
  3901. sharedContext.deactivate = (vnode) => {
  3902. const instance = vnode.component;
  3903. move(vnode, storageContainer, null, 1 /* MoveType.LEAVE */, parentSuspense);
  3904. queuePostRenderEffect(() => {
  3905. if (instance.da) {
  3906. invokeArrayFns(instance.da);
  3907. }
  3908. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  3909. if (vnodeHook) {
  3910. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3911. }
  3912. instance.isDeactivated = true;
  3913. }, parentSuspense);
  3914. {
  3915. // Update components tree
  3916. devtoolsComponentAdded(instance);
  3917. }
  3918. };
  3919. function unmount(vnode) {
  3920. // reset the shapeFlag so it can be properly unmounted
  3921. resetShapeFlag(vnode);
  3922. _unmount(vnode, instance, parentSuspense, true);
  3923. }
  3924. function pruneCache(filter) {
  3925. cache.forEach((vnode, key) => {
  3926. const name = getComponentName(vnode.type);
  3927. if (name && (!filter || !filter(name))) {
  3928. pruneCacheEntry(key);
  3929. }
  3930. });
  3931. }
  3932. function pruneCacheEntry(key) {
  3933. const cached = cache.get(key);
  3934. if (!current || cached.type !== current.type) {
  3935. unmount(cached);
  3936. }
  3937. else if (current) {
  3938. // current active instance should no longer be kept-alive.
  3939. // we can't unmount it now but it might be later, so reset its flag now.
  3940. resetShapeFlag(current);
  3941. }
  3942. cache.delete(key);
  3943. keys.delete(key);
  3944. }
  3945. // prune cache on include/exclude prop change
  3946. watch(() => [props.include, props.exclude], ([include, exclude]) => {
  3947. include && pruneCache(name => matches(include, name));
  3948. exclude && pruneCache(name => !matches(exclude, name));
  3949. },
  3950. // prune post-render after `current` has been updated
  3951. { flush: 'post', deep: true });
  3952. // cache sub tree after render
  3953. let pendingCacheKey = null;
  3954. const cacheSubtree = () => {
  3955. // fix #1621, the pendingCacheKey could be 0
  3956. if (pendingCacheKey != null) {
  3957. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  3958. }
  3959. };
  3960. onMounted(cacheSubtree);
  3961. onUpdated(cacheSubtree);
  3962. onBeforeUnmount(() => {
  3963. cache.forEach(cached => {
  3964. const { subTree, suspense } = instance;
  3965. const vnode = getInnerChild(subTree);
  3966. if (cached.type === vnode.type) {
  3967. // current instance will be unmounted as part of keep-alive's unmount
  3968. resetShapeFlag(vnode);
  3969. // but invoke its deactivated hook here
  3970. const da = vnode.component.da;
  3971. da && queuePostRenderEffect(da, suspense);
  3972. return;
  3973. }
  3974. unmount(cached);
  3975. });
  3976. });
  3977. return () => {
  3978. pendingCacheKey = null;
  3979. if (!slots.default) {
  3980. return null;
  3981. }
  3982. const children = slots.default();
  3983. const rawVNode = children[0];
  3984. if (children.length > 1) {
  3985. {
  3986. warn$1(`KeepAlive should contain exactly one component child.`);
  3987. }
  3988. current = null;
  3989. return children;
  3990. }
  3991. else if (!isVNode(rawVNode) ||
  3992. (!(rawVNode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */) &&
  3993. !(rawVNode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */))) {
  3994. current = null;
  3995. return rawVNode;
  3996. }
  3997. let vnode = getInnerChild(rawVNode);
  3998. const comp = vnode.type;
  3999. // for async components, name check should be based in its loaded
  4000. // inner component if available
  4001. const name = getComponentName(isAsyncWrapper(vnode)
  4002. ? vnode.type.__asyncResolved || {}
  4003. : comp);
  4004. const { include, exclude, max } = props;
  4005. if ((include && (!name || !matches(include, name))) ||
  4006. (exclude && name && matches(exclude, name))) {
  4007. current = vnode;
  4008. return rawVNode;
  4009. }
  4010. const key = vnode.key == null ? comp : vnode.key;
  4011. const cachedVNode = cache.get(key);
  4012. // clone vnode if it's reused because we are going to mutate it
  4013. if (vnode.el) {
  4014. vnode = cloneVNode(vnode);
  4015. if (rawVNode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  4016. rawVNode.ssContent = vnode;
  4017. }
  4018. }
  4019. // #1513 it's possible for the returned vnode to be cloned due to attr
  4020. // fallthrough or scopeId, so the vnode here may not be the final vnode
  4021. // that is mounted. Instead of caching it directly, we store the pending
  4022. // key and cache `instance.subTree` (the normalized vnode) in
  4023. // beforeMount/beforeUpdate hooks.
  4024. pendingCacheKey = key;
  4025. if (cachedVNode) {
  4026. // copy over mounted state
  4027. vnode.el = cachedVNode.el;
  4028. vnode.component = cachedVNode.component;
  4029. if (vnode.transition) {
  4030. // recursively update transition hooks on subTree
  4031. setTransitionHooks(vnode, vnode.transition);
  4032. }
  4033. // avoid vnode being mounted as fresh
  4034. vnode.shapeFlag |= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
  4035. // make this key the freshest
  4036. keys.delete(key);
  4037. keys.add(key);
  4038. }
  4039. else {
  4040. keys.add(key);
  4041. // prune oldest entry
  4042. if (max && keys.size > parseInt(max, 10)) {
  4043. pruneCacheEntry(keys.values().next().value);
  4044. }
  4045. }
  4046. // avoid vnode being unmounted
  4047. vnode.shapeFlag |= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
  4048. current = vnode;
  4049. return isSuspense(rawVNode.type) ? rawVNode : vnode;
  4050. };
  4051. }
  4052. };
  4053. // export the public type for h/tsx inference
  4054. // also to avoid inline import() in generated d.ts files
  4055. const KeepAlive = KeepAliveImpl;
  4056. function matches(pattern, name) {
  4057. if (isArray(pattern)) {
  4058. return pattern.some((p) => matches(p, name));
  4059. }
  4060. else if (isString(pattern)) {
  4061. return pattern.split(',').includes(name);
  4062. }
  4063. else if (pattern.test) {
  4064. return pattern.test(name);
  4065. }
  4066. /* istanbul ignore next */
  4067. return false;
  4068. }
  4069. function onActivated(hook, target) {
  4070. registerKeepAliveHook(hook, "a" /* LifecycleHooks.ACTIVATED */, target);
  4071. }
  4072. function onDeactivated(hook, target) {
  4073. registerKeepAliveHook(hook, "da" /* LifecycleHooks.DEACTIVATED */, target);
  4074. }
  4075. function registerKeepAliveHook(hook, type, target = currentInstance) {
  4076. // cache the deactivate branch check wrapper for injected hooks so the same
  4077. // hook can be properly deduped by the scheduler. "__wdc" stands for "with
  4078. // deactivation check".
  4079. const wrappedHook = hook.__wdc ||
  4080. (hook.__wdc = () => {
  4081. // only fire the hook if the target instance is NOT in a deactivated branch.
  4082. let current = target;
  4083. while (current) {
  4084. if (current.isDeactivated) {
  4085. return;
  4086. }
  4087. current = current.parent;
  4088. }
  4089. return hook();
  4090. });
  4091. injectHook(type, wrappedHook, target);
  4092. // In addition to registering it on the target instance, we walk up the parent
  4093. // chain and register it on all ancestor instances that are keep-alive roots.
  4094. // This avoids the need to walk the entire component tree when invoking these
  4095. // hooks, and more importantly, avoids the need to track child components in
  4096. // arrays.
  4097. if (target) {
  4098. let current = target.parent;
  4099. while (current && current.parent) {
  4100. if (isKeepAlive(current.parent.vnode)) {
  4101. injectToKeepAliveRoot(wrappedHook, type, target, current);
  4102. }
  4103. current = current.parent;
  4104. }
  4105. }
  4106. }
  4107. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  4108. // injectHook wraps the original for error handling, so make sure to remove
  4109. // the wrapped version.
  4110. const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
  4111. onUnmounted(() => {
  4112. remove(keepAliveRoot[type], injected);
  4113. }, target);
  4114. }
  4115. function resetShapeFlag(vnode) {
  4116. // bitwise operations to remove keep alive flags
  4117. vnode.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
  4118. vnode.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
  4119. }
  4120. function getInnerChild(vnode) {
  4121. return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
  4122. }
  4123. function injectHook(type, hook, target = currentInstance, prepend = false) {
  4124. if (target) {
  4125. const hooks = target[type] || (target[type] = []);
  4126. // cache the error handling wrapper for injected hooks so the same hook
  4127. // can be properly deduped by the scheduler. "__weh" stands for "with error
  4128. // handling".
  4129. const wrappedHook = hook.__weh ||
  4130. (hook.__weh = (...args) => {
  4131. if (target.isUnmounted) {
  4132. return;
  4133. }
  4134. // disable tracking inside all lifecycle hooks
  4135. // since they can potentially be called inside effects.
  4136. pauseTracking();
  4137. // Set currentInstance during hook invocation.
  4138. // This assumes the hook does not synchronously trigger other hooks, which
  4139. // can only be false when the user does something really funky.
  4140. setCurrentInstance(target);
  4141. const res = callWithAsyncErrorHandling(hook, target, type, args);
  4142. unsetCurrentInstance();
  4143. resetTracking();
  4144. return res;
  4145. });
  4146. if (prepend) {
  4147. hooks.unshift(wrappedHook);
  4148. }
  4149. else {
  4150. hooks.push(wrappedHook);
  4151. }
  4152. return wrappedHook;
  4153. }
  4154. else {
  4155. const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
  4156. warn$1(`${apiName} is called when there is no active component instance to be ` +
  4157. `associated with. ` +
  4158. `Lifecycle injection APIs can only be used during execution of setup().` +
  4159. (` If you are using async setup(), make sure to register lifecycle ` +
  4160. `hooks before the first await statement.`
  4161. ));
  4162. }
  4163. }
  4164. const createHook = (lifecycle) => (hook, target = currentInstance) =>
  4165. // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
  4166. (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
  4167. injectHook(lifecycle, (...args) => hook(...args), target);
  4168. const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
  4169. const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
  4170. const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
  4171. const onUpdated = createHook("u" /* LifecycleHooks.UPDATED */);
  4172. const onBeforeUnmount = createHook("bum" /* LifecycleHooks.BEFORE_UNMOUNT */);
  4173. const onUnmounted = createHook("um" /* LifecycleHooks.UNMOUNTED */);
  4174. const onServerPrefetch = createHook("sp" /* LifecycleHooks.SERVER_PREFETCH */);
  4175. const onRenderTriggered = createHook("rtg" /* LifecycleHooks.RENDER_TRIGGERED */);
  4176. const onRenderTracked = createHook("rtc" /* LifecycleHooks.RENDER_TRACKED */);
  4177. function onErrorCaptured(hook, target = currentInstance) {
  4178. injectHook("ec" /* LifecycleHooks.ERROR_CAPTURED */, hook, target);
  4179. }
  4180. /**
  4181. Runtime helper for applying directives to a vnode. Example usage:
  4182. const comp = resolveComponent('comp')
  4183. const foo = resolveDirective('foo')
  4184. const bar = resolveDirective('bar')
  4185. return withDirectives(h(comp), [
  4186. [foo, this.x],
  4187. [bar, this.y]
  4188. ])
  4189. */
  4190. function validateDirectiveName(name) {
  4191. if (isBuiltInDirective(name)) {
  4192. warn$1('Do not use built-in directive ids as custom directive id: ' + name);
  4193. }
  4194. }
  4195. /**
  4196. * Adds directives to a VNode.
  4197. */
  4198. function withDirectives(vnode, directives) {
  4199. const internalInstance = currentRenderingInstance;
  4200. if (internalInstance === null) {
  4201. warn$1(`withDirectives can only be used inside render functions.`);
  4202. return vnode;
  4203. }
  4204. const instance = getExposeProxy(internalInstance) ||
  4205. internalInstance.proxy;
  4206. const bindings = vnode.dirs || (vnode.dirs = []);
  4207. for (let i = 0; i < directives.length; i++) {
  4208. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  4209. if (dir) {
  4210. if (isFunction(dir)) {
  4211. dir = {
  4212. mounted: dir,
  4213. updated: dir
  4214. };
  4215. }
  4216. if (dir.deep) {
  4217. traverse(value);
  4218. }
  4219. bindings.push({
  4220. dir,
  4221. instance,
  4222. value,
  4223. oldValue: void 0,
  4224. arg,
  4225. modifiers
  4226. });
  4227. }
  4228. }
  4229. return vnode;
  4230. }
  4231. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  4232. const bindings = vnode.dirs;
  4233. const oldBindings = prevVNode && prevVNode.dirs;
  4234. for (let i = 0; i < bindings.length; i++) {
  4235. const binding = bindings[i];
  4236. if (oldBindings) {
  4237. binding.oldValue = oldBindings[i].value;
  4238. }
  4239. let hook = binding.dir[name];
  4240. if (hook) {
  4241. // disable tracking inside all lifecycle hooks
  4242. // since they can potentially be called inside effects.
  4243. pauseTracking();
  4244. callWithAsyncErrorHandling(hook, instance, 8 /* ErrorCodes.DIRECTIVE_HOOK */, [
  4245. vnode.el,
  4246. binding,
  4247. vnode,
  4248. prevVNode
  4249. ]);
  4250. resetTracking();
  4251. }
  4252. }
  4253. }
  4254. const COMPONENTS = 'components';
  4255. const DIRECTIVES = 'directives';
  4256. /**
  4257. * @private
  4258. */
  4259. function resolveComponent(name, maybeSelfReference) {
  4260. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
  4261. }
  4262. const NULL_DYNAMIC_COMPONENT = Symbol();
  4263. /**
  4264. * @private
  4265. */
  4266. function resolveDynamicComponent(component) {
  4267. if (isString(component)) {
  4268. return resolveAsset(COMPONENTS, component, false) || component;
  4269. }
  4270. else {
  4271. // invalid types will fallthrough to createVNode and raise warning
  4272. return (component || NULL_DYNAMIC_COMPONENT);
  4273. }
  4274. }
  4275. /**
  4276. * @private
  4277. */
  4278. function resolveDirective(name) {
  4279. return resolveAsset(DIRECTIVES, name);
  4280. }
  4281. // implementation
  4282. function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
  4283. const instance = currentRenderingInstance || currentInstance;
  4284. if (instance) {
  4285. const Component = instance.type;
  4286. // explicit self name has highest priority
  4287. if (type === COMPONENTS) {
  4288. const selfName = getComponentName(Component, false /* do not include inferred name to avoid breaking existing code */);
  4289. if (selfName &&
  4290. (selfName === name ||
  4291. selfName === camelize(name) ||
  4292. selfName === capitalize(camelize(name)))) {
  4293. return Component;
  4294. }
  4295. }
  4296. const res =
  4297. // local registration
  4298. // check instance[type] first which is resolved for options API
  4299. resolve(instance[type] || Component[type], name) ||
  4300. // global registration
  4301. resolve(instance.appContext[type], name);
  4302. if (!res && maybeSelfReference) {
  4303. // fallback to implicit self-reference
  4304. return Component;
  4305. }
  4306. if (warnMissing && !res) {
  4307. const extra = type === COMPONENTS
  4308. ? `\nIf this is a native custom element, make sure to exclude it from ` +
  4309. `component resolution via compilerOptions.isCustomElement.`
  4310. : ``;
  4311. warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
  4312. }
  4313. return res;
  4314. }
  4315. else {
  4316. warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
  4317. `can only be used in render() or setup().`);
  4318. }
  4319. }
  4320. function resolve(registry, name) {
  4321. return (registry &&
  4322. (registry[name] ||
  4323. registry[camelize(name)] ||
  4324. registry[capitalize(camelize(name))]));
  4325. }
  4326. /**
  4327. * Actual implementation
  4328. */
  4329. function renderList(source, renderItem, cache, index) {
  4330. let ret;
  4331. const cached = (cache && cache[index]);
  4332. if (isArray(source) || isString(source)) {
  4333. ret = new Array(source.length);
  4334. for (let i = 0, l = source.length; i < l; i++) {
  4335. ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
  4336. }
  4337. }
  4338. else if (typeof source === 'number') {
  4339. if (!Number.isInteger(source)) {
  4340. warn$1(`The v-for range expect an integer value but got ${source}.`);
  4341. }
  4342. ret = new Array(source);
  4343. for (let i = 0; i < source; i++) {
  4344. ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
  4345. }
  4346. }
  4347. else if (isObject(source)) {
  4348. if (source[Symbol.iterator]) {
  4349. ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
  4350. }
  4351. else {
  4352. const keys = Object.keys(source);
  4353. ret = new Array(keys.length);
  4354. for (let i = 0, l = keys.length; i < l; i++) {
  4355. const key = keys[i];
  4356. ret[i] = renderItem(source[key], key, i, cached && cached[i]);
  4357. }
  4358. }
  4359. }
  4360. else {
  4361. ret = [];
  4362. }
  4363. if (cache) {
  4364. cache[index] = ret;
  4365. }
  4366. return ret;
  4367. }
  4368. /**
  4369. * Compiler runtime helper for creating dynamic slots object
  4370. * @private
  4371. */
  4372. function createSlots(slots, dynamicSlots) {
  4373. for (let i = 0; i < dynamicSlots.length; i++) {
  4374. const slot = dynamicSlots[i];
  4375. // array of dynamic slot generated by <template v-for="..." #[...]>
  4376. if (isArray(slot)) {
  4377. for (let j = 0; j < slot.length; j++) {
  4378. slots[slot[j].name] = slot[j].fn;
  4379. }
  4380. }
  4381. else if (slot) {
  4382. // conditional single slot generated by <template v-if="..." #foo>
  4383. slots[slot.name] = slot.key
  4384. ? (...args) => {
  4385. const res = slot.fn(...args);
  4386. // attach branch key so each conditional branch is considered a
  4387. // different fragment
  4388. if (res)
  4389. res.key = slot.key;
  4390. return res;
  4391. }
  4392. : slot.fn;
  4393. }
  4394. }
  4395. return slots;
  4396. }
  4397. /**
  4398. * Compiler runtime helper for rendering `<slot/>`
  4399. * @private
  4400. */
  4401. function renderSlot(slots, name, props = {},
  4402. // this is not a user-facing function, so the fallback is always generated by
  4403. // the compiler and guaranteed to be a function returning an array
  4404. fallback, noSlotted) {
  4405. if (currentRenderingInstance.isCE ||
  4406. (currentRenderingInstance.parent &&
  4407. isAsyncWrapper(currentRenderingInstance.parent) &&
  4408. currentRenderingInstance.parent.isCE)) {
  4409. if (name !== 'default')
  4410. props.name = name;
  4411. return createVNode('slot', props, fallback && fallback());
  4412. }
  4413. let slot = slots[name];
  4414. if (slot && slot.length > 1) {
  4415. warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
  4416. `function. You need to mark this component with $dynamic-slots in the ` +
  4417. `parent template.`);
  4418. slot = () => [];
  4419. }
  4420. // a compiled slot disables block tracking by default to avoid manual
  4421. // invocation interfering with template-based block tracking, but in
  4422. // `renderSlot` we can be sure that it's template-based so we can force
  4423. // enable it.
  4424. if (slot && slot._c) {
  4425. slot._d = false;
  4426. }
  4427. openBlock();
  4428. const validSlotContent = slot && ensureValidVNode(slot(props));
  4429. const rendered = createBlock(Fragment, {
  4430. key: props.key ||
  4431. // slot content array of a dynamic conditional slot may have a branch
  4432. // key attached in the `createSlots` helper, respect that
  4433. (validSlotContent && validSlotContent.key) ||
  4434. `_${name}`
  4435. }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* SlotFlags.STABLE */
  4436. ? 64 /* PatchFlags.STABLE_FRAGMENT */
  4437. : -2 /* PatchFlags.BAIL */);
  4438. if (!noSlotted && rendered.scopeId) {
  4439. rendered.slotScopeIds = [rendered.scopeId + '-s'];
  4440. }
  4441. if (slot && slot._c) {
  4442. slot._d = true;
  4443. }
  4444. return rendered;
  4445. }
  4446. function ensureValidVNode(vnodes) {
  4447. return vnodes.some(child => {
  4448. if (!isVNode(child))
  4449. return true;
  4450. if (child.type === Comment)
  4451. return false;
  4452. if (child.type === Fragment &&
  4453. !ensureValidVNode(child.children))
  4454. return false;
  4455. return true;
  4456. })
  4457. ? vnodes
  4458. : null;
  4459. }
  4460. /**
  4461. * For prefixing keys in v-on="obj" with "on"
  4462. * @private
  4463. */
  4464. function toHandlers(obj, preserveCaseIfNecessary) {
  4465. const ret = {};
  4466. if (!isObject(obj)) {
  4467. warn$1(`v-on with no argument expects an object value.`);
  4468. return ret;
  4469. }
  4470. for (const key in obj) {
  4471. ret[preserveCaseIfNecessary && /[A-Z]/.test(key)
  4472. ? `on:${key}`
  4473. : toHandlerKey(key)] = obj[key];
  4474. }
  4475. return ret;
  4476. }
  4477. /**
  4478. * #2437 In Vue 3, functional components do not have a public instance proxy but
  4479. * they exist in the internal parent chain. For code that relies on traversing
  4480. * public $parent chains, skip functional ones and go to the parent instead.
  4481. */
  4482. const getPublicInstance = (i) => {
  4483. if (!i)
  4484. return null;
  4485. if (isStatefulComponent(i))
  4486. return getExposeProxy(i) || i.proxy;
  4487. return getPublicInstance(i.parent);
  4488. };
  4489. const publicPropertiesMap =
  4490. // Move PURE marker to new line to workaround compiler discarding it
  4491. // due to type annotation
  4492. /*#__PURE__*/ extend(Object.create(null), {
  4493. $: i => i,
  4494. $el: i => i.vnode.el,
  4495. $data: i => i.data,
  4496. $props: i => (shallowReadonly(i.props) ),
  4497. $attrs: i => (shallowReadonly(i.attrs) ),
  4498. $slots: i => (shallowReadonly(i.slots) ),
  4499. $refs: i => (shallowReadonly(i.refs) ),
  4500. $parent: i => getPublicInstance(i.parent),
  4501. $root: i => getPublicInstance(i.root),
  4502. $emit: i => i.emit,
  4503. $options: i => (resolveMergedOptions(i) ),
  4504. $forceUpdate: i => i.f || (i.f = () => queueJob(i.update)),
  4505. $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy)),
  4506. $watch: i => (instanceWatch.bind(i) )
  4507. });
  4508. const isReservedPrefix = (key) => key === '_' || key === '$';
  4509. const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
  4510. const PublicInstanceProxyHandlers = {
  4511. get({ _: instance }, key) {
  4512. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  4513. // for internal formatters to know that this is a Vue instance
  4514. if (key === '__isVue') {
  4515. return true;
  4516. }
  4517. // data / props / ctx
  4518. // This getter gets called for every property access on the render context
  4519. // during render and is a major hotspot. The most expensive part of this
  4520. // is the multiple hasOwn() calls. It's much faster to do a simple property
  4521. // access on a plain object, so we use an accessCache object (with null
  4522. // prototype) to memoize what access type a key corresponds to.
  4523. let normalizedProps;
  4524. if (key[0] !== '$') {
  4525. const n = accessCache[key];
  4526. if (n !== undefined) {
  4527. switch (n) {
  4528. case 1 /* AccessTypes.SETUP */:
  4529. return setupState[key];
  4530. case 2 /* AccessTypes.DATA */:
  4531. return data[key];
  4532. case 4 /* AccessTypes.CONTEXT */:
  4533. return ctx[key];
  4534. case 3 /* AccessTypes.PROPS */:
  4535. return props[key];
  4536. // default: just fallthrough
  4537. }
  4538. }
  4539. else if (hasSetupBinding(setupState, key)) {
  4540. accessCache[key] = 1 /* AccessTypes.SETUP */;
  4541. return setupState[key];
  4542. }
  4543. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4544. accessCache[key] = 2 /* AccessTypes.DATA */;
  4545. return data[key];
  4546. }
  4547. else if (
  4548. // only cache other properties when instance has declared (thus stable)
  4549. // props
  4550. (normalizedProps = instance.propsOptions[0]) &&
  4551. hasOwn(normalizedProps, key)) {
  4552. accessCache[key] = 3 /* AccessTypes.PROPS */;
  4553. return props[key];
  4554. }
  4555. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4556. accessCache[key] = 4 /* AccessTypes.CONTEXT */;
  4557. return ctx[key];
  4558. }
  4559. else if (shouldCacheAccess) {
  4560. accessCache[key] = 0 /* AccessTypes.OTHER */;
  4561. }
  4562. }
  4563. const publicGetter = publicPropertiesMap[key];
  4564. let cssModule, globalProperties;
  4565. // public $xxx properties
  4566. if (publicGetter) {
  4567. if (key === '$attrs') {
  4568. track(instance, "get" /* TrackOpTypes.GET */, key);
  4569. markAttrsAccessed();
  4570. }
  4571. return publicGetter(instance);
  4572. }
  4573. else if (
  4574. // css module (injected by vue-loader)
  4575. (cssModule = type.__cssModules) &&
  4576. (cssModule = cssModule[key])) {
  4577. return cssModule;
  4578. }
  4579. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4580. // user may set custom properties to `this` that start with `$`
  4581. accessCache[key] = 4 /* AccessTypes.CONTEXT */;
  4582. return ctx[key];
  4583. }
  4584. else if (
  4585. // global properties
  4586. ((globalProperties = appContext.config.globalProperties),
  4587. hasOwn(globalProperties, key))) {
  4588. {
  4589. return globalProperties[key];
  4590. }
  4591. }
  4592. else if (currentRenderingInstance &&
  4593. (!isString(key) ||
  4594. // #1091 avoid internal isRef/isVNode checks on component instance leading
  4595. // to infinite warning loop
  4596. key.indexOf('__v') !== 0)) {
  4597. if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
  4598. warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
  4599. `character ("$" or "_") and is not proxied on the render context.`);
  4600. }
  4601. else if (instance === currentRenderingInstance) {
  4602. warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
  4603. `but is not defined on instance.`);
  4604. }
  4605. }
  4606. },
  4607. set({ _: instance }, key, value) {
  4608. const { data, setupState, ctx } = instance;
  4609. if (hasSetupBinding(setupState, key)) {
  4610. setupState[key] = value;
  4611. return true;
  4612. }
  4613. else if (setupState.__isScriptSetup &&
  4614. hasOwn(setupState, key)) {
  4615. warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
  4616. return false;
  4617. }
  4618. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4619. data[key] = value;
  4620. return true;
  4621. }
  4622. else if (hasOwn(instance.props, key)) {
  4623. warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
  4624. return false;
  4625. }
  4626. if (key[0] === '$' && key.slice(1) in instance) {
  4627. warn$1(`Attempting to mutate public property "${key}". ` +
  4628. `Properties starting with $ are reserved and readonly.`);
  4629. return false;
  4630. }
  4631. else {
  4632. if (key in instance.appContext.config.globalProperties) {
  4633. Object.defineProperty(ctx, key, {
  4634. enumerable: true,
  4635. configurable: true,
  4636. value
  4637. });
  4638. }
  4639. else {
  4640. ctx[key] = value;
  4641. }
  4642. }
  4643. return true;
  4644. },
  4645. has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
  4646. let normalizedProps;
  4647. return (!!accessCache[key] ||
  4648. (data !== EMPTY_OBJ && hasOwn(data, key)) ||
  4649. hasSetupBinding(setupState, key) ||
  4650. ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
  4651. hasOwn(ctx, key) ||
  4652. hasOwn(publicPropertiesMap, key) ||
  4653. hasOwn(appContext.config.globalProperties, key));
  4654. },
  4655. defineProperty(target, key, descriptor) {
  4656. if (descriptor.get != null) {
  4657. // invalidate key cache of a getter based property #5417
  4658. target._.accessCache[key] = 0;
  4659. }
  4660. else if (hasOwn(descriptor, 'value')) {
  4661. this.set(target, key, descriptor.value, null);
  4662. }
  4663. return Reflect.defineProperty(target, key, descriptor);
  4664. }
  4665. };
  4666. {
  4667. PublicInstanceProxyHandlers.ownKeys = (target) => {
  4668. warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
  4669. `The keys will be empty in production mode to avoid performance overhead.`);
  4670. return Reflect.ownKeys(target);
  4671. };
  4672. }
  4673. const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
  4674. get(target, key) {
  4675. // fast path for unscopables when using `with` block
  4676. if (key === Symbol.unscopables) {
  4677. return;
  4678. }
  4679. return PublicInstanceProxyHandlers.get(target, key, target);
  4680. },
  4681. has(_, key) {
  4682. const has = key[0] !== '_' && !isGloballyWhitelisted(key);
  4683. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  4684. warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
  4685. }
  4686. return has;
  4687. }
  4688. });
  4689. // dev only
  4690. // In dev mode, the proxy target exposes the same properties as seen on `this`
  4691. // for easier console inspection. In prod mode it will be an empty object so
  4692. // these properties definitions can be skipped.
  4693. function createDevRenderContext(instance) {
  4694. const target = {};
  4695. // expose internal instance for proxy handlers
  4696. Object.defineProperty(target, `_`, {
  4697. configurable: true,
  4698. enumerable: false,
  4699. get: () => instance
  4700. });
  4701. // expose public properties
  4702. Object.keys(publicPropertiesMap).forEach(key => {
  4703. Object.defineProperty(target, key, {
  4704. configurable: true,
  4705. enumerable: false,
  4706. get: () => publicPropertiesMap[key](instance),
  4707. // intercepted by the proxy so no need for implementation,
  4708. // but needed to prevent set errors
  4709. set: NOOP
  4710. });
  4711. });
  4712. return target;
  4713. }
  4714. // dev only
  4715. function exposePropsOnRenderContext(instance) {
  4716. const { ctx, propsOptions: [propsOptions] } = instance;
  4717. if (propsOptions) {
  4718. Object.keys(propsOptions).forEach(key => {
  4719. Object.defineProperty(ctx, key, {
  4720. enumerable: true,
  4721. configurable: true,
  4722. get: () => instance.props[key],
  4723. set: NOOP
  4724. });
  4725. });
  4726. }
  4727. }
  4728. // dev only
  4729. function exposeSetupStateOnRenderContext(instance) {
  4730. const { ctx, setupState } = instance;
  4731. Object.keys(toRaw(setupState)).forEach(key => {
  4732. if (!setupState.__isScriptSetup) {
  4733. if (isReservedPrefix(key[0])) {
  4734. warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
  4735. `which are reserved prefixes for Vue internals.`);
  4736. return;
  4737. }
  4738. Object.defineProperty(ctx, key, {
  4739. enumerable: true,
  4740. configurable: true,
  4741. get: () => setupState[key],
  4742. set: NOOP
  4743. });
  4744. }
  4745. });
  4746. }
  4747. function createDuplicateChecker() {
  4748. const cache = Object.create(null);
  4749. return (type, key) => {
  4750. if (cache[key]) {
  4751. warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
  4752. }
  4753. else {
  4754. cache[key] = type;
  4755. }
  4756. };
  4757. }
  4758. let shouldCacheAccess = true;
  4759. function applyOptions(instance) {
  4760. const options = resolveMergedOptions(instance);
  4761. const publicThis = instance.proxy;
  4762. const ctx = instance.ctx;
  4763. // do not cache property access on public proxy during state initialization
  4764. shouldCacheAccess = false;
  4765. // call beforeCreate first before accessing other options since
  4766. // the hook may mutate resolved options (#2791)
  4767. if (options.beforeCreate) {
  4768. callHook(options.beforeCreate, instance, "bc" /* LifecycleHooks.BEFORE_CREATE */);
  4769. }
  4770. const {
  4771. // state
  4772. data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
  4773. // lifecycle
  4774. created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
  4775. // public API
  4776. expose, inheritAttrs,
  4777. // assets
  4778. components, directives, filters } = options;
  4779. const checkDuplicateProperties = createDuplicateChecker() ;
  4780. {
  4781. const [propsOptions] = instance.propsOptions;
  4782. if (propsOptions) {
  4783. for (const key in propsOptions) {
  4784. checkDuplicateProperties("Props" /* OptionTypes.PROPS */, key);
  4785. }
  4786. }
  4787. }
  4788. // options initialization order (to be consistent with Vue 2):
  4789. // - props (already done outside of this function)
  4790. // - inject
  4791. // - methods
  4792. // - data (deferred since it relies on `this` access)
  4793. // - computed
  4794. // - watch (deferred since it relies on `this` access)
  4795. if (injectOptions) {
  4796. resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
  4797. }
  4798. if (methods) {
  4799. for (const key in methods) {
  4800. const methodHandler = methods[key];
  4801. if (isFunction(methodHandler)) {
  4802. // In dev mode, we use the `createRenderContext` function to define
  4803. // methods to the proxy target, and those are read-only but
  4804. // reconfigurable, so it needs to be redefined here
  4805. {
  4806. Object.defineProperty(ctx, key, {
  4807. value: methodHandler.bind(publicThis),
  4808. configurable: true,
  4809. enumerable: true,
  4810. writable: true
  4811. });
  4812. }
  4813. {
  4814. checkDuplicateProperties("Methods" /* OptionTypes.METHODS */, key);
  4815. }
  4816. }
  4817. else {
  4818. warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
  4819. `Did you reference the function correctly?`);
  4820. }
  4821. }
  4822. }
  4823. if (dataOptions) {
  4824. if (!isFunction(dataOptions)) {
  4825. warn$1(`The data option must be a function. ` +
  4826. `Plain object usage is no longer supported.`);
  4827. }
  4828. const data = dataOptions.call(publicThis, publicThis);
  4829. if (isPromise(data)) {
  4830. warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
  4831. `intend to perform data fetching before component renders, use ` +
  4832. `async setup() + <Suspense>.`);
  4833. }
  4834. if (!isObject(data)) {
  4835. warn$1(`data() should return an object.`);
  4836. }
  4837. else {
  4838. instance.data = reactive(data);
  4839. {
  4840. for (const key in data) {
  4841. checkDuplicateProperties("Data" /* OptionTypes.DATA */, key);
  4842. // expose data on ctx during dev
  4843. if (!isReservedPrefix(key[0])) {
  4844. Object.defineProperty(ctx, key, {
  4845. configurable: true,
  4846. enumerable: true,
  4847. get: () => data[key],
  4848. set: NOOP
  4849. });
  4850. }
  4851. }
  4852. }
  4853. }
  4854. }
  4855. // state initialization complete at this point - start caching access
  4856. shouldCacheAccess = true;
  4857. if (computedOptions) {
  4858. for (const key in computedOptions) {
  4859. const opt = computedOptions[key];
  4860. const get = isFunction(opt)
  4861. ? opt.bind(publicThis, publicThis)
  4862. : isFunction(opt.get)
  4863. ? opt.get.bind(publicThis, publicThis)
  4864. : NOOP;
  4865. if (get === NOOP) {
  4866. warn$1(`Computed property "${key}" has no getter.`);
  4867. }
  4868. const set = !isFunction(opt) && isFunction(opt.set)
  4869. ? opt.set.bind(publicThis)
  4870. : () => {
  4871. warn$1(`Write operation failed: computed property "${key}" is readonly.`);
  4872. }
  4873. ;
  4874. const c = computed$1({
  4875. get,
  4876. set
  4877. });
  4878. Object.defineProperty(ctx, key, {
  4879. enumerable: true,
  4880. configurable: true,
  4881. get: () => c.value,
  4882. set: v => (c.value = v)
  4883. });
  4884. {
  4885. checkDuplicateProperties("Computed" /* OptionTypes.COMPUTED */, key);
  4886. }
  4887. }
  4888. }
  4889. if (watchOptions) {
  4890. for (const key in watchOptions) {
  4891. createWatcher(watchOptions[key], ctx, publicThis, key);
  4892. }
  4893. }
  4894. if (provideOptions) {
  4895. const provides = isFunction(provideOptions)
  4896. ? provideOptions.call(publicThis)
  4897. : provideOptions;
  4898. Reflect.ownKeys(provides).forEach(key => {
  4899. provide(key, provides[key]);
  4900. });
  4901. }
  4902. if (created) {
  4903. callHook(created, instance, "c" /* LifecycleHooks.CREATED */);
  4904. }
  4905. function registerLifecycleHook(register, hook) {
  4906. if (isArray(hook)) {
  4907. hook.forEach(_hook => register(_hook.bind(publicThis)));
  4908. }
  4909. else if (hook) {
  4910. register(hook.bind(publicThis));
  4911. }
  4912. }
  4913. registerLifecycleHook(onBeforeMount, beforeMount);
  4914. registerLifecycleHook(onMounted, mounted);
  4915. registerLifecycleHook(onBeforeUpdate, beforeUpdate);
  4916. registerLifecycleHook(onUpdated, updated);
  4917. registerLifecycleHook(onActivated, activated);
  4918. registerLifecycleHook(onDeactivated, deactivated);
  4919. registerLifecycleHook(onErrorCaptured, errorCaptured);
  4920. registerLifecycleHook(onRenderTracked, renderTracked);
  4921. registerLifecycleHook(onRenderTriggered, renderTriggered);
  4922. registerLifecycleHook(onBeforeUnmount, beforeUnmount);
  4923. registerLifecycleHook(onUnmounted, unmounted);
  4924. registerLifecycleHook(onServerPrefetch, serverPrefetch);
  4925. if (isArray(expose)) {
  4926. if (expose.length) {
  4927. const exposed = instance.exposed || (instance.exposed = {});
  4928. expose.forEach(key => {
  4929. Object.defineProperty(exposed, key, {
  4930. get: () => publicThis[key],
  4931. set: val => (publicThis[key] = val)
  4932. });
  4933. });
  4934. }
  4935. else if (!instance.exposed) {
  4936. instance.exposed = {};
  4937. }
  4938. }
  4939. // options that are handled when creating the instance but also need to be
  4940. // applied from mixins
  4941. if (render && instance.render === NOOP) {
  4942. instance.render = render;
  4943. }
  4944. if (inheritAttrs != null) {
  4945. instance.inheritAttrs = inheritAttrs;
  4946. }
  4947. // asset options.
  4948. if (components)
  4949. instance.components = components;
  4950. if (directives)
  4951. instance.directives = directives;
  4952. }
  4953. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
  4954. if (isArray(injectOptions)) {
  4955. injectOptions = normalizeInject(injectOptions);
  4956. }
  4957. for (const key in injectOptions) {
  4958. const opt = injectOptions[key];
  4959. let injected;
  4960. if (isObject(opt)) {
  4961. if ('default' in opt) {
  4962. injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
  4963. }
  4964. else {
  4965. injected = inject(opt.from || key);
  4966. }
  4967. }
  4968. else {
  4969. injected = inject(opt);
  4970. }
  4971. if (isRef(injected)) {
  4972. // TODO remove the check in 3.3
  4973. if (unwrapRef) {
  4974. Object.defineProperty(ctx, key, {
  4975. enumerable: true,
  4976. configurable: true,
  4977. get: () => injected.value,
  4978. set: v => (injected.value = v)
  4979. });
  4980. }
  4981. else {
  4982. {
  4983. warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
  4984. `and no longer needs \`.value\` in the next minor release. ` +
  4985. `To opt-in to the new behavior now, ` +
  4986. `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
  4987. `temporary and will not be needed in the future.)`);
  4988. }
  4989. ctx[key] = injected;
  4990. }
  4991. }
  4992. else {
  4993. ctx[key] = injected;
  4994. }
  4995. {
  4996. checkDuplicateProperties("Inject" /* OptionTypes.INJECT */, key);
  4997. }
  4998. }
  4999. }
  5000. function callHook(hook, instance, type) {
  5001. callWithAsyncErrorHandling(isArray(hook)
  5002. ? hook.map(h => h.bind(instance.proxy))
  5003. : hook.bind(instance.proxy), instance, type);
  5004. }
  5005. function createWatcher(raw, ctx, publicThis, key) {
  5006. const getter = key.includes('.')
  5007. ? createPathGetter(publicThis, key)
  5008. : () => publicThis[key];
  5009. if (isString(raw)) {
  5010. const handler = ctx[raw];
  5011. if (isFunction(handler)) {
  5012. watch(getter, handler);
  5013. }
  5014. else {
  5015. warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
  5016. }
  5017. }
  5018. else if (isFunction(raw)) {
  5019. watch(getter, raw.bind(publicThis));
  5020. }
  5021. else if (isObject(raw)) {
  5022. if (isArray(raw)) {
  5023. raw.forEach(r => createWatcher(r, ctx, publicThis, key));
  5024. }
  5025. else {
  5026. const handler = isFunction(raw.handler)
  5027. ? raw.handler.bind(publicThis)
  5028. : ctx[raw.handler];
  5029. if (isFunction(handler)) {
  5030. watch(getter, handler, raw);
  5031. }
  5032. else {
  5033. warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  5034. }
  5035. }
  5036. }
  5037. else {
  5038. warn$1(`Invalid watch option: "${key}"`, raw);
  5039. }
  5040. }
  5041. /**
  5042. * Resolve merged options and cache it on the component.
  5043. * This is done only once per-component since the merging does not involve
  5044. * instances.
  5045. */
  5046. function resolveMergedOptions(instance) {
  5047. const base = instance.type;
  5048. const { mixins, extends: extendsOptions } = base;
  5049. const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
  5050. const cached = cache.get(base);
  5051. let resolved;
  5052. if (cached) {
  5053. resolved = cached;
  5054. }
  5055. else if (!globalMixins.length && !mixins && !extendsOptions) {
  5056. {
  5057. resolved = base;
  5058. }
  5059. }
  5060. else {
  5061. resolved = {};
  5062. if (globalMixins.length) {
  5063. globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
  5064. }
  5065. mergeOptions(resolved, base, optionMergeStrategies);
  5066. }
  5067. if (isObject(base)) {
  5068. cache.set(base, resolved);
  5069. }
  5070. return resolved;
  5071. }
  5072. function mergeOptions(to, from, strats, asMixin = false) {
  5073. const { mixins, extends: extendsOptions } = from;
  5074. if (extendsOptions) {
  5075. mergeOptions(to, extendsOptions, strats, true);
  5076. }
  5077. if (mixins) {
  5078. mixins.forEach((m) => mergeOptions(to, m, strats, true));
  5079. }
  5080. for (const key in from) {
  5081. if (asMixin && key === 'expose') {
  5082. warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
  5083. `It should only be declared in the base component itself.`);
  5084. }
  5085. else {
  5086. const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
  5087. to[key] = strat ? strat(to[key], from[key]) : from[key];
  5088. }
  5089. }
  5090. return to;
  5091. }
  5092. const internalOptionMergeStrats = {
  5093. data: mergeDataFn,
  5094. props: mergeObjectOptions,
  5095. emits: mergeObjectOptions,
  5096. // objects
  5097. methods: mergeObjectOptions,
  5098. computed: mergeObjectOptions,
  5099. // lifecycle
  5100. beforeCreate: mergeAsArray,
  5101. created: mergeAsArray,
  5102. beforeMount: mergeAsArray,
  5103. mounted: mergeAsArray,
  5104. beforeUpdate: mergeAsArray,
  5105. updated: mergeAsArray,
  5106. beforeDestroy: mergeAsArray,
  5107. beforeUnmount: mergeAsArray,
  5108. destroyed: mergeAsArray,
  5109. unmounted: mergeAsArray,
  5110. activated: mergeAsArray,
  5111. deactivated: mergeAsArray,
  5112. errorCaptured: mergeAsArray,
  5113. serverPrefetch: mergeAsArray,
  5114. // assets
  5115. components: mergeObjectOptions,
  5116. directives: mergeObjectOptions,
  5117. // watch
  5118. watch: mergeWatchOptions,
  5119. // provide / inject
  5120. provide: mergeDataFn,
  5121. inject: mergeInject
  5122. };
  5123. function mergeDataFn(to, from) {
  5124. if (!from) {
  5125. return to;
  5126. }
  5127. if (!to) {
  5128. return from;
  5129. }
  5130. return function mergedDataFn() {
  5131. return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
  5132. };
  5133. }
  5134. function mergeInject(to, from) {
  5135. return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  5136. }
  5137. function normalizeInject(raw) {
  5138. if (isArray(raw)) {
  5139. const res = {};
  5140. for (let i = 0; i < raw.length; i++) {
  5141. res[raw[i]] = raw[i];
  5142. }
  5143. return res;
  5144. }
  5145. return raw;
  5146. }
  5147. function mergeAsArray(to, from) {
  5148. return to ? [...new Set([].concat(to, from))] : from;
  5149. }
  5150. function mergeObjectOptions(to, from) {
  5151. return to ? extend(extend(Object.create(null), to), from) : from;
  5152. }
  5153. function mergeWatchOptions(to, from) {
  5154. if (!to)
  5155. return from;
  5156. if (!from)
  5157. return to;
  5158. const merged = extend(Object.create(null), to);
  5159. for (const key in from) {
  5160. merged[key] = mergeAsArray(to[key], from[key]);
  5161. }
  5162. return merged;
  5163. }
  5164. function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
  5165. isSSR = false) {
  5166. const props = {};
  5167. const attrs = {};
  5168. def(attrs, InternalObjectKey, 1);
  5169. instance.propsDefaults = Object.create(null);
  5170. setFullProps(instance, rawProps, props, attrs);
  5171. // ensure all declared prop keys are present
  5172. for (const key in instance.propsOptions[0]) {
  5173. if (!(key in props)) {
  5174. props[key] = undefined;
  5175. }
  5176. }
  5177. // validation
  5178. {
  5179. validateProps(rawProps || {}, props, instance);
  5180. }
  5181. if (isStateful) {
  5182. // stateful
  5183. instance.props = isSSR ? props : shallowReactive(props);
  5184. }
  5185. else {
  5186. if (!instance.type.props) {
  5187. // functional w/ optional props, props === attrs
  5188. instance.props = attrs;
  5189. }
  5190. else {
  5191. // functional w/ declared props
  5192. instance.props = props;
  5193. }
  5194. }
  5195. instance.attrs = attrs;
  5196. }
  5197. function isInHmrContext(instance) {
  5198. while (instance) {
  5199. if (instance.type.__hmrId)
  5200. return true;
  5201. instance = instance.parent;
  5202. }
  5203. }
  5204. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  5205. const { props, attrs, vnode: { patchFlag } } = instance;
  5206. const rawCurrentProps = toRaw(props);
  5207. const [options] = instance.propsOptions;
  5208. let hasAttrsChanged = false;
  5209. if (
  5210. // always force full diff in dev
  5211. // - #1942 if hmr is enabled with sfc component
  5212. // - vite#872 non-sfc component used by sfc component
  5213. !(isInHmrContext(instance)) &&
  5214. (optimized || patchFlag > 0) &&
  5215. !(patchFlag & 16 /* PatchFlags.FULL_PROPS */)) {
  5216. if (patchFlag & 8 /* PatchFlags.PROPS */) {
  5217. // Compiler-generated props & no keys change, just set the updated
  5218. // the props.
  5219. const propsToUpdate = instance.vnode.dynamicProps;
  5220. for (let i = 0; i < propsToUpdate.length; i++) {
  5221. let key = propsToUpdate[i];
  5222. // skip if the prop key is a declared emit event listener
  5223. if (isEmitListener(instance.emitsOptions, key)) {
  5224. continue;
  5225. }
  5226. // PROPS flag guarantees rawProps to be non-null
  5227. const value = rawProps[key];
  5228. if (options) {
  5229. // attr / props separation was done on init and will be consistent
  5230. // in this code path, so just check if attrs have it.
  5231. if (hasOwn(attrs, key)) {
  5232. if (value !== attrs[key]) {
  5233. attrs[key] = value;
  5234. hasAttrsChanged = true;
  5235. }
  5236. }
  5237. else {
  5238. const camelizedKey = camelize(key);
  5239. props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
  5240. }
  5241. }
  5242. else {
  5243. if (value !== attrs[key]) {
  5244. attrs[key] = value;
  5245. hasAttrsChanged = true;
  5246. }
  5247. }
  5248. }
  5249. }
  5250. }
  5251. else {
  5252. // full props update.
  5253. if (setFullProps(instance, rawProps, props, attrs)) {
  5254. hasAttrsChanged = true;
  5255. }
  5256. // in case of dynamic props, check if we need to delete keys from
  5257. // the props object
  5258. let kebabKey;
  5259. for (const key in rawCurrentProps) {
  5260. if (!rawProps ||
  5261. // for camelCase
  5262. (!hasOwn(rawProps, key) &&
  5263. // it's possible the original props was passed in as kebab-case
  5264. // and converted to camelCase (#955)
  5265. ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
  5266. if (options) {
  5267. if (rawPrevProps &&
  5268. // for camelCase
  5269. (rawPrevProps[key] !== undefined ||
  5270. // for kebab-case
  5271. rawPrevProps[kebabKey] !== undefined)) {
  5272. props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
  5273. }
  5274. }
  5275. else {
  5276. delete props[key];
  5277. }
  5278. }
  5279. }
  5280. // in the case of functional component w/o props declaration, props and
  5281. // attrs point to the same object so it should already have been updated.
  5282. if (attrs !== rawCurrentProps) {
  5283. for (const key in attrs) {
  5284. if (!rawProps ||
  5285. (!hasOwn(rawProps, key) &&
  5286. (!false ))) {
  5287. delete attrs[key];
  5288. hasAttrsChanged = true;
  5289. }
  5290. }
  5291. }
  5292. }
  5293. // trigger updates for $attrs in case it's used in component slots
  5294. if (hasAttrsChanged) {
  5295. trigger(instance, "set" /* TriggerOpTypes.SET */, '$attrs');
  5296. }
  5297. {
  5298. validateProps(rawProps || {}, props, instance);
  5299. }
  5300. }
  5301. function setFullProps(instance, rawProps, props, attrs) {
  5302. const [options, needCastKeys] = instance.propsOptions;
  5303. let hasAttrsChanged = false;
  5304. let rawCastValues;
  5305. if (rawProps) {
  5306. for (let key in rawProps) {
  5307. // key, ref are reserved and never passed down
  5308. if (isReservedProp(key)) {
  5309. continue;
  5310. }
  5311. const value = rawProps[key];
  5312. // prop option names are camelized during normalization, so to support
  5313. // kebab -> camel conversion here we need to camelize the key.
  5314. let camelKey;
  5315. if (options && hasOwn(options, (camelKey = camelize(key)))) {
  5316. if (!needCastKeys || !needCastKeys.includes(camelKey)) {
  5317. props[camelKey] = value;
  5318. }
  5319. else {
  5320. (rawCastValues || (rawCastValues = {}))[camelKey] = value;
  5321. }
  5322. }
  5323. else if (!isEmitListener(instance.emitsOptions, key)) {
  5324. if (!(key in attrs) || value !== attrs[key]) {
  5325. attrs[key] = value;
  5326. hasAttrsChanged = true;
  5327. }
  5328. }
  5329. }
  5330. }
  5331. if (needCastKeys) {
  5332. const rawCurrentProps = toRaw(props);
  5333. const castValues = rawCastValues || EMPTY_OBJ;
  5334. for (let i = 0; i < needCastKeys.length; i++) {
  5335. const key = needCastKeys[i];
  5336. props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
  5337. }
  5338. }
  5339. return hasAttrsChanged;
  5340. }
  5341. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  5342. const opt = options[key];
  5343. if (opt != null) {
  5344. const hasDefault = hasOwn(opt, 'default');
  5345. // default values
  5346. if (hasDefault && value === undefined) {
  5347. const defaultValue = opt.default;
  5348. if (opt.type !== Function && isFunction(defaultValue)) {
  5349. const { propsDefaults } = instance;
  5350. if (key in propsDefaults) {
  5351. value = propsDefaults[key];
  5352. }
  5353. else {
  5354. setCurrentInstance(instance);
  5355. value = propsDefaults[key] = defaultValue.call(null, props);
  5356. unsetCurrentInstance();
  5357. }
  5358. }
  5359. else {
  5360. value = defaultValue;
  5361. }
  5362. }
  5363. // boolean casting
  5364. if (opt[0 /* BooleanFlags.shouldCast */]) {
  5365. if (isAbsent && !hasDefault) {
  5366. value = false;
  5367. }
  5368. else if (opt[1 /* BooleanFlags.shouldCastTrue */] &&
  5369. (value === '' || value === hyphenate(key))) {
  5370. value = true;
  5371. }
  5372. }
  5373. }
  5374. return value;
  5375. }
  5376. function normalizePropsOptions(comp, appContext, asMixin = false) {
  5377. const cache = appContext.propsCache;
  5378. const cached = cache.get(comp);
  5379. if (cached) {
  5380. return cached;
  5381. }
  5382. const raw = comp.props;
  5383. const normalized = {};
  5384. const needCastKeys = [];
  5385. // apply mixin/extends props
  5386. let hasExtends = false;
  5387. if (!isFunction(comp)) {
  5388. const extendProps = (raw) => {
  5389. hasExtends = true;
  5390. const [props, keys] = normalizePropsOptions(raw, appContext, true);
  5391. extend(normalized, props);
  5392. if (keys)
  5393. needCastKeys.push(...keys);
  5394. };
  5395. if (!asMixin && appContext.mixins.length) {
  5396. appContext.mixins.forEach(extendProps);
  5397. }
  5398. if (comp.extends) {
  5399. extendProps(comp.extends);
  5400. }
  5401. if (comp.mixins) {
  5402. comp.mixins.forEach(extendProps);
  5403. }
  5404. }
  5405. if (!raw && !hasExtends) {
  5406. if (isObject(comp)) {
  5407. cache.set(comp, EMPTY_ARR);
  5408. }
  5409. return EMPTY_ARR;
  5410. }
  5411. if (isArray(raw)) {
  5412. for (let i = 0; i < raw.length; i++) {
  5413. if (!isString(raw[i])) {
  5414. warn$1(`props must be strings when using array syntax.`, raw[i]);
  5415. }
  5416. const normalizedKey = camelize(raw[i]);
  5417. if (validatePropName(normalizedKey)) {
  5418. normalized[normalizedKey] = EMPTY_OBJ;
  5419. }
  5420. }
  5421. }
  5422. else if (raw) {
  5423. if (!isObject(raw)) {
  5424. warn$1(`invalid props options`, raw);
  5425. }
  5426. for (const key in raw) {
  5427. const normalizedKey = camelize(key);
  5428. if (validatePropName(normalizedKey)) {
  5429. const opt = raw[key];
  5430. const prop = (normalized[normalizedKey] =
  5431. isArray(opt) || isFunction(opt) ? { type: opt } : Object.assign({}, opt));
  5432. if (prop) {
  5433. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5434. const stringIndex = getTypeIndex(String, prop.type);
  5435. prop[0 /* BooleanFlags.shouldCast */] = booleanIndex > -1;
  5436. prop[1 /* BooleanFlags.shouldCastTrue */] =
  5437. stringIndex < 0 || booleanIndex < stringIndex;
  5438. // if the prop needs boolean casting or default value
  5439. if (booleanIndex > -1 || hasOwn(prop, 'default')) {
  5440. needCastKeys.push(normalizedKey);
  5441. }
  5442. }
  5443. }
  5444. }
  5445. }
  5446. const res = [normalized, needCastKeys];
  5447. if (isObject(comp)) {
  5448. cache.set(comp, res);
  5449. }
  5450. return res;
  5451. }
  5452. function validatePropName(key) {
  5453. if (key[0] !== '$') {
  5454. return true;
  5455. }
  5456. else {
  5457. warn$1(`Invalid prop name: "${key}" is a reserved property.`);
  5458. }
  5459. return false;
  5460. }
  5461. // use function string name to check type constructors
  5462. // so that it works across vms / iframes.
  5463. function getType(ctor) {
  5464. const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
  5465. return match ? match[1] : ctor === null ? 'null' : '';
  5466. }
  5467. function isSameType(a, b) {
  5468. return getType(a) === getType(b);
  5469. }
  5470. function getTypeIndex(type, expectedTypes) {
  5471. if (isArray(expectedTypes)) {
  5472. return expectedTypes.findIndex(t => isSameType(t, type));
  5473. }
  5474. else if (isFunction(expectedTypes)) {
  5475. return isSameType(expectedTypes, type) ? 0 : -1;
  5476. }
  5477. return -1;
  5478. }
  5479. /**
  5480. * dev only
  5481. */
  5482. function validateProps(rawProps, props, instance) {
  5483. const resolvedValues = toRaw(props);
  5484. const options = instance.propsOptions[0];
  5485. for (const key in options) {
  5486. let opt = options[key];
  5487. if (opt == null)
  5488. continue;
  5489. validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
  5490. }
  5491. }
  5492. /**
  5493. * dev only
  5494. */
  5495. function validateProp(name, value, prop, isAbsent) {
  5496. const { type, required, validator } = prop;
  5497. // required!
  5498. if (required && isAbsent) {
  5499. warn$1('Missing required prop: "' + name + '"');
  5500. return;
  5501. }
  5502. // missing but optional
  5503. if (value == null && !prop.required) {
  5504. return;
  5505. }
  5506. // type check
  5507. if (type != null && type !== true) {
  5508. let isValid = false;
  5509. const types = isArray(type) ? type : [type];
  5510. const expectedTypes = [];
  5511. // value is valid as long as one of the specified types match
  5512. for (let i = 0; i < types.length && !isValid; i++) {
  5513. const { valid, expectedType } = assertType(value, types[i]);
  5514. expectedTypes.push(expectedType || '');
  5515. isValid = valid;
  5516. }
  5517. if (!isValid) {
  5518. warn$1(getInvalidTypeMessage(name, value, expectedTypes));
  5519. return;
  5520. }
  5521. }
  5522. // custom validator
  5523. if (validator && !validator(value)) {
  5524. warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
  5525. }
  5526. }
  5527. const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
  5528. /**
  5529. * dev only
  5530. */
  5531. function assertType(value, type) {
  5532. let valid;
  5533. const expectedType = getType(type);
  5534. if (isSimpleType(expectedType)) {
  5535. const t = typeof value;
  5536. valid = t === expectedType.toLowerCase();
  5537. // for primitive wrapper objects
  5538. if (!valid && t === 'object') {
  5539. valid = value instanceof type;
  5540. }
  5541. }
  5542. else if (expectedType === 'Object') {
  5543. valid = isObject(value);
  5544. }
  5545. else if (expectedType === 'Array') {
  5546. valid = isArray(value);
  5547. }
  5548. else if (expectedType === 'null') {
  5549. valid = value === null;
  5550. }
  5551. else {
  5552. valid = value instanceof type;
  5553. }
  5554. return {
  5555. valid,
  5556. expectedType
  5557. };
  5558. }
  5559. /**
  5560. * dev only
  5561. */
  5562. function getInvalidTypeMessage(name, value, expectedTypes) {
  5563. let message = `Invalid prop: type check failed for prop "${name}".` +
  5564. ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
  5565. const expectedType = expectedTypes[0];
  5566. const receivedType = toRawType(value);
  5567. const expectedValue = styleValue(value, expectedType);
  5568. const receivedValue = styleValue(value, receivedType);
  5569. // check if we need to specify expected value
  5570. if (expectedTypes.length === 1 &&
  5571. isExplicable(expectedType) &&
  5572. !isBoolean(expectedType, receivedType)) {
  5573. message += ` with value ${expectedValue}`;
  5574. }
  5575. message += `, got ${receivedType} `;
  5576. // check if we need to specify received value
  5577. if (isExplicable(receivedType)) {
  5578. message += `with value ${receivedValue}.`;
  5579. }
  5580. return message;
  5581. }
  5582. /**
  5583. * dev only
  5584. */
  5585. function styleValue(value, type) {
  5586. if (type === 'String') {
  5587. return `"${value}"`;
  5588. }
  5589. else if (type === 'Number') {
  5590. return `${Number(value)}`;
  5591. }
  5592. else {
  5593. return `${value}`;
  5594. }
  5595. }
  5596. /**
  5597. * dev only
  5598. */
  5599. function isExplicable(type) {
  5600. const explicitTypes = ['string', 'number', 'boolean'];
  5601. return explicitTypes.some(elem => type.toLowerCase() === elem);
  5602. }
  5603. /**
  5604. * dev only
  5605. */
  5606. function isBoolean(...args) {
  5607. return args.some(elem => elem.toLowerCase() === 'boolean');
  5608. }
  5609. const isInternalKey = (key) => key[0] === '_' || key === '$stable';
  5610. const normalizeSlotValue = (value) => isArray(value)
  5611. ? value.map(normalizeVNode)
  5612. : [normalizeVNode(value)];
  5613. const normalizeSlot = (key, rawSlot, ctx) => {
  5614. if (rawSlot._n) {
  5615. // already normalized - #5353
  5616. return rawSlot;
  5617. }
  5618. const normalized = withCtx((...args) => {
  5619. if (true && currentInstance) {
  5620. warn$1(`Slot "${key}" invoked outside of the render function: ` +
  5621. `this will not track dependencies used in the slot. ` +
  5622. `Invoke the slot function inside the render function instead.`);
  5623. }
  5624. return normalizeSlotValue(rawSlot(...args));
  5625. }, ctx);
  5626. normalized._c = false;
  5627. return normalized;
  5628. };
  5629. const normalizeObjectSlots = (rawSlots, slots, instance) => {
  5630. const ctx = rawSlots._ctx;
  5631. for (const key in rawSlots) {
  5632. if (isInternalKey(key))
  5633. continue;
  5634. const value = rawSlots[key];
  5635. if (isFunction(value)) {
  5636. slots[key] = normalizeSlot(key, value, ctx);
  5637. }
  5638. else if (value != null) {
  5639. {
  5640. warn$1(`Non-function value encountered for slot "${key}". ` +
  5641. `Prefer function slots for better performance.`);
  5642. }
  5643. const normalized = normalizeSlotValue(value);
  5644. slots[key] = () => normalized;
  5645. }
  5646. }
  5647. };
  5648. const normalizeVNodeSlots = (instance, children) => {
  5649. if (!isKeepAlive(instance.vnode) &&
  5650. !(false )) {
  5651. warn$1(`Non-function value encountered for default slot. ` +
  5652. `Prefer function slots for better performance.`);
  5653. }
  5654. const normalized = normalizeSlotValue(children);
  5655. instance.slots.default = () => normalized;
  5656. };
  5657. const initSlots = (instance, children) => {
  5658. if (instance.vnode.shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */) {
  5659. const type = children._;
  5660. if (type) {
  5661. // users can get the shallow readonly version of the slots object through `this.$slots`,
  5662. // we should avoid the proxy object polluting the slots of the internal instance
  5663. instance.slots = toRaw(children);
  5664. // make compiler marker non-enumerable
  5665. def(children, '_', type);
  5666. }
  5667. else {
  5668. normalizeObjectSlots(children, (instance.slots = {}));
  5669. }
  5670. }
  5671. else {
  5672. instance.slots = {};
  5673. if (children) {
  5674. normalizeVNodeSlots(instance, children);
  5675. }
  5676. }
  5677. def(instance.slots, InternalObjectKey, 1);
  5678. };
  5679. const updateSlots = (instance, children, optimized) => {
  5680. const { vnode, slots } = instance;
  5681. let needDeletionCheck = true;
  5682. let deletionComparisonTarget = EMPTY_OBJ;
  5683. if (vnode.shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */) {
  5684. const type = children._;
  5685. if (type) {
  5686. // compiled slots.
  5687. if (isHmrUpdating) {
  5688. // Parent was HMR updated so slot content may have changed.
  5689. // force update slots and mark instance for hmr as well
  5690. extend(slots, children);
  5691. }
  5692. else if (optimized && type === 1 /* SlotFlags.STABLE */) {
  5693. // compiled AND stable.
  5694. // no need to update, and skip stale slots removal.
  5695. needDeletionCheck = false;
  5696. }
  5697. else {
  5698. // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
  5699. // normalization.
  5700. extend(slots, children);
  5701. // #2893
  5702. // when rendering the optimized slots by manually written render function,
  5703. // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
  5704. // i.e. let the `renderSlot` create the bailed Fragment
  5705. if (!optimized && type === 1 /* SlotFlags.STABLE */) {
  5706. delete slots._;
  5707. }
  5708. }
  5709. }
  5710. else {
  5711. needDeletionCheck = !children.$stable;
  5712. normalizeObjectSlots(children, slots);
  5713. }
  5714. deletionComparisonTarget = children;
  5715. }
  5716. else if (children) {
  5717. // non slot object children (direct value) passed to a component
  5718. normalizeVNodeSlots(instance, children);
  5719. deletionComparisonTarget = { default: 1 };
  5720. }
  5721. // delete stale slots
  5722. if (needDeletionCheck) {
  5723. for (const key in slots) {
  5724. if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
  5725. delete slots[key];
  5726. }
  5727. }
  5728. }
  5729. };
  5730. function createAppContext() {
  5731. return {
  5732. app: null,
  5733. config: {
  5734. isNativeTag: NO,
  5735. performance: false,
  5736. globalProperties: {},
  5737. optionMergeStrategies: {},
  5738. errorHandler: undefined,
  5739. warnHandler: undefined,
  5740. compilerOptions: {}
  5741. },
  5742. mixins: [],
  5743. components: {},
  5744. directives: {},
  5745. provides: Object.create(null),
  5746. optionsCache: new WeakMap(),
  5747. propsCache: new WeakMap(),
  5748. emitsCache: new WeakMap()
  5749. };
  5750. }
  5751. let uid = 0;
  5752. function createAppAPI(render, hydrate) {
  5753. return function createApp(rootComponent, rootProps = null) {
  5754. if (!isFunction(rootComponent)) {
  5755. rootComponent = Object.assign({}, rootComponent);
  5756. }
  5757. if (rootProps != null && !isObject(rootProps)) {
  5758. warn$1(`root props passed to app.mount() must be an object.`);
  5759. rootProps = null;
  5760. }
  5761. const context = createAppContext();
  5762. const installedPlugins = new Set();
  5763. let isMounted = false;
  5764. const app = (context.app = {
  5765. _uid: uid++,
  5766. _component: rootComponent,
  5767. _props: rootProps,
  5768. _container: null,
  5769. _context: context,
  5770. _instance: null,
  5771. version,
  5772. get config() {
  5773. return context.config;
  5774. },
  5775. set config(v) {
  5776. {
  5777. warn$1(`app.config cannot be replaced. Modify individual options instead.`);
  5778. }
  5779. },
  5780. use(plugin, ...options) {
  5781. if (installedPlugins.has(plugin)) {
  5782. warn$1(`Plugin has already been applied to target app.`);
  5783. }
  5784. else if (plugin && isFunction(plugin.install)) {
  5785. installedPlugins.add(plugin);
  5786. plugin.install(app, ...options);
  5787. }
  5788. else if (isFunction(plugin)) {
  5789. installedPlugins.add(plugin);
  5790. plugin(app, ...options);
  5791. }
  5792. else {
  5793. warn$1(`A plugin must either be a function or an object with an "install" ` +
  5794. `function.`);
  5795. }
  5796. return app;
  5797. },
  5798. mixin(mixin) {
  5799. {
  5800. if (!context.mixins.includes(mixin)) {
  5801. context.mixins.push(mixin);
  5802. }
  5803. else {
  5804. warn$1('Mixin has already been applied to target app' +
  5805. (mixin.name ? `: ${mixin.name}` : ''));
  5806. }
  5807. }
  5808. return app;
  5809. },
  5810. component(name, component) {
  5811. {
  5812. validateComponentName(name, context.config);
  5813. }
  5814. if (!component) {
  5815. return context.components[name];
  5816. }
  5817. if (context.components[name]) {
  5818. warn$1(`Component "${name}" has already been registered in target app.`);
  5819. }
  5820. context.components[name] = component;
  5821. return app;
  5822. },
  5823. directive(name, directive) {
  5824. {
  5825. validateDirectiveName(name);
  5826. }
  5827. if (!directive) {
  5828. return context.directives[name];
  5829. }
  5830. if (context.directives[name]) {
  5831. warn$1(`Directive "${name}" has already been registered in target app.`);
  5832. }
  5833. context.directives[name] = directive;
  5834. return app;
  5835. },
  5836. mount(rootContainer, isHydrate, isSVG) {
  5837. if (!isMounted) {
  5838. // #5571
  5839. if (rootContainer.__vue_app__) {
  5840. warn$1(`There is already an app instance mounted on the host container.\n` +
  5841. ` If you want to mount another app on the same host container,` +
  5842. ` you need to unmount the previous app by calling \`app.unmount()\` first.`);
  5843. }
  5844. const vnode = createVNode(rootComponent, rootProps);
  5845. // store app context on the root VNode.
  5846. // this will be set on the root instance on initial mount.
  5847. vnode.appContext = context;
  5848. // HMR root reload
  5849. {
  5850. context.reload = () => {
  5851. render(cloneVNode(vnode), rootContainer, isSVG);
  5852. };
  5853. }
  5854. if (isHydrate && hydrate) {
  5855. hydrate(vnode, rootContainer);
  5856. }
  5857. else {
  5858. render(vnode, rootContainer, isSVG);
  5859. }
  5860. isMounted = true;
  5861. app._container = rootContainer;
  5862. rootContainer.__vue_app__ = app;
  5863. {
  5864. app._instance = vnode.component;
  5865. devtoolsInitApp(app, version);
  5866. }
  5867. return getExposeProxy(vnode.component) || vnode.component.proxy;
  5868. }
  5869. else {
  5870. warn$1(`App has already been mounted.\n` +
  5871. `If you want to remount the same app, move your app creation logic ` +
  5872. `into a factory function and create fresh app instances for each ` +
  5873. `mount - e.g. \`const createMyApp = () => createApp(App)\``);
  5874. }
  5875. },
  5876. unmount() {
  5877. if (isMounted) {
  5878. render(null, app._container);
  5879. {
  5880. app._instance = null;
  5881. devtoolsUnmountApp(app);
  5882. }
  5883. delete app._container.__vue_app__;
  5884. }
  5885. else {
  5886. warn$1(`Cannot unmount an app that is not mounted.`);
  5887. }
  5888. },
  5889. provide(key, value) {
  5890. if (key in context.provides) {
  5891. warn$1(`App already provides property with key "${String(key)}". ` +
  5892. `It will be overwritten with the new value.`);
  5893. }
  5894. context.provides[key] = value;
  5895. return app;
  5896. }
  5897. });
  5898. return app;
  5899. };
  5900. }
  5901. /**
  5902. * Function for handling a template ref
  5903. */
  5904. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  5905. if (isArray(rawRef)) {
  5906. rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
  5907. return;
  5908. }
  5909. if (isAsyncWrapper(vnode) && !isUnmount) {
  5910. // when mounting async components, nothing needs to be done,
  5911. // because the template ref is forwarded to inner component
  5912. return;
  5913. }
  5914. const refValue = vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */
  5915. ? getExposeProxy(vnode.component) || vnode.component.proxy
  5916. : vnode.el;
  5917. const value = isUnmount ? null : refValue;
  5918. const { i: owner, r: ref } = rawRef;
  5919. if (!owner) {
  5920. warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
  5921. `A vnode with ref must be created inside the render function.`);
  5922. return;
  5923. }
  5924. const oldRef = oldRawRef && oldRawRef.r;
  5925. const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
  5926. const setupState = owner.setupState;
  5927. // dynamic ref changed. unset old ref
  5928. if (oldRef != null && oldRef !== ref) {
  5929. if (isString(oldRef)) {
  5930. refs[oldRef] = null;
  5931. if (hasOwn(setupState, oldRef)) {
  5932. setupState[oldRef] = null;
  5933. }
  5934. }
  5935. else if (isRef(oldRef)) {
  5936. oldRef.value = null;
  5937. }
  5938. }
  5939. if (isFunction(ref)) {
  5940. callWithErrorHandling(ref, owner, 12 /* ErrorCodes.FUNCTION_REF */, [value, refs]);
  5941. }
  5942. else {
  5943. const _isString = isString(ref);
  5944. const _isRef = isRef(ref);
  5945. if (_isString || _isRef) {
  5946. const doSet = () => {
  5947. if (rawRef.f) {
  5948. const existing = _isString
  5949. ? hasOwn(setupState, ref)
  5950. ? setupState[ref]
  5951. : refs[ref]
  5952. : ref.value;
  5953. if (isUnmount) {
  5954. isArray(existing) && remove(existing, refValue);
  5955. }
  5956. else {
  5957. if (!isArray(existing)) {
  5958. if (_isString) {
  5959. refs[ref] = [refValue];
  5960. if (hasOwn(setupState, ref)) {
  5961. setupState[ref] = refs[ref];
  5962. }
  5963. }
  5964. else {
  5965. ref.value = [refValue];
  5966. if (rawRef.k)
  5967. refs[rawRef.k] = ref.value;
  5968. }
  5969. }
  5970. else if (!existing.includes(refValue)) {
  5971. existing.push(refValue);
  5972. }
  5973. }
  5974. }
  5975. else if (_isString) {
  5976. refs[ref] = value;
  5977. if (hasOwn(setupState, ref)) {
  5978. setupState[ref] = value;
  5979. }
  5980. }
  5981. else if (_isRef) {
  5982. ref.value = value;
  5983. if (rawRef.k)
  5984. refs[rawRef.k] = value;
  5985. }
  5986. else {
  5987. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  5988. }
  5989. };
  5990. if (value) {
  5991. doSet.id = -1;
  5992. queuePostRenderEffect(doSet, parentSuspense);
  5993. }
  5994. else {
  5995. doSet();
  5996. }
  5997. }
  5998. else {
  5999. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  6000. }
  6001. }
  6002. }
  6003. let hasMismatch = false;
  6004. const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
  6005. const isComment = (node) => node.nodeType === 8 /* DOMNodeTypes.COMMENT */;
  6006. // Note: hydration is DOM-specific
  6007. // But we have to place it in core due to tight coupling with core - splitting
  6008. // it out creates a ton of unnecessary complexity.
  6009. // Hydration also depends on some renderer internal logic which needs to be
  6010. // passed in via arguments.
  6011. function createHydrationFunctions(rendererInternals) {
  6012. const { mt: mountComponent, p: patch, o: { patchProp, createText, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
  6013. const hydrate = (vnode, container) => {
  6014. if (!container.hasChildNodes()) {
  6015. warn$1(`Attempting to hydrate existing markup but container is empty. ` +
  6016. `Performing full mount instead.`);
  6017. patch(null, vnode, container);
  6018. flushPostFlushCbs();
  6019. container._vnode = vnode;
  6020. return;
  6021. }
  6022. hasMismatch = false;
  6023. hydrateNode(container.firstChild, vnode, null, null, null);
  6024. flushPostFlushCbs();
  6025. container._vnode = vnode;
  6026. if (hasMismatch && !false) {
  6027. // this error should show up in production
  6028. console.error(`Hydration completed but contains mismatches.`);
  6029. }
  6030. };
  6031. const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
  6032. const isFragmentStart = isComment(node) && node.data === '[';
  6033. const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
  6034. const { type, ref, shapeFlag, patchFlag } = vnode;
  6035. let domType = node.nodeType;
  6036. vnode.el = node;
  6037. if (patchFlag === -2 /* PatchFlags.BAIL */) {
  6038. optimized = false;
  6039. vnode.dynamicChildren = null;
  6040. }
  6041. let nextNode = null;
  6042. switch (type) {
  6043. case Text:
  6044. if (domType !== 3 /* DOMNodeTypes.TEXT */) {
  6045. // #5728 empty text node inside a slot can cause hydration failure
  6046. // because the server rendered HTML won't contain a text node
  6047. if (vnode.children === '') {
  6048. insert((vnode.el = createText('')), parentNode(node), node);
  6049. nextNode = node;
  6050. }
  6051. else {
  6052. nextNode = onMismatch();
  6053. }
  6054. }
  6055. else {
  6056. if (node.data !== vnode.children) {
  6057. hasMismatch = true;
  6058. warn$1(`Hydration text mismatch:` +
  6059. `\n- Client: ${JSON.stringify(node.data)}` +
  6060. `\n- Server: ${JSON.stringify(vnode.children)}`);
  6061. node.data = vnode.children;
  6062. }
  6063. nextNode = nextSibling(node);
  6064. }
  6065. break;
  6066. case Comment:
  6067. if (domType !== 8 /* DOMNodeTypes.COMMENT */ || isFragmentStart) {
  6068. nextNode = onMismatch();
  6069. }
  6070. else {
  6071. nextNode = nextSibling(node);
  6072. }
  6073. break;
  6074. case Static:
  6075. if (isFragmentStart) {
  6076. // entire template is static but SSRed as a fragment
  6077. node = nextSibling(node);
  6078. domType = node.nodeType;
  6079. }
  6080. if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
  6081. // determine anchor, adopt content
  6082. nextNode = node;
  6083. // if the static vnode has its content stripped during build,
  6084. // adopt it from the server-rendered HTML.
  6085. const needToAdoptContent = !vnode.children.length;
  6086. for (let i = 0; i < vnode.staticCount; i++) {
  6087. if (needToAdoptContent)
  6088. vnode.children +=
  6089. nextNode.nodeType === 1 /* DOMNodeTypes.ELEMENT */
  6090. ? nextNode.outerHTML
  6091. : nextNode.data;
  6092. if (i === vnode.staticCount - 1) {
  6093. vnode.anchor = nextNode;
  6094. }
  6095. nextNode = nextSibling(nextNode);
  6096. }
  6097. return isFragmentStart ? nextSibling(nextNode) : nextNode;
  6098. }
  6099. else {
  6100. onMismatch();
  6101. }
  6102. break;
  6103. case Fragment:
  6104. if (!isFragmentStart) {
  6105. nextNode = onMismatch();
  6106. }
  6107. else {
  6108. nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6109. }
  6110. break;
  6111. default:
  6112. if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
  6113. if (domType !== 1 /* DOMNodeTypes.ELEMENT */ ||
  6114. vnode.type.toLowerCase() !==
  6115. node.tagName.toLowerCase()) {
  6116. nextNode = onMismatch();
  6117. }
  6118. else {
  6119. nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6120. }
  6121. }
  6122. else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  6123. // when setting up the render effect, if the initial vnode already
  6124. // has .el set, the component will perform hydration instead of mount
  6125. // on its sub-tree.
  6126. vnode.slotScopeIds = slotScopeIds;
  6127. const container = parentNode(node);
  6128. mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
  6129. // component may be async, so in the case of fragments we cannot rely
  6130. // on component's rendered output to determine the end of the fragment
  6131. // instead, we do a lookahead to find the end anchor node.
  6132. nextNode = isFragmentStart
  6133. ? locateClosingAsyncAnchor(node)
  6134. : nextSibling(node);
  6135. // #4293 teleport as component root
  6136. if (nextNode &&
  6137. isComment(nextNode) &&
  6138. nextNode.data === 'teleport end') {
  6139. nextNode = nextSibling(nextNode);
  6140. }
  6141. // #3787
  6142. // if component is async, it may get moved / unmounted before its
  6143. // inner component is loaded, so we need to give it a placeholder
  6144. // vnode that matches its adopted DOM.
  6145. if (isAsyncWrapper(vnode)) {
  6146. let subTree;
  6147. if (isFragmentStart) {
  6148. subTree = createVNode(Fragment);
  6149. subTree.anchor = nextNode
  6150. ? nextNode.previousSibling
  6151. : container.lastChild;
  6152. }
  6153. else {
  6154. subTree =
  6155. node.nodeType === 3 ? createTextVNode('') : createVNode('div');
  6156. }
  6157. subTree.el = node;
  6158. vnode.component.subTree = subTree;
  6159. }
  6160. }
  6161. else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  6162. if (domType !== 8 /* DOMNodeTypes.COMMENT */) {
  6163. nextNode = onMismatch();
  6164. }
  6165. else {
  6166. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
  6167. }
  6168. }
  6169. else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  6170. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
  6171. }
  6172. else {
  6173. warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
  6174. }
  6175. }
  6176. if (ref != null) {
  6177. setRef(ref, null, parentSuspense, vnode);
  6178. }
  6179. return nextNode;
  6180. };
  6181. const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6182. optimized = optimized || !!vnode.dynamicChildren;
  6183. const { type, props, patchFlag, shapeFlag, dirs } = vnode;
  6184. // #4006 for form elements with non-string v-model value bindings
  6185. // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
  6186. const forcePatchValue = (type === 'input' && dirs) || type === 'option';
  6187. // skip props & children if this is hoisted static nodes
  6188. // #5405 in dev, always hydrate children for HMR
  6189. {
  6190. if (dirs) {
  6191. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  6192. }
  6193. // props
  6194. if (props) {
  6195. if (forcePatchValue ||
  6196. !optimized ||
  6197. patchFlag & (16 /* PatchFlags.FULL_PROPS */ | 32 /* PatchFlags.HYDRATE_EVENTS */)) {
  6198. for (const key in props) {
  6199. if ((forcePatchValue && key.endsWith('value')) ||
  6200. (isOn(key) && !isReservedProp(key))) {
  6201. patchProp(el, key, null, props[key], false, undefined, parentComponent);
  6202. }
  6203. }
  6204. }
  6205. else if (props.onClick) {
  6206. // Fast path for click listeners (which is most often) to avoid
  6207. // iterating through props.
  6208. patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
  6209. }
  6210. }
  6211. // vnode / directive hooks
  6212. let vnodeHooks;
  6213. if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
  6214. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6215. }
  6216. if (dirs) {
  6217. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  6218. }
  6219. if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
  6220. queueEffectWithSuspense(() => {
  6221. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6222. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  6223. }, parentSuspense);
  6224. }
  6225. // children
  6226. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */ &&
  6227. // skip if element has innerHTML / textContent
  6228. !(props && (props.innerHTML || props.textContent))) {
  6229. let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
  6230. let hasWarned = false;
  6231. while (next) {
  6232. hasMismatch = true;
  6233. if (!hasWarned) {
  6234. warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
  6235. `server rendered element contains more child nodes than client vdom.`);
  6236. hasWarned = true;
  6237. }
  6238. // The SSRed DOM contains more nodes than it should. Remove them.
  6239. const cur = next;
  6240. next = next.nextSibling;
  6241. remove(cur);
  6242. }
  6243. }
  6244. else if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  6245. if (el.textContent !== vnode.children) {
  6246. hasMismatch = true;
  6247. warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
  6248. `- Client: ${el.textContent}\n` +
  6249. `- Server: ${vnode.children}`);
  6250. el.textContent = vnode.children;
  6251. }
  6252. }
  6253. }
  6254. return el.nextSibling;
  6255. };
  6256. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6257. optimized = optimized || !!parentVNode.dynamicChildren;
  6258. const children = parentVNode.children;
  6259. const l = children.length;
  6260. let hasWarned = false;
  6261. for (let i = 0; i < l; i++) {
  6262. const vnode = optimized
  6263. ? children[i]
  6264. : (children[i] = normalizeVNode(children[i]));
  6265. if (node) {
  6266. node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6267. }
  6268. else if (vnode.type === Text && !vnode.children) {
  6269. continue;
  6270. }
  6271. else {
  6272. hasMismatch = true;
  6273. if (!hasWarned) {
  6274. warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
  6275. `server rendered element contains fewer child nodes than client vdom.`);
  6276. hasWarned = true;
  6277. }
  6278. // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
  6279. patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  6280. }
  6281. }
  6282. return node;
  6283. };
  6284. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6285. const { slotScopeIds: fragmentSlotScopeIds } = vnode;
  6286. if (fragmentSlotScopeIds) {
  6287. slotScopeIds = slotScopeIds
  6288. ? slotScopeIds.concat(fragmentSlotScopeIds)
  6289. : fragmentSlotScopeIds;
  6290. }
  6291. const container = parentNode(node);
  6292. const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
  6293. if (next && isComment(next) && next.data === ']') {
  6294. return nextSibling((vnode.anchor = next));
  6295. }
  6296. else {
  6297. // fragment didn't hydrate successfully, since we didn't get a end anchor
  6298. // back. This should have led to node/children mismatch warnings.
  6299. hasMismatch = true;
  6300. // since the anchor is missing, we need to create one and insert it
  6301. insert((vnode.anchor = createComment(`]`)), container, next);
  6302. return next;
  6303. }
  6304. };
  6305. const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  6306. hasMismatch = true;
  6307. warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* DOMNodeTypes.TEXT */
  6308. ? `(text)`
  6309. : isComment(node) && node.data === '['
  6310. ? `(start of fragment)`
  6311. : ``);
  6312. vnode.el = null;
  6313. if (isFragment) {
  6314. // remove excessive fragment nodes
  6315. const end = locateClosingAsyncAnchor(node);
  6316. while (true) {
  6317. const next = nextSibling(node);
  6318. if (next && next !== end) {
  6319. remove(next);
  6320. }
  6321. else {
  6322. break;
  6323. }
  6324. }
  6325. }
  6326. const next = nextSibling(node);
  6327. const container = parentNode(node);
  6328. remove(node);
  6329. patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  6330. return next;
  6331. };
  6332. const locateClosingAsyncAnchor = (node) => {
  6333. let match = 0;
  6334. while (node) {
  6335. node = nextSibling(node);
  6336. if (node && isComment(node)) {
  6337. if (node.data === '[')
  6338. match++;
  6339. if (node.data === ']') {
  6340. if (match === 0) {
  6341. return nextSibling(node);
  6342. }
  6343. else {
  6344. match--;
  6345. }
  6346. }
  6347. }
  6348. }
  6349. return node;
  6350. };
  6351. return [hydrate, hydrateNode];
  6352. }
  6353. /* eslint-disable no-restricted-globals */
  6354. let supported;
  6355. let perf;
  6356. function startMeasure(instance, type) {
  6357. if (instance.appContext.config.performance && isSupported()) {
  6358. perf.mark(`vue-${type}-${instance.uid}`);
  6359. }
  6360. {
  6361. devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
  6362. }
  6363. }
  6364. function endMeasure(instance, type) {
  6365. if (instance.appContext.config.performance && isSupported()) {
  6366. const startTag = `vue-${type}-${instance.uid}`;
  6367. const endTag = startTag + `:end`;
  6368. perf.mark(endTag);
  6369. perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
  6370. perf.clearMarks(startTag);
  6371. perf.clearMarks(endTag);
  6372. }
  6373. {
  6374. devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
  6375. }
  6376. }
  6377. function isSupported() {
  6378. if (supported !== undefined) {
  6379. return supported;
  6380. }
  6381. if (typeof window !== 'undefined' && window.performance) {
  6382. supported = true;
  6383. perf = window.performance;
  6384. }
  6385. else {
  6386. supported = false;
  6387. }
  6388. return supported;
  6389. }
  6390. const queuePostRenderEffect = queueEffectWithSuspense
  6391. ;
  6392. /**
  6393. * The createRenderer function accepts two generic arguments:
  6394. * HostNode and HostElement, corresponding to Node and Element types in the
  6395. * host environment. For example, for runtime-dom, HostNode would be the DOM
  6396. * `Node` interface and HostElement would be the DOM `Element` interface.
  6397. *
  6398. * Custom renderers can pass in the platform specific types like this:
  6399. *
  6400. * ``` js
  6401. * const { render, createApp } = createRenderer<Node, Element>({
  6402. * patchProp,
  6403. * ...nodeOps
  6404. * })
  6405. * ```
  6406. */
  6407. function createRenderer(options) {
  6408. return baseCreateRenderer(options);
  6409. }
  6410. // Separate API for creating hydration-enabled renderer.
  6411. // Hydration logic is only used when calling this function, making it
  6412. // tree-shakable.
  6413. function createHydrationRenderer(options) {
  6414. return baseCreateRenderer(options, createHydrationFunctions);
  6415. }
  6416. // implementation
  6417. function baseCreateRenderer(options, createHydrationFns) {
  6418. const target = getGlobalThis();
  6419. target.__VUE__ = true;
  6420. {
  6421. setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
  6422. }
  6423. const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, insertStaticContent: hostInsertStaticContent } = options;
  6424. // Note: functions inside this closure should use `const xxx = () => {}`
  6425. // style in order to prevent being inlined by minifiers.
  6426. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  6427. if (n1 === n2) {
  6428. return;
  6429. }
  6430. // patching & not same type, unmount old tree
  6431. if (n1 && !isSameVNodeType(n1, n2)) {
  6432. anchor = getNextHostNode(n1);
  6433. unmount(n1, parentComponent, parentSuspense, true);
  6434. n1 = null;
  6435. }
  6436. if (n2.patchFlag === -2 /* PatchFlags.BAIL */) {
  6437. optimized = false;
  6438. n2.dynamicChildren = null;
  6439. }
  6440. const { type, ref, shapeFlag } = n2;
  6441. switch (type) {
  6442. case Text:
  6443. processText(n1, n2, container, anchor);
  6444. break;
  6445. case Comment:
  6446. processCommentNode(n1, n2, container, anchor);
  6447. break;
  6448. case Static:
  6449. if (n1 == null) {
  6450. mountStaticNode(n2, container, anchor, isSVG);
  6451. }
  6452. else {
  6453. patchStaticNode(n1, n2, container, isSVG);
  6454. }
  6455. break;
  6456. case Fragment:
  6457. processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6458. break;
  6459. default:
  6460. if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
  6461. processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6462. }
  6463. else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  6464. processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6465. }
  6466. else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  6467. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  6468. }
  6469. else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  6470. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  6471. }
  6472. else {
  6473. warn$1('Invalid VNode type:', type, `(${typeof type})`);
  6474. }
  6475. }
  6476. // set ref
  6477. if (ref != null && parentComponent) {
  6478. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
  6479. }
  6480. };
  6481. const processText = (n1, n2, container, anchor) => {
  6482. if (n1 == null) {
  6483. hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
  6484. }
  6485. else {
  6486. const el = (n2.el = n1.el);
  6487. if (n2.children !== n1.children) {
  6488. hostSetText(el, n2.children);
  6489. }
  6490. }
  6491. };
  6492. const processCommentNode = (n1, n2, container, anchor) => {
  6493. if (n1 == null) {
  6494. hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
  6495. }
  6496. else {
  6497. // there's no support for dynamic comments
  6498. n2.el = n1.el;
  6499. }
  6500. };
  6501. const mountStaticNode = (n2, container, anchor, isSVG) => {
  6502. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG, n2.el, n2.anchor);
  6503. };
  6504. /**
  6505. * Dev / HMR only
  6506. */
  6507. const patchStaticNode = (n1, n2, container, isSVG) => {
  6508. // static nodes are only patched during dev for HMR
  6509. if (n2.children !== n1.children) {
  6510. const anchor = hostNextSibling(n1.anchor);
  6511. // remove existing
  6512. removeStaticNode(n1);
  6513. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
  6514. }
  6515. else {
  6516. n2.el = n1.el;
  6517. n2.anchor = n1.anchor;
  6518. }
  6519. };
  6520. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  6521. let next;
  6522. while (el && el !== anchor) {
  6523. next = hostNextSibling(el);
  6524. hostInsert(el, container, nextSibling);
  6525. el = next;
  6526. }
  6527. hostInsert(anchor, container, nextSibling);
  6528. };
  6529. const removeStaticNode = ({ el, anchor }) => {
  6530. let next;
  6531. while (el && el !== anchor) {
  6532. next = hostNextSibling(el);
  6533. hostRemove(el);
  6534. el = next;
  6535. }
  6536. hostRemove(anchor);
  6537. };
  6538. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6539. isSVG = isSVG || n2.type === 'svg';
  6540. if (n1 == null) {
  6541. mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6542. }
  6543. else {
  6544. patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6545. }
  6546. };
  6547. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6548. let el;
  6549. let vnodeHook;
  6550. const { type, props, shapeFlag, transition, dirs } = vnode;
  6551. el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
  6552. // mount children first, since some props may rely on child content
  6553. // being already rendered, e.g. `<select value>`
  6554. if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  6555. hostSetElementText(el, vnode.children);
  6556. }
  6557. else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  6558. mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
  6559. }
  6560. if (dirs) {
  6561. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  6562. }
  6563. // props
  6564. if (props) {
  6565. for (const key in props) {
  6566. if (key !== 'value' && !isReservedProp(key)) {
  6567. hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6568. }
  6569. }
  6570. /**
  6571. * Special case for setting value on DOM elements:
  6572. * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
  6573. * - it needs to be forced (#1471)
  6574. * #2353 proposes adding another renderer option to configure this, but
  6575. * the properties affects are so finite it is worth special casing it
  6576. * here to reduce the complexity. (Special casing it also should not
  6577. * affect non-DOM renderers)
  6578. */
  6579. if ('value' in props) {
  6580. hostPatchProp(el, 'value', null, props.value);
  6581. }
  6582. if ((vnodeHook = props.onVnodeBeforeMount)) {
  6583. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6584. }
  6585. }
  6586. // scopeId
  6587. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
  6588. {
  6589. Object.defineProperty(el, '__vnode', {
  6590. value: vnode,
  6591. enumerable: false
  6592. });
  6593. Object.defineProperty(el, '__vueParentComponent', {
  6594. value: parentComponent,
  6595. enumerable: false
  6596. });
  6597. }
  6598. if (dirs) {
  6599. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  6600. }
  6601. // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
  6602. // #1689 For inside suspense + suspense resolved case, just call it
  6603. const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
  6604. transition &&
  6605. !transition.persisted;
  6606. if (needCallTransitionHooks) {
  6607. transition.beforeEnter(el);
  6608. }
  6609. hostInsert(el, container, anchor);
  6610. if ((vnodeHook = props && props.onVnodeMounted) ||
  6611. needCallTransitionHooks ||
  6612. dirs) {
  6613. queuePostRenderEffect(() => {
  6614. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6615. needCallTransitionHooks && transition.enter(el);
  6616. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  6617. }, parentSuspense);
  6618. }
  6619. };
  6620. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  6621. if (scopeId) {
  6622. hostSetScopeId(el, scopeId);
  6623. }
  6624. if (slotScopeIds) {
  6625. for (let i = 0; i < slotScopeIds.length; i++) {
  6626. hostSetScopeId(el, slotScopeIds[i]);
  6627. }
  6628. }
  6629. if (parentComponent) {
  6630. let subTree = parentComponent.subTree;
  6631. if (subTree.patchFlag > 0 &&
  6632. subTree.patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */) {
  6633. subTree =
  6634. filterSingleRoot(subTree.children) || subTree;
  6635. }
  6636. if (vnode === subTree) {
  6637. const parentVNode = parentComponent.vnode;
  6638. setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
  6639. }
  6640. }
  6641. };
  6642. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
  6643. for (let i = start; i < children.length; i++) {
  6644. const child = (children[i] = optimized
  6645. ? cloneIfMounted(children[i])
  6646. : normalizeVNode(children[i]));
  6647. patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6648. }
  6649. };
  6650. const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6651. const el = (n2.el = n1.el);
  6652. let { patchFlag, dynamicChildren, dirs } = n2;
  6653. // #1426 take the old vnode's patch flag into account since user may clone a
  6654. // compiler-generated vnode, which de-opts to FULL_PROPS
  6655. patchFlag |= n1.patchFlag & 16 /* PatchFlags.FULL_PROPS */;
  6656. const oldProps = n1.props || EMPTY_OBJ;
  6657. const newProps = n2.props || EMPTY_OBJ;
  6658. let vnodeHook;
  6659. // disable recurse in beforeUpdate hooks
  6660. parentComponent && toggleRecurse(parentComponent, false);
  6661. if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
  6662. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6663. }
  6664. if (dirs) {
  6665. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
  6666. }
  6667. parentComponent && toggleRecurse(parentComponent, true);
  6668. if (isHmrUpdating) {
  6669. // HMR updated, force full diff
  6670. patchFlag = 0;
  6671. optimized = false;
  6672. dynamicChildren = null;
  6673. }
  6674. const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
  6675. if (dynamicChildren) {
  6676. patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
  6677. if (parentComponent && parentComponent.type.__hmrId) {
  6678. traverseStaticChildren(n1, n2);
  6679. }
  6680. }
  6681. else if (!optimized) {
  6682. // full diff
  6683. patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
  6684. }
  6685. if (patchFlag > 0) {
  6686. // the presence of a patchFlag means this element's render code was
  6687. // generated by the compiler and can take the fast path.
  6688. // in this path old node and new node are guaranteed to have the same shape
  6689. // (i.e. at the exact same position in the source template)
  6690. if (patchFlag & 16 /* PatchFlags.FULL_PROPS */) {
  6691. // element props contain dynamic keys, full diff needed
  6692. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  6693. }
  6694. else {
  6695. // class
  6696. // this flag is matched when the element has dynamic class bindings.
  6697. if (patchFlag & 2 /* PatchFlags.CLASS */) {
  6698. if (oldProps.class !== newProps.class) {
  6699. hostPatchProp(el, 'class', null, newProps.class, isSVG);
  6700. }
  6701. }
  6702. // style
  6703. // this flag is matched when the element has dynamic style bindings
  6704. if (patchFlag & 4 /* PatchFlags.STYLE */) {
  6705. hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
  6706. }
  6707. // props
  6708. // This flag is matched when the element has dynamic prop/attr bindings
  6709. // other than class and style. The keys of dynamic prop/attrs are saved for
  6710. // faster iteration.
  6711. // Note dynamic keys like :[foo]="bar" will cause this optimization to
  6712. // bail out and go through a full diff because we need to unset the old key
  6713. if (patchFlag & 8 /* PatchFlags.PROPS */) {
  6714. // if the flag is present then dynamicProps must be non-null
  6715. const propsToUpdate = n2.dynamicProps;
  6716. for (let i = 0; i < propsToUpdate.length; i++) {
  6717. const key = propsToUpdate[i];
  6718. const prev = oldProps[key];
  6719. const next = newProps[key];
  6720. // #1471 force patch value
  6721. if (next !== prev || key === 'value') {
  6722. hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
  6723. }
  6724. }
  6725. }
  6726. }
  6727. // text
  6728. // This flag is matched when the element has only dynamic text children.
  6729. if (patchFlag & 1 /* PatchFlags.TEXT */) {
  6730. if (n1.children !== n2.children) {
  6731. hostSetElementText(el, n2.children);
  6732. }
  6733. }
  6734. }
  6735. else if (!optimized && dynamicChildren == null) {
  6736. // unoptimized, full diff
  6737. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  6738. }
  6739. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  6740. queuePostRenderEffect(() => {
  6741. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6742. dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
  6743. }, parentSuspense);
  6744. }
  6745. };
  6746. // The fast path for blocks.
  6747. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
  6748. for (let i = 0; i < newChildren.length; i++) {
  6749. const oldVNode = oldChildren[i];
  6750. const newVNode = newChildren[i];
  6751. // Determine the container (parent element) for the patch.
  6752. const container =
  6753. // oldVNode may be an errored async setup() component inside Suspense
  6754. // which will not have a mounted element
  6755. oldVNode.el &&
  6756. // - In the case of a Fragment, we need to provide the actual parent
  6757. // of the Fragment itself so it can move its children.
  6758. (oldVNode.type === Fragment ||
  6759. // - In the case of different nodes, there is going to be a replacement
  6760. // which also requires the correct parent container
  6761. !isSameVNodeType(oldVNode, newVNode) ||
  6762. // - In the case of a component, it could contain anything.
  6763. oldVNode.shapeFlag & (6 /* ShapeFlags.COMPONENT */ | 64 /* ShapeFlags.TELEPORT */))
  6764. ? hostParentNode(oldVNode.el)
  6765. : // In other cases, the parent container is not actually used so we
  6766. // just pass the block element here to avoid a DOM parentNode call.
  6767. fallbackContainer;
  6768. patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
  6769. }
  6770. };
  6771. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  6772. if (oldProps !== newProps) {
  6773. if (oldProps !== EMPTY_OBJ) {
  6774. for (const key in oldProps) {
  6775. if (!isReservedProp(key) && !(key in newProps)) {
  6776. hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6777. }
  6778. }
  6779. }
  6780. for (const key in newProps) {
  6781. // empty string is not valid prop
  6782. if (isReservedProp(key))
  6783. continue;
  6784. const next = newProps[key];
  6785. const prev = oldProps[key];
  6786. // defer patching value
  6787. if (next !== prev && key !== 'value') {
  6788. hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6789. }
  6790. }
  6791. if ('value' in newProps) {
  6792. hostPatchProp(el, 'value', oldProps.value, newProps.value);
  6793. }
  6794. }
  6795. };
  6796. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6797. const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
  6798. const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
  6799. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
  6800. if (// #5523 dev root fragment may inherit directives
  6801. (isHmrUpdating || patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */)) {
  6802. // HMR updated / Dev root fragment (w/ comments), force full diff
  6803. patchFlag = 0;
  6804. optimized = false;
  6805. dynamicChildren = null;
  6806. }
  6807. // check if this is a slot fragment with :slotted scope ids
  6808. if (fragmentSlotScopeIds) {
  6809. slotScopeIds = slotScopeIds
  6810. ? slotScopeIds.concat(fragmentSlotScopeIds)
  6811. : fragmentSlotScopeIds;
  6812. }
  6813. if (n1 == null) {
  6814. hostInsert(fragmentStartAnchor, container, anchor);
  6815. hostInsert(fragmentEndAnchor, container, anchor);
  6816. // a fragment can only have array children
  6817. // since they are either generated by the compiler, or implicitly created
  6818. // from arrays.
  6819. mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6820. }
  6821. else {
  6822. if (patchFlag > 0 &&
  6823. patchFlag & 64 /* PatchFlags.STABLE_FRAGMENT */ &&
  6824. dynamicChildren &&
  6825. // #2715 the previous fragment could've been a BAILed one as a result
  6826. // of renderSlot() with no valid children
  6827. n1.dynamicChildren) {
  6828. // a stable fragment (template root or <template v-for>) doesn't need to
  6829. // patch children order, but it may contain dynamicChildren.
  6830. patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
  6831. if (parentComponent && parentComponent.type.__hmrId) {
  6832. traverseStaticChildren(n1, n2);
  6833. }
  6834. else if (
  6835. // #2080 if the stable fragment has a key, it's a <template v-for> that may
  6836. // get moved around. Make sure all root level vnodes inherit el.
  6837. // #2134 or if it's a component root, it may also get moved around
  6838. // as the component is being moved.
  6839. n2.key != null ||
  6840. (parentComponent && n2 === parentComponent.subTree)) {
  6841. traverseStaticChildren(n1, n2, true /* shallow */);
  6842. }
  6843. }
  6844. else {
  6845. // keyed / unkeyed, or manual fragments.
  6846. // for keyed & unkeyed, since they are compiler generated from v-for,
  6847. // each child is guaranteed to be a block so the fragment will never
  6848. // have dynamicChildren.
  6849. patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6850. }
  6851. }
  6852. };
  6853. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6854. n2.slotScopeIds = slotScopeIds;
  6855. if (n1 == null) {
  6856. if (n2.shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
  6857. parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
  6858. }
  6859. else {
  6860. mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  6861. }
  6862. }
  6863. else {
  6864. updateComponent(n1, n2, optimized);
  6865. }
  6866. };
  6867. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  6868. const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
  6869. if (instance.type.__hmrId) {
  6870. registerHMR(instance);
  6871. }
  6872. {
  6873. pushWarningContext(initialVNode);
  6874. startMeasure(instance, `mount`);
  6875. }
  6876. // inject renderer internals for keepAlive
  6877. if (isKeepAlive(initialVNode)) {
  6878. instance.ctx.renderer = internals;
  6879. }
  6880. // resolve props and slots for setup context
  6881. {
  6882. {
  6883. startMeasure(instance, `init`);
  6884. }
  6885. setupComponent(instance);
  6886. {
  6887. endMeasure(instance, `init`);
  6888. }
  6889. }
  6890. // setup() is async. This component relies on async logic to be resolved
  6891. // before proceeding
  6892. if (instance.asyncDep) {
  6893. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  6894. // Give it a placeholder if this is not hydration
  6895. // TODO handle self-defined fallback
  6896. if (!initialVNode.el) {
  6897. const placeholder = (instance.subTree = createVNode(Comment));
  6898. processCommentNode(null, placeholder, container, anchor);
  6899. }
  6900. return;
  6901. }
  6902. setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
  6903. {
  6904. popWarningContext();
  6905. endMeasure(instance, `mount`);
  6906. }
  6907. };
  6908. const updateComponent = (n1, n2, optimized) => {
  6909. const instance = (n2.component = n1.component);
  6910. if (shouldUpdateComponent(n1, n2, optimized)) {
  6911. if (instance.asyncDep &&
  6912. !instance.asyncResolved) {
  6913. // async & still pending - just update props and slots
  6914. // since the component's reactive effect for render isn't set-up yet
  6915. {
  6916. pushWarningContext(n2);
  6917. }
  6918. updateComponentPreRender(instance, n2, optimized);
  6919. {
  6920. popWarningContext();
  6921. }
  6922. return;
  6923. }
  6924. else {
  6925. // normal update
  6926. instance.next = n2;
  6927. // in case the child component is also queued, remove it to avoid
  6928. // double updating the same child component in the same flush.
  6929. invalidateJob(instance.update);
  6930. // instance.update is the reactive effect.
  6931. instance.update();
  6932. }
  6933. }
  6934. else {
  6935. // no update needed. just copy over properties
  6936. n2.el = n1.el;
  6937. instance.vnode = n2;
  6938. }
  6939. };
  6940. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  6941. const componentUpdateFn = () => {
  6942. if (!instance.isMounted) {
  6943. let vnodeHook;
  6944. const { el, props } = initialVNode;
  6945. const { bm, m, parent } = instance;
  6946. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
  6947. toggleRecurse(instance, false);
  6948. // beforeMount hook
  6949. if (bm) {
  6950. invokeArrayFns(bm);
  6951. }
  6952. // onVnodeBeforeMount
  6953. if (!isAsyncWrapperVNode &&
  6954. (vnodeHook = props && props.onVnodeBeforeMount)) {
  6955. invokeVNodeHook(vnodeHook, parent, initialVNode);
  6956. }
  6957. toggleRecurse(instance, true);
  6958. if (el && hydrateNode) {
  6959. // vnode has adopted host node - perform hydration instead of mount.
  6960. const hydrateSubTree = () => {
  6961. {
  6962. startMeasure(instance, `render`);
  6963. }
  6964. instance.subTree = renderComponentRoot(instance);
  6965. {
  6966. endMeasure(instance, `render`);
  6967. }
  6968. {
  6969. startMeasure(instance, `hydrate`);
  6970. }
  6971. hydrateNode(el, instance.subTree, instance, parentSuspense, null);
  6972. {
  6973. endMeasure(instance, `hydrate`);
  6974. }
  6975. };
  6976. if (isAsyncWrapperVNode) {
  6977. initialVNode.type.__asyncLoader().then(
  6978. // note: we are moving the render call into an async callback,
  6979. // which means it won't track dependencies - but it's ok because
  6980. // a server-rendered async wrapper is already in resolved state
  6981. // and it will never need to change.
  6982. () => !instance.isUnmounted && hydrateSubTree());
  6983. }
  6984. else {
  6985. hydrateSubTree();
  6986. }
  6987. }
  6988. else {
  6989. {
  6990. startMeasure(instance, `render`);
  6991. }
  6992. const subTree = (instance.subTree = renderComponentRoot(instance));
  6993. {
  6994. endMeasure(instance, `render`);
  6995. }
  6996. {
  6997. startMeasure(instance, `patch`);
  6998. }
  6999. patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
  7000. {
  7001. endMeasure(instance, `patch`);
  7002. }
  7003. initialVNode.el = subTree.el;
  7004. }
  7005. // mounted hook
  7006. if (m) {
  7007. queuePostRenderEffect(m, parentSuspense);
  7008. }
  7009. // onVnodeMounted
  7010. if (!isAsyncWrapperVNode &&
  7011. (vnodeHook = props && props.onVnodeMounted)) {
  7012. const scopedInitialVNode = initialVNode;
  7013. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
  7014. }
  7015. // activated hook for keep-alive roots.
  7016. // #1742 activated hook must be accessed after first render
  7017. // since the hook may be injected by a child keep-alive
  7018. if (initialVNode.shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */ ||
  7019. (parent &&
  7020. isAsyncWrapper(parent.vnode) &&
  7021. parent.vnode.shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */)) {
  7022. instance.a && queuePostRenderEffect(instance.a, parentSuspense);
  7023. }
  7024. instance.isMounted = true;
  7025. {
  7026. devtoolsComponentAdded(instance);
  7027. }
  7028. // #2458: deference mount-only object parameters to prevent memleaks
  7029. initialVNode = container = anchor = null;
  7030. }
  7031. else {
  7032. // updateComponent
  7033. // This is triggered by mutation of component's own state (next: null)
  7034. // OR parent calling processComponent (next: VNode)
  7035. let { next, bu, u, parent, vnode } = instance;
  7036. let originNext = next;
  7037. let vnodeHook;
  7038. {
  7039. pushWarningContext(next || instance.vnode);
  7040. }
  7041. // Disallow component effect recursion during pre-lifecycle hooks.
  7042. toggleRecurse(instance, false);
  7043. if (next) {
  7044. next.el = vnode.el;
  7045. updateComponentPreRender(instance, next, optimized);
  7046. }
  7047. else {
  7048. next = vnode;
  7049. }
  7050. // beforeUpdate hook
  7051. if (bu) {
  7052. invokeArrayFns(bu);
  7053. }
  7054. // onVnodeBeforeUpdate
  7055. if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
  7056. invokeVNodeHook(vnodeHook, parent, next, vnode);
  7057. }
  7058. toggleRecurse(instance, true);
  7059. // render
  7060. {
  7061. startMeasure(instance, `render`);
  7062. }
  7063. const nextTree = renderComponentRoot(instance);
  7064. {
  7065. endMeasure(instance, `render`);
  7066. }
  7067. const prevTree = instance.subTree;
  7068. instance.subTree = nextTree;
  7069. {
  7070. startMeasure(instance, `patch`);
  7071. }
  7072. patch(prevTree, nextTree,
  7073. // parent may have changed if it's in a teleport
  7074. hostParentNode(prevTree.el),
  7075. // anchor may have changed if it's in a fragment
  7076. getNextHostNode(prevTree), instance, parentSuspense, isSVG);
  7077. {
  7078. endMeasure(instance, `patch`);
  7079. }
  7080. next.el = nextTree.el;
  7081. if (originNext === null) {
  7082. // self-triggered update. In case of HOC, update parent component
  7083. // vnode el. HOC is indicated by parent instance's subTree pointing
  7084. // to child component's vnode
  7085. updateHOCHostEl(instance, nextTree.el);
  7086. }
  7087. // updated hook
  7088. if (u) {
  7089. queuePostRenderEffect(u, parentSuspense);
  7090. }
  7091. // onVnodeUpdated
  7092. if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
  7093. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
  7094. }
  7095. {
  7096. devtoolsComponentUpdated(instance);
  7097. }
  7098. {
  7099. popWarningContext();
  7100. }
  7101. }
  7102. };
  7103. // create reactive effect for rendering
  7104. const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(update), instance.scope // track it in component's effect scope
  7105. ));
  7106. const update = (instance.update = () => effect.run());
  7107. update.id = instance.uid;
  7108. // allowRecurse
  7109. // #1801, #2043 component render effects should allow recursive updates
  7110. toggleRecurse(instance, true);
  7111. {
  7112. effect.onTrack = instance.rtc
  7113. ? e => invokeArrayFns(instance.rtc, e)
  7114. : void 0;
  7115. effect.onTrigger = instance.rtg
  7116. ? e => invokeArrayFns(instance.rtg, e)
  7117. : void 0;
  7118. update.ownerInstance = instance;
  7119. }
  7120. update();
  7121. };
  7122. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  7123. nextVNode.component = instance;
  7124. const prevProps = instance.vnode.props;
  7125. instance.vnode = nextVNode;
  7126. instance.next = null;
  7127. updateProps(instance, nextVNode.props, prevProps, optimized);
  7128. updateSlots(instance, nextVNode.children, optimized);
  7129. pauseTracking();
  7130. // props update may have triggered pre-flush watchers.
  7131. // flush them before the render update.
  7132. flushPreFlushCbs();
  7133. resetTracking();
  7134. };
  7135. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
  7136. const c1 = n1 && n1.children;
  7137. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  7138. const c2 = n2.children;
  7139. const { patchFlag, shapeFlag } = n2;
  7140. // fast path
  7141. if (patchFlag > 0) {
  7142. if (patchFlag & 128 /* PatchFlags.KEYED_FRAGMENT */) {
  7143. // this could be either fully-keyed or mixed (some keyed some not)
  7144. // presence of patchFlag means children are guaranteed to be arrays
  7145. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7146. return;
  7147. }
  7148. else if (patchFlag & 256 /* PatchFlags.UNKEYED_FRAGMENT */) {
  7149. // unkeyed
  7150. patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7151. return;
  7152. }
  7153. }
  7154. // children has 3 possibilities: text, array or no children.
  7155. if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  7156. // text children fast path
  7157. if (prevShapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7158. unmountChildren(c1, parentComponent, parentSuspense);
  7159. }
  7160. if (c2 !== c1) {
  7161. hostSetElementText(container, c2);
  7162. }
  7163. }
  7164. else {
  7165. if (prevShapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7166. // prev children was array
  7167. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7168. // two arrays, cannot assume anything, do full diff
  7169. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7170. }
  7171. else {
  7172. // no new children, just unmount old
  7173. unmountChildren(c1, parentComponent, parentSuspense, true);
  7174. }
  7175. }
  7176. else {
  7177. // prev children was text OR null
  7178. // new children is array OR null
  7179. if (prevShapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  7180. hostSetElementText(container, '');
  7181. }
  7182. // mount new if array
  7183. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7184. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7185. }
  7186. }
  7187. }
  7188. };
  7189. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7190. c1 = c1 || EMPTY_ARR;
  7191. c2 = c2 || EMPTY_ARR;
  7192. const oldLength = c1.length;
  7193. const newLength = c2.length;
  7194. const commonLength = Math.min(oldLength, newLength);
  7195. let i;
  7196. for (i = 0; i < commonLength; i++) {
  7197. const nextChild = (c2[i] = optimized
  7198. ? cloneIfMounted(c2[i])
  7199. : normalizeVNode(c2[i]));
  7200. patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7201. }
  7202. if (oldLength > newLength) {
  7203. // remove old
  7204. unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
  7205. }
  7206. else {
  7207. // mount new
  7208. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
  7209. }
  7210. };
  7211. // can be all-keyed or mixed
  7212. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7213. let i = 0;
  7214. const l2 = c2.length;
  7215. let e1 = c1.length - 1; // prev ending index
  7216. let e2 = l2 - 1; // next ending index
  7217. // 1. sync from start
  7218. // (a b) c
  7219. // (a b) d e
  7220. while (i <= e1 && i <= e2) {
  7221. const n1 = c1[i];
  7222. const n2 = (c2[i] = optimized
  7223. ? cloneIfMounted(c2[i])
  7224. : normalizeVNode(c2[i]));
  7225. if (isSameVNodeType(n1, n2)) {
  7226. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7227. }
  7228. else {
  7229. break;
  7230. }
  7231. i++;
  7232. }
  7233. // 2. sync from end
  7234. // a (b c)
  7235. // d e (b c)
  7236. while (i <= e1 && i <= e2) {
  7237. const n1 = c1[e1];
  7238. const n2 = (c2[e2] = optimized
  7239. ? cloneIfMounted(c2[e2])
  7240. : normalizeVNode(c2[e2]));
  7241. if (isSameVNodeType(n1, n2)) {
  7242. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7243. }
  7244. else {
  7245. break;
  7246. }
  7247. e1--;
  7248. e2--;
  7249. }
  7250. // 3. common sequence + mount
  7251. // (a b)
  7252. // (a b) c
  7253. // i = 2, e1 = 1, e2 = 2
  7254. // (a b)
  7255. // c (a b)
  7256. // i = 0, e1 = -1, e2 = 0
  7257. if (i > e1) {
  7258. if (i <= e2) {
  7259. const nextPos = e2 + 1;
  7260. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  7261. while (i <= e2) {
  7262. patch(null, (c2[i] = optimized
  7263. ? cloneIfMounted(c2[i])
  7264. : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7265. i++;
  7266. }
  7267. }
  7268. }
  7269. // 4. common sequence + unmount
  7270. // (a b) c
  7271. // (a b)
  7272. // i = 2, e1 = 2, e2 = 1
  7273. // a (b c)
  7274. // (b c)
  7275. // i = 0, e1 = 0, e2 = -1
  7276. else if (i > e2) {
  7277. while (i <= e1) {
  7278. unmount(c1[i], parentComponent, parentSuspense, true);
  7279. i++;
  7280. }
  7281. }
  7282. // 5. unknown sequence
  7283. // [i ... e1 + 1]: a b [c d e] f g
  7284. // [i ... e2 + 1]: a b [e d c h] f g
  7285. // i = 2, e1 = 4, e2 = 5
  7286. else {
  7287. const s1 = i; // prev starting index
  7288. const s2 = i; // next starting index
  7289. // 5.1 build key:index map for newChildren
  7290. const keyToNewIndexMap = new Map();
  7291. for (i = s2; i <= e2; i++) {
  7292. const nextChild = (c2[i] = optimized
  7293. ? cloneIfMounted(c2[i])
  7294. : normalizeVNode(c2[i]));
  7295. if (nextChild.key != null) {
  7296. if (keyToNewIndexMap.has(nextChild.key)) {
  7297. warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
  7298. }
  7299. keyToNewIndexMap.set(nextChild.key, i);
  7300. }
  7301. }
  7302. // 5.2 loop through old children left to be patched and try to patch
  7303. // matching nodes & remove nodes that are no longer present
  7304. let j;
  7305. let patched = 0;
  7306. const toBePatched = e2 - s2 + 1;
  7307. let moved = false;
  7308. // used to track whether any node has moved
  7309. let maxNewIndexSoFar = 0;
  7310. // works as Map<newIndex, oldIndex>
  7311. // Note that oldIndex is offset by +1
  7312. // and oldIndex = 0 is a special value indicating the new node has
  7313. // no corresponding old node.
  7314. // used for determining longest stable subsequence
  7315. const newIndexToOldIndexMap = new Array(toBePatched);
  7316. for (i = 0; i < toBePatched; i++)
  7317. newIndexToOldIndexMap[i] = 0;
  7318. for (i = s1; i <= e1; i++) {
  7319. const prevChild = c1[i];
  7320. if (patched >= toBePatched) {
  7321. // all new children have been patched so this can only be a removal
  7322. unmount(prevChild, parentComponent, parentSuspense, true);
  7323. continue;
  7324. }
  7325. let newIndex;
  7326. if (prevChild.key != null) {
  7327. newIndex = keyToNewIndexMap.get(prevChild.key);
  7328. }
  7329. else {
  7330. // key-less node, try to locate a key-less node of the same type
  7331. for (j = s2; j <= e2; j++) {
  7332. if (newIndexToOldIndexMap[j - s2] === 0 &&
  7333. isSameVNodeType(prevChild, c2[j])) {
  7334. newIndex = j;
  7335. break;
  7336. }
  7337. }
  7338. }
  7339. if (newIndex === undefined) {
  7340. unmount(prevChild, parentComponent, parentSuspense, true);
  7341. }
  7342. else {
  7343. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  7344. if (newIndex >= maxNewIndexSoFar) {
  7345. maxNewIndexSoFar = newIndex;
  7346. }
  7347. else {
  7348. moved = true;
  7349. }
  7350. patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7351. patched++;
  7352. }
  7353. }
  7354. // 5.3 move and mount
  7355. // generate longest stable subsequence only when nodes have moved
  7356. const increasingNewIndexSequence = moved
  7357. ? getSequence(newIndexToOldIndexMap)
  7358. : EMPTY_ARR;
  7359. j = increasingNewIndexSequence.length - 1;
  7360. // looping backwards so that we can use last patched node as anchor
  7361. for (i = toBePatched - 1; i >= 0; i--) {
  7362. const nextIndex = s2 + i;
  7363. const nextChild = c2[nextIndex];
  7364. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  7365. if (newIndexToOldIndexMap[i] === 0) {
  7366. // mount new
  7367. patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7368. }
  7369. else if (moved) {
  7370. // move if:
  7371. // There is no stable subsequence (e.g. a reverse)
  7372. // OR current node is not among the stable sequence
  7373. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  7374. move(nextChild, container, anchor, 2 /* MoveType.REORDER */);
  7375. }
  7376. else {
  7377. j--;
  7378. }
  7379. }
  7380. }
  7381. }
  7382. };
  7383. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  7384. const { el, type, transition, children, shapeFlag } = vnode;
  7385. if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  7386. move(vnode.component.subTree, container, anchor, moveType);
  7387. return;
  7388. }
  7389. if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  7390. vnode.suspense.move(container, anchor, moveType);
  7391. return;
  7392. }
  7393. if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  7394. type.move(vnode, container, anchor, internals);
  7395. return;
  7396. }
  7397. if (type === Fragment) {
  7398. hostInsert(el, container, anchor);
  7399. for (let i = 0; i < children.length; i++) {
  7400. move(children[i], container, anchor, moveType);
  7401. }
  7402. hostInsert(vnode.anchor, container, anchor);
  7403. return;
  7404. }
  7405. if (type === Static) {
  7406. moveStaticNode(vnode, container, anchor);
  7407. return;
  7408. }
  7409. // single nodes
  7410. const needTransition = moveType !== 2 /* MoveType.REORDER */ &&
  7411. shapeFlag & 1 /* ShapeFlags.ELEMENT */ &&
  7412. transition;
  7413. if (needTransition) {
  7414. if (moveType === 0 /* MoveType.ENTER */) {
  7415. transition.beforeEnter(el);
  7416. hostInsert(el, container, anchor);
  7417. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  7418. }
  7419. else {
  7420. const { leave, delayLeave, afterLeave } = transition;
  7421. const remove = () => hostInsert(el, container, anchor);
  7422. const performLeave = () => {
  7423. leave(el, () => {
  7424. remove();
  7425. afterLeave && afterLeave();
  7426. });
  7427. };
  7428. if (delayLeave) {
  7429. delayLeave(el, remove, performLeave);
  7430. }
  7431. else {
  7432. performLeave();
  7433. }
  7434. }
  7435. }
  7436. else {
  7437. hostInsert(el, container, anchor);
  7438. }
  7439. };
  7440. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  7441. const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
  7442. // unset ref
  7443. if (ref != null) {
  7444. setRef(ref, null, parentSuspense, vnode, true);
  7445. }
  7446. if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
  7447. parentComponent.ctx.deactivate(vnode);
  7448. return;
  7449. }
  7450. const shouldInvokeDirs = shapeFlag & 1 /* ShapeFlags.ELEMENT */ && dirs;
  7451. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
  7452. let vnodeHook;
  7453. if (shouldInvokeVnodeHook &&
  7454. (vnodeHook = props && props.onVnodeBeforeUnmount)) {
  7455. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7456. }
  7457. if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  7458. unmountComponent(vnode.component, parentSuspense, doRemove);
  7459. }
  7460. else {
  7461. if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  7462. vnode.suspense.unmount(parentSuspense, doRemove);
  7463. return;
  7464. }
  7465. if (shouldInvokeDirs) {
  7466. invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
  7467. }
  7468. if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  7469. vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
  7470. }
  7471. else if (dynamicChildren &&
  7472. // #1153: fast path should not be taken for non-stable (v-for) fragments
  7473. (type !== Fragment ||
  7474. (patchFlag > 0 && patchFlag & 64 /* PatchFlags.STABLE_FRAGMENT */))) {
  7475. // fast path for block nodes: only need to unmount dynamic children.
  7476. unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
  7477. }
  7478. else if ((type === Fragment &&
  7479. patchFlag &
  7480. (128 /* PatchFlags.KEYED_FRAGMENT */ | 256 /* PatchFlags.UNKEYED_FRAGMENT */)) ||
  7481. (!optimized && shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */)) {
  7482. unmountChildren(children, parentComponent, parentSuspense);
  7483. }
  7484. if (doRemove) {
  7485. remove(vnode);
  7486. }
  7487. }
  7488. if ((shouldInvokeVnodeHook &&
  7489. (vnodeHook = props && props.onVnodeUnmounted)) ||
  7490. shouldInvokeDirs) {
  7491. queuePostRenderEffect(() => {
  7492. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7493. shouldInvokeDirs &&
  7494. invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
  7495. }, parentSuspense);
  7496. }
  7497. };
  7498. const remove = vnode => {
  7499. const { type, el, anchor, transition } = vnode;
  7500. if (type === Fragment) {
  7501. if (vnode.patchFlag > 0 &&
  7502. vnode.patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */ &&
  7503. transition &&
  7504. !transition.persisted) {
  7505. vnode.children.forEach(child => {
  7506. if (child.type === Comment) {
  7507. hostRemove(child.el);
  7508. }
  7509. else {
  7510. remove(child);
  7511. }
  7512. });
  7513. }
  7514. else {
  7515. removeFragment(el, anchor);
  7516. }
  7517. return;
  7518. }
  7519. if (type === Static) {
  7520. removeStaticNode(vnode);
  7521. return;
  7522. }
  7523. const performRemove = () => {
  7524. hostRemove(el);
  7525. if (transition && !transition.persisted && transition.afterLeave) {
  7526. transition.afterLeave();
  7527. }
  7528. };
  7529. if (vnode.shapeFlag & 1 /* ShapeFlags.ELEMENT */ &&
  7530. transition &&
  7531. !transition.persisted) {
  7532. const { leave, delayLeave } = transition;
  7533. const performLeave = () => leave(el, performRemove);
  7534. if (delayLeave) {
  7535. delayLeave(vnode.el, performRemove, performLeave);
  7536. }
  7537. else {
  7538. performLeave();
  7539. }
  7540. }
  7541. else {
  7542. performRemove();
  7543. }
  7544. };
  7545. const removeFragment = (cur, end) => {
  7546. // For fragments, directly remove all contained DOM nodes.
  7547. // (fragment child nodes cannot have transition)
  7548. let next;
  7549. while (cur !== end) {
  7550. next = hostNextSibling(cur);
  7551. hostRemove(cur);
  7552. cur = next;
  7553. }
  7554. hostRemove(end);
  7555. };
  7556. const unmountComponent = (instance, parentSuspense, doRemove) => {
  7557. if (instance.type.__hmrId) {
  7558. unregisterHMR(instance);
  7559. }
  7560. const { bum, scope, update, subTree, um } = instance;
  7561. // beforeUnmount hook
  7562. if (bum) {
  7563. invokeArrayFns(bum);
  7564. }
  7565. // stop effects in component scope
  7566. scope.stop();
  7567. // update may be null if a component is unmounted before its async
  7568. // setup has resolved.
  7569. if (update) {
  7570. // so that scheduler will no longer invoke it
  7571. update.active = false;
  7572. unmount(subTree, instance, parentSuspense, doRemove);
  7573. }
  7574. // unmounted hook
  7575. if (um) {
  7576. queuePostRenderEffect(um, parentSuspense);
  7577. }
  7578. queuePostRenderEffect(() => {
  7579. instance.isUnmounted = true;
  7580. }, parentSuspense);
  7581. // A component with async dep inside a pending suspense is unmounted before
  7582. // its async dep resolves. This should remove the dep from the suspense, and
  7583. // cause the suspense to resolve immediately if that was the last dep.
  7584. if (parentSuspense &&
  7585. parentSuspense.pendingBranch &&
  7586. !parentSuspense.isUnmounted &&
  7587. instance.asyncDep &&
  7588. !instance.asyncResolved &&
  7589. instance.suspenseId === parentSuspense.pendingId) {
  7590. parentSuspense.deps--;
  7591. if (parentSuspense.deps === 0) {
  7592. parentSuspense.resolve();
  7593. }
  7594. }
  7595. {
  7596. devtoolsComponentRemoved(instance);
  7597. }
  7598. };
  7599. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  7600. for (let i = start; i < children.length; i++) {
  7601. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  7602. }
  7603. };
  7604. const getNextHostNode = vnode => {
  7605. if (vnode.shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  7606. return getNextHostNode(vnode.component.subTree);
  7607. }
  7608. if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  7609. return vnode.suspense.next();
  7610. }
  7611. return hostNextSibling((vnode.anchor || vnode.el));
  7612. };
  7613. const render = (vnode, container, isSVG) => {
  7614. if (vnode == null) {
  7615. if (container._vnode) {
  7616. unmount(container._vnode, null, null, true);
  7617. }
  7618. }
  7619. else {
  7620. patch(container._vnode || null, vnode, container, null, null, null, isSVG);
  7621. }
  7622. flushPreFlushCbs();
  7623. flushPostFlushCbs();
  7624. container._vnode = vnode;
  7625. };
  7626. const internals = {
  7627. p: patch,
  7628. um: unmount,
  7629. m: move,
  7630. r: remove,
  7631. mt: mountComponent,
  7632. mc: mountChildren,
  7633. pc: patchChildren,
  7634. pbc: patchBlockChildren,
  7635. n: getNextHostNode,
  7636. o: options
  7637. };
  7638. let hydrate;
  7639. let hydrateNode;
  7640. if (createHydrationFns) {
  7641. [hydrate, hydrateNode] = createHydrationFns(internals);
  7642. }
  7643. return {
  7644. render,
  7645. hydrate,
  7646. createApp: createAppAPI(render, hydrate)
  7647. };
  7648. }
  7649. function toggleRecurse({ effect, update }, allowed) {
  7650. effect.allowRecurse = update.allowRecurse = allowed;
  7651. }
  7652. /**
  7653. * #1156
  7654. * When a component is HMR-enabled, we need to make sure that all static nodes
  7655. * inside a block also inherit the DOM element from the previous tree so that
  7656. * HMR updates (which are full updates) can retrieve the element for patching.
  7657. *
  7658. * #2080
  7659. * Inside keyed `template` fragment static children, if a fragment is moved,
  7660. * the children will always be moved. Therefore, in order to ensure correct move
  7661. * position, el should be inherited from previous nodes.
  7662. */
  7663. function traverseStaticChildren(n1, n2, shallow = false) {
  7664. const ch1 = n1.children;
  7665. const ch2 = n2.children;
  7666. if (isArray(ch1) && isArray(ch2)) {
  7667. for (let i = 0; i < ch1.length; i++) {
  7668. // this is only called in the optimized path so array children are
  7669. // guaranteed to be vnodes
  7670. const c1 = ch1[i];
  7671. let c2 = ch2[i];
  7672. if (c2.shapeFlag & 1 /* ShapeFlags.ELEMENT */ && !c2.dynamicChildren) {
  7673. if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* PatchFlags.HYDRATE_EVENTS */) {
  7674. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  7675. c2.el = c1.el;
  7676. }
  7677. if (!shallow)
  7678. traverseStaticChildren(c1, c2);
  7679. }
  7680. // #6852 also inherit for text nodes
  7681. if (c2.type === Text) {
  7682. c2.el = c1.el;
  7683. }
  7684. // also inherit for comment nodes, but not placeholders (e.g. v-if which
  7685. // would have received .el during block patch)
  7686. if (c2.type === Comment && !c2.el) {
  7687. c2.el = c1.el;
  7688. }
  7689. }
  7690. }
  7691. }
  7692. // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
  7693. function getSequence(arr) {
  7694. const p = arr.slice();
  7695. const result = [0];
  7696. let i, j, u, v, c;
  7697. const len = arr.length;
  7698. for (i = 0; i < len; i++) {
  7699. const arrI = arr[i];
  7700. if (arrI !== 0) {
  7701. j = result[result.length - 1];
  7702. if (arr[j] < arrI) {
  7703. p[i] = j;
  7704. result.push(i);
  7705. continue;
  7706. }
  7707. u = 0;
  7708. v = result.length - 1;
  7709. while (u < v) {
  7710. c = (u + v) >> 1;
  7711. if (arr[result[c]] < arrI) {
  7712. u = c + 1;
  7713. }
  7714. else {
  7715. v = c;
  7716. }
  7717. }
  7718. if (arrI < arr[result[u]]) {
  7719. if (u > 0) {
  7720. p[i] = result[u - 1];
  7721. }
  7722. result[u] = i;
  7723. }
  7724. }
  7725. }
  7726. u = result.length;
  7727. v = result[u - 1];
  7728. while (u-- > 0) {
  7729. result[u] = v;
  7730. v = p[v];
  7731. }
  7732. return result;
  7733. }
  7734. const isTeleport = (type) => type.__isTeleport;
  7735. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
  7736. const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
  7737. const resolveTarget = (props, select) => {
  7738. const targetSelector = props && props.to;
  7739. if (isString(targetSelector)) {
  7740. if (!select) {
  7741. warn$1(`Current renderer does not support string target for Teleports. ` +
  7742. `(missing querySelector renderer option)`);
  7743. return null;
  7744. }
  7745. else {
  7746. const target = select(targetSelector);
  7747. if (!target) {
  7748. warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
  7749. `Note the target element must exist before the component is mounted - ` +
  7750. `i.e. the target cannot be rendered by the component itself, and ` +
  7751. `ideally should be outside of the entire Vue component tree.`);
  7752. }
  7753. return target;
  7754. }
  7755. }
  7756. else {
  7757. if (!targetSelector && !isTeleportDisabled(props)) {
  7758. warn$1(`Invalid Teleport target: ${targetSelector}`);
  7759. }
  7760. return targetSelector;
  7761. }
  7762. };
  7763. const TeleportImpl = {
  7764. __isTeleport: true,
  7765. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
  7766. const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
  7767. const disabled = isTeleportDisabled(n2.props);
  7768. let { shapeFlag, children, dynamicChildren } = n2;
  7769. // #3302
  7770. // HMR updated, force full diff
  7771. if (isHmrUpdating) {
  7772. optimized = false;
  7773. dynamicChildren = null;
  7774. }
  7775. if (n1 == null) {
  7776. // insert anchors in the main view
  7777. const placeholder = (n2.el = createComment('teleport start')
  7778. );
  7779. const mainAnchor = (n2.anchor = createComment('teleport end')
  7780. );
  7781. insert(placeholder, container, anchor);
  7782. insert(mainAnchor, container, anchor);
  7783. const target = (n2.target = resolveTarget(n2.props, querySelector));
  7784. const targetAnchor = (n2.targetAnchor = createText(''));
  7785. if (target) {
  7786. insert(targetAnchor, target);
  7787. // #2652 we could be teleporting from a non-SVG tree into an SVG tree
  7788. isSVG = isSVG || isTargetSVG(target);
  7789. }
  7790. else if (!disabled) {
  7791. warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
  7792. }
  7793. const mount = (container, anchor) => {
  7794. // Teleport *always* has Array children. This is enforced in both the
  7795. // compiler and vnode children normalization.
  7796. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7797. mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7798. }
  7799. };
  7800. if (disabled) {
  7801. mount(container, mainAnchor);
  7802. }
  7803. else if (target) {
  7804. mount(target, targetAnchor);
  7805. }
  7806. }
  7807. else {
  7808. // update content
  7809. n2.el = n1.el;
  7810. const mainAnchor = (n2.anchor = n1.anchor);
  7811. const target = (n2.target = n1.target);
  7812. const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
  7813. const wasDisabled = isTeleportDisabled(n1.props);
  7814. const currentContainer = wasDisabled ? container : target;
  7815. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  7816. isSVG = isSVG || isTargetSVG(target);
  7817. if (dynamicChildren) {
  7818. // fast path when the teleport happens to be a block root
  7819. patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
  7820. // even in block tree mode we need to make sure all root-level nodes
  7821. // in the teleport inherit previous DOM references so that they can
  7822. // be moved in future patches.
  7823. traverseStaticChildren(n1, n2, true);
  7824. }
  7825. else if (!optimized) {
  7826. patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
  7827. }
  7828. if (disabled) {
  7829. if (!wasDisabled) {
  7830. // enabled -> disabled
  7831. // move into main container
  7832. moveTeleport(n2, container, mainAnchor, internals, 1 /* TeleportMoveTypes.TOGGLE */);
  7833. }
  7834. }
  7835. else {
  7836. // target changed
  7837. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  7838. const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
  7839. if (nextTarget) {
  7840. moveTeleport(n2, nextTarget, null, internals, 0 /* TeleportMoveTypes.TARGET_CHANGE */);
  7841. }
  7842. else {
  7843. warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
  7844. }
  7845. }
  7846. else if (wasDisabled) {
  7847. // disabled -> enabled
  7848. // move into teleport target
  7849. moveTeleport(n2, target, targetAnchor, internals, 1 /* TeleportMoveTypes.TOGGLE */);
  7850. }
  7851. }
  7852. }
  7853. updateCssVars(n2);
  7854. },
  7855. remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
  7856. const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
  7857. if (target) {
  7858. hostRemove(targetAnchor);
  7859. }
  7860. // an unmounted teleport should always remove its children if not disabled
  7861. if (doRemove || !isTeleportDisabled(props)) {
  7862. hostRemove(anchor);
  7863. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7864. for (let i = 0; i < children.length; i++) {
  7865. const child = children[i];
  7866. unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
  7867. }
  7868. }
  7869. }
  7870. },
  7871. move: moveTeleport,
  7872. hydrate: hydrateTeleport
  7873. };
  7874. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* TeleportMoveTypes.REORDER */) {
  7875. // move target anchor if this is a target change.
  7876. if (moveType === 0 /* TeleportMoveTypes.TARGET_CHANGE */) {
  7877. insert(vnode.targetAnchor, container, parentAnchor);
  7878. }
  7879. const { el, anchor, shapeFlag, children, props } = vnode;
  7880. const isReorder = moveType === 2 /* TeleportMoveTypes.REORDER */;
  7881. // move main view anchor if this is a re-order.
  7882. if (isReorder) {
  7883. insert(el, container, parentAnchor);
  7884. }
  7885. // if this is a re-order and teleport is enabled (content is in target)
  7886. // do not move children. So the opposite is: only move children if this
  7887. // is not a reorder, or the teleport is disabled
  7888. if (!isReorder || isTeleportDisabled(props)) {
  7889. // Teleport has either Array children or no children.
  7890. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7891. for (let i = 0; i < children.length; i++) {
  7892. move(children[i], container, parentAnchor, 2 /* MoveType.REORDER */);
  7893. }
  7894. }
  7895. }
  7896. // move main view anchor if this is a re-order.
  7897. if (isReorder) {
  7898. insert(anchor, container, parentAnchor);
  7899. }
  7900. }
  7901. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
  7902. const target = (vnode.target = resolveTarget(vnode.props, querySelector));
  7903. if (target) {
  7904. // if multiple teleports rendered to the same target element, we need to
  7905. // pick up from where the last teleport finished instead of the first node
  7906. const targetNode = target._lpa || target.firstChild;
  7907. if (vnode.shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7908. if (isTeleportDisabled(vnode.props)) {
  7909. vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
  7910. vnode.targetAnchor = targetNode;
  7911. }
  7912. else {
  7913. vnode.anchor = nextSibling(node);
  7914. // lookahead until we find the target anchor
  7915. // we cannot rely on return value of hydrateChildren() because there
  7916. // could be nested teleports
  7917. let targetAnchor = targetNode;
  7918. while (targetAnchor) {
  7919. targetAnchor = nextSibling(targetAnchor);
  7920. if (targetAnchor &&
  7921. targetAnchor.nodeType === 8 &&
  7922. targetAnchor.data === 'teleport anchor') {
  7923. vnode.targetAnchor = targetAnchor;
  7924. target._lpa =
  7925. vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  7926. break;
  7927. }
  7928. }
  7929. hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
  7930. }
  7931. }
  7932. updateCssVars(vnode);
  7933. }
  7934. return vnode.anchor && nextSibling(vnode.anchor);
  7935. }
  7936. // Force-casted public typing for h and TSX props inference
  7937. const Teleport = TeleportImpl;
  7938. function updateCssVars(vnode) {
  7939. // presence of .ut method indicates owner component uses css vars.
  7940. // code path here can assume browser environment.
  7941. const ctx = vnode.ctx;
  7942. if (ctx && ctx.ut) {
  7943. let node = vnode.children[0].el;
  7944. while (node !== vnode.targetAnchor) {
  7945. if (node.nodeType === 1)
  7946. node.setAttribute('data-v-owner', ctx.uid);
  7947. node = node.nextSibling;
  7948. }
  7949. ctx.ut();
  7950. }
  7951. }
  7952. const Fragment = Symbol('Fragment' );
  7953. const Text = Symbol('Text' );
  7954. const Comment = Symbol('Comment' );
  7955. const Static = Symbol('Static' );
  7956. // Since v-if and v-for are the two possible ways node structure can dynamically
  7957. // change, once we consider v-if branches and each v-for fragment a block, we
  7958. // can divide a template into nested blocks, and within each block the node
  7959. // structure would be stable. This allows us to skip most children diffing
  7960. // and only worry about the dynamic nodes (indicated by patch flags).
  7961. const blockStack = [];
  7962. let currentBlock = null;
  7963. /**
  7964. * Open a block.
  7965. * This must be called before `createBlock`. It cannot be part of `createBlock`
  7966. * because the children of the block are evaluated before `createBlock` itself
  7967. * is called. The generated code typically looks like this:
  7968. *
  7969. * ```js
  7970. * function render() {
  7971. * return (openBlock(),createBlock('div', null, [...]))
  7972. * }
  7973. * ```
  7974. * disableTracking is true when creating a v-for fragment block, since a v-for
  7975. * fragment always diffs its children.
  7976. *
  7977. * @private
  7978. */
  7979. function openBlock(disableTracking = false) {
  7980. blockStack.push((currentBlock = disableTracking ? null : []));
  7981. }
  7982. function closeBlock() {
  7983. blockStack.pop();
  7984. currentBlock = blockStack[blockStack.length - 1] || null;
  7985. }
  7986. // Whether we should be tracking dynamic child nodes inside a block.
  7987. // Only tracks when this value is > 0
  7988. // We are not using a simple boolean because this value may need to be
  7989. // incremented/decremented by nested usage of v-once (see below)
  7990. let isBlockTreeEnabled = 1;
  7991. /**
  7992. * Block tracking sometimes needs to be disabled, for example during the
  7993. * creation of a tree that needs to be cached by v-once. The compiler generates
  7994. * code like this:
  7995. *
  7996. * ``` js
  7997. * _cache[1] || (
  7998. * setBlockTracking(-1),
  7999. * _cache[1] = createVNode(...),
  8000. * setBlockTracking(1),
  8001. * _cache[1]
  8002. * )
  8003. * ```
  8004. *
  8005. * @private
  8006. */
  8007. function setBlockTracking(value) {
  8008. isBlockTreeEnabled += value;
  8009. }
  8010. function setupBlock(vnode) {
  8011. // save current block children on the block vnode
  8012. vnode.dynamicChildren =
  8013. isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
  8014. // close block
  8015. closeBlock();
  8016. // a block is always going to be patched, so track it as a child of its
  8017. // parent block
  8018. if (isBlockTreeEnabled > 0 && currentBlock) {
  8019. currentBlock.push(vnode);
  8020. }
  8021. return vnode;
  8022. }
  8023. /**
  8024. * @private
  8025. */
  8026. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  8027. return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true /* isBlock */));
  8028. }
  8029. /**
  8030. * Create a block root vnode. Takes the same exact arguments as `createVNode`.
  8031. * A block root keeps track of dynamic nodes within the block in the
  8032. * `dynamicChildren` array.
  8033. *
  8034. * @private
  8035. */
  8036. function createBlock(type, props, children, patchFlag, dynamicProps) {
  8037. return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */));
  8038. }
  8039. function isVNode(value) {
  8040. return value ? value.__v_isVNode === true : false;
  8041. }
  8042. function isSameVNodeType(n1, n2) {
  8043. if (n2.shapeFlag & 6 /* ShapeFlags.COMPONENT */ &&
  8044. hmrDirtyComponents.has(n2.type)) {
  8045. // #7042, ensure the vnode being unmounted during HMR
  8046. // bitwise operations to remove keep alive flags
  8047. n1.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
  8048. n2.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
  8049. // HMR only: if the component has been hot-updated, force a reload.
  8050. return false;
  8051. }
  8052. return n1.type === n2.type && n1.key === n2.key;
  8053. }
  8054. let vnodeArgsTransformer;
  8055. /**
  8056. * Internal API for registering an arguments transform for createVNode
  8057. * used for creating stubs in the test-utils
  8058. * It is *internal* but needs to be exposed for test-utils to pick up proper
  8059. * typings
  8060. */
  8061. function transformVNodeArgs(transformer) {
  8062. vnodeArgsTransformer = transformer;
  8063. }
  8064. const createVNodeWithArgsTransform = (...args) => {
  8065. return _createVNode(...(vnodeArgsTransformer
  8066. ? vnodeArgsTransformer(args, currentRenderingInstance)
  8067. : args));
  8068. };
  8069. const InternalObjectKey = `__vInternal`;
  8070. const normalizeKey = ({ key }) => key != null ? key : null;
  8071. const normalizeRef = ({ ref, ref_key, ref_for }) => {
  8072. return (ref != null
  8073. ? isString(ref) || isRef(ref) || isFunction(ref)
  8074. ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
  8075. : ref
  8076. : null);
  8077. };
  8078. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ShapeFlags.ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
  8079. const vnode = {
  8080. __v_isVNode: true,
  8081. __v_skip: true,
  8082. type,
  8083. props,
  8084. key: props && normalizeKey(props),
  8085. ref: props && normalizeRef(props),
  8086. scopeId: currentScopeId,
  8087. slotScopeIds: null,
  8088. children,
  8089. component: null,
  8090. suspense: null,
  8091. ssContent: null,
  8092. ssFallback: null,
  8093. dirs: null,
  8094. transition: null,
  8095. el: null,
  8096. anchor: null,
  8097. target: null,
  8098. targetAnchor: null,
  8099. staticCount: 0,
  8100. shapeFlag,
  8101. patchFlag,
  8102. dynamicProps,
  8103. dynamicChildren: null,
  8104. appContext: null,
  8105. ctx: currentRenderingInstance
  8106. };
  8107. if (needFullChildrenNormalization) {
  8108. normalizeChildren(vnode, children);
  8109. // normalize suspense children
  8110. if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  8111. type.normalize(vnode);
  8112. }
  8113. }
  8114. else if (children) {
  8115. // compiled element vnode - if children is passed, only possible types are
  8116. // string or Array.
  8117. vnode.shapeFlag |= isString(children)
  8118. ? 8 /* ShapeFlags.TEXT_CHILDREN */
  8119. : 16 /* ShapeFlags.ARRAY_CHILDREN */;
  8120. }
  8121. // validate key
  8122. if (vnode.key !== vnode.key) {
  8123. warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  8124. }
  8125. // track vnode for block tree
  8126. if (isBlockTreeEnabled > 0 &&
  8127. // avoid a block node from tracking itself
  8128. !isBlockNode &&
  8129. // has current parent block
  8130. currentBlock &&
  8131. // presence of a patch flag indicates this node needs patching on updates.
  8132. // component nodes also should always be patched, because even if the
  8133. // component doesn't need to update, it needs to persist the instance on to
  8134. // the next vnode so that it can be properly unmounted later.
  8135. (vnode.patchFlag > 0 || shapeFlag & 6 /* ShapeFlags.COMPONENT */) &&
  8136. // the EVENTS flag is only for hydration and if it is the only flag, the
  8137. // vnode should not be considered dynamic due to handler caching.
  8138. vnode.patchFlag !== 32 /* PatchFlags.HYDRATE_EVENTS */) {
  8139. currentBlock.push(vnode);
  8140. }
  8141. return vnode;
  8142. }
  8143. const createVNode = (createVNodeWithArgsTransform );
  8144. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  8145. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  8146. if (!type) {
  8147. warn$1(`Invalid vnode type when creating vnode: ${type}.`);
  8148. }
  8149. type = Comment;
  8150. }
  8151. if (isVNode(type)) {
  8152. // createVNode receiving an existing vnode. This happens in cases like
  8153. // <component :is="vnode"/>
  8154. // #2078 make sure to merge refs during the clone instead of overwriting it
  8155. const cloned = cloneVNode(type, props, true /* mergeRef: true */);
  8156. if (children) {
  8157. normalizeChildren(cloned, children);
  8158. }
  8159. if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
  8160. if (cloned.shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  8161. currentBlock[currentBlock.indexOf(type)] = cloned;
  8162. }
  8163. else {
  8164. currentBlock.push(cloned);
  8165. }
  8166. }
  8167. cloned.patchFlag |= -2 /* PatchFlags.BAIL */;
  8168. return cloned;
  8169. }
  8170. // class component normalization.
  8171. if (isClassComponent(type)) {
  8172. type = type.__vccOpts;
  8173. }
  8174. // class & style normalization.
  8175. if (props) {
  8176. // for reactive or proxy objects, we need to clone it to enable mutation.
  8177. props = guardReactiveProps(props);
  8178. let { class: klass, style } = props;
  8179. if (klass && !isString(klass)) {
  8180. props.class = normalizeClass(klass);
  8181. }
  8182. if (isObject(style)) {
  8183. // reactive state objects need to be cloned since they are likely to be
  8184. // mutated
  8185. if (isProxy(style) && !isArray(style)) {
  8186. style = extend({}, style);
  8187. }
  8188. props.style = normalizeStyle(style);
  8189. }
  8190. }
  8191. // encode the vnode type information into a bitmap
  8192. const shapeFlag = isString(type)
  8193. ? 1 /* ShapeFlags.ELEMENT */
  8194. : isSuspense(type)
  8195. ? 128 /* ShapeFlags.SUSPENSE */
  8196. : isTeleport(type)
  8197. ? 64 /* ShapeFlags.TELEPORT */
  8198. : isObject(type)
  8199. ? 4 /* ShapeFlags.STATEFUL_COMPONENT */
  8200. : isFunction(type)
  8201. ? 2 /* ShapeFlags.FUNCTIONAL_COMPONENT */
  8202. : 0;
  8203. if (shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */ && isProxy(type)) {
  8204. type = toRaw(type);
  8205. warn$1(`Vue received a Component which was made a reactive object. This can ` +
  8206. `lead to unnecessary performance overhead, and should be avoided by ` +
  8207. `marking the component with \`markRaw\` or using \`shallowRef\` ` +
  8208. `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
  8209. }
  8210. return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
  8211. }
  8212. function guardReactiveProps(props) {
  8213. if (!props)
  8214. return null;
  8215. return isProxy(props) || InternalObjectKey in props
  8216. ? extend({}, props)
  8217. : props;
  8218. }
  8219. function cloneVNode(vnode, extraProps, mergeRef = false) {
  8220. // This is intentionally NOT using spread or extend to avoid the runtime
  8221. // key enumeration cost.
  8222. const { props, ref, patchFlag, children } = vnode;
  8223. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  8224. const cloned = {
  8225. __v_isVNode: true,
  8226. __v_skip: true,
  8227. type: vnode.type,
  8228. props: mergedProps,
  8229. key: mergedProps && normalizeKey(mergedProps),
  8230. ref: extraProps && extraProps.ref
  8231. ? // #2078 in the case of <component :is="vnode" ref="extra"/>
  8232. // if the vnode itself already has a ref, cloneVNode will need to merge
  8233. // the refs so the single vnode can be set on multiple refs
  8234. mergeRef && ref
  8235. ? isArray(ref)
  8236. ? ref.concat(normalizeRef(extraProps))
  8237. : [ref, normalizeRef(extraProps)]
  8238. : normalizeRef(extraProps)
  8239. : ref,
  8240. scopeId: vnode.scopeId,
  8241. slotScopeIds: vnode.slotScopeIds,
  8242. children: patchFlag === -1 /* PatchFlags.HOISTED */ && isArray(children)
  8243. ? children.map(deepCloneVNode)
  8244. : children,
  8245. target: vnode.target,
  8246. targetAnchor: vnode.targetAnchor,
  8247. staticCount: vnode.staticCount,
  8248. shapeFlag: vnode.shapeFlag,
  8249. // if the vnode is cloned with extra props, we can no longer assume its
  8250. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  8251. // note: preserve flag for fragments since they use the flag for children
  8252. // fast paths only.
  8253. patchFlag: extraProps && vnode.type !== Fragment
  8254. ? patchFlag === -1 // hoisted node
  8255. ? 16 /* PatchFlags.FULL_PROPS */
  8256. : patchFlag | 16 /* PatchFlags.FULL_PROPS */
  8257. : patchFlag,
  8258. dynamicProps: vnode.dynamicProps,
  8259. dynamicChildren: vnode.dynamicChildren,
  8260. appContext: vnode.appContext,
  8261. dirs: vnode.dirs,
  8262. transition: vnode.transition,
  8263. // These should technically only be non-null on mounted VNodes. However,
  8264. // they *should* be copied for kept-alive vnodes. So we just always copy
  8265. // them since them being non-null during a mount doesn't affect the logic as
  8266. // they will simply be overwritten.
  8267. component: vnode.component,
  8268. suspense: vnode.suspense,
  8269. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  8270. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  8271. el: vnode.el,
  8272. anchor: vnode.anchor,
  8273. ctx: vnode.ctx
  8274. };
  8275. return cloned;
  8276. }
  8277. /**
  8278. * Dev only, for HMR of hoisted vnodes reused in v-for
  8279. * https://github.com/vitejs/vite/issues/2022
  8280. */
  8281. function deepCloneVNode(vnode) {
  8282. const cloned = cloneVNode(vnode);
  8283. if (isArray(vnode.children)) {
  8284. cloned.children = vnode.children.map(deepCloneVNode);
  8285. }
  8286. return cloned;
  8287. }
  8288. /**
  8289. * @private
  8290. */
  8291. function createTextVNode(text = ' ', flag = 0) {
  8292. return createVNode(Text, null, text, flag);
  8293. }
  8294. /**
  8295. * @private
  8296. */
  8297. function createStaticVNode(content, numberOfNodes) {
  8298. // A static vnode can contain multiple stringified elements, and the number
  8299. // of elements is necessary for hydration.
  8300. const vnode = createVNode(Static, null, content);
  8301. vnode.staticCount = numberOfNodes;
  8302. return vnode;
  8303. }
  8304. /**
  8305. * @private
  8306. */
  8307. function createCommentVNode(text = '',
  8308. // when used as the v-else branch, the comment node must be created as a
  8309. // block to ensure correct updates.
  8310. asBlock = false) {
  8311. return asBlock
  8312. ? (openBlock(), createBlock(Comment, null, text))
  8313. : createVNode(Comment, null, text);
  8314. }
  8315. function normalizeVNode(child) {
  8316. if (child == null || typeof child === 'boolean') {
  8317. // empty placeholder
  8318. return createVNode(Comment);
  8319. }
  8320. else if (isArray(child)) {
  8321. // fragment
  8322. return createVNode(Fragment, null,
  8323. // #3666, avoid reference pollution when reusing vnode
  8324. child.slice());
  8325. }
  8326. else if (typeof child === 'object') {
  8327. // already vnode, this should be the most common since compiled templates
  8328. // always produce all-vnode children arrays
  8329. return cloneIfMounted(child);
  8330. }
  8331. else {
  8332. // strings and numbers
  8333. return createVNode(Text, null, String(child));
  8334. }
  8335. }
  8336. // optimized normalization for template-compiled render fns
  8337. function cloneIfMounted(child) {
  8338. return (child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */) ||
  8339. child.memo
  8340. ? child
  8341. : cloneVNode(child);
  8342. }
  8343. function normalizeChildren(vnode, children) {
  8344. let type = 0;
  8345. const { shapeFlag } = vnode;
  8346. if (children == null) {
  8347. children = null;
  8348. }
  8349. else if (isArray(children)) {
  8350. type = 16 /* ShapeFlags.ARRAY_CHILDREN */;
  8351. }
  8352. else if (typeof children === 'object') {
  8353. if (shapeFlag & (1 /* ShapeFlags.ELEMENT */ | 64 /* ShapeFlags.TELEPORT */)) {
  8354. // Normalize slot to plain children for plain element and Teleport
  8355. const slot = children.default;
  8356. if (slot) {
  8357. // _c marker is added by withCtx() indicating this is a compiled slot
  8358. slot._c && (slot._d = false);
  8359. normalizeChildren(vnode, slot());
  8360. slot._c && (slot._d = true);
  8361. }
  8362. return;
  8363. }
  8364. else {
  8365. type = 32 /* ShapeFlags.SLOTS_CHILDREN */;
  8366. const slotFlag = children._;
  8367. if (!slotFlag && !(InternalObjectKey in children)) {
  8368. children._ctx = currentRenderingInstance;
  8369. }
  8370. else if (slotFlag === 3 /* SlotFlags.FORWARDED */ && currentRenderingInstance) {
  8371. // a child component receives forwarded slots from the parent.
  8372. // its slot type is determined by its parent's slot type.
  8373. if (currentRenderingInstance.slots._ === 1 /* SlotFlags.STABLE */) {
  8374. children._ = 1 /* SlotFlags.STABLE */;
  8375. }
  8376. else {
  8377. children._ = 2 /* SlotFlags.DYNAMIC */;
  8378. vnode.patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
  8379. }
  8380. }
  8381. }
  8382. }
  8383. else if (isFunction(children)) {
  8384. children = { default: children, _ctx: currentRenderingInstance };
  8385. type = 32 /* ShapeFlags.SLOTS_CHILDREN */;
  8386. }
  8387. else {
  8388. children = String(children);
  8389. // force teleport children to array so it can be moved around
  8390. if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  8391. type = 16 /* ShapeFlags.ARRAY_CHILDREN */;
  8392. children = [createTextVNode(children)];
  8393. }
  8394. else {
  8395. type = 8 /* ShapeFlags.TEXT_CHILDREN */;
  8396. }
  8397. }
  8398. vnode.children = children;
  8399. vnode.shapeFlag |= type;
  8400. }
  8401. function mergeProps(...args) {
  8402. const ret = {};
  8403. for (let i = 0; i < args.length; i++) {
  8404. const toMerge = args[i];
  8405. for (const key in toMerge) {
  8406. if (key === 'class') {
  8407. if (ret.class !== toMerge.class) {
  8408. ret.class = normalizeClass([ret.class, toMerge.class]);
  8409. }
  8410. }
  8411. else if (key === 'style') {
  8412. ret.style = normalizeStyle([ret.style, toMerge.style]);
  8413. }
  8414. else if (isOn(key)) {
  8415. const existing = ret[key];
  8416. const incoming = toMerge[key];
  8417. if (incoming &&
  8418. existing !== incoming &&
  8419. !(isArray(existing) && existing.includes(incoming))) {
  8420. ret[key] = existing
  8421. ? [].concat(existing, incoming)
  8422. : incoming;
  8423. }
  8424. }
  8425. else if (key !== '') {
  8426. ret[key] = toMerge[key];
  8427. }
  8428. }
  8429. }
  8430. return ret;
  8431. }
  8432. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  8433. callWithAsyncErrorHandling(hook, instance, 7 /* ErrorCodes.VNODE_HOOK */, [
  8434. vnode,
  8435. prevVNode
  8436. ]);
  8437. }
  8438. const emptyAppContext = createAppContext();
  8439. let uid$1 = 0;
  8440. function createComponentInstance(vnode, parent, suspense) {
  8441. const type = vnode.type;
  8442. // inherit parent app context - or - if root, adopt from root vnode
  8443. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  8444. const instance = {
  8445. uid: uid$1++,
  8446. vnode,
  8447. type,
  8448. parent,
  8449. appContext,
  8450. root: null,
  8451. next: null,
  8452. subTree: null,
  8453. effect: null,
  8454. update: null,
  8455. scope: new EffectScope(true /* detached */),
  8456. render: null,
  8457. proxy: null,
  8458. exposed: null,
  8459. exposeProxy: null,
  8460. withProxy: null,
  8461. provides: parent ? parent.provides : Object.create(appContext.provides),
  8462. accessCache: null,
  8463. renderCache: [],
  8464. // local resolved assets
  8465. components: null,
  8466. directives: null,
  8467. // resolved props and emits options
  8468. propsOptions: normalizePropsOptions(type, appContext),
  8469. emitsOptions: normalizeEmitsOptions(type, appContext),
  8470. // emit
  8471. emit: null,
  8472. emitted: null,
  8473. // props default value
  8474. propsDefaults: EMPTY_OBJ,
  8475. // inheritAttrs
  8476. inheritAttrs: type.inheritAttrs,
  8477. // state
  8478. ctx: EMPTY_OBJ,
  8479. data: EMPTY_OBJ,
  8480. props: EMPTY_OBJ,
  8481. attrs: EMPTY_OBJ,
  8482. slots: EMPTY_OBJ,
  8483. refs: EMPTY_OBJ,
  8484. setupState: EMPTY_OBJ,
  8485. setupContext: null,
  8486. // suspense related
  8487. suspense,
  8488. suspenseId: suspense ? suspense.pendingId : 0,
  8489. asyncDep: null,
  8490. asyncResolved: false,
  8491. // lifecycle hooks
  8492. // not using enums here because it results in computed properties
  8493. isMounted: false,
  8494. isUnmounted: false,
  8495. isDeactivated: false,
  8496. bc: null,
  8497. c: null,
  8498. bm: null,
  8499. m: null,
  8500. bu: null,
  8501. u: null,
  8502. um: null,
  8503. bum: null,
  8504. da: null,
  8505. a: null,
  8506. rtg: null,
  8507. rtc: null,
  8508. ec: null,
  8509. sp: null
  8510. };
  8511. {
  8512. instance.ctx = createDevRenderContext(instance);
  8513. }
  8514. instance.root = parent ? parent.root : instance;
  8515. instance.emit = emit$1.bind(null, instance);
  8516. // apply custom element special handling
  8517. if (vnode.ce) {
  8518. vnode.ce(instance);
  8519. }
  8520. return instance;
  8521. }
  8522. let currentInstance = null;
  8523. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  8524. const setCurrentInstance = (instance) => {
  8525. currentInstance = instance;
  8526. instance.scope.on();
  8527. };
  8528. const unsetCurrentInstance = () => {
  8529. currentInstance && currentInstance.scope.off();
  8530. currentInstance = null;
  8531. };
  8532. const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');
  8533. function validateComponentName(name, config) {
  8534. const appIsNativeTag = config.isNativeTag || NO;
  8535. if (isBuiltInTag(name) || appIsNativeTag(name)) {
  8536. warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
  8537. }
  8538. }
  8539. function isStatefulComponent(instance) {
  8540. return instance.vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */;
  8541. }
  8542. let isInSSRComponentSetup = false;
  8543. function setupComponent(instance, isSSR = false) {
  8544. isInSSRComponentSetup = isSSR;
  8545. const { props, children } = instance.vnode;
  8546. const isStateful = isStatefulComponent(instance);
  8547. initProps(instance, props, isStateful, isSSR);
  8548. initSlots(instance, children);
  8549. const setupResult = isStateful
  8550. ? setupStatefulComponent(instance, isSSR)
  8551. : undefined;
  8552. isInSSRComponentSetup = false;
  8553. return setupResult;
  8554. }
  8555. function setupStatefulComponent(instance, isSSR) {
  8556. var _a;
  8557. const Component = instance.type;
  8558. {
  8559. if (Component.name) {
  8560. validateComponentName(Component.name, instance.appContext.config);
  8561. }
  8562. if (Component.components) {
  8563. const names = Object.keys(Component.components);
  8564. for (let i = 0; i < names.length; i++) {
  8565. validateComponentName(names[i], instance.appContext.config);
  8566. }
  8567. }
  8568. if (Component.directives) {
  8569. const names = Object.keys(Component.directives);
  8570. for (let i = 0; i < names.length; i++) {
  8571. validateDirectiveName(names[i]);
  8572. }
  8573. }
  8574. if (Component.compilerOptions && isRuntimeOnly()) {
  8575. warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
  8576. `includes the runtime compiler. Since you are using a runtime-only ` +
  8577. `build, the options should be passed via your build tool config instead.`);
  8578. }
  8579. }
  8580. // 0. create render proxy property access cache
  8581. instance.accessCache = Object.create(null);
  8582. // 1. create public instance / render proxy
  8583. // also mark it raw so it's never observed
  8584. instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
  8585. {
  8586. exposePropsOnRenderContext(instance);
  8587. }
  8588. // 2. call setup()
  8589. const { setup } = Component;
  8590. if (setup) {
  8591. const setupContext = (instance.setupContext =
  8592. setup.length > 1 ? createSetupContext(instance) : null);
  8593. setCurrentInstance(instance);
  8594. pauseTracking();
  8595. const setupResult = callWithErrorHandling(setup, instance, 0 /* ErrorCodes.SETUP_FUNCTION */, [shallowReadonly(instance.props) , setupContext]);
  8596. resetTracking();
  8597. unsetCurrentInstance();
  8598. if (isPromise(setupResult)) {
  8599. setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
  8600. if (isSSR) {
  8601. // return the promise so server-renderer can wait on it
  8602. return setupResult
  8603. .then((resolvedResult) => {
  8604. handleSetupResult(instance, resolvedResult, isSSR);
  8605. })
  8606. .catch(e => {
  8607. handleError(e, instance, 0 /* ErrorCodes.SETUP_FUNCTION */);
  8608. });
  8609. }
  8610. else {
  8611. // async setup returned Promise.
  8612. // bail here and wait for re-entry.
  8613. instance.asyncDep = setupResult;
  8614. if (!instance.suspense) {
  8615. const name = (_a = Component.name) !== null && _a !== void 0 ? _a : 'Anonymous';
  8616. warn$1(`Component <${name}>: setup function returned a promise, but no ` +
  8617. `<Suspense> boundary was found in the parent component tree. ` +
  8618. `A component with async setup() must be nested in a <Suspense> ` +
  8619. `in order to be rendered.`);
  8620. }
  8621. }
  8622. }
  8623. else {
  8624. handleSetupResult(instance, setupResult, isSSR);
  8625. }
  8626. }
  8627. else {
  8628. finishComponentSetup(instance, isSSR);
  8629. }
  8630. }
  8631. function handleSetupResult(instance, setupResult, isSSR) {
  8632. if (isFunction(setupResult)) {
  8633. // setup returned an inline render function
  8634. {
  8635. instance.render = setupResult;
  8636. }
  8637. }
  8638. else if (isObject(setupResult)) {
  8639. if (isVNode(setupResult)) {
  8640. warn$1(`setup() should not return VNodes directly - ` +
  8641. `return a render function instead.`);
  8642. }
  8643. // setup returned bindings.
  8644. // assuming a render function compiled from template is present.
  8645. {
  8646. instance.devtoolsRawSetupState = setupResult;
  8647. }
  8648. instance.setupState = proxyRefs(setupResult);
  8649. {
  8650. exposeSetupStateOnRenderContext(instance);
  8651. }
  8652. }
  8653. else if (setupResult !== undefined) {
  8654. warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  8655. }
  8656. finishComponentSetup(instance, isSSR);
  8657. }
  8658. let compile;
  8659. let installWithProxy;
  8660. /**
  8661. * For runtime-dom to register the compiler.
  8662. * Note the exported method uses any to avoid d.ts relying on the compiler types.
  8663. */
  8664. function registerRuntimeCompiler(_compile) {
  8665. compile = _compile;
  8666. installWithProxy = i => {
  8667. if (i.render._rc) {
  8668. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  8669. }
  8670. };
  8671. }
  8672. // dev only
  8673. const isRuntimeOnly = () => !compile;
  8674. function finishComponentSetup(instance, isSSR, skipOptions) {
  8675. const Component = instance.type;
  8676. // template / render function normalization
  8677. // could be already set when returned from setup()
  8678. if (!instance.render) {
  8679. // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
  8680. // is done by server-renderer
  8681. if (!isSSR && compile && !Component.render) {
  8682. const template = Component.template ||
  8683. resolveMergedOptions(instance).template;
  8684. if (template) {
  8685. {
  8686. startMeasure(instance, `compile`);
  8687. }
  8688. const { isCustomElement, compilerOptions } = instance.appContext.config;
  8689. const { delimiters, compilerOptions: componentCompilerOptions } = Component;
  8690. const finalCompilerOptions = extend(extend({
  8691. isCustomElement,
  8692. delimiters
  8693. }, compilerOptions), componentCompilerOptions);
  8694. Component.render = compile(template, finalCompilerOptions);
  8695. {
  8696. endMeasure(instance, `compile`);
  8697. }
  8698. }
  8699. }
  8700. instance.render = (Component.render || NOOP);
  8701. // for runtime-compiled render functions using `with` blocks, the render
  8702. // proxy used needs a different `has` handler which is more performant and
  8703. // also only allows a whitelist of globals to fallthrough.
  8704. if (installWithProxy) {
  8705. installWithProxy(instance);
  8706. }
  8707. }
  8708. // support for 2.x options
  8709. {
  8710. setCurrentInstance(instance);
  8711. pauseTracking();
  8712. applyOptions(instance);
  8713. resetTracking();
  8714. unsetCurrentInstance();
  8715. }
  8716. // warn missing template/render
  8717. // the runtime compilation of template in SSR is done by server-render
  8718. if (!Component.render && instance.render === NOOP && !isSSR) {
  8719. /* istanbul ignore if */
  8720. if (!compile && Component.template) {
  8721. warn$1(`Component provided template option but ` +
  8722. `runtime compilation is not supported in this build of Vue.` +
  8723. (` Use "vue.global.js" instead.`
  8724. ) /* should not happen */);
  8725. }
  8726. else {
  8727. warn$1(`Component is missing template or render function.`);
  8728. }
  8729. }
  8730. }
  8731. function createAttrsProxy(instance) {
  8732. return new Proxy(instance.attrs, {
  8733. get(target, key) {
  8734. markAttrsAccessed();
  8735. track(instance, "get" /* TrackOpTypes.GET */, '$attrs');
  8736. return target[key];
  8737. },
  8738. set() {
  8739. warn$1(`setupContext.attrs is readonly.`);
  8740. return false;
  8741. },
  8742. deleteProperty() {
  8743. warn$1(`setupContext.attrs is readonly.`);
  8744. return false;
  8745. }
  8746. }
  8747. );
  8748. }
  8749. function createSetupContext(instance) {
  8750. const expose = exposed => {
  8751. if (instance.exposed) {
  8752. warn$1(`expose() should be called only once per setup().`);
  8753. }
  8754. instance.exposed = exposed || {};
  8755. };
  8756. let attrs;
  8757. {
  8758. // We use getters in dev in case libs like test-utils overwrite instance
  8759. // properties (overwrites should not be done in prod)
  8760. return Object.freeze({
  8761. get attrs() {
  8762. return attrs || (attrs = createAttrsProxy(instance));
  8763. },
  8764. get slots() {
  8765. return shallowReadonly(instance.slots);
  8766. },
  8767. get emit() {
  8768. return (event, ...args) => instance.emit(event, ...args);
  8769. },
  8770. expose
  8771. });
  8772. }
  8773. }
  8774. function getExposeProxy(instance) {
  8775. if (instance.exposed) {
  8776. return (instance.exposeProxy ||
  8777. (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  8778. get(target, key) {
  8779. if (key in target) {
  8780. return target[key];
  8781. }
  8782. else if (key in publicPropertiesMap) {
  8783. return publicPropertiesMap[key](instance);
  8784. }
  8785. },
  8786. has(target, key) {
  8787. return key in target || key in publicPropertiesMap;
  8788. }
  8789. })));
  8790. }
  8791. }
  8792. const classifyRE = /(?:^|[-_])(\w)/g;
  8793. const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  8794. function getComponentName(Component, includeInferred = true) {
  8795. return isFunction(Component)
  8796. ? Component.displayName || Component.name
  8797. : Component.name || (includeInferred && Component.__name);
  8798. }
  8799. /* istanbul ignore next */
  8800. function formatComponentName(instance, Component, isRoot = false) {
  8801. let name = getComponentName(Component);
  8802. if (!name && Component.__file) {
  8803. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  8804. if (match) {
  8805. name = match[1];
  8806. }
  8807. }
  8808. if (!name && instance && instance.parent) {
  8809. // try to infer the name based on reverse resolution
  8810. const inferFromRegistry = (registry) => {
  8811. for (const key in registry) {
  8812. if (registry[key] === Component) {
  8813. return key;
  8814. }
  8815. }
  8816. };
  8817. name =
  8818. inferFromRegistry(instance.components ||
  8819. instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
  8820. }
  8821. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  8822. }
  8823. function isClassComponent(value) {
  8824. return isFunction(value) && '__vccOpts' in value;
  8825. }
  8826. const computed$1 = ((getterOrOptions, debugOptions) => {
  8827. // @ts-ignore
  8828. return computed(getterOrOptions, debugOptions, isInSSRComponentSetup);
  8829. });
  8830. // dev only
  8831. const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
  8832. `<script setup> of a single file component. Its arguments should be ` +
  8833. `compiled away and passing it at runtime has no effect.`);
  8834. // implementation
  8835. function defineProps() {
  8836. {
  8837. warnRuntimeUsage(`defineProps`);
  8838. }
  8839. return null;
  8840. }
  8841. // implementation
  8842. function defineEmits() {
  8843. {
  8844. warnRuntimeUsage(`defineEmits`);
  8845. }
  8846. return null;
  8847. }
  8848. /**
  8849. * Vue `<script setup>` compiler macro for declaring a component's exposed
  8850. * instance properties when it is accessed by a parent component via template
  8851. * refs.
  8852. *
  8853. * `<script setup>` components are closed by default - i.e. variables inside
  8854. * the `<script setup>` scope is not exposed to parent unless explicitly exposed
  8855. * via `defineExpose`.
  8856. *
  8857. * This is only usable inside `<script setup>`, is compiled away in the
  8858. * output and should **not** be actually called at runtime.
  8859. */
  8860. function defineExpose(exposed) {
  8861. {
  8862. warnRuntimeUsage(`defineExpose`);
  8863. }
  8864. }
  8865. /**
  8866. * Vue `<script setup>` compiler macro for providing props default values when
  8867. * using type-based `defineProps` declaration.
  8868. *
  8869. * Example usage:
  8870. * ```ts
  8871. * withDefaults(defineProps<{
  8872. * size?: number
  8873. * labels?: string[]
  8874. * }>(), {
  8875. * size: 3,
  8876. * labels: () => ['default label']
  8877. * })
  8878. * ```
  8879. *
  8880. * This is only usable inside `<script setup>`, is compiled away in the output
  8881. * and should **not** be actually called at runtime.
  8882. */
  8883. function withDefaults(props, defaults) {
  8884. {
  8885. warnRuntimeUsage(`withDefaults`);
  8886. }
  8887. return null;
  8888. }
  8889. function useSlots() {
  8890. return getContext().slots;
  8891. }
  8892. function useAttrs() {
  8893. return getContext().attrs;
  8894. }
  8895. function getContext() {
  8896. const i = getCurrentInstance();
  8897. if (!i) {
  8898. warn$1(`useContext() called without active instance.`);
  8899. }
  8900. return i.setupContext || (i.setupContext = createSetupContext(i));
  8901. }
  8902. /**
  8903. * Runtime helper for merging default declarations. Imported by compiled code
  8904. * only.
  8905. * @internal
  8906. */
  8907. function mergeDefaults(raw, defaults) {
  8908. const props = isArray(raw)
  8909. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  8910. : raw;
  8911. for (const key in defaults) {
  8912. const opt = props[key];
  8913. if (opt) {
  8914. if (isArray(opt) || isFunction(opt)) {
  8915. props[key] = { type: opt, default: defaults[key] };
  8916. }
  8917. else {
  8918. opt.default = defaults[key];
  8919. }
  8920. }
  8921. else if (opt === null) {
  8922. props[key] = { default: defaults[key] };
  8923. }
  8924. else {
  8925. warn$1(`props default key "${key}" has no corresponding declaration.`);
  8926. }
  8927. }
  8928. return props;
  8929. }
  8930. /**
  8931. * Used to create a proxy for the rest element when destructuring props with
  8932. * defineProps().
  8933. * @internal
  8934. */
  8935. function createPropsRestProxy(props, excludedKeys) {
  8936. const ret = {};
  8937. for (const key in props) {
  8938. if (!excludedKeys.includes(key)) {
  8939. Object.defineProperty(ret, key, {
  8940. enumerable: true,
  8941. get: () => props[key]
  8942. });
  8943. }
  8944. }
  8945. return ret;
  8946. }
  8947. /**
  8948. * `<script setup>` helper for persisting the current instance context over
  8949. * async/await flows.
  8950. *
  8951. * `@vue/compiler-sfc` converts the following:
  8952. *
  8953. * ```ts
  8954. * const x = await foo()
  8955. * ```
  8956. *
  8957. * into:
  8958. *
  8959. * ```ts
  8960. * let __temp, __restore
  8961. * const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
  8962. * ```
  8963. * @internal
  8964. */
  8965. function withAsyncContext(getAwaitable) {
  8966. const ctx = getCurrentInstance();
  8967. if (!ctx) {
  8968. warn$1(`withAsyncContext called without active current instance. ` +
  8969. `This is likely a bug.`);
  8970. }
  8971. let awaitable = getAwaitable();
  8972. unsetCurrentInstance();
  8973. if (isPromise(awaitable)) {
  8974. awaitable = awaitable.catch(e => {
  8975. setCurrentInstance(ctx);
  8976. throw e;
  8977. });
  8978. }
  8979. return [awaitable, () => setCurrentInstance(ctx)];
  8980. }
  8981. // Actual implementation
  8982. function h(type, propsOrChildren, children) {
  8983. const l = arguments.length;
  8984. if (l === 2) {
  8985. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  8986. // single vnode without props
  8987. if (isVNode(propsOrChildren)) {
  8988. return createVNode(type, null, [propsOrChildren]);
  8989. }
  8990. // props without children
  8991. return createVNode(type, propsOrChildren);
  8992. }
  8993. else {
  8994. // omit props
  8995. return createVNode(type, null, propsOrChildren);
  8996. }
  8997. }
  8998. else {
  8999. if (l > 3) {
  9000. children = Array.prototype.slice.call(arguments, 2);
  9001. }
  9002. else if (l === 3 && isVNode(children)) {
  9003. children = [children];
  9004. }
  9005. return createVNode(type, propsOrChildren, children);
  9006. }
  9007. }
  9008. const ssrContextKey = Symbol(`ssrContext` );
  9009. const useSSRContext = () => {
  9010. {
  9011. warn$1(`useSSRContext() is not supported in the global build.`);
  9012. }
  9013. };
  9014. function initCustomFormatter() {
  9015. /* eslint-disable no-restricted-globals */
  9016. if (typeof window === 'undefined') {
  9017. return;
  9018. }
  9019. const vueStyle = { style: 'color:#3ba776' };
  9020. const numberStyle = { style: 'color:#0b1bc9' };
  9021. const stringStyle = { style: 'color:#b62e24' };
  9022. const keywordStyle = { style: 'color:#9d288c' };
  9023. // custom formatter for Chrome
  9024. // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
  9025. const formatter = {
  9026. header(obj) {
  9027. // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
  9028. if (!isObject(obj)) {
  9029. return null;
  9030. }
  9031. if (obj.__isVue) {
  9032. return ['div', vueStyle, `VueInstance`];
  9033. }
  9034. else if (isRef(obj)) {
  9035. return [
  9036. 'div',
  9037. {},
  9038. ['span', vueStyle, genRefFlag(obj)],
  9039. '<',
  9040. formatValue(obj.value),
  9041. `>`
  9042. ];
  9043. }
  9044. else if (isReactive(obj)) {
  9045. return [
  9046. 'div',
  9047. {},
  9048. ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'],
  9049. '<',
  9050. formatValue(obj),
  9051. `>${isReadonly(obj) ? ` (readonly)` : ``}`
  9052. ];
  9053. }
  9054. else if (isReadonly(obj)) {
  9055. return [
  9056. 'div',
  9057. {},
  9058. ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'],
  9059. '<',
  9060. formatValue(obj),
  9061. '>'
  9062. ];
  9063. }
  9064. return null;
  9065. },
  9066. hasBody(obj) {
  9067. return obj && obj.__isVue;
  9068. },
  9069. body(obj) {
  9070. if (obj && obj.__isVue) {
  9071. return [
  9072. 'div',
  9073. {},
  9074. ...formatInstance(obj.$)
  9075. ];
  9076. }
  9077. }
  9078. };
  9079. function formatInstance(instance) {
  9080. const blocks = [];
  9081. if (instance.type.props && instance.props) {
  9082. blocks.push(createInstanceBlock('props', toRaw(instance.props)));
  9083. }
  9084. if (instance.setupState !== EMPTY_OBJ) {
  9085. blocks.push(createInstanceBlock('setup', instance.setupState));
  9086. }
  9087. if (instance.data !== EMPTY_OBJ) {
  9088. blocks.push(createInstanceBlock('data', toRaw(instance.data)));
  9089. }
  9090. const computed = extractKeys(instance, 'computed');
  9091. if (computed) {
  9092. blocks.push(createInstanceBlock('computed', computed));
  9093. }
  9094. const injected = extractKeys(instance, 'inject');
  9095. if (injected) {
  9096. blocks.push(createInstanceBlock('injected', injected));
  9097. }
  9098. blocks.push([
  9099. 'div',
  9100. {},
  9101. [
  9102. 'span',
  9103. {
  9104. style: keywordStyle.style + ';opacity:0.66'
  9105. },
  9106. '$ (internal): '
  9107. ],
  9108. ['object', { object: instance }]
  9109. ]);
  9110. return blocks;
  9111. }
  9112. function createInstanceBlock(type, target) {
  9113. target = extend({}, target);
  9114. if (!Object.keys(target).length) {
  9115. return ['span', {}];
  9116. }
  9117. return [
  9118. 'div',
  9119. { style: 'line-height:1.25em;margin-bottom:0.6em' },
  9120. [
  9121. 'div',
  9122. {
  9123. style: 'color:#476582'
  9124. },
  9125. type
  9126. ],
  9127. [
  9128. 'div',
  9129. {
  9130. style: 'padding-left:1.25em'
  9131. },
  9132. ...Object.keys(target).map(key => {
  9133. return [
  9134. 'div',
  9135. {},
  9136. ['span', keywordStyle, key + ': '],
  9137. formatValue(target[key], false)
  9138. ];
  9139. })
  9140. ]
  9141. ];
  9142. }
  9143. function formatValue(v, asRaw = true) {
  9144. if (typeof v === 'number') {
  9145. return ['span', numberStyle, v];
  9146. }
  9147. else if (typeof v === 'string') {
  9148. return ['span', stringStyle, JSON.stringify(v)];
  9149. }
  9150. else if (typeof v === 'boolean') {
  9151. return ['span', keywordStyle, v];
  9152. }
  9153. else if (isObject(v)) {
  9154. return ['object', { object: asRaw ? toRaw(v) : v }];
  9155. }
  9156. else {
  9157. return ['span', stringStyle, String(v)];
  9158. }
  9159. }
  9160. function extractKeys(instance, type) {
  9161. const Comp = instance.type;
  9162. if (isFunction(Comp)) {
  9163. return;
  9164. }
  9165. const extracted = {};
  9166. for (const key in instance.ctx) {
  9167. if (isKeyOfType(Comp, key, type)) {
  9168. extracted[key] = instance.ctx[key];
  9169. }
  9170. }
  9171. return extracted;
  9172. }
  9173. function isKeyOfType(Comp, key, type) {
  9174. const opts = Comp[type];
  9175. if ((isArray(opts) && opts.includes(key)) ||
  9176. (isObject(opts) && key in opts)) {
  9177. return true;
  9178. }
  9179. if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
  9180. return true;
  9181. }
  9182. if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
  9183. return true;
  9184. }
  9185. }
  9186. function genRefFlag(v) {
  9187. if (isShallow(v)) {
  9188. return `ShallowRef`;
  9189. }
  9190. if (v.effect) {
  9191. return `ComputedRef`;
  9192. }
  9193. return `Ref`;
  9194. }
  9195. if (window.devtoolsFormatters) {
  9196. window.devtoolsFormatters.push(formatter);
  9197. }
  9198. else {
  9199. window.devtoolsFormatters = [formatter];
  9200. }
  9201. }
  9202. function withMemo(memo, render, cache, index) {
  9203. const cached = cache[index];
  9204. if (cached && isMemoSame(cached, memo)) {
  9205. return cached;
  9206. }
  9207. const ret = render();
  9208. // shallow clone
  9209. ret.memo = memo.slice();
  9210. return (cache[index] = ret);
  9211. }
  9212. function isMemoSame(cached, memo) {
  9213. const prev = cached.memo;
  9214. if (prev.length != memo.length) {
  9215. return false;
  9216. }
  9217. for (let i = 0; i < prev.length; i++) {
  9218. if (hasChanged(prev[i], memo[i])) {
  9219. return false;
  9220. }
  9221. }
  9222. // make sure to let parent block track it when returning cached
  9223. if (isBlockTreeEnabled > 0 && currentBlock) {
  9224. currentBlock.push(cached);
  9225. }
  9226. return true;
  9227. }
  9228. // Core API ------------------------------------------------------------------
  9229. const version = "3.2.45";
  9230. /**
  9231. * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
  9232. * @internal
  9233. */
  9234. const ssrUtils = (null);
  9235. /**
  9236. * @internal only exposed in compat builds
  9237. */
  9238. const resolveFilter = null;
  9239. /**
  9240. * @internal only exposed in compat builds.
  9241. */
  9242. const compatUtils = (null);
  9243. const svgNS = 'http://www.w3.org/2000/svg';
  9244. const doc = (typeof document !== 'undefined' ? document : null);
  9245. const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
  9246. const nodeOps = {
  9247. insert: (child, parent, anchor) => {
  9248. parent.insertBefore(child, anchor || null);
  9249. },
  9250. remove: child => {
  9251. const parent = child.parentNode;
  9252. if (parent) {
  9253. parent.removeChild(child);
  9254. }
  9255. },
  9256. createElement: (tag, isSVG, is, props) => {
  9257. const el = isSVG
  9258. ? doc.createElementNS(svgNS, tag)
  9259. : doc.createElement(tag, is ? { is } : undefined);
  9260. if (tag === 'select' && props && props.multiple != null) {
  9261. el.setAttribute('multiple', props.multiple);
  9262. }
  9263. return el;
  9264. },
  9265. createText: text => doc.createTextNode(text),
  9266. createComment: text => doc.createComment(text),
  9267. setText: (node, text) => {
  9268. node.nodeValue = text;
  9269. },
  9270. setElementText: (el, text) => {
  9271. el.textContent = text;
  9272. },
  9273. parentNode: node => node.parentNode,
  9274. nextSibling: node => node.nextSibling,
  9275. querySelector: selector => doc.querySelector(selector),
  9276. setScopeId(el, id) {
  9277. el.setAttribute(id, '');
  9278. },
  9279. // __UNSAFE__
  9280. // Reason: innerHTML.
  9281. // Static content here can only come from compiled templates.
  9282. // As long as the user only uses trusted templates, this is safe.
  9283. insertStaticContent(content, parent, anchor, isSVG, start, end) {
  9284. // <parent> before | first ... last | anchor </parent>
  9285. const before = anchor ? anchor.previousSibling : parent.lastChild;
  9286. // #5308 can only take cached path if:
  9287. // - has a single root node
  9288. // - nextSibling info is still available
  9289. if (start && (start === end || start.nextSibling)) {
  9290. // cached
  9291. while (true) {
  9292. parent.insertBefore(start.cloneNode(true), anchor);
  9293. if (start === end || !(start = start.nextSibling))
  9294. break;
  9295. }
  9296. }
  9297. else {
  9298. // fresh insert
  9299. templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
  9300. const template = templateContainer.content;
  9301. if (isSVG) {
  9302. // remove outer svg wrapper
  9303. const wrapper = template.firstChild;
  9304. while (wrapper.firstChild) {
  9305. template.appendChild(wrapper.firstChild);
  9306. }
  9307. template.removeChild(wrapper);
  9308. }
  9309. parent.insertBefore(template, anchor);
  9310. }
  9311. return [
  9312. // first
  9313. before ? before.nextSibling : parent.firstChild,
  9314. // last
  9315. anchor ? anchor.previousSibling : parent.lastChild
  9316. ];
  9317. }
  9318. };
  9319. // compiler should normalize class + :class bindings on the same element
  9320. // into a single binding ['staticClass', dynamic]
  9321. function patchClass(el, value, isSVG) {
  9322. // directly setting className should be faster than setAttribute in theory
  9323. // if this is an element during a transition, take the temporary transition
  9324. // classes into account.
  9325. const transitionClasses = el._vtc;
  9326. if (transitionClasses) {
  9327. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
  9328. }
  9329. if (value == null) {
  9330. el.removeAttribute('class');
  9331. }
  9332. else if (isSVG) {
  9333. el.setAttribute('class', value);
  9334. }
  9335. else {
  9336. el.className = value;
  9337. }
  9338. }
  9339. function patchStyle(el, prev, next) {
  9340. const style = el.style;
  9341. const isCssString = isString(next);
  9342. if (next && !isCssString) {
  9343. for (const key in next) {
  9344. setStyle(style, key, next[key]);
  9345. }
  9346. if (prev && !isString(prev)) {
  9347. for (const key in prev) {
  9348. if (next[key] == null) {
  9349. setStyle(style, key, '');
  9350. }
  9351. }
  9352. }
  9353. }
  9354. else {
  9355. const currentDisplay = style.display;
  9356. if (isCssString) {
  9357. if (prev !== next) {
  9358. style.cssText = next;
  9359. }
  9360. }
  9361. else if (prev) {
  9362. el.removeAttribute('style');
  9363. }
  9364. // indicates that the `display` of the element is controlled by `v-show`,
  9365. // so we always keep the current `display` value regardless of the `style`
  9366. // value, thus handing over control to `v-show`.
  9367. if ('_vod' in el) {
  9368. style.display = currentDisplay;
  9369. }
  9370. }
  9371. }
  9372. const semicolonRE = /[^\\];\s*$/;
  9373. const importantRE = /\s*!important$/;
  9374. function setStyle(style, name, val) {
  9375. if (isArray(val)) {
  9376. val.forEach(v => setStyle(style, name, v));
  9377. }
  9378. else {
  9379. if (val == null)
  9380. val = '';
  9381. {
  9382. if (semicolonRE.test(val)) {
  9383. warn$1(`Unexpected semicolon at the end of '${name}' style value: '${val}'`);
  9384. }
  9385. }
  9386. if (name.startsWith('--')) {
  9387. // custom property definition
  9388. style.setProperty(name, val);
  9389. }
  9390. else {
  9391. const prefixed = autoPrefix(style, name);
  9392. if (importantRE.test(val)) {
  9393. // !important
  9394. style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
  9395. }
  9396. else {
  9397. style[prefixed] = val;
  9398. }
  9399. }
  9400. }
  9401. }
  9402. const prefixes = ['Webkit', 'Moz', 'ms'];
  9403. const prefixCache = {};
  9404. function autoPrefix(style, rawName) {
  9405. const cached = prefixCache[rawName];
  9406. if (cached) {
  9407. return cached;
  9408. }
  9409. let name = camelize(rawName);
  9410. if (name !== 'filter' && name in style) {
  9411. return (prefixCache[rawName] = name);
  9412. }
  9413. name = capitalize(name);
  9414. for (let i = 0; i < prefixes.length; i++) {
  9415. const prefixed = prefixes[i] + name;
  9416. if (prefixed in style) {
  9417. return (prefixCache[rawName] = prefixed);
  9418. }
  9419. }
  9420. return rawName;
  9421. }
  9422. const xlinkNS = 'http://www.w3.org/1999/xlink';
  9423. function patchAttr(el, key, value, isSVG, instance) {
  9424. if (isSVG && key.startsWith('xlink:')) {
  9425. if (value == null) {
  9426. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  9427. }
  9428. else {
  9429. el.setAttributeNS(xlinkNS, key, value);
  9430. }
  9431. }
  9432. else {
  9433. // note we are only checking boolean attributes that don't have a
  9434. // corresponding dom prop of the same name here.
  9435. const isBoolean = isSpecialBooleanAttr(key);
  9436. if (value == null || (isBoolean && !includeBooleanAttr(value))) {
  9437. el.removeAttribute(key);
  9438. }
  9439. else {
  9440. el.setAttribute(key, isBoolean ? '' : value);
  9441. }
  9442. }
  9443. }
  9444. // __UNSAFE__
  9445. // functions. The user is responsible for using them with only trusted content.
  9446. function patchDOMProp(el, key, value,
  9447. // the following args are passed only due to potential innerHTML/textContent
  9448. // overriding existing VNodes, in which case the old tree must be properly
  9449. // unmounted.
  9450. prevChildren, parentComponent, parentSuspense, unmountChildren) {
  9451. if (key === 'innerHTML' || key === 'textContent') {
  9452. if (prevChildren) {
  9453. unmountChildren(prevChildren, parentComponent, parentSuspense);
  9454. }
  9455. el[key] = value == null ? '' : value;
  9456. return;
  9457. }
  9458. if (key === 'value' &&
  9459. el.tagName !== 'PROGRESS' &&
  9460. // custom elements may use _value internally
  9461. !el.tagName.includes('-')) {
  9462. // store value as _value as well since
  9463. // non-string values will be stringified.
  9464. el._value = value;
  9465. const newValue = value == null ? '' : value;
  9466. if (el.value !== newValue ||
  9467. // #4956: always set for OPTION elements because its value falls back to
  9468. // textContent if no value attribute is present. And setting .value for
  9469. // OPTION has no side effect
  9470. el.tagName === 'OPTION') {
  9471. el.value = newValue;
  9472. }
  9473. if (value == null) {
  9474. el.removeAttribute(key);
  9475. }
  9476. return;
  9477. }
  9478. let needRemove = false;
  9479. if (value === '' || value == null) {
  9480. const type = typeof el[key];
  9481. if (type === 'boolean') {
  9482. // e.g. <select multiple> compiles to { multiple: '' }
  9483. value = includeBooleanAttr(value);
  9484. }
  9485. else if (value == null && type === 'string') {
  9486. // e.g. <div :id="null">
  9487. value = '';
  9488. needRemove = true;
  9489. }
  9490. else if (type === 'number') {
  9491. // e.g. <img :width="null">
  9492. value = 0;
  9493. needRemove = true;
  9494. }
  9495. }
  9496. // some properties perform value validation and throw,
  9497. // some properties has getter, no setter, will error in 'use strict'
  9498. // eg. <select :type="null"></select> <select :willValidate="null"></select>
  9499. try {
  9500. el[key] = value;
  9501. }
  9502. catch (e) {
  9503. // do not warn if value is auto-coerced from nullish values
  9504. if (!needRemove) {
  9505. warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
  9506. `value ${value} is invalid.`, e);
  9507. }
  9508. }
  9509. needRemove && el.removeAttribute(key);
  9510. }
  9511. function addEventListener(el, event, handler, options) {
  9512. el.addEventListener(event, handler, options);
  9513. }
  9514. function removeEventListener(el, event, handler, options) {
  9515. el.removeEventListener(event, handler, options);
  9516. }
  9517. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  9518. // vei = vue event invokers
  9519. const invokers = el._vei || (el._vei = {});
  9520. const existingInvoker = invokers[rawName];
  9521. if (nextValue && existingInvoker) {
  9522. // patch
  9523. existingInvoker.value = nextValue;
  9524. }
  9525. else {
  9526. const [name, options] = parseName(rawName);
  9527. if (nextValue) {
  9528. // add
  9529. const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
  9530. addEventListener(el, name, invoker, options);
  9531. }
  9532. else if (existingInvoker) {
  9533. // remove
  9534. removeEventListener(el, name, existingInvoker, options);
  9535. invokers[rawName] = undefined;
  9536. }
  9537. }
  9538. }
  9539. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  9540. function parseName(name) {
  9541. let options;
  9542. if (optionsModifierRE.test(name)) {
  9543. options = {};
  9544. let m;
  9545. while ((m = name.match(optionsModifierRE))) {
  9546. name = name.slice(0, name.length - m[0].length);
  9547. options[m[0].toLowerCase()] = true;
  9548. }
  9549. }
  9550. const event = name[2] === ':' ? name.slice(3) : hyphenate(name.slice(2));
  9551. return [event, options];
  9552. }
  9553. // To avoid the overhead of repeatedly calling Date.now(), we cache
  9554. // and use the same timestamp for all event listeners attached in the same tick.
  9555. let cachedNow = 0;
  9556. const p = /*#__PURE__*/ Promise.resolve();
  9557. const getNow = () => cachedNow || (p.then(() => (cachedNow = 0)), (cachedNow = Date.now()));
  9558. function createInvoker(initialValue, instance) {
  9559. const invoker = (e) => {
  9560. // async edge case vuejs/vue#6566
  9561. // inner click event triggers patch, event handler
  9562. // attached to outer element during patch, and triggered again. This
  9563. // happens because browsers fire microtask ticks between event propagation.
  9564. // this no longer happens for templates in Vue 3, but could still be
  9565. // theoretically possible for hand-written render functions.
  9566. // the solution: we save the timestamp when a handler is attached,
  9567. // and also attach the timestamp to any event that was handled by vue
  9568. // for the first time (to avoid inconsistent event timestamp implementations
  9569. // or events fired from iframes, e.g. #2513)
  9570. // The handler would only fire if the event passed to it was fired
  9571. // AFTER it was attached.
  9572. if (!e._vts) {
  9573. e._vts = Date.now();
  9574. }
  9575. else if (e._vts <= invoker.attached) {
  9576. return;
  9577. }
  9578. callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* ErrorCodes.NATIVE_EVENT_HANDLER */, [e]);
  9579. };
  9580. invoker.value = initialValue;
  9581. invoker.attached = getNow();
  9582. return invoker;
  9583. }
  9584. function patchStopImmediatePropagation(e, value) {
  9585. if (isArray(value)) {
  9586. const originalStop = e.stopImmediatePropagation;
  9587. e.stopImmediatePropagation = () => {
  9588. originalStop.call(e);
  9589. e._stopped = true;
  9590. };
  9591. return value.map(fn => (e) => !e._stopped && fn && fn(e));
  9592. }
  9593. else {
  9594. return value;
  9595. }
  9596. }
  9597. const nativeOnRE = /^on[a-z]/;
  9598. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  9599. if (key === 'class') {
  9600. patchClass(el, nextValue, isSVG);
  9601. }
  9602. else if (key === 'style') {
  9603. patchStyle(el, prevValue, nextValue);
  9604. }
  9605. else if (isOn(key)) {
  9606. // ignore v-model listeners
  9607. if (!isModelListener(key)) {
  9608. patchEvent(el, key, prevValue, nextValue, parentComponent);
  9609. }
  9610. }
  9611. else if (key[0] === '.'
  9612. ? ((key = key.slice(1)), true)
  9613. : key[0] === '^'
  9614. ? ((key = key.slice(1)), false)
  9615. : shouldSetAsProp(el, key, nextValue, isSVG)) {
  9616. patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
  9617. }
  9618. else {
  9619. // special case for <input v-model type="checkbox"> with
  9620. // :true-value & :false-value
  9621. // store value as dom properties since non-string values will be
  9622. // stringified.
  9623. if (key === 'true-value') {
  9624. el._trueValue = nextValue;
  9625. }
  9626. else if (key === 'false-value') {
  9627. el._falseValue = nextValue;
  9628. }
  9629. patchAttr(el, key, nextValue, isSVG);
  9630. }
  9631. };
  9632. function shouldSetAsProp(el, key, value, isSVG) {
  9633. if (isSVG) {
  9634. // most keys must be set as attribute on svg elements to work
  9635. // ...except innerHTML & textContent
  9636. if (key === 'innerHTML' || key === 'textContent') {
  9637. return true;
  9638. }
  9639. // or native onclick with function values
  9640. if (key in el && nativeOnRE.test(key) && isFunction(value)) {
  9641. return true;
  9642. }
  9643. return false;
  9644. }
  9645. // these are enumerated attrs, however their corresponding DOM properties
  9646. // are actually booleans - this leads to setting it with a string "false"
  9647. // value leading it to be coerced to `true`, so we need to always treat
  9648. // them as attributes.
  9649. // Note that `contentEditable` doesn't have this problem: its DOM
  9650. // property is also enumerated string values.
  9651. if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
  9652. return false;
  9653. }
  9654. // #1787, #2840 form property on form elements is readonly and must be set as
  9655. // attribute.
  9656. if (key === 'form') {
  9657. return false;
  9658. }
  9659. // #1526 <input list> must be set as attribute
  9660. if (key === 'list' && el.tagName === 'INPUT') {
  9661. return false;
  9662. }
  9663. // #2766 <textarea type> must be set as attribute
  9664. if (key === 'type' && el.tagName === 'TEXTAREA') {
  9665. return false;
  9666. }
  9667. // native onclick with string value, must be set as attribute
  9668. if (nativeOnRE.test(key) && isString(value)) {
  9669. return false;
  9670. }
  9671. return key in el;
  9672. }
  9673. function defineCustomElement(options, hydrate) {
  9674. const Comp = defineComponent(options);
  9675. class VueCustomElement extends VueElement {
  9676. constructor(initialProps) {
  9677. super(Comp, initialProps, hydrate);
  9678. }
  9679. }
  9680. VueCustomElement.def = Comp;
  9681. return VueCustomElement;
  9682. }
  9683. const defineSSRCustomElement = ((options) => {
  9684. // @ts-ignore
  9685. return defineCustomElement(options, hydrate);
  9686. });
  9687. const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
  9688. });
  9689. class VueElement extends BaseClass {
  9690. constructor(_def, _props = {}, hydrate) {
  9691. super();
  9692. this._def = _def;
  9693. this._props = _props;
  9694. /**
  9695. * @internal
  9696. */
  9697. this._instance = null;
  9698. this._connected = false;
  9699. this._resolved = false;
  9700. this._numberProps = null;
  9701. if (this.shadowRoot && hydrate) {
  9702. hydrate(this._createVNode(), this.shadowRoot);
  9703. }
  9704. else {
  9705. if (this.shadowRoot) {
  9706. warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
  9707. `defined as hydratable. Use \`defineSSRCustomElement\`.`);
  9708. }
  9709. this.attachShadow({ mode: 'open' });
  9710. if (!this._def.__asyncLoader) {
  9711. // for sync component defs we can immediately resolve props
  9712. this._resolveProps(this._def);
  9713. }
  9714. }
  9715. }
  9716. connectedCallback() {
  9717. this._connected = true;
  9718. if (!this._instance) {
  9719. if (this._resolved) {
  9720. this._update();
  9721. }
  9722. else {
  9723. this._resolveDef();
  9724. }
  9725. }
  9726. }
  9727. disconnectedCallback() {
  9728. this._connected = false;
  9729. nextTick(() => {
  9730. if (!this._connected) {
  9731. render(null, this.shadowRoot);
  9732. this._instance = null;
  9733. }
  9734. });
  9735. }
  9736. /**
  9737. * resolve inner component definition (handle possible async component)
  9738. */
  9739. _resolveDef() {
  9740. this._resolved = true;
  9741. // set initial attrs
  9742. for (let i = 0; i < this.attributes.length; i++) {
  9743. this._setAttr(this.attributes[i].name);
  9744. }
  9745. // watch future attr changes
  9746. new MutationObserver(mutations => {
  9747. for (const m of mutations) {
  9748. this._setAttr(m.attributeName);
  9749. }
  9750. }).observe(this, { attributes: true });
  9751. const resolve = (def, isAsync = false) => {
  9752. const { props, styles } = def;
  9753. // cast Number-type props set before resolve
  9754. let numberProps;
  9755. if (props && !isArray(props)) {
  9756. for (const key in props) {
  9757. const opt = props[key];
  9758. if (opt === Number || (opt && opt.type === Number)) {
  9759. if (key in this._props) {
  9760. this._props[key] = toNumber(this._props[key]);
  9761. }
  9762. (numberProps || (numberProps = Object.create(null)))[camelize(key)] = true;
  9763. }
  9764. }
  9765. }
  9766. this._numberProps = numberProps;
  9767. if (isAsync) {
  9768. // defining getter/setters on prototype
  9769. // for sync defs, this already happened in the constructor
  9770. this._resolveProps(def);
  9771. }
  9772. // apply CSS
  9773. this._applyStyles(styles);
  9774. // initial render
  9775. this._update();
  9776. };
  9777. const asyncDef = this._def.__asyncLoader;
  9778. if (asyncDef) {
  9779. asyncDef().then(def => resolve(def, true));
  9780. }
  9781. else {
  9782. resolve(this._def);
  9783. }
  9784. }
  9785. _resolveProps(def) {
  9786. const { props } = def;
  9787. const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
  9788. // check if there are props set pre-upgrade or connect
  9789. for (const key of Object.keys(this)) {
  9790. if (key[0] !== '_' && declaredPropKeys.includes(key)) {
  9791. this._setProp(key, this[key], true, false);
  9792. }
  9793. }
  9794. // defining getter/setters on prototype
  9795. for (const key of declaredPropKeys.map(camelize)) {
  9796. Object.defineProperty(this, key, {
  9797. get() {
  9798. return this._getProp(key);
  9799. },
  9800. set(val) {
  9801. this._setProp(key, val);
  9802. }
  9803. });
  9804. }
  9805. }
  9806. _setAttr(key) {
  9807. let value = this.getAttribute(key);
  9808. const camelKey = camelize(key);
  9809. if (this._numberProps && this._numberProps[camelKey]) {
  9810. value = toNumber(value);
  9811. }
  9812. this._setProp(camelKey, value, false);
  9813. }
  9814. /**
  9815. * @internal
  9816. */
  9817. _getProp(key) {
  9818. return this._props[key];
  9819. }
  9820. /**
  9821. * @internal
  9822. */
  9823. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  9824. if (val !== this._props[key]) {
  9825. this._props[key] = val;
  9826. if (shouldUpdate && this._instance) {
  9827. this._update();
  9828. }
  9829. // reflect
  9830. if (shouldReflect) {
  9831. if (val === true) {
  9832. this.setAttribute(hyphenate(key), '');
  9833. }
  9834. else if (typeof val === 'string' || typeof val === 'number') {
  9835. this.setAttribute(hyphenate(key), val + '');
  9836. }
  9837. else if (!val) {
  9838. this.removeAttribute(hyphenate(key));
  9839. }
  9840. }
  9841. }
  9842. }
  9843. _update() {
  9844. render(this._createVNode(), this.shadowRoot);
  9845. }
  9846. _createVNode() {
  9847. const vnode = createVNode(this._def, extend({}, this._props));
  9848. if (!this._instance) {
  9849. vnode.ce = instance => {
  9850. this._instance = instance;
  9851. instance.isCE = true;
  9852. // HMR
  9853. {
  9854. instance.ceReload = newStyles => {
  9855. // always reset styles
  9856. if (this._styles) {
  9857. this._styles.forEach(s => this.shadowRoot.removeChild(s));
  9858. this._styles.length = 0;
  9859. }
  9860. this._applyStyles(newStyles);
  9861. this._instance = null;
  9862. this._update();
  9863. };
  9864. }
  9865. const dispatch = (event, args) => {
  9866. this.dispatchEvent(new CustomEvent(event, {
  9867. detail: args
  9868. }));
  9869. };
  9870. // intercept emit
  9871. instance.emit = (event, ...args) => {
  9872. // dispatch both the raw and hyphenated versions of an event
  9873. // to match Vue behavior
  9874. dispatch(event, args);
  9875. if (hyphenate(event) !== event) {
  9876. dispatch(hyphenate(event), args);
  9877. }
  9878. };
  9879. // locate nearest Vue custom element parent for provide/inject
  9880. let parent = this;
  9881. while ((parent =
  9882. parent && (parent.parentNode || parent.host))) {
  9883. if (parent instanceof VueElement) {
  9884. instance.parent = parent._instance;
  9885. instance.provides = parent._instance.provides;
  9886. break;
  9887. }
  9888. }
  9889. };
  9890. }
  9891. return vnode;
  9892. }
  9893. _applyStyles(styles) {
  9894. if (styles) {
  9895. styles.forEach(css => {
  9896. const s = document.createElement('style');
  9897. s.textContent = css;
  9898. this.shadowRoot.appendChild(s);
  9899. // record for HMR
  9900. {
  9901. (this._styles || (this._styles = [])).push(s);
  9902. }
  9903. });
  9904. }
  9905. }
  9906. }
  9907. function useCssModule(name = '$style') {
  9908. /* istanbul ignore else */
  9909. {
  9910. {
  9911. warn$1(`useCssModule() is not supported in the global build.`);
  9912. }
  9913. return EMPTY_OBJ;
  9914. }
  9915. }
  9916. /**
  9917. * Runtime helper for SFC's CSS variable injection feature.
  9918. * @private
  9919. */
  9920. function useCssVars(getter) {
  9921. const instance = getCurrentInstance();
  9922. /* istanbul ignore next */
  9923. if (!instance) {
  9924. warn$1(`useCssVars is called without current active component instance.`);
  9925. return;
  9926. }
  9927. const updateTeleports = (instance.ut = (vars = getter(instance.proxy)) => {
  9928. Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach(node => setVarsOnNode(node, vars));
  9929. });
  9930. const setVars = () => {
  9931. const vars = getter(instance.proxy);
  9932. setVarsOnVNode(instance.subTree, vars);
  9933. updateTeleports(vars);
  9934. };
  9935. watchPostEffect(setVars);
  9936. onMounted(() => {
  9937. const ob = new MutationObserver(setVars);
  9938. ob.observe(instance.subTree.el.parentNode, { childList: true });
  9939. onUnmounted(() => ob.disconnect());
  9940. });
  9941. }
  9942. function setVarsOnVNode(vnode, vars) {
  9943. if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  9944. const suspense = vnode.suspense;
  9945. vnode = suspense.activeBranch;
  9946. if (suspense.pendingBranch && !suspense.isHydrating) {
  9947. suspense.effects.push(() => {
  9948. setVarsOnVNode(suspense.activeBranch, vars);
  9949. });
  9950. }
  9951. }
  9952. // drill down HOCs until it's a non-component vnode
  9953. while (vnode.component) {
  9954. vnode = vnode.component.subTree;
  9955. }
  9956. if (vnode.shapeFlag & 1 /* ShapeFlags.ELEMENT */ && vnode.el) {
  9957. setVarsOnNode(vnode.el, vars);
  9958. }
  9959. else if (vnode.type === Fragment) {
  9960. vnode.children.forEach(c => setVarsOnVNode(c, vars));
  9961. }
  9962. else if (vnode.type === Static) {
  9963. let { el, anchor } = vnode;
  9964. while (el) {
  9965. setVarsOnNode(el, vars);
  9966. if (el === anchor)
  9967. break;
  9968. el = el.nextSibling;
  9969. }
  9970. }
  9971. }
  9972. function setVarsOnNode(el, vars) {
  9973. if (el.nodeType === 1) {
  9974. const style = el.style;
  9975. for (const key in vars) {
  9976. style.setProperty(`--${key}`, vars[key]);
  9977. }
  9978. }
  9979. }
  9980. const TRANSITION = 'transition';
  9981. const ANIMATION = 'animation';
  9982. // DOM Transition is a higher-order-component based on the platform-agnostic
  9983. // base Transition component, with DOM-specific logic.
  9984. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
  9985. Transition.displayName = 'Transition';
  9986. const DOMTransitionPropsValidators = {
  9987. name: String,
  9988. type: String,
  9989. css: {
  9990. type: Boolean,
  9991. default: true
  9992. },
  9993. duration: [String, Number, Object],
  9994. enterFromClass: String,
  9995. enterActiveClass: String,
  9996. enterToClass: String,
  9997. appearFromClass: String,
  9998. appearActiveClass: String,
  9999. appearToClass: String,
  10000. leaveFromClass: String,
  10001. leaveActiveClass: String,
  10002. leaveToClass: String
  10003. };
  10004. const TransitionPropsValidators = (Transition.props =
  10005. /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
  10006. /**
  10007. * #3227 Incoming hooks may be merged into arrays when wrapping Transition
  10008. * with custom HOCs.
  10009. */
  10010. const callHook$1 = (hook, args = []) => {
  10011. if (isArray(hook)) {
  10012. hook.forEach(h => h(...args));
  10013. }
  10014. else if (hook) {
  10015. hook(...args);
  10016. }
  10017. };
  10018. /**
  10019. * Check if a hook expects a callback (2nd arg), which means the user
  10020. * intends to explicitly control the end of the transition.
  10021. */
  10022. const hasExplicitCallback = (hook) => {
  10023. return hook
  10024. ? isArray(hook)
  10025. ? hook.some(h => h.length > 1)
  10026. : hook.length > 1
  10027. : false;
  10028. };
  10029. function resolveTransitionProps(rawProps) {
  10030. const baseProps = {};
  10031. for (const key in rawProps) {
  10032. if (!(key in DOMTransitionPropsValidators)) {
  10033. baseProps[key] = rawProps[key];
  10034. }
  10035. }
  10036. if (rawProps.css === false) {
  10037. return baseProps;
  10038. }
  10039. 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;
  10040. const durations = normalizeDuration(duration);
  10041. const enterDuration = durations && durations[0];
  10042. const leaveDuration = durations && durations[1];
  10043. const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
  10044. const finishEnter = (el, isAppear, done) => {
  10045. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  10046. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  10047. done && done();
  10048. };
  10049. const finishLeave = (el, done) => {
  10050. el._isLeaving = false;
  10051. removeTransitionClass(el, leaveFromClass);
  10052. removeTransitionClass(el, leaveToClass);
  10053. removeTransitionClass(el, leaveActiveClass);
  10054. done && done();
  10055. };
  10056. const makeEnterHook = (isAppear) => {
  10057. return (el, done) => {
  10058. const hook = isAppear ? onAppear : onEnter;
  10059. const resolve = () => finishEnter(el, isAppear, done);
  10060. callHook$1(hook, [el, resolve]);
  10061. nextFrame(() => {
  10062. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  10063. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  10064. if (!hasExplicitCallback(hook)) {
  10065. whenTransitionEnds(el, type, enterDuration, resolve);
  10066. }
  10067. });
  10068. };
  10069. };
  10070. return extend(baseProps, {
  10071. onBeforeEnter(el) {
  10072. callHook$1(onBeforeEnter, [el]);
  10073. addTransitionClass(el, enterFromClass);
  10074. addTransitionClass(el, enterActiveClass);
  10075. },
  10076. onBeforeAppear(el) {
  10077. callHook$1(onBeforeAppear, [el]);
  10078. addTransitionClass(el, appearFromClass);
  10079. addTransitionClass(el, appearActiveClass);
  10080. },
  10081. onEnter: makeEnterHook(false),
  10082. onAppear: makeEnterHook(true),
  10083. onLeave(el, done) {
  10084. el._isLeaving = true;
  10085. const resolve = () => finishLeave(el, done);
  10086. addTransitionClass(el, leaveFromClass);
  10087. // force reflow so *-leave-from classes immediately take effect (#2593)
  10088. forceReflow();
  10089. addTransitionClass(el, leaveActiveClass);
  10090. nextFrame(() => {
  10091. if (!el._isLeaving) {
  10092. // cancelled
  10093. return;
  10094. }
  10095. removeTransitionClass(el, leaveFromClass);
  10096. addTransitionClass(el, leaveToClass);
  10097. if (!hasExplicitCallback(onLeave)) {
  10098. whenTransitionEnds(el, type, leaveDuration, resolve);
  10099. }
  10100. });
  10101. callHook$1(onLeave, [el, resolve]);
  10102. },
  10103. onEnterCancelled(el) {
  10104. finishEnter(el, false);
  10105. callHook$1(onEnterCancelled, [el]);
  10106. },
  10107. onAppearCancelled(el) {
  10108. finishEnter(el, true);
  10109. callHook$1(onAppearCancelled, [el]);
  10110. },
  10111. onLeaveCancelled(el) {
  10112. finishLeave(el);
  10113. callHook$1(onLeaveCancelled, [el]);
  10114. }
  10115. });
  10116. }
  10117. function normalizeDuration(duration) {
  10118. if (duration == null) {
  10119. return null;
  10120. }
  10121. else if (isObject(duration)) {
  10122. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  10123. }
  10124. else {
  10125. const n = NumberOf(duration);
  10126. return [n, n];
  10127. }
  10128. }
  10129. function NumberOf(val) {
  10130. const res = toNumber(val);
  10131. validateDuration(res);
  10132. return res;
  10133. }
  10134. function validateDuration(val) {
  10135. if (typeof val !== 'number') {
  10136. warn$1(`<transition> explicit duration is not a valid number - ` +
  10137. `got ${JSON.stringify(val)}.`);
  10138. }
  10139. else if (isNaN(val)) {
  10140. warn$1(`<transition> explicit duration is NaN - ` +
  10141. 'the duration expression might be incorrect.');
  10142. }
  10143. }
  10144. function addTransitionClass(el, cls) {
  10145. cls.split(/\s+/).forEach(c => c && el.classList.add(c));
  10146. (el._vtc ||
  10147. (el._vtc = new Set())).add(cls);
  10148. }
  10149. function removeTransitionClass(el, cls) {
  10150. cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
  10151. const { _vtc } = el;
  10152. if (_vtc) {
  10153. _vtc.delete(cls);
  10154. if (!_vtc.size) {
  10155. el._vtc = undefined;
  10156. }
  10157. }
  10158. }
  10159. function nextFrame(cb) {
  10160. requestAnimationFrame(() => {
  10161. requestAnimationFrame(cb);
  10162. });
  10163. }
  10164. let endId = 0;
  10165. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  10166. const id = (el._endId = ++endId);
  10167. const resolveIfNotStale = () => {
  10168. if (id === el._endId) {
  10169. resolve();
  10170. }
  10171. };
  10172. if (explicitTimeout) {
  10173. return setTimeout(resolveIfNotStale, explicitTimeout);
  10174. }
  10175. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  10176. if (!type) {
  10177. return resolve();
  10178. }
  10179. const endEvent = type + 'end';
  10180. let ended = 0;
  10181. const end = () => {
  10182. el.removeEventListener(endEvent, onEnd);
  10183. resolveIfNotStale();
  10184. };
  10185. const onEnd = (e) => {
  10186. if (e.target === el && ++ended >= propCount) {
  10187. end();
  10188. }
  10189. };
  10190. setTimeout(() => {
  10191. if (ended < propCount) {
  10192. end();
  10193. }
  10194. }, timeout + 1);
  10195. el.addEventListener(endEvent, onEnd);
  10196. }
  10197. function getTransitionInfo(el, expectedType) {
  10198. const styles = window.getComputedStyle(el);
  10199. // JSDOM may return undefined for transition properties
  10200. const getStyleProperties = (key) => (styles[key] || '').split(', ');
  10201. const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
  10202. const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
  10203. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  10204. const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
  10205. const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
  10206. const animationTimeout = getTimeout(animationDelays, animationDurations);
  10207. let type = null;
  10208. let timeout = 0;
  10209. let propCount = 0;
  10210. /* istanbul ignore if */
  10211. if (expectedType === TRANSITION) {
  10212. if (transitionTimeout > 0) {
  10213. type = TRANSITION;
  10214. timeout = transitionTimeout;
  10215. propCount = transitionDurations.length;
  10216. }
  10217. }
  10218. else if (expectedType === ANIMATION) {
  10219. if (animationTimeout > 0) {
  10220. type = ANIMATION;
  10221. timeout = animationTimeout;
  10222. propCount = animationDurations.length;
  10223. }
  10224. }
  10225. else {
  10226. timeout = Math.max(transitionTimeout, animationTimeout);
  10227. type =
  10228. timeout > 0
  10229. ? transitionTimeout > animationTimeout
  10230. ? TRANSITION
  10231. : ANIMATION
  10232. : null;
  10233. propCount = type
  10234. ? type === TRANSITION
  10235. ? transitionDurations.length
  10236. : animationDurations.length
  10237. : 0;
  10238. }
  10239. const hasTransform = type === TRANSITION &&
  10240. /\b(transform|all)(,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString());
  10241. return {
  10242. type,
  10243. timeout,
  10244. propCount,
  10245. hasTransform
  10246. };
  10247. }
  10248. function getTimeout(delays, durations) {
  10249. while (delays.length < durations.length) {
  10250. delays = delays.concat(delays);
  10251. }
  10252. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  10253. }
  10254. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer
  10255. // numbers in a locale-dependent way, using a comma instead of a dot.
  10256. // If comma is not replaced with a dot, the input will be rounded down
  10257. // (i.e. acting as a floor function) causing unexpected behaviors
  10258. function toMs(s) {
  10259. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  10260. }
  10261. // synchronously force layout to put elements into a certain state
  10262. function forceReflow() {
  10263. return document.body.offsetHeight;
  10264. }
  10265. const positionMap = new WeakMap();
  10266. const newPositionMap = new WeakMap();
  10267. const TransitionGroupImpl = {
  10268. name: 'TransitionGroup',
  10269. props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
  10270. tag: String,
  10271. moveClass: String
  10272. }),
  10273. setup(props, { slots }) {
  10274. const instance = getCurrentInstance();
  10275. const state = useTransitionState();
  10276. let prevChildren;
  10277. let children;
  10278. onUpdated(() => {
  10279. // children is guaranteed to exist after initial render
  10280. if (!prevChildren.length) {
  10281. return;
  10282. }
  10283. const moveClass = props.moveClass || `${props.name || 'v'}-move`;
  10284. if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
  10285. return;
  10286. }
  10287. // we divide the work into three loops to avoid mixing DOM reads and writes
  10288. // in each iteration - which helps prevent layout thrashing.
  10289. prevChildren.forEach(callPendingCbs);
  10290. prevChildren.forEach(recordPosition);
  10291. const movedChildren = prevChildren.filter(applyTranslation);
  10292. // force reflow to put everything in position
  10293. forceReflow();
  10294. movedChildren.forEach(c => {
  10295. const el = c.el;
  10296. const style = el.style;
  10297. addTransitionClass(el, moveClass);
  10298. style.transform = style.webkitTransform = style.transitionDuration = '';
  10299. const cb = (el._moveCb = (e) => {
  10300. if (e && e.target !== el) {
  10301. return;
  10302. }
  10303. if (!e || /transform$/.test(e.propertyName)) {
  10304. el.removeEventListener('transitionend', cb);
  10305. el._moveCb = null;
  10306. removeTransitionClass(el, moveClass);
  10307. }
  10308. });
  10309. el.addEventListener('transitionend', cb);
  10310. });
  10311. });
  10312. return () => {
  10313. const rawProps = toRaw(props);
  10314. const cssTransitionProps = resolveTransitionProps(rawProps);
  10315. let tag = rawProps.tag || Fragment;
  10316. prevChildren = children;
  10317. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  10318. for (let i = 0; i < children.length; i++) {
  10319. const child = children[i];
  10320. if (child.key != null) {
  10321. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10322. }
  10323. else {
  10324. warn$1(`<TransitionGroup> children must be keyed.`);
  10325. }
  10326. }
  10327. if (prevChildren) {
  10328. for (let i = 0; i < prevChildren.length; i++) {
  10329. const child = prevChildren[i];
  10330. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10331. positionMap.set(child, child.el.getBoundingClientRect());
  10332. }
  10333. }
  10334. return createVNode(tag, null, children);
  10335. };
  10336. }
  10337. };
  10338. const TransitionGroup = TransitionGroupImpl;
  10339. function callPendingCbs(c) {
  10340. const el = c.el;
  10341. if (el._moveCb) {
  10342. el._moveCb();
  10343. }
  10344. if (el._enterCb) {
  10345. el._enterCb();
  10346. }
  10347. }
  10348. function recordPosition(c) {
  10349. newPositionMap.set(c, c.el.getBoundingClientRect());
  10350. }
  10351. function applyTranslation(c) {
  10352. const oldPos = positionMap.get(c);
  10353. const newPos = newPositionMap.get(c);
  10354. const dx = oldPos.left - newPos.left;
  10355. const dy = oldPos.top - newPos.top;
  10356. if (dx || dy) {
  10357. const s = c.el.style;
  10358. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  10359. s.transitionDuration = '0s';
  10360. return c;
  10361. }
  10362. }
  10363. function hasCSSTransform(el, root, moveClass) {
  10364. // Detect whether an element with the move class applied has
  10365. // CSS transitions. Since the element may be inside an entering
  10366. // transition at this very moment, we make a clone of it and remove
  10367. // all other transition classes applied to ensure only the move class
  10368. // is applied.
  10369. const clone = el.cloneNode();
  10370. if (el._vtc) {
  10371. el._vtc.forEach(cls => {
  10372. cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
  10373. });
  10374. }
  10375. moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
  10376. clone.style.display = 'none';
  10377. const container = (root.nodeType === 1 ? root : root.parentNode);
  10378. container.appendChild(clone);
  10379. const { hasTransform } = getTransitionInfo(clone);
  10380. container.removeChild(clone);
  10381. return hasTransform;
  10382. }
  10383. const getModelAssigner = (vnode) => {
  10384. const fn = vnode.props['onUpdate:modelValue'] ||
  10385. (false );
  10386. return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
  10387. };
  10388. function onCompositionStart(e) {
  10389. e.target.composing = true;
  10390. }
  10391. function onCompositionEnd(e) {
  10392. const target = e.target;
  10393. if (target.composing) {
  10394. target.composing = false;
  10395. target.dispatchEvent(new Event('input'));
  10396. }
  10397. }
  10398. // We are exporting the v-model runtime directly as vnode hooks so that it can
  10399. // be tree-shaken in case v-model is never used.
  10400. const vModelText = {
  10401. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  10402. el._assign = getModelAssigner(vnode);
  10403. const castToNumber = number || (vnode.props && vnode.props.type === 'number');
  10404. addEventListener(el, lazy ? 'change' : 'input', e => {
  10405. if (e.target.composing)
  10406. return;
  10407. let domValue = el.value;
  10408. if (trim) {
  10409. domValue = domValue.trim();
  10410. }
  10411. if (castToNumber) {
  10412. domValue = toNumber(domValue);
  10413. }
  10414. el._assign(domValue);
  10415. });
  10416. if (trim) {
  10417. addEventListener(el, 'change', () => {
  10418. el.value = el.value.trim();
  10419. });
  10420. }
  10421. if (!lazy) {
  10422. addEventListener(el, 'compositionstart', onCompositionStart);
  10423. addEventListener(el, 'compositionend', onCompositionEnd);
  10424. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  10425. // switching focus before confirming composition choice
  10426. // this also fixes the issue where some browsers e.g. iOS Chrome
  10427. // fires "change" instead of "input" on autocomplete.
  10428. addEventListener(el, 'change', onCompositionEnd);
  10429. }
  10430. },
  10431. // set value on mounted so it's after min/max for type="range"
  10432. mounted(el, { value }) {
  10433. el.value = value == null ? '' : value;
  10434. },
  10435. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  10436. el._assign = getModelAssigner(vnode);
  10437. // avoid clearing unresolved text. #2302
  10438. if (el.composing)
  10439. return;
  10440. if (document.activeElement === el && el.type !== 'range') {
  10441. if (lazy) {
  10442. return;
  10443. }
  10444. if (trim && el.value.trim() === value) {
  10445. return;
  10446. }
  10447. if ((number || el.type === 'number') && toNumber(el.value) === value) {
  10448. return;
  10449. }
  10450. }
  10451. const newValue = value == null ? '' : value;
  10452. if (el.value !== newValue) {
  10453. el.value = newValue;
  10454. }
  10455. }
  10456. };
  10457. const vModelCheckbox = {
  10458. // #4096 array checkboxes need to be deep traversed
  10459. deep: true,
  10460. created(el, _, vnode) {
  10461. el._assign = getModelAssigner(vnode);
  10462. addEventListener(el, 'change', () => {
  10463. const modelValue = el._modelValue;
  10464. const elementValue = getValue(el);
  10465. const checked = el.checked;
  10466. const assign = el._assign;
  10467. if (isArray(modelValue)) {
  10468. const index = looseIndexOf(modelValue, elementValue);
  10469. const found = index !== -1;
  10470. if (checked && !found) {
  10471. assign(modelValue.concat(elementValue));
  10472. }
  10473. else if (!checked && found) {
  10474. const filtered = [...modelValue];
  10475. filtered.splice(index, 1);
  10476. assign(filtered);
  10477. }
  10478. }
  10479. else if (isSet(modelValue)) {
  10480. const cloned = new Set(modelValue);
  10481. if (checked) {
  10482. cloned.add(elementValue);
  10483. }
  10484. else {
  10485. cloned.delete(elementValue);
  10486. }
  10487. assign(cloned);
  10488. }
  10489. else {
  10490. assign(getCheckboxValue(el, checked));
  10491. }
  10492. });
  10493. },
  10494. // set initial checked on mount to wait for true-value/false-value
  10495. mounted: setChecked,
  10496. beforeUpdate(el, binding, vnode) {
  10497. el._assign = getModelAssigner(vnode);
  10498. setChecked(el, binding, vnode);
  10499. }
  10500. };
  10501. function setChecked(el, { value, oldValue }, vnode) {
  10502. el._modelValue = value;
  10503. if (isArray(value)) {
  10504. el.checked = looseIndexOf(value, vnode.props.value) > -1;
  10505. }
  10506. else if (isSet(value)) {
  10507. el.checked = value.has(vnode.props.value);
  10508. }
  10509. else if (value !== oldValue) {
  10510. el.checked = looseEqual(value, getCheckboxValue(el, true));
  10511. }
  10512. }
  10513. const vModelRadio = {
  10514. created(el, { value }, vnode) {
  10515. el.checked = looseEqual(value, vnode.props.value);
  10516. el._assign = getModelAssigner(vnode);
  10517. addEventListener(el, 'change', () => {
  10518. el._assign(getValue(el));
  10519. });
  10520. },
  10521. beforeUpdate(el, { value, oldValue }, vnode) {
  10522. el._assign = getModelAssigner(vnode);
  10523. if (value !== oldValue) {
  10524. el.checked = looseEqual(value, vnode.props.value);
  10525. }
  10526. }
  10527. };
  10528. const vModelSelect = {
  10529. // <select multiple> value need to be deep traversed
  10530. deep: true,
  10531. created(el, { value, modifiers: { number } }, vnode) {
  10532. const isSetModel = isSet(value);
  10533. addEventListener(el, 'change', () => {
  10534. const selectedVal = Array.prototype.filter
  10535. .call(el.options, (o) => o.selected)
  10536. .map((o) => number ? toNumber(getValue(o)) : getValue(o));
  10537. el._assign(el.multiple
  10538. ? isSetModel
  10539. ? new Set(selectedVal)
  10540. : selectedVal
  10541. : selectedVal[0]);
  10542. });
  10543. el._assign = getModelAssigner(vnode);
  10544. },
  10545. // set value in mounted & updated because <select> relies on its children
  10546. // <option>s.
  10547. mounted(el, { value }) {
  10548. setSelected(el, value);
  10549. },
  10550. beforeUpdate(el, _binding, vnode) {
  10551. el._assign = getModelAssigner(vnode);
  10552. },
  10553. updated(el, { value }) {
  10554. setSelected(el, value);
  10555. }
  10556. };
  10557. function setSelected(el, value) {
  10558. const isMultiple = el.multiple;
  10559. if (isMultiple && !isArray(value) && !isSet(value)) {
  10560. warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
  10561. `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
  10562. return;
  10563. }
  10564. for (let i = 0, l = el.options.length; i < l; i++) {
  10565. const option = el.options[i];
  10566. const optionValue = getValue(option);
  10567. if (isMultiple) {
  10568. if (isArray(value)) {
  10569. option.selected = looseIndexOf(value, optionValue) > -1;
  10570. }
  10571. else {
  10572. option.selected = value.has(optionValue);
  10573. }
  10574. }
  10575. else {
  10576. if (looseEqual(getValue(option), value)) {
  10577. if (el.selectedIndex !== i)
  10578. el.selectedIndex = i;
  10579. return;
  10580. }
  10581. }
  10582. }
  10583. if (!isMultiple && el.selectedIndex !== -1) {
  10584. el.selectedIndex = -1;
  10585. }
  10586. }
  10587. // retrieve raw value set via :value bindings
  10588. function getValue(el) {
  10589. return '_value' in el ? el._value : el.value;
  10590. }
  10591. // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
  10592. function getCheckboxValue(el, checked) {
  10593. const key = checked ? '_trueValue' : '_falseValue';
  10594. return key in el ? el[key] : checked;
  10595. }
  10596. const vModelDynamic = {
  10597. created(el, binding, vnode) {
  10598. callModelHook(el, binding, vnode, null, 'created');
  10599. },
  10600. mounted(el, binding, vnode) {
  10601. callModelHook(el, binding, vnode, null, 'mounted');
  10602. },
  10603. beforeUpdate(el, binding, vnode, prevVNode) {
  10604. callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
  10605. },
  10606. updated(el, binding, vnode, prevVNode) {
  10607. callModelHook(el, binding, vnode, prevVNode, 'updated');
  10608. }
  10609. };
  10610. function resolveDynamicModel(tagName, type) {
  10611. switch (tagName) {
  10612. case 'SELECT':
  10613. return vModelSelect;
  10614. case 'TEXTAREA':
  10615. return vModelText;
  10616. default:
  10617. switch (type) {
  10618. case 'checkbox':
  10619. return vModelCheckbox;
  10620. case 'radio':
  10621. return vModelRadio;
  10622. default:
  10623. return vModelText;
  10624. }
  10625. }
  10626. }
  10627. function callModelHook(el, binding, vnode, prevVNode, hook) {
  10628. const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
  10629. const fn = modelToUse[hook];
  10630. fn && fn(el, binding, vnode, prevVNode);
  10631. }
  10632. const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
  10633. const modifierGuards = {
  10634. stop: e => e.stopPropagation(),
  10635. prevent: e => e.preventDefault(),
  10636. self: e => e.target !== e.currentTarget,
  10637. ctrl: e => !e.ctrlKey,
  10638. shift: e => !e.shiftKey,
  10639. alt: e => !e.altKey,
  10640. meta: e => !e.metaKey,
  10641. left: e => 'button' in e && e.button !== 0,
  10642. middle: e => 'button' in e && e.button !== 1,
  10643. right: e => 'button' in e && e.button !== 2,
  10644. exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
  10645. };
  10646. /**
  10647. * @private
  10648. */
  10649. const withModifiers = (fn, modifiers) => {
  10650. return (event, ...args) => {
  10651. for (let i = 0; i < modifiers.length; i++) {
  10652. const guard = modifierGuards[modifiers[i]];
  10653. if (guard && guard(event, modifiers))
  10654. return;
  10655. }
  10656. return fn(event, ...args);
  10657. };
  10658. };
  10659. // Kept for 2.x compat.
  10660. // Note: IE11 compat for `spacebar` and `del` is removed for now.
  10661. const keyNames = {
  10662. esc: 'escape',
  10663. space: ' ',
  10664. up: 'arrow-up',
  10665. left: 'arrow-left',
  10666. right: 'arrow-right',
  10667. down: 'arrow-down',
  10668. delete: 'backspace'
  10669. };
  10670. /**
  10671. * @private
  10672. */
  10673. const withKeys = (fn, modifiers) => {
  10674. return (event) => {
  10675. if (!('key' in event)) {
  10676. return;
  10677. }
  10678. const eventKey = hyphenate(event.key);
  10679. if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
  10680. return fn(event);
  10681. }
  10682. };
  10683. };
  10684. const vShow = {
  10685. beforeMount(el, { value }, { transition }) {
  10686. el._vod = el.style.display === 'none' ? '' : el.style.display;
  10687. if (transition && value) {
  10688. transition.beforeEnter(el);
  10689. }
  10690. else {
  10691. setDisplay(el, value);
  10692. }
  10693. },
  10694. mounted(el, { value }, { transition }) {
  10695. if (transition && value) {
  10696. transition.enter(el);
  10697. }
  10698. },
  10699. updated(el, { value, oldValue }, { transition }) {
  10700. if (!value === !oldValue)
  10701. return;
  10702. if (transition) {
  10703. if (value) {
  10704. transition.beforeEnter(el);
  10705. setDisplay(el, true);
  10706. transition.enter(el);
  10707. }
  10708. else {
  10709. transition.leave(el, () => {
  10710. setDisplay(el, false);
  10711. });
  10712. }
  10713. }
  10714. else {
  10715. setDisplay(el, value);
  10716. }
  10717. },
  10718. beforeUnmount(el, { value }) {
  10719. setDisplay(el, value);
  10720. }
  10721. };
  10722. function setDisplay(el, value) {
  10723. el.style.display = value ? el._vod : 'none';
  10724. }
  10725. const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
  10726. // lazy create the renderer - this makes core renderer logic tree-shakable
  10727. // in case the user only imports reactivity utilities from Vue.
  10728. let renderer;
  10729. let enabledHydration = false;
  10730. function ensureRenderer() {
  10731. return (renderer ||
  10732. (renderer = createRenderer(rendererOptions)));
  10733. }
  10734. function ensureHydrationRenderer() {
  10735. renderer = enabledHydration
  10736. ? renderer
  10737. : createHydrationRenderer(rendererOptions);
  10738. enabledHydration = true;
  10739. return renderer;
  10740. }
  10741. // use explicit type casts here to avoid import() calls in rolled-up d.ts
  10742. const render = ((...args) => {
  10743. ensureRenderer().render(...args);
  10744. });
  10745. const hydrate = ((...args) => {
  10746. ensureHydrationRenderer().hydrate(...args);
  10747. });
  10748. const createApp = ((...args) => {
  10749. const app = ensureRenderer().createApp(...args);
  10750. {
  10751. injectNativeTagCheck(app);
  10752. injectCompilerOptionsCheck(app);
  10753. }
  10754. const { mount } = app;
  10755. app.mount = (containerOrSelector) => {
  10756. const container = normalizeContainer(containerOrSelector);
  10757. if (!container)
  10758. return;
  10759. const component = app._component;
  10760. if (!isFunction(component) && !component.render && !component.template) {
  10761. // __UNSAFE__
  10762. // Reason: potential execution of JS expressions in in-DOM template.
  10763. // The user must make sure the in-DOM template is trusted. If it's
  10764. // rendered by the server, the template should not contain any user data.
  10765. component.template = container.innerHTML;
  10766. }
  10767. // clear content before mounting
  10768. container.innerHTML = '';
  10769. const proxy = mount(container, false, container instanceof SVGElement);
  10770. if (container instanceof Element) {
  10771. container.removeAttribute('v-cloak');
  10772. container.setAttribute('data-v-app', '');
  10773. }
  10774. return proxy;
  10775. };
  10776. return app;
  10777. });
  10778. const createSSRApp = ((...args) => {
  10779. const app = ensureHydrationRenderer().createApp(...args);
  10780. {
  10781. injectNativeTagCheck(app);
  10782. injectCompilerOptionsCheck(app);
  10783. }
  10784. const { mount } = app;
  10785. app.mount = (containerOrSelector) => {
  10786. const container = normalizeContainer(containerOrSelector);
  10787. if (container) {
  10788. return mount(container, true, container instanceof SVGElement);
  10789. }
  10790. };
  10791. return app;
  10792. });
  10793. function injectNativeTagCheck(app) {
  10794. // Inject `isNativeTag`
  10795. // this is used for component name validation (dev only)
  10796. Object.defineProperty(app.config, 'isNativeTag', {
  10797. value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  10798. writable: false
  10799. });
  10800. }
  10801. // dev only
  10802. function injectCompilerOptionsCheck(app) {
  10803. if (isRuntimeOnly()) {
  10804. const isCustomElement = app.config.isCustomElement;
  10805. Object.defineProperty(app.config, 'isCustomElement', {
  10806. get() {
  10807. return isCustomElement;
  10808. },
  10809. set() {
  10810. warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
  10811. `\`compilerOptions.isCustomElement\` instead.`);
  10812. }
  10813. });
  10814. const compilerOptions = app.config.compilerOptions;
  10815. const msg = `The \`compilerOptions\` config option is only respected when using ` +
  10816. `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
  10817. `Since you are using the runtime-only build, \`compilerOptions\` ` +
  10818. `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
  10819. `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
  10820. `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
  10821. `- 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`;
  10822. Object.defineProperty(app.config, 'compilerOptions', {
  10823. get() {
  10824. warn$1(msg);
  10825. return compilerOptions;
  10826. },
  10827. set() {
  10828. warn$1(msg);
  10829. }
  10830. });
  10831. }
  10832. }
  10833. function normalizeContainer(container) {
  10834. if (isString(container)) {
  10835. const res = document.querySelector(container);
  10836. if (!res) {
  10837. warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
  10838. }
  10839. return res;
  10840. }
  10841. if (window.ShadowRoot &&
  10842. container instanceof window.ShadowRoot &&
  10843. container.mode === 'closed') {
  10844. warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
  10845. }
  10846. return container;
  10847. }
  10848. /**
  10849. * @internal
  10850. */
  10851. const initDirectivesForSSR = NOOP;
  10852. exports.BaseTransition = BaseTransition;
  10853. exports.Comment = Comment;
  10854. exports.EffectScope = EffectScope;
  10855. exports.Fragment = Fragment;
  10856. exports.KeepAlive = KeepAlive;
  10857. exports.ReactiveEffect = ReactiveEffect;
  10858. exports.Static = Static;
  10859. exports.Suspense = Suspense;
  10860. exports.Teleport = Teleport;
  10861. exports.Text = Text;
  10862. exports.Transition = Transition;
  10863. exports.TransitionGroup = TransitionGroup;
  10864. exports.VueElement = VueElement;
  10865. exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
  10866. exports.callWithErrorHandling = callWithErrorHandling;
  10867. exports.camelize = camelize;
  10868. exports.capitalize = capitalize;
  10869. exports.cloneVNode = cloneVNode;
  10870. exports.compatUtils = compatUtils;
  10871. exports.computed = computed$1;
  10872. exports.createApp = createApp;
  10873. exports.createBlock = createBlock;
  10874. exports.createCommentVNode = createCommentVNode;
  10875. exports.createElementBlock = createElementBlock;
  10876. exports.createElementVNode = createBaseVNode;
  10877. exports.createHydrationRenderer = createHydrationRenderer;
  10878. exports.createPropsRestProxy = createPropsRestProxy;
  10879. exports.createRenderer = createRenderer;
  10880. exports.createSSRApp = createSSRApp;
  10881. exports.createSlots = createSlots;
  10882. exports.createStaticVNode = createStaticVNode;
  10883. exports.createTextVNode = createTextVNode;
  10884. exports.createVNode = createVNode;
  10885. exports.customRef = customRef;
  10886. exports.defineAsyncComponent = defineAsyncComponent;
  10887. exports.defineComponent = defineComponent;
  10888. exports.defineCustomElement = defineCustomElement;
  10889. exports.defineEmits = defineEmits;
  10890. exports.defineExpose = defineExpose;
  10891. exports.defineProps = defineProps;
  10892. exports.defineSSRCustomElement = defineSSRCustomElement;
  10893. exports.effect = effect;
  10894. exports.effectScope = effectScope;
  10895. exports.getCurrentInstance = getCurrentInstance;
  10896. exports.getCurrentScope = getCurrentScope;
  10897. exports.getTransitionRawChildren = getTransitionRawChildren;
  10898. exports.guardReactiveProps = guardReactiveProps;
  10899. exports.h = h;
  10900. exports.handleError = handleError;
  10901. exports.hydrate = hydrate;
  10902. exports.initCustomFormatter = initCustomFormatter;
  10903. exports.initDirectivesForSSR = initDirectivesForSSR;
  10904. exports.inject = inject;
  10905. exports.isMemoSame = isMemoSame;
  10906. exports.isProxy = isProxy;
  10907. exports.isReactive = isReactive;
  10908. exports.isReadonly = isReadonly;
  10909. exports.isRef = isRef;
  10910. exports.isRuntimeOnly = isRuntimeOnly;
  10911. exports.isShallow = isShallow;
  10912. exports.isVNode = isVNode;
  10913. exports.markRaw = markRaw;
  10914. exports.mergeDefaults = mergeDefaults;
  10915. exports.mergeProps = mergeProps;
  10916. exports.nextTick = nextTick;
  10917. exports.normalizeClass = normalizeClass;
  10918. exports.normalizeProps = normalizeProps;
  10919. exports.normalizeStyle = normalizeStyle;
  10920. exports.onActivated = onActivated;
  10921. exports.onBeforeMount = onBeforeMount;
  10922. exports.onBeforeUnmount = onBeforeUnmount;
  10923. exports.onBeforeUpdate = onBeforeUpdate;
  10924. exports.onDeactivated = onDeactivated;
  10925. exports.onErrorCaptured = onErrorCaptured;
  10926. exports.onMounted = onMounted;
  10927. exports.onRenderTracked = onRenderTracked;
  10928. exports.onRenderTriggered = onRenderTriggered;
  10929. exports.onScopeDispose = onScopeDispose;
  10930. exports.onServerPrefetch = onServerPrefetch;
  10931. exports.onUnmounted = onUnmounted;
  10932. exports.onUpdated = onUpdated;
  10933. exports.openBlock = openBlock;
  10934. exports.popScopeId = popScopeId;
  10935. exports.provide = provide;
  10936. exports.proxyRefs = proxyRefs;
  10937. exports.pushScopeId = pushScopeId;
  10938. exports.queuePostFlushCb = queuePostFlushCb;
  10939. exports.reactive = reactive;
  10940. exports.readonly = readonly;
  10941. exports.ref = ref;
  10942. exports.registerRuntimeCompiler = registerRuntimeCompiler;
  10943. exports.render = render;
  10944. exports.renderList = renderList;
  10945. exports.renderSlot = renderSlot;
  10946. exports.resolveComponent = resolveComponent;
  10947. exports.resolveDirective = resolveDirective;
  10948. exports.resolveDynamicComponent = resolveDynamicComponent;
  10949. exports.resolveFilter = resolveFilter;
  10950. exports.resolveTransitionHooks = resolveTransitionHooks;
  10951. exports.setBlockTracking = setBlockTracking;
  10952. exports.setDevtoolsHook = setDevtoolsHook;
  10953. exports.setTransitionHooks = setTransitionHooks;
  10954. exports.shallowReactive = shallowReactive;
  10955. exports.shallowReadonly = shallowReadonly;
  10956. exports.shallowRef = shallowRef;
  10957. exports.ssrContextKey = ssrContextKey;
  10958. exports.ssrUtils = ssrUtils;
  10959. exports.stop = stop;
  10960. exports.toDisplayString = toDisplayString;
  10961. exports.toHandlerKey = toHandlerKey;
  10962. exports.toHandlers = toHandlers;
  10963. exports.toRaw = toRaw;
  10964. exports.toRef = toRef;
  10965. exports.toRefs = toRefs;
  10966. exports.transformVNodeArgs = transformVNodeArgs;
  10967. exports.triggerRef = triggerRef;
  10968. exports.unref = unref;
  10969. exports.useAttrs = useAttrs;
  10970. exports.useCssModule = useCssModule;
  10971. exports.useCssVars = useCssVars;
  10972. exports.useSSRContext = useSSRContext;
  10973. exports.useSlots = useSlots;
  10974. exports.useTransitionState = useTransitionState;
  10975. exports.vModelCheckbox = vModelCheckbox;
  10976. exports.vModelDynamic = vModelDynamic;
  10977. exports.vModelRadio = vModelRadio;
  10978. exports.vModelSelect = vModelSelect;
  10979. exports.vModelText = vModelText;
  10980. exports.vShow = vShow;
  10981. exports.version = version;
  10982. exports.warn = warn$1;
  10983. exports.watch = watch;
  10984. exports.watchEffect = watchEffect;
  10985. exports.watchPostEffect = watchPostEffect;
  10986. exports.watchSyncEffect = watchSyncEffect;
  10987. exports.withAsyncContext = withAsyncContext;
  10988. exports.withCtx = withCtx;
  10989. exports.withDefaults = withDefaults;
  10990. exports.withDirectives = withDirectives;
  10991. exports.withKeys = withKeys;
  10992. exports.withMemo = withMemo;
  10993. exports.withModifiers = withModifiers;
  10994. exports.withScopeId = withScopeId;
  10995. Object.defineProperty(exports, '__esModule', { value: true });
  10996. return exports;
  10997. }({}));