nvue.runtime.esm.prod.js 222 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662
  1. import { isFunction, isPromise, isArray, EMPTY_OBJ, remove, isString, camelize, capitalize, isObject, toHandlerKey, getGlobalThis, normalizeClass, extend, normalizeStyle, isOn, hasChanged, hasOwn, hyphenate, toNumber, NOOP, isSet, isMap, isPlainObject, invokeArrayFns, isRegExp, EMPTY_ARR, isModelListener, isReservedProp, parseStringStyle, looseToNumber, def, NO, isGloballyWhitelisted } from '@vue/shared';
  2. export { camelize, capitalize, hyphenate, normalizeClass, normalizeProps, normalizeStyle, toDisplayString, toHandlerKey } from '@vue/shared';
  3. import { getCurrentScope, isRef, isShallow, isReactive, ReactiveEffect, ref, pauseTracking, resetTracking, isProxy, computed as computed$1, toRaw, proxyRefs, markRaw, EffectScope, track, reactive, shallowReactive, trigger } from '@vue/reactivity';
  4. export { EffectScope, ReactiveEffect, customRef, effect, effectScope, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, triggerRef, unref } from '@vue/reactivity';
  5. import { isRootHook, isRootImmediateHook, ON_LOAD } from '@dcloudio/uni-shared';
  6. function warn(msg) {
  7. return;
  8. }
  9. /**
  10. * @internal
  11. */
  12. function assertNumber(val, type) {
  13. return;
  14. }
  15. function callWithErrorHandling(fn, instance, type, args) {
  16. var res;
  17. try {
  18. res = args ? fn(...args) : fn();
  19. } catch (err) {
  20. handleError(err, instance, type);
  21. }
  22. return res;
  23. }
  24. function callWithAsyncErrorHandling(fn, instance, type, args) {
  25. if (isFunction(fn)) {
  26. var res = callWithErrorHandling(fn, instance, type, args);
  27. if (res && isPromise(res)) {
  28. res.catch(err => {
  29. handleError(err, instance, type);
  30. });
  31. }
  32. return res;
  33. }
  34. var values = [];
  35. for (var i = 0; i < fn.length; i++) {
  36. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  37. }
  38. return values;
  39. }
  40. function handleError(err, instance, type) {
  41. var throwInDev = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  42. var contextVNode = instance ? instance.vnode : null;
  43. if (instance) {
  44. var cur = instance.parent;
  45. // the exposed instance is the render proxy to keep it consistent with 2.x
  46. var exposedInstance = instance.proxy;
  47. // in production the hook receives only the error code
  48. // fixed by xxxxxx
  49. var errorInfo = type;
  50. while (cur) {
  51. var errorCapturedHooks = cur.ec;
  52. if (errorCapturedHooks) {
  53. for (var i = 0; i < errorCapturedHooks.length; i++) {
  54. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  55. return;
  56. }
  57. }
  58. }
  59. cur = cur.parent;
  60. }
  61. // app-level handling
  62. var appErrorHandler = instance.appContext.config.errorHandler;
  63. if (appErrorHandler) {
  64. callWithErrorHandling(appErrorHandler, null, 10 /* ErrorCodes.APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
  65. return;
  66. }
  67. }
  68. logError(err, type, contextVNode, throwInDev);
  69. }
  70. function logError(err, type, contextVNode) {
  71. var throwInDev = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  72. {
  73. // recover in prod to reduce the impact on end-user
  74. console.error(err);
  75. }
  76. }
  77. var isFlushing = false;
  78. var isFlushPending = false;
  79. var queue = [];
  80. var flushIndex = 0;
  81. var pendingPostFlushCbs = [];
  82. var activePostFlushCbs = null;
  83. var postFlushIndex = 0;
  84. var resolvedPromise = /*#__PURE__*/Promise.resolve();
  85. var currentFlushPromise = null;
  86. function nextTick(fn) {
  87. var p = currentFlushPromise || resolvedPromise;
  88. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  89. }
  90. // #2768
  91. // Use binary-search to find a suitable position in the queue,
  92. // so that the queue maintains the increasing order of job's id,
  93. // which can prevent the job from being skipped and also can avoid repeated patching.
  94. function findInsertionIndex(id) {
  95. // the start index should be `flushIndex + 1`
  96. var start = flushIndex + 1;
  97. var end = queue.length;
  98. while (start < end) {
  99. var middle = start + end >>> 1;
  100. var middleJobId = getId(queue[middle]);
  101. middleJobId < id ? start = middle + 1 : end = middle;
  102. }
  103. return start;
  104. }
  105. function queueJob(job) {
  106. // the dedupe search uses the startIndex argument of Array.includes()
  107. // by default the search index includes the current job that is being run
  108. // so it cannot recursively trigger itself again.
  109. // if the job is a watch() callback, the search will start with a +1 index to
  110. // allow it recursively trigger itself - it is the user's responsibility to
  111. // ensure it doesn't end up in an infinite loop.
  112. if (!queue.length || !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) {
  113. if (job.id == null) {
  114. queue.push(job);
  115. } else {
  116. queue.splice(findInsertionIndex(job.id), 0, job);
  117. }
  118. queueFlush();
  119. }
  120. }
  121. function queueFlush() {
  122. if (!isFlushing && !isFlushPending) {
  123. isFlushPending = true;
  124. currentFlushPromise = resolvedPromise.then(flushJobs);
  125. }
  126. }
  127. function invalidateJob(job) {
  128. var i = queue.indexOf(job);
  129. if (i > flushIndex) {
  130. queue.splice(i, 1);
  131. }
  132. }
  133. function queuePostFlushCb(cb) {
  134. if (!isArray(cb)) {
  135. if (!activePostFlushCbs || !activePostFlushCbs.includes(cb, cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex)) {
  136. pendingPostFlushCbs.push(cb);
  137. }
  138. } else {
  139. // if cb is an array, it is a component lifecycle hook which can only be
  140. // triggered by a job, which is already deduped in the main queue, so
  141. // we can skip duplicate check here to improve perf
  142. pendingPostFlushCbs.push(...cb);
  143. }
  144. queueFlush();
  145. }
  146. function flushPreFlushCbs(seen) {
  147. var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isFlushing ? flushIndex + 1 : 0;
  148. for (; i < queue.length; i++) {
  149. var cb = queue[i];
  150. if (cb && cb.pre) {
  151. queue.splice(i, 1);
  152. i--;
  153. cb();
  154. }
  155. }
  156. }
  157. function flushPostFlushCbs(seen) {
  158. if (pendingPostFlushCbs.length) {
  159. var deduped = [...new Set(pendingPostFlushCbs)];
  160. pendingPostFlushCbs.length = 0;
  161. // #1947 already has active queue, nested flushPostFlushCbs call
  162. if (activePostFlushCbs) {
  163. activePostFlushCbs.push(...deduped);
  164. return;
  165. }
  166. activePostFlushCbs = deduped;
  167. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  168. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  169. activePostFlushCbs[postFlushIndex]();
  170. }
  171. activePostFlushCbs = null;
  172. postFlushIndex = 0;
  173. }
  174. }
  175. var getId = job => job.id == null ? Infinity : job.id;
  176. var comparator = (a, b) => {
  177. var diff = getId(a) - getId(b);
  178. if (diff === 0) {
  179. if (a.pre && !b.pre) return -1;
  180. if (b.pre && !a.pre) return 1;
  181. }
  182. return diff;
  183. };
  184. function flushJobs(seen) {
  185. isFlushPending = false;
  186. isFlushing = true;
  187. // Sort queue before flush.
  188. // This ensures that:
  189. // 1. Components are updated from parent to child. (because parent is always
  190. // created before the child so its render effect will have smaller
  191. // priority number)
  192. // 2. If a component is unmounted during a parent component's update,
  193. // its update can be skipped.
  194. queue.sort(comparator);
  195. // conditional usage of checkRecursiveUpdate must be determined out of
  196. // try ... catch block since Rollup by default de-optimizes treeshaking
  197. // inside try-catch. This can leave all warning code unshaked. Although
  198. // they would get eventually shaken by a minifier like terser, some minifiers
  199. // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
  200. var check = NOOP;
  201. try {
  202. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  203. var job = queue[flushIndex];
  204. if (job && job.active !== false) {
  205. if ("production" !== 'production' && check(job)) ;
  206. // console.log(`running:`, job.id)
  207. callWithErrorHandling(job, null, 14 /* ErrorCodes.SCHEDULER */);
  208. }
  209. }
  210. } finally {
  211. flushIndex = 0;
  212. queue.length = 0;
  213. flushPostFlushCbs();
  214. isFlushing = false;
  215. currentFlushPromise = null;
  216. // some postFlushCb queued jobs!
  217. // keep flushing until it drains.
  218. if (queue.length || pendingPostFlushCbs.length) {
  219. flushJobs();
  220. }
  221. }
  222. }
  223. var devtools;
  224. var buffer = [];
  225. function setDevtoolsHook(hook, target) {
  226. var _a, _b;
  227. devtools = hook;
  228. if (devtools) {
  229. devtools.enabled = true;
  230. buffer.forEach(_ref => {
  231. var {
  232. event,
  233. args
  234. } = _ref;
  235. return devtools.emit(event, ...args);
  236. });
  237. buffer = [];
  238. } else if (
  239. // handle late devtools injection - only do this if we are in an actual
  240. // browser environment to avoid the timer handle stalling test runner exit
  241. // (#4815)
  242. typeof window !== 'undefined' &&
  243. // some envs mock window but not fully
  244. window.HTMLElement &&
  245. // also exclude jsdom
  246. !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
  247. var replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
  248. replay.push(newHook => {
  249. setDevtoolsHook(newHook, target);
  250. });
  251. // clear buffer after 3s - the user probably doesn't have devtools installed
  252. // at all, and keeping the buffer will cause memory leaks (#4738)
  253. setTimeout(() => {
  254. if (!devtools) {
  255. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  256. buffer = [];
  257. }
  258. }, 3000);
  259. } else {
  260. buffer = [];
  261. }
  262. }
  263. function emit(instance, event) {
  264. if (instance.isUnmounted) return;
  265. var props = instance.vnode.props || EMPTY_OBJ;
  266. for (var _len = arguments.length, rawArgs = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  267. rawArgs[_key - 2] = arguments[_key];
  268. }
  269. var args = rawArgs;
  270. var isModelListener = event.startsWith('update:');
  271. // for v-model update:xxx events, apply modifiers on args
  272. var modelArg = isModelListener && event.slice(7);
  273. if (modelArg && modelArg in props) {
  274. var modifiersKey = "".concat(modelArg === 'modelValue' ? 'model' : modelArg, "Modifiers");
  275. var {
  276. number,
  277. trim
  278. } = props[modifiersKey] || EMPTY_OBJ;
  279. if (trim) {
  280. args = rawArgs.map(a => isString(a) ? a.trim() : a);
  281. }
  282. if (number) {
  283. args = rawArgs.map(looseToNumber);
  284. }
  285. }
  286. var handlerName;
  287. var handler = props[handlerName = toHandlerKey(event)] ||
  288. // also try camelCase event handler (#2249)
  289. props[handlerName = toHandlerKey(camelize(event))];
  290. // for v-model update:xxx events, also trigger kebab-case equivalent
  291. // for props passed via kebab-case
  292. if (!handler && isModelListener) {
  293. handler = props[handlerName = toHandlerKey(hyphenate(event))];
  294. }
  295. if (handler) {
  296. callWithAsyncErrorHandling(handler, instance, 6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */, args);
  297. }
  298. var onceHandler = props[handlerName + "Once"];
  299. if (onceHandler) {
  300. if (!instance.emitted) {
  301. instance.emitted = {};
  302. } else if (instance.emitted[handlerName]) {
  303. return;
  304. }
  305. instance.emitted[handlerName] = true;
  306. callWithAsyncErrorHandling(onceHandler, instance, 6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */, args);
  307. }
  308. }
  309. function normalizeEmitsOptions(comp, appContext) {
  310. var asMixin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  311. var cache = appContext.emitsCache;
  312. var cached = cache.get(comp);
  313. if (cached !== undefined) {
  314. return cached;
  315. }
  316. var raw = comp.emits;
  317. var normalized = {};
  318. // apply mixin/extends props
  319. var hasExtends = false;
  320. if (!isFunction(comp)) {
  321. var extendEmits = raw => {
  322. var normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
  323. if (normalizedFromExtend) {
  324. hasExtends = true;
  325. extend(normalized, normalizedFromExtend);
  326. }
  327. };
  328. if (!asMixin && appContext.mixins.length) {
  329. appContext.mixins.forEach(extendEmits);
  330. }
  331. if (comp.extends) {
  332. extendEmits(comp.extends);
  333. }
  334. if (comp.mixins) {
  335. comp.mixins.forEach(extendEmits);
  336. }
  337. }
  338. if (!raw && !hasExtends) {
  339. if (isObject(comp)) {
  340. cache.set(comp, null);
  341. }
  342. return null;
  343. }
  344. if (isArray(raw)) {
  345. raw.forEach(key => normalized[key] = null);
  346. } else {
  347. extend(normalized, raw);
  348. }
  349. if (isObject(comp)) {
  350. cache.set(comp, normalized);
  351. }
  352. return normalized;
  353. }
  354. // Check if an incoming prop key is a declared emit event listener.
  355. // e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
  356. // both considered matched listeners.
  357. function isEmitListener(options, key) {
  358. if (!options || !isOn(key)) {
  359. return false;
  360. }
  361. key = key.slice(2).replace(/Once$/, '');
  362. return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
  363. }
  364. /**
  365. * mark the current rendering instance for asset resolution (e.g.
  366. * resolveComponent, resolveDirective) during render
  367. */
  368. var currentRenderingInstance = null;
  369. var currentScopeId = null;
  370. /**
  371. * Note: rendering calls maybe nested. The function returns the parent rendering
  372. * instance if present, which should be restored after the render is done:
  373. *
  374. * ```js
  375. * const prev = setCurrentRenderingInstance(i)
  376. * // ...render
  377. * setCurrentRenderingInstance(prev)
  378. * ```
  379. */
  380. function setCurrentRenderingInstance(instance) {
  381. var prev = currentRenderingInstance;
  382. currentRenderingInstance = instance;
  383. currentScopeId = instance && instance.type.__scopeId || null;
  384. return prev;
  385. }
  386. /**
  387. * Set scope id when creating hoisted vnodes.
  388. * @private compiler helper
  389. */
  390. function pushScopeId(id) {
  391. currentScopeId = id;
  392. }
  393. /**
  394. * Technically we no longer need this after 3.0.8 but we need to keep the same
  395. * API for backwards compat w/ code generated by compilers.
  396. * @private
  397. */
  398. function popScopeId() {
  399. currentScopeId = null;
  400. }
  401. /**
  402. * Only for backwards compat
  403. * @private
  404. */
  405. var withScopeId = _id => withCtx;
  406. /**
  407. * Wrap a slot function to memoize current rendering instance
  408. * @private compiler helper
  409. */
  410. function withCtx(fn) {
  411. var ctx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : currentRenderingInstance;
  412. var isNonScopedSlot // false only
  413. = arguments.length > 2 ? arguments[2] : undefined;
  414. if (!ctx) return fn;
  415. // already normalized
  416. if (fn._n) {
  417. return fn;
  418. }
  419. var renderFnWithContext = function () {
  420. // If a user calls a compiled slot inside a template expression (#1745), it
  421. // can mess up block tracking, so by default we disable block tracking and
  422. // force bail out when invoking a compiled slot (indicated by the ._d flag).
  423. // This isn't necessary if rendering a compiled `<slot>`, so we flip the
  424. // ._d flag off when invoking the wrapped fn inside `renderSlot`.
  425. if (renderFnWithContext._d) {
  426. setBlockTracking(-1);
  427. }
  428. var prevInstance = setCurrentRenderingInstance(ctx);
  429. var res;
  430. try {
  431. res = fn(...arguments);
  432. } finally {
  433. setCurrentRenderingInstance(prevInstance);
  434. if (renderFnWithContext._d) {
  435. setBlockTracking(1);
  436. }
  437. }
  438. return res;
  439. };
  440. // mark normalized to avoid duplicated wrapping
  441. renderFnWithContext._n = true;
  442. // mark this as compiled by default
  443. // this is used in vnode.ts -> normalizeChildren() to set the slot
  444. // rendering flag.
  445. renderFnWithContext._c = true;
  446. // disable block tracking by default
  447. renderFnWithContext._d = true;
  448. return renderFnWithContext;
  449. }
  450. function markAttrsAccessed() {}
  451. function renderComponentRoot(instance) {
  452. var {
  453. type: Component,
  454. vnode,
  455. proxy,
  456. withProxy,
  457. props,
  458. propsOptions: [propsOptions],
  459. slots,
  460. attrs,
  461. emit,
  462. render,
  463. renderCache,
  464. data,
  465. setupState,
  466. ctx,
  467. inheritAttrs
  468. } = instance;
  469. var result;
  470. var fallthroughAttrs;
  471. var prev = setCurrentRenderingInstance(instance);
  472. try {
  473. if (vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */) {
  474. // withProxy is a proxy with a different `has` trap only for
  475. // runtime-compiled render functions using `with` block.
  476. var proxyToUse = withProxy || proxy;
  477. result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
  478. fallthroughAttrs = attrs;
  479. } else {
  480. // functional
  481. var _render = Component;
  482. // in dev, mark attrs accessed if optional props (attrs === props)
  483. if ("production" !== 'production' && attrs === props) ;
  484. result = normalizeVNode(_render.length > 1 ? _render(props, "production" !== 'production' ? {
  485. get attrs() {
  486. markAttrsAccessed();
  487. return attrs;
  488. },
  489. slots,
  490. emit
  491. } : {
  492. attrs,
  493. slots,
  494. emit
  495. }) : _render(props, null /* we know it doesn't need it */));
  496. fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
  497. }
  498. } catch (err) {
  499. blockStack.length = 0;
  500. handleError(err, instance, 1 /* ErrorCodes.RENDER_FUNCTION */);
  501. result = createVNode(Comment);
  502. }
  503. // attr merging
  504. // in dev mode, comments are preserved, and it's possible for a template
  505. // to have comments along side the root element which makes it a fragment
  506. var root = result;
  507. if (fallthroughAttrs && inheritAttrs !== false) {
  508. var keys = Object.keys(fallthroughAttrs);
  509. var {
  510. shapeFlag
  511. } = root;
  512. if (keys.length) {
  513. if (shapeFlag & (1 /* ShapeFlags.ELEMENT */ | 6 /* ShapeFlags.COMPONENT */)) {
  514. if (propsOptions && keys.some(isModelListener)) {
  515. // If a v-model listener (onUpdate:xxx) has a corresponding declared
  516. // prop, it indicates this component expects to handle v-model and
  517. // it should not fallthrough.
  518. // related: #1543, #1643, #1989
  519. fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
  520. }
  521. root = cloneVNode(root, fallthroughAttrs);
  522. }
  523. }
  524. }
  525. // inherit directives
  526. if (vnode.dirs) {
  527. // clone before mutating since the root may be a hoisted vnode
  528. root = cloneVNode(root);
  529. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  530. }
  531. // inherit transition data
  532. if (vnode.transition) {
  533. root.transition = vnode.transition;
  534. }
  535. {
  536. result = root;
  537. }
  538. setCurrentRenderingInstance(prev);
  539. return result;
  540. }
  541. function filterSingleRoot(children) {
  542. var singleRoot;
  543. for (var i = 0; i < children.length; i++) {
  544. var child = children[i];
  545. if (isVNode(child)) {
  546. // ignore user comment
  547. if (child.type !== Comment || child.children === 'v-if') {
  548. if (singleRoot) {
  549. // has more than 1 non-comment child, return now
  550. return;
  551. } else {
  552. singleRoot = child;
  553. }
  554. }
  555. } else {
  556. return;
  557. }
  558. }
  559. return singleRoot;
  560. }
  561. var getFunctionalFallthrough = attrs => {
  562. var res;
  563. for (var key in attrs) {
  564. if (key === 'class' || key === 'style' || isOn(key)) {
  565. (res || (res = {}))[key] = attrs[key];
  566. }
  567. }
  568. return res;
  569. };
  570. var filterModelListeners = (attrs, props) => {
  571. var res = {};
  572. for (var key in attrs) {
  573. if (!isModelListener(key) || !(key.slice(9) in props)) {
  574. res[key] = attrs[key];
  575. }
  576. }
  577. return res;
  578. };
  579. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  580. var {
  581. props: prevProps,
  582. children: prevChildren,
  583. component
  584. } = prevVNode;
  585. var {
  586. props: nextProps,
  587. children: nextChildren,
  588. patchFlag
  589. } = nextVNode;
  590. var emits = component.emitsOptions;
  591. // force child update for runtime directive or transition on component vnode.
  592. if (nextVNode.dirs || nextVNode.transition) {
  593. return true;
  594. }
  595. if (optimized && patchFlag >= 0) {
  596. if (patchFlag & 1024 /* PatchFlags.DYNAMIC_SLOTS */) {
  597. // slot content that references values that might have changed,
  598. // e.g. in a v-for
  599. return true;
  600. }
  601. if (patchFlag & 16 /* PatchFlags.FULL_PROPS */) {
  602. if (!prevProps) {
  603. return !!nextProps;
  604. }
  605. // presence of this flag indicates props are always non-null
  606. return hasPropsChanged(prevProps, nextProps, emits);
  607. } else if (patchFlag & 8 /* PatchFlags.PROPS */) {
  608. var dynamicProps = nextVNode.dynamicProps;
  609. for (var i = 0; i < dynamicProps.length; i++) {
  610. var key = dynamicProps[i];
  611. if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
  612. return true;
  613. }
  614. }
  615. }
  616. } else {
  617. // this path is only taken by manually written render functions
  618. // so presence of any children leads to a forced update
  619. if (prevChildren || nextChildren) {
  620. if (!nextChildren || !nextChildren.$stable) {
  621. return true;
  622. }
  623. }
  624. if (prevProps === nextProps) {
  625. return false;
  626. }
  627. if (!prevProps) {
  628. return !!nextProps;
  629. }
  630. if (!nextProps) {
  631. return true;
  632. }
  633. return hasPropsChanged(prevProps, nextProps, emits);
  634. }
  635. return false;
  636. }
  637. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  638. var nextKeys = Object.keys(nextProps);
  639. if (nextKeys.length !== Object.keys(prevProps).length) {
  640. return true;
  641. }
  642. for (var i = 0; i < nextKeys.length; i++) {
  643. var key = nextKeys[i];
  644. if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
  645. return true;
  646. }
  647. }
  648. return false;
  649. }
  650. function updateHOCHostEl(_ref2, el // HostNode
  651. ) {
  652. var {
  653. vnode,
  654. parent
  655. } = _ref2;
  656. while (parent && parent.subTree === vnode) {
  657. (vnode = parent.vnode).el = el;
  658. parent = parent.parent;
  659. }
  660. }
  661. var isSuspense = type => type.__isSuspense;
  662. // Suspense exposes a component-like API, and is treated like a component
  663. // in the compiler, but internally it's a special built-in type that hooks
  664. // directly into the renderer.
  665. var SuspenseImpl = {
  666. name: 'Suspense',
  667. // In order to make Suspense tree-shakable, we need to avoid importing it
  668. // directly in the renderer. The renderer checks for the __isSuspense flag
  669. // on a vnode's type and calls the `process` method, passing in renderer
  670. // internals.
  671. __isSuspense: true,
  672. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
  673. // platform-specific impl passed from renderer
  674. rendererInternals) {
  675. if (n1 == null) {
  676. mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
  677. } else {
  678. patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
  679. }
  680. },
  681. hydrate: hydrateSuspense,
  682. create: createSuspenseBoundary,
  683. normalize: normalizeSuspenseChildren
  684. };
  685. // Force-casted public typing for h and TSX props inference
  686. var Suspense = SuspenseImpl;
  687. function triggerEvent(vnode, name) {
  688. var eventListener = vnode.props && vnode.props[name];
  689. if (isFunction(eventListener)) {
  690. eventListener();
  691. }
  692. }
  693. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  694. var {
  695. p: patch,
  696. o: {
  697. createElement
  698. }
  699. } = rendererInternals;
  700. var hiddenContainer = createElement('div');
  701. var suspense = vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals);
  702. // start mounting the content subtree in an off-dom container
  703. patch(null, suspense.pendingBranch = vnode.ssContent, hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
  704. // now check if we have encountered any async deps
  705. if (suspense.deps > 0) {
  706. // has async
  707. // invoke @fallback event
  708. triggerEvent(vnode, 'onPending');
  709. triggerEvent(vnode, 'onFallback');
  710. // mount the fallback tree
  711. patch(null, vnode.ssFallback, container, anchor, parentComponent, null,
  712. // fallback tree will not have suspense context
  713. isSVG, slotScopeIds);
  714. setActiveBranch(suspense, vnode.ssFallback);
  715. } else {
  716. // Suspense has no async deps. Just resolve.
  717. suspense.resolve();
  718. }
  719. }
  720. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, _ref3) {
  721. var {
  722. p: patch,
  723. um: unmount,
  724. o: {
  725. createElement
  726. }
  727. } = _ref3;
  728. var suspense = n2.suspense = n1.suspense;
  729. suspense.vnode = n2;
  730. n2.el = n1.el;
  731. var newBranch = n2.ssContent;
  732. var newFallback = n2.ssFallback;
  733. var {
  734. activeBranch,
  735. pendingBranch,
  736. isInFallback,
  737. isHydrating
  738. } = suspense;
  739. if (pendingBranch) {
  740. suspense.pendingBranch = newBranch;
  741. if (isSameVNodeType(newBranch, pendingBranch)) {
  742. // same root type but content may have changed.
  743. patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  744. if (suspense.deps <= 0) {
  745. suspense.resolve();
  746. } else if (isInFallback) {
  747. patch(activeBranch, newFallback, container, anchor, parentComponent, null,
  748. // fallback tree will not have suspense context
  749. isSVG, slotScopeIds, optimized);
  750. setActiveBranch(suspense, newFallback);
  751. }
  752. } else {
  753. // toggled before pending tree is resolved
  754. suspense.pendingId++;
  755. if (isHydrating) {
  756. // if toggled before hydration is finished, the current DOM tree is
  757. // no longer valid. set it as the active branch so it will be unmounted
  758. // when resolved
  759. suspense.isHydrating = false;
  760. suspense.activeBranch = pendingBranch;
  761. } else {
  762. unmount(pendingBranch, parentComponent, suspense);
  763. }
  764. // increment pending ID. this is used to invalidate async callbacks
  765. // reset suspense state
  766. suspense.deps = 0;
  767. // discard effects from pending branch
  768. suspense.effects.length = 0;
  769. // discard previous container
  770. suspense.hiddenContainer = createElement('div');
  771. if (isInFallback) {
  772. // already in fallback state
  773. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  774. if (suspense.deps <= 0) {
  775. suspense.resolve();
  776. } else {
  777. patch(activeBranch, newFallback, container, anchor, parentComponent, null,
  778. // fallback tree will not have suspense context
  779. isSVG, slotScopeIds, optimized);
  780. setActiveBranch(suspense, newFallback);
  781. }
  782. } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  783. // toggled "back" to current active branch
  784. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  785. // force resolve
  786. suspense.resolve(true);
  787. } else {
  788. // switched to a 3rd branch
  789. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  790. if (suspense.deps <= 0) {
  791. suspense.resolve();
  792. }
  793. }
  794. }
  795. } else {
  796. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  797. // root did not change, just normal patch
  798. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  799. setActiveBranch(suspense, newBranch);
  800. } else {
  801. // root node toggled
  802. // invoke @pending event
  803. triggerEvent(n2, 'onPending');
  804. // mount pending branch in off-dom container
  805. suspense.pendingBranch = newBranch;
  806. suspense.pendingId++;
  807. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  808. if (suspense.deps <= 0) {
  809. // incoming branch has no async deps, resolve now.
  810. suspense.resolve();
  811. } else {
  812. var {
  813. timeout,
  814. pendingId
  815. } = suspense;
  816. if (timeout > 0) {
  817. setTimeout(() => {
  818. if (suspense.pendingId === pendingId) {
  819. suspense.fallback(newFallback);
  820. }
  821. }, timeout);
  822. } else if (timeout === 0) {
  823. suspense.fallback(newFallback);
  824. }
  825. }
  826. }
  827. }
  828. }
  829. function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals) {
  830. var isHydrating = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false;
  831. var {
  832. p: patch,
  833. m: move,
  834. um: unmount,
  835. n: next,
  836. o: {
  837. parentNode,
  838. remove
  839. }
  840. } = rendererInternals;
  841. var timeout = vnode.props ? toNumber(vnode.props.timeout) : undefined;
  842. var suspense = {
  843. vnode,
  844. parent,
  845. parentComponent,
  846. isSVG,
  847. container,
  848. hiddenContainer,
  849. anchor,
  850. deps: 0,
  851. pendingId: 0,
  852. timeout: typeof timeout === 'number' ? timeout : -1,
  853. activeBranch: null,
  854. pendingBranch: null,
  855. isInFallback: true,
  856. isHydrating,
  857. isUnmounted: false,
  858. effects: [],
  859. resolve() {
  860. var resume = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  861. var {
  862. vnode,
  863. activeBranch,
  864. pendingBranch,
  865. pendingId,
  866. effects,
  867. parentComponent,
  868. container
  869. } = suspense;
  870. if (suspense.isHydrating) {
  871. suspense.isHydrating = false;
  872. } else if (!resume) {
  873. var delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === 'out-in';
  874. if (delayEnter) {
  875. activeBranch.transition.afterLeave = () => {
  876. if (pendingId === suspense.pendingId) {
  877. move(pendingBranch, container, _anchor, 0 /* MoveType.ENTER */);
  878. }
  879. };
  880. }
  881. // this is initial anchor on mount
  882. var {
  883. anchor: _anchor
  884. } = suspense;
  885. // unmount current active tree
  886. if (activeBranch) {
  887. // if the fallback tree was mounted, it may have been moved
  888. // as part of a parent suspense. get the latest anchor for insertion
  889. _anchor = next(activeBranch);
  890. unmount(activeBranch, parentComponent, suspense, true);
  891. }
  892. if (!delayEnter) {
  893. // move content from off-dom container to actual container
  894. move(pendingBranch, container, _anchor, 0 /* MoveType.ENTER */);
  895. }
  896. }
  897. setActiveBranch(suspense, pendingBranch);
  898. suspense.pendingBranch = null;
  899. suspense.isInFallback = false;
  900. // flush buffered effects
  901. // check if there is a pending parent suspense
  902. var parent = suspense.parent;
  903. var hasUnresolvedAncestor = false;
  904. while (parent) {
  905. if (parent.pendingBranch) {
  906. // found a pending parent suspense, merge buffered post jobs
  907. // into that parent
  908. parent.effects.push(...effects);
  909. hasUnresolvedAncestor = true;
  910. break;
  911. }
  912. parent = parent.parent;
  913. }
  914. // no pending parent suspense, flush all jobs
  915. if (!hasUnresolvedAncestor) {
  916. queuePostFlushCb(effects);
  917. }
  918. suspense.effects = [];
  919. // invoke @resolve event
  920. triggerEvent(vnode, 'onResolve');
  921. },
  922. fallback(fallbackVNode) {
  923. if (!suspense.pendingBranch) {
  924. return;
  925. }
  926. var {
  927. vnode,
  928. activeBranch,
  929. parentComponent,
  930. container,
  931. isSVG
  932. } = suspense;
  933. // invoke @fallback event
  934. triggerEvent(vnode, 'onFallback');
  935. var anchor = next(activeBranch);
  936. var mountFallback = () => {
  937. if (!suspense.isInFallback) {
  938. return;
  939. }
  940. // mount the fallback tree
  941. patch(null, fallbackVNode, container, anchor, parentComponent, null,
  942. // fallback tree will not have suspense context
  943. isSVG, slotScopeIds, optimized);
  944. setActiveBranch(suspense, fallbackVNode);
  945. };
  946. var delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
  947. if (delayEnter) {
  948. activeBranch.transition.afterLeave = mountFallback;
  949. }
  950. suspense.isInFallback = true;
  951. // unmount current active branch
  952. unmount(activeBranch, parentComponent, null,
  953. // no suspense so unmount hooks fire now
  954. true // shouldRemove
  955. );
  956. if (!delayEnter) {
  957. mountFallback();
  958. }
  959. },
  960. move(container, anchor, type) {
  961. suspense.activeBranch && move(suspense.activeBranch, container, anchor, type);
  962. suspense.container = container;
  963. },
  964. next() {
  965. return suspense.activeBranch && next(suspense.activeBranch);
  966. },
  967. registerDep(instance, setupRenderEffect) {
  968. var isInPendingSuspense = !!suspense.pendingBranch;
  969. if (isInPendingSuspense) {
  970. suspense.deps++;
  971. }
  972. var hydratedEl = instance.vnode.el;
  973. instance.asyncDep.catch(err => {
  974. handleError(err, instance, 0 /* ErrorCodes.SETUP_FUNCTION */);
  975. }).then(asyncSetupResult => {
  976. // retry when the setup() promise resolves.
  977. // component may have been unmounted before resolve.
  978. if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
  979. return;
  980. }
  981. // retry from this component
  982. instance.asyncResolved = true;
  983. var {
  984. vnode
  985. } = instance;
  986. handleSetupResult(instance, asyncSetupResult, false);
  987. if (hydratedEl) {
  988. // vnode may have been replaced if an update happened before the
  989. // async dep is resolved.
  990. vnode.el = hydratedEl;
  991. }
  992. var placeholder = !hydratedEl && instance.subTree.el;
  993. setupRenderEffect(instance, vnode,
  994. // component may have been moved before resolve.
  995. // if this is not a hydration, instance.subTree will be the comment
  996. // placeholder.
  997. parentNode(hydratedEl || instance.subTree.el),
  998. // anchor will not be used if this is hydration, so only need to
  999. // consider the comment placeholder case.
  1000. hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
  1001. if (placeholder) {
  1002. remove(placeholder);
  1003. }
  1004. updateHOCHostEl(instance, vnode.el);
  1005. // only decrease deps count if suspense is not already resolved
  1006. if (isInPendingSuspense && --suspense.deps === 0) {
  1007. suspense.resolve();
  1008. }
  1009. });
  1010. },
  1011. unmount(parentSuspense, doRemove) {
  1012. suspense.isUnmounted = true;
  1013. if (suspense.activeBranch) {
  1014. unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
  1015. }
  1016. if (suspense.pendingBranch) {
  1017. unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
  1018. }
  1019. }
  1020. };
  1021. return suspense;
  1022. }
  1023. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  1024. /* eslint-disable no-restricted-globals */
  1025. var suspense = vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true /* hydrating */);
  1026. // there are two possible scenarios for server-rendered suspense:
  1027. // - success: ssr content should be fully resolved
  1028. // - failure: ssr content should be the fallback branch.
  1029. // however, on the client we don't really know if it has failed or not
  1030. // attempt to hydrate the DOM assuming it has succeeded, but we still
  1031. // need to construct a suspense boundary first
  1032. var result = hydrateNode(node, suspense.pendingBranch = vnode.ssContent, parentComponent, suspense, slotScopeIds, optimized);
  1033. if (suspense.deps === 0) {
  1034. suspense.resolve();
  1035. }
  1036. return result;
  1037. /* eslint-enable no-restricted-globals */
  1038. }
  1039. function normalizeSuspenseChildren(vnode) {
  1040. var {
  1041. shapeFlag,
  1042. children
  1043. } = vnode;
  1044. var isSlotChildren = shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */;
  1045. vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
  1046. vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
  1047. }
  1048. function normalizeSuspenseSlot(s) {
  1049. var block;
  1050. if (isFunction(s)) {
  1051. var trackBlock = isBlockTreeEnabled && s._c;
  1052. if (trackBlock) {
  1053. // disableTracking: false
  1054. // allow block tracking for compiled slots
  1055. // (see ./componentRenderContext.ts)
  1056. s._d = false;
  1057. openBlock();
  1058. }
  1059. s = s();
  1060. if (trackBlock) {
  1061. s._d = true;
  1062. block = currentBlock;
  1063. closeBlock();
  1064. }
  1065. }
  1066. if (isArray(s)) {
  1067. var singleChild = filterSingleRoot(s);
  1068. s = singleChild;
  1069. }
  1070. s = normalizeVNode(s);
  1071. if (block && !s.dynamicChildren) {
  1072. s.dynamicChildren = block.filter(c => c !== s);
  1073. }
  1074. return s;
  1075. }
  1076. function queueEffectWithSuspense(fn, suspense) {
  1077. if (suspense && suspense.pendingBranch) {
  1078. if (isArray(fn)) {
  1079. suspense.effects.push(...fn);
  1080. } else {
  1081. suspense.effects.push(fn);
  1082. }
  1083. } else {
  1084. queuePostFlushCb(fn);
  1085. }
  1086. }
  1087. function setActiveBranch(suspense, branch) {
  1088. suspense.activeBranch = branch;
  1089. var {
  1090. vnode,
  1091. parentComponent
  1092. } = suspense;
  1093. var el = vnode.el = branch.el;
  1094. // in case suspense is the root node of a component,
  1095. // recursively update the HOC el
  1096. if (parentComponent && parentComponent.subTree === vnode) {
  1097. parentComponent.vnode.el = el;
  1098. updateHOCHostEl(parentComponent, el);
  1099. }
  1100. }
  1101. function provide(key, value) {
  1102. if (!currentInstance) ;else {
  1103. var provides = currentInstance.provides;
  1104. // by default an instance inherits its parent's provides object
  1105. // but when it needs to provide values of its own, it creates its
  1106. // own provides object using parent provides object as prototype.
  1107. // this way in `inject` we can simply look up injections from direct
  1108. // parent and let the prototype chain do the work.
  1109. var parentProvides = currentInstance.parent && currentInstance.parent.provides;
  1110. if (parentProvides === provides) {
  1111. provides = currentInstance.provides = Object.create(parentProvides);
  1112. }
  1113. // TS doesn't allow symbol as index type
  1114. provides[key] = value;
  1115. // 当实例为 App 时,同步到全局 provide
  1116. if (currentInstance.type.mpType === 'app') {
  1117. currentInstance.appContext.app.provide(key, value);
  1118. }
  1119. }
  1120. }
  1121. function inject(key, defaultValue) {
  1122. var treatDefaultAsFactory = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  1123. // fallback to `currentRenderingInstance` so that this can be called in
  1124. // a functional component
  1125. var instance = currentInstance || currentRenderingInstance;
  1126. if (instance) {
  1127. // #2400
  1128. // to support `app.use` plugins,
  1129. // fallback to appContext's `provides` if the instance is at root
  1130. var provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides;
  1131. if (provides && key in provides) {
  1132. // TS doesn't allow symbol as index type
  1133. return provides[key];
  1134. } else if (arguments.length > 1) {
  1135. return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue;
  1136. } else ;
  1137. }
  1138. }
  1139. // Simple effect.
  1140. function watchEffect(effect, options) {
  1141. return doWatch(effect, null, options);
  1142. }
  1143. function watchPostEffect(effect, options) {
  1144. return doWatch(effect, null, {
  1145. flush: 'post'
  1146. });
  1147. }
  1148. function watchSyncEffect(effect, options) {
  1149. return doWatch(effect, null, {
  1150. flush: 'sync'
  1151. });
  1152. }
  1153. // initial value for watchers to trigger on undefined initial values
  1154. var INITIAL_WATCHER_VALUE = {};
  1155. // implementation
  1156. function watch(source, cb, options) {
  1157. return doWatch(source, cb, options);
  1158. }
  1159. function doWatch(source, cb) {
  1160. var {
  1161. immediate,
  1162. deep,
  1163. flush,
  1164. onTrack,
  1165. onTrigger
  1166. } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EMPTY_OBJ;
  1167. var instance = getCurrentScope() === (currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope) ? currentInstance : null;
  1168. // const instance = currentInstance
  1169. var getter;
  1170. var forceTrigger = false;
  1171. var isMultiSource = false;
  1172. if (isRef(source)) {
  1173. getter = () => source.value;
  1174. forceTrigger = isShallow(source);
  1175. } else if (isReactive(source)) {
  1176. getter = () => source;
  1177. deep = true;
  1178. } else if (isArray(source)) {
  1179. isMultiSource = true;
  1180. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  1181. getter = () => source.map(s => {
  1182. if (isRef(s)) {
  1183. return s.value;
  1184. } else if (isReactive(s)) {
  1185. return traverse(s);
  1186. } else if (isFunction(s)) {
  1187. return callWithErrorHandling(s, instance, 2 /* ErrorCodes.WATCH_GETTER */);
  1188. } else ;
  1189. });
  1190. } else if (isFunction(source)) {
  1191. if (cb) {
  1192. // getter with cb
  1193. getter = () => callWithErrorHandling(source, instance, 2 /* ErrorCodes.WATCH_GETTER */);
  1194. } else {
  1195. // no cb -> simple effect
  1196. getter = () => {
  1197. if (instance && instance.isUnmounted) {
  1198. return;
  1199. }
  1200. if (cleanup) {
  1201. cleanup();
  1202. }
  1203. return callWithAsyncErrorHandling(source, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [onCleanup]);
  1204. };
  1205. }
  1206. } else {
  1207. getter = NOOP;
  1208. }
  1209. if (cb && deep) {
  1210. var baseGetter = getter;
  1211. getter = () => traverse(baseGetter());
  1212. }
  1213. var cleanup;
  1214. var onCleanup = fn => {
  1215. cleanup = effect.onStop = () => {
  1216. callWithErrorHandling(fn, instance, 4 /* ErrorCodes.WATCH_CLEANUP */);
  1217. };
  1218. };
  1219. var oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
  1220. var job = () => {
  1221. if (!effect.active) {
  1222. return;
  1223. }
  1224. if (cb) {
  1225. // watch(source, cb)
  1226. var newValue = effect.run();
  1227. if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {
  1228. // cleanup before running cb again
  1229. if (cleanup) {
  1230. cleanup();
  1231. }
  1232. callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [newValue,
  1233. // pass undefined as the old value when it's changed for the first time
  1234. oldValue === INITIAL_WATCHER_VALUE ? undefined : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue, onCleanup]);
  1235. oldValue = newValue;
  1236. }
  1237. } else {
  1238. // watchEffect
  1239. effect.run();
  1240. }
  1241. };
  1242. // important: mark the job as a watcher callback so that scheduler knows
  1243. // it is allowed to self-trigger (#1727)
  1244. job.allowRecurse = !!cb;
  1245. var scheduler;
  1246. if (flush === 'sync') {
  1247. scheduler = job; // the scheduler function gets called directly
  1248. } else if (flush === 'post') {
  1249. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  1250. } else {
  1251. // default: 'pre'
  1252. job.pre = true;
  1253. if (instance) job.id = instance.uid;
  1254. scheduler = () => queueJob(job);
  1255. }
  1256. var effect = new ReactiveEffect(getter, scheduler);
  1257. // initial run
  1258. if (cb) {
  1259. if (immediate) {
  1260. job();
  1261. } else {
  1262. oldValue = effect.run();
  1263. }
  1264. } else if (flush === 'post') {
  1265. queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
  1266. } else {
  1267. effect.run();
  1268. }
  1269. var unwatch = () => {
  1270. effect.stop();
  1271. if (instance && instance.scope) {
  1272. remove(instance.scope.effects, effect);
  1273. }
  1274. };
  1275. return unwatch;
  1276. }
  1277. // this.$watch
  1278. function instanceWatch(source, value, options) {
  1279. var publicThis = this.proxy;
  1280. var getter = isString(source) ? source.includes('.') ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
  1281. var cb;
  1282. if (isFunction(value)) {
  1283. cb = value;
  1284. } else {
  1285. cb = value.handler;
  1286. options = value;
  1287. }
  1288. var cur = currentInstance;
  1289. setCurrentInstance(this);
  1290. var res = doWatch(getter, cb.bind(publicThis), options);
  1291. if (cur) {
  1292. setCurrentInstance(cur);
  1293. } else {
  1294. unsetCurrentInstance();
  1295. }
  1296. return res;
  1297. }
  1298. function createPathGetter(ctx, path) {
  1299. var segments = path.split('.');
  1300. return () => {
  1301. var cur = ctx;
  1302. for (var i = 0; i < segments.length && cur; i++) {
  1303. cur = cur[segments[i]];
  1304. }
  1305. return cur;
  1306. };
  1307. }
  1308. function traverse(value, seen) {
  1309. if (!isObject(value) || value["__v_skip" /* ReactiveFlags.SKIP */]) {
  1310. return value;
  1311. }
  1312. seen = seen || new Set();
  1313. if (seen.has(value)) {
  1314. return value;
  1315. }
  1316. seen.add(value);
  1317. if (isRef(value)) {
  1318. traverse(value.value, seen);
  1319. } else if (isArray(value)) {
  1320. for (var i = 0; i < value.length; i++) {
  1321. traverse(value[i], seen);
  1322. }
  1323. } else if (isSet(value) || isMap(value)) {
  1324. value.forEach(v => {
  1325. traverse(v, seen);
  1326. });
  1327. } else if (isPlainObject(value)) {
  1328. for (var key in value) {
  1329. traverse(value[key], seen);
  1330. }
  1331. }
  1332. return value;
  1333. }
  1334. function useTransitionState() {
  1335. var state = {
  1336. isMounted: false,
  1337. isLeaving: false,
  1338. isUnmounting: false,
  1339. leavingVNodes: new Map()
  1340. };
  1341. onMounted(() => {
  1342. state.isMounted = true;
  1343. });
  1344. onBeforeUnmount(() => {
  1345. state.isUnmounting = true;
  1346. });
  1347. return state;
  1348. }
  1349. var TransitionHookValidator = [Function, Array];
  1350. var BaseTransitionPropsValidators = {
  1351. mode: String,
  1352. appear: Boolean,
  1353. persisted: Boolean,
  1354. // enter
  1355. onBeforeEnter: TransitionHookValidator,
  1356. onEnter: TransitionHookValidator,
  1357. onAfterEnter: TransitionHookValidator,
  1358. onEnterCancelled: TransitionHookValidator,
  1359. // leave
  1360. onBeforeLeave: TransitionHookValidator,
  1361. onLeave: TransitionHookValidator,
  1362. onAfterLeave: TransitionHookValidator,
  1363. onLeaveCancelled: TransitionHookValidator,
  1364. // appear
  1365. onBeforeAppear: TransitionHookValidator,
  1366. onAppear: TransitionHookValidator,
  1367. onAfterAppear: TransitionHookValidator,
  1368. onAppearCancelled: TransitionHookValidator
  1369. };
  1370. var BaseTransitionImpl = {
  1371. name: "BaseTransition",
  1372. props: BaseTransitionPropsValidators,
  1373. setup(props, _ref4) {
  1374. var {
  1375. slots
  1376. } = _ref4;
  1377. var instance = getCurrentInstance();
  1378. var state = useTransitionState();
  1379. var prevTransitionKey;
  1380. return () => {
  1381. var children = slots.default && getTransitionRawChildren(slots.default(), true);
  1382. if (!children || !children.length) {
  1383. return;
  1384. }
  1385. var child = children[0];
  1386. if (children.length > 1) {
  1387. // locate first non-comment child
  1388. for (var c of children) {
  1389. if (c.type !== Comment) {
  1390. child = c;
  1391. break;
  1392. }
  1393. }
  1394. }
  1395. // there's no need to track reactivity for these props so use the raw
  1396. // props for a bit better perf
  1397. var rawProps = toRaw(props);
  1398. var {
  1399. mode
  1400. } = rawProps;
  1401. if (state.isLeaving) {
  1402. return emptyPlaceholder(child);
  1403. }
  1404. // in the case of <transition><keep-alive/></transition>, we need to
  1405. // compare the type of the kept-alive children.
  1406. var innerChild = getKeepAliveChild(child);
  1407. if (!innerChild) {
  1408. return emptyPlaceholder(child);
  1409. }
  1410. var enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
  1411. setTransitionHooks(innerChild, enterHooks);
  1412. var oldChild = instance.subTree;
  1413. var oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  1414. var transitionKeyChanged = false;
  1415. var {
  1416. getTransitionKey
  1417. } = innerChild.type;
  1418. if (getTransitionKey) {
  1419. var key = getTransitionKey();
  1420. if (prevTransitionKey === undefined) {
  1421. prevTransitionKey = key;
  1422. } else if (key !== prevTransitionKey) {
  1423. prevTransitionKey = key;
  1424. transitionKeyChanged = true;
  1425. }
  1426. }
  1427. // handle mode
  1428. if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  1429. var leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
  1430. // update old tree's hooks in case of dynamic transition
  1431. setTransitionHooks(oldInnerChild, leavingHooks);
  1432. // switching between different views
  1433. if (mode === 'out-in') {
  1434. state.isLeaving = true;
  1435. // return placeholder node and queue update when leave finishes
  1436. leavingHooks.afterLeave = () => {
  1437. state.isLeaving = false;
  1438. // #6835
  1439. // it also needs to be updated when active is undefined
  1440. if (instance.update.active !== false) {
  1441. instance.update();
  1442. }
  1443. };
  1444. return emptyPlaceholder(child);
  1445. } else if (mode === 'in-out' && innerChild.type !== Comment) {
  1446. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  1447. var leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
  1448. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  1449. // early removal callback
  1450. el._leaveCb = () => {
  1451. earlyRemove();
  1452. el._leaveCb = undefined;
  1453. delete enterHooks.delayedLeave;
  1454. };
  1455. enterHooks.delayedLeave = delayedLeave;
  1456. };
  1457. }
  1458. }
  1459. return child;
  1460. };
  1461. }
  1462. };
  1463. // export the public type for h/tsx inference
  1464. // also to avoid inline import() in generated d.ts files
  1465. var BaseTransition = BaseTransitionImpl;
  1466. function getLeavingNodesForType(state, vnode) {
  1467. var {
  1468. leavingVNodes
  1469. } = state;
  1470. var leavingVNodesCache = leavingVNodes.get(vnode.type);
  1471. if (!leavingVNodesCache) {
  1472. leavingVNodesCache = Object.create(null);
  1473. leavingVNodes.set(vnode.type, leavingVNodesCache);
  1474. }
  1475. return leavingVNodesCache;
  1476. }
  1477. // The transition hooks are attached to the vnode as vnode.transition
  1478. // and will be called at appropriate timing in the renderer.
  1479. function resolveTransitionHooks(vnode, props, state, instance) {
  1480. var {
  1481. appear,
  1482. mode,
  1483. persisted = false,
  1484. onBeforeEnter,
  1485. onEnter,
  1486. onAfterEnter,
  1487. onEnterCancelled,
  1488. onBeforeLeave,
  1489. onLeave,
  1490. onAfterLeave,
  1491. onLeaveCancelled,
  1492. onBeforeAppear,
  1493. onAppear,
  1494. onAfterAppear,
  1495. onAppearCancelled
  1496. } = props;
  1497. var key = String(vnode.key);
  1498. var leavingVNodesCache = getLeavingNodesForType(state, vnode);
  1499. var callHook = (hook, args) => {
  1500. hook && callWithAsyncErrorHandling(hook, instance, 9 /* ErrorCodes.TRANSITION_HOOK */, args);
  1501. };
  1502. var callAsyncHook = (hook, args) => {
  1503. var done = args[1];
  1504. callHook(hook, args);
  1505. if (isArray(hook)) {
  1506. if (hook.every(hook => hook.length <= 1)) done();
  1507. } else if (hook.length <= 1) {
  1508. done();
  1509. }
  1510. };
  1511. var hooks = {
  1512. mode,
  1513. persisted,
  1514. beforeEnter(el) {
  1515. var hook = onBeforeEnter;
  1516. if (!state.isMounted) {
  1517. if (appear) {
  1518. hook = onBeforeAppear || onBeforeEnter;
  1519. } else {
  1520. return;
  1521. }
  1522. }
  1523. // for same element (v-show)
  1524. if (el._leaveCb) {
  1525. el._leaveCb(true /* cancelled */);
  1526. }
  1527. // for toggled element with same key (v-if)
  1528. var leavingVNode = leavingVNodesCache[key];
  1529. if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el._leaveCb) {
  1530. // force early removal (not cancelled)
  1531. leavingVNode.el._leaveCb();
  1532. }
  1533. callHook(hook, [el]);
  1534. },
  1535. enter(el) {
  1536. var hook = onEnter;
  1537. var afterHook = onAfterEnter;
  1538. var cancelHook = onEnterCancelled;
  1539. if (!state.isMounted) {
  1540. if (appear) {
  1541. hook = onAppear || onEnter;
  1542. afterHook = onAfterAppear || onAfterEnter;
  1543. cancelHook = onAppearCancelled || onEnterCancelled;
  1544. } else {
  1545. return;
  1546. }
  1547. }
  1548. var called = false;
  1549. var done = el._enterCb = cancelled => {
  1550. if (called) return;
  1551. called = true;
  1552. if (cancelled) {
  1553. callHook(cancelHook, [el]);
  1554. } else {
  1555. callHook(afterHook, [el]);
  1556. }
  1557. if (hooks.delayedLeave) {
  1558. hooks.delayedLeave();
  1559. }
  1560. el._enterCb = undefined;
  1561. };
  1562. if (hook) {
  1563. callAsyncHook(hook, [el, done]);
  1564. } else {
  1565. done();
  1566. }
  1567. },
  1568. leave(el, remove) {
  1569. var key = String(vnode.key);
  1570. if (el._enterCb) {
  1571. el._enterCb(true /* cancelled */);
  1572. }
  1573. if (state.isUnmounting) {
  1574. return remove();
  1575. }
  1576. callHook(onBeforeLeave, [el]);
  1577. var called = false;
  1578. var done = el._leaveCb = cancelled => {
  1579. if (called) return;
  1580. called = true;
  1581. remove();
  1582. if (cancelled) {
  1583. callHook(onLeaveCancelled, [el]);
  1584. } else {
  1585. callHook(onAfterLeave, [el]);
  1586. }
  1587. el._leaveCb = undefined;
  1588. if (leavingVNodesCache[key] === vnode) {
  1589. delete leavingVNodesCache[key];
  1590. }
  1591. };
  1592. leavingVNodesCache[key] = vnode;
  1593. if (onLeave) {
  1594. callAsyncHook(onLeave, [el, done]);
  1595. } else {
  1596. done();
  1597. }
  1598. },
  1599. clone(vnode) {
  1600. return resolveTransitionHooks(vnode, props, state, instance);
  1601. }
  1602. };
  1603. return hooks;
  1604. }
  1605. // the placeholder really only handles one special case: KeepAlive
  1606. // in the case of a KeepAlive in a leave phase we need to return a KeepAlive
  1607. // placeholder with empty content to avoid the KeepAlive instance from being
  1608. // unmounted.
  1609. function emptyPlaceholder(vnode) {
  1610. if (isKeepAlive(vnode)) {
  1611. vnode = cloneVNode(vnode);
  1612. vnode.children = null;
  1613. return vnode;
  1614. }
  1615. }
  1616. function getKeepAliveChild(vnode) {
  1617. return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : undefined : vnode;
  1618. }
  1619. function setTransitionHooks(vnode, hooks) {
  1620. if (vnode.shapeFlag & 6 /* ShapeFlags.COMPONENT */ && vnode.component) {
  1621. setTransitionHooks(vnode.component.subTree, hooks);
  1622. } else if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  1623. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  1624. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  1625. } else {
  1626. vnode.transition = hooks;
  1627. }
  1628. }
  1629. function getTransitionRawChildren(children) {
  1630. var keepComment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1631. var parentKey = arguments.length > 2 ? arguments[2] : undefined;
  1632. var ret = [];
  1633. var keyedFragmentCount = 0;
  1634. for (var i = 0; i < children.length; i++) {
  1635. var child = children[i];
  1636. // #5360 inherit parent key in case of <template v-for>
  1637. var key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
  1638. // handle fragment children case, e.g. v-for
  1639. if (child.type === Fragment) {
  1640. if (child.patchFlag & 128 /* PatchFlags.KEYED_FRAGMENT */) keyedFragmentCount++;
  1641. ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
  1642. }
  1643. // comment placeholders should be skipped, e.g. v-if
  1644. else if (keepComment || child.type !== Comment) {
  1645. ret.push(key != null ? cloneVNode(child, {
  1646. key
  1647. }) : child);
  1648. }
  1649. }
  1650. // #1126 if a transition children list contains multiple sub fragments, these
  1651. // fragments will be merged into a flat children array. Since each v-for
  1652. // fragment may contain different static bindings inside, we need to de-op
  1653. // these children to force full diffs to ensure correct behavior.
  1654. if (keyedFragmentCount > 1) {
  1655. for (var _i = 0; _i < ret.length; _i++) {
  1656. ret[_i].patchFlag = -2 /* PatchFlags.BAIL */;
  1657. }
  1658. }
  1659. return ret;
  1660. }
  1661. // implementation, close to no-op
  1662. function defineComponent(options) {
  1663. return isFunction(options) ? {
  1664. setup: options,
  1665. name: options.name
  1666. } : options;
  1667. }
  1668. var isAsyncWrapper = i => !!i.type.__asyncLoader;
  1669. function defineAsyncComponent(source) {
  1670. if (isFunction(source)) {
  1671. source = {
  1672. loader: source
  1673. };
  1674. }
  1675. var {
  1676. loader,
  1677. loadingComponent,
  1678. errorComponent,
  1679. delay = 200,
  1680. timeout,
  1681. // undefined = never times out
  1682. suspensible = true,
  1683. onError: userOnError
  1684. } = source;
  1685. var pendingRequest = null;
  1686. var resolvedComp;
  1687. var retries = 0;
  1688. var retry = () => {
  1689. retries++;
  1690. pendingRequest = null;
  1691. return load();
  1692. };
  1693. var load = () => {
  1694. var thisRequest;
  1695. return pendingRequest || (thisRequest = pendingRequest = loader().catch(err => {
  1696. err = err instanceof Error ? err : new Error(String(err));
  1697. if (userOnError) {
  1698. return new Promise((resolve, reject) => {
  1699. var userRetry = () => resolve(retry());
  1700. var userFail = () => reject(err);
  1701. userOnError(err, userRetry, userFail, retries + 1);
  1702. });
  1703. } else {
  1704. throw err;
  1705. }
  1706. }).then(comp => {
  1707. if (thisRequest !== pendingRequest && pendingRequest) {
  1708. return pendingRequest;
  1709. }
  1710. // interop module default
  1711. if (comp && (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  1712. comp = comp.default;
  1713. }
  1714. resolvedComp = comp;
  1715. return comp;
  1716. }));
  1717. };
  1718. return defineComponent({
  1719. name: 'AsyncComponentWrapper',
  1720. __asyncLoader: load,
  1721. get __asyncResolved() {
  1722. return resolvedComp;
  1723. },
  1724. setup() {
  1725. var instance = currentInstance;
  1726. // already resolved
  1727. if (resolvedComp) {
  1728. return () => createInnerComp(resolvedComp, instance);
  1729. }
  1730. var onError = err => {
  1731. pendingRequest = null;
  1732. handleError(err, instance, 13 /* ErrorCodes.ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
  1733. };
  1734. // suspense-controlled or SSR.
  1735. if (suspensible && instance.suspense || false) {
  1736. return load().then(comp => {
  1737. return () => createInnerComp(comp, instance);
  1738. }).catch(err => {
  1739. onError(err);
  1740. return () => errorComponent ? createVNode(errorComponent, {
  1741. error: err
  1742. }) : null;
  1743. });
  1744. }
  1745. var loaded = ref(false);
  1746. var error = ref();
  1747. var delayed = ref(!!delay);
  1748. if (delay) {
  1749. setTimeout(() => {
  1750. delayed.value = false;
  1751. }, delay);
  1752. }
  1753. if (timeout != null) {
  1754. setTimeout(() => {
  1755. if (!loaded.value && !error.value) {
  1756. var err = new Error("Async component timed out after ".concat(timeout, "ms."));
  1757. onError(err);
  1758. error.value = err;
  1759. }
  1760. }, timeout);
  1761. }
  1762. load().then(() => {
  1763. loaded.value = true;
  1764. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  1765. // parent is keep-alive, force update so the loaded component's
  1766. // name is taken into account
  1767. queueJob(instance.parent.update);
  1768. }
  1769. }).catch(err => {
  1770. onError(err);
  1771. error.value = err;
  1772. });
  1773. return () => {
  1774. if (loaded.value && resolvedComp) {
  1775. return createInnerComp(resolvedComp, instance);
  1776. } else if (error.value && errorComponent) {
  1777. return createVNode(errorComponent, {
  1778. error: error.value
  1779. });
  1780. } else if (loadingComponent && !delayed.value) {
  1781. return createVNode(loadingComponent);
  1782. }
  1783. };
  1784. }
  1785. });
  1786. }
  1787. function createInnerComp(comp, parent) {
  1788. var {
  1789. ref,
  1790. props,
  1791. children,
  1792. ce
  1793. } = parent.vnode;
  1794. var vnode = createVNode(comp, props, children);
  1795. // ensure inner component inherits the async wrapper's ref owner
  1796. vnode.ref = ref;
  1797. // pass the custom element callback on to the inner comp
  1798. // and remove it from the async wrapper
  1799. vnode.ce = ce;
  1800. delete parent.vnode.ce;
  1801. return vnode;
  1802. }
  1803. var isKeepAlive = vnode => vnode.type.__isKeepAlive;
  1804. var KeepAliveImpl = {
  1805. name: "KeepAlive",
  1806. // Marker for special handling inside the renderer. We are not using a ===
  1807. // check directly on KeepAlive in the renderer, because importing it directly
  1808. // would prevent it from being tree-shaken.
  1809. __isKeepAlive: true,
  1810. props: {
  1811. include: [String, RegExp, Array],
  1812. exclude: [String, RegExp, Array],
  1813. max: [String, Number]
  1814. },
  1815. setup(props, _ref5) {
  1816. var {
  1817. slots
  1818. } = _ref5;
  1819. var instance = getCurrentInstance();
  1820. // KeepAlive communicates with the instantiated renderer via the
  1821. // ctx where the renderer passes in its internals,
  1822. // and the KeepAlive instance exposes activate/deactivate implementations.
  1823. // The whole point of this is to avoid importing KeepAlive directly in the
  1824. // renderer to facilitate tree-shaking.
  1825. var sharedContext = instance.ctx;
  1826. var cache = new Map();
  1827. var keys = new Set();
  1828. var current = null;
  1829. var parentSuspense = instance.suspense;
  1830. var {
  1831. renderer: {
  1832. p: patch,
  1833. m: move,
  1834. um: _unmount,
  1835. o: {
  1836. createElement
  1837. }
  1838. }
  1839. } = sharedContext;
  1840. var storageContainer = createElement('div');
  1841. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  1842. var instance = vnode.component;
  1843. move(vnode, container, anchor, 0 /* MoveType.ENTER */, parentSuspense);
  1844. // in case props have changed
  1845. patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
  1846. queuePostRenderEffect(() => {
  1847. instance.isDeactivated = false;
  1848. if (instance.a) {
  1849. invokeArrayFns(instance.a);
  1850. }
  1851. var vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  1852. if (vnodeHook) {
  1853. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  1854. }
  1855. }, parentSuspense);
  1856. };
  1857. sharedContext.deactivate = vnode => {
  1858. var instance = vnode.component;
  1859. move(vnode, storageContainer, null, 1 /* MoveType.LEAVE */, parentSuspense);
  1860. queuePostRenderEffect(() => {
  1861. if (instance.da) {
  1862. invokeArrayFns(instance.da);
  1863. }
  1864. var vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  1865. if (vnodeHook) {
  1866. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  1867. }
  1868. instance.isDeactivated = true;
  1869. }, parentSuspense);
  1870. };
  1871. function unmount(vnode) {
  1872. // reset the shapeFlag so it can be properly unmounted
  1873. resetShapeFlag(vnode);
  1874. _unmount(vnode, instance, parentSuspense, true);
  1875. }
  1876. function pruneCache(filter) {
  1877. cache.forEach((vnode, key) => {
  1878. var name = getComponentName(vnode.type);
  1879. if (name && (!filter || !filter(name))) {
  1880. pruneCacheEntry(key);
  1881. }
  1882. });
  1883. }
  1884. function pruneCacheEntry(key) {
  1885. var cached = cache.get(key);
  1886. if (!current || !isSameVNodeType(cached, current)) {
  1887. unmount(cached);
  1888. } else if (current) {
  1889. // current active instance should no longer be kept-alive.
  1890. // we can't unmount it now but it might be later, so reset its flag now.
  1891. resetShapeFlag(current);
  1892. }
  1893. cache.delete(key);
  1894. keys.delete(key);
  1895. }
  1896. // prune cache on include/exclude prop change
  1897. watch(() => [props.include, props.exclude], _ref6 => {
  1898. var [include, exclude] = _ref6;
  1899. include && pruneCache(name => matches(include, name));
  1900. exclude && pruneCache(name => !matches(exclude, name));
  1901. },
  1902. // prune post-render after `current` has been updated
  1903. {
  1904. flush: 'post',
  1905. deep: true
  1906. });
  1907. // cache sub tree after render
  1908. var pendingCacheKey = null;
  1909. var cacheSubtree = () => {
  1910. // fix #1621, the pendingCacheKey could be 0
  1911. if (pendingCacheKey != null) {
  1912. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  1913. }
  1914. };
  1915. onMounted(cacheSubtree);
  1916. onUpdated(cacheSubtree);
  1917. onBeforeUnmount(() => {
  1918. cache.forEach(cached => {
  1919. var {
  1920. subTree,
  1921. suspense
  1922. } = instance;
  1923. var vnode = getInnerChild(subTree);
  1924. if (cached.type === vnode.type && cached.key === vnode.key) {
  1925. // current instance will be unmounted as part of keep-alive's unmount
  1926. resetShapeFlag(vnode);
  1927. // but invoke its deactivated hook here
  1928. var da = vnode.component.da;
  1929. da && queuePostRenderEffect(da, suspense);
  1930. return;
  1931. }
  1932. unmount(cached);
  1933. });
  1934. });
  1935. return () => {
  1936. pendingCacheKey = null;
  1937. if (!slots.default) {
  1938. return null;
  1939. }
  1940. var children = slots.default();
  1941. var rawVNode = children[0];
  1942. if (children.length > 1) {
  1943. current = null;
  1944. return children;
  1945. } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */) && !(rawVNode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */)) {
  1946. current = null;
  1947. return rawVNode;
  1948. }
  1949. var vnode = getInnerChild(rawVNode);
  1950. var comp = vnode.type;
  1951. // for async components, name check should be based in its loaded
  1952. // inner component if available
  1953. var name = getComponentName(isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp);
  1954. var {
  1955. include,
  1956. exclude,
  1957. max
  1958. } = props;
  1959. if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
  1960. current = vnode;
  1961. return rawVNode;
  1962. }
  1963. var key = vnode.key == null ? comp : vnode.key;
  1964. var cachedVNode = cache.get(key);
  1965. // clone vnode if it's reused because we are going to mutate it
  1966. if (vnode.el) {
  1967. vnode = cloneVNode(vnode);
  1968. if (rawVNode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  1969. rawVNode.ssContent = vnode;
  1970. }
  1971. }
  1972. // #1513 it's possible for the returned vnode to be cloned due to attr
  1973. // fallthrough or scopeId, so the vnode here may not be the final vnode
  1974. // that is mounted. Instead of caching it directly, we store the pending
  1975. // key and cache `instance.subTree` (the normalized vnode) in
  1976. // beforeMount/beforeUpdate hooks.
  1977. pendingCacheKey = key;
  1978. if (cachedVNode) {
  1979. // copy over mounted state
  1980. vnode.el = cachedVNode.el;
  1981. vnode.component = cachedVNode.component;
  1982. if (vnode.transition) {
  1983. // recursively update transition hooks on subTree
  1984. setTransitionHooks(vnode, vnode.transition);
  1985. }
  1986. // avoid vnode being mounted as fresh
  1987. vnode.shapeFlag |= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
  1988. // make this key the freshest
  1989. keys.delete(key);
  1990. keys.add(key);
  1991. } else {
  1992. keys.add(key);
  1993. // prune oldest entry
  1994. if (max && keys.size > parseInt(max, 10)) {
  1995. pruneCacheEntry(keys.values().next().value);
  1996. }
  1997. }
  1998. // avoid vnode being unmounted
  1999. vnode.shapeFlag |= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
  2000. current = vnode;
  2001. return isSuspense(rawVNode.type) ? rawVNode : vnode;
  2002. };
  2003. }
  2004. };
  2005. // export the public type for h/tsx inference
  2006. // also to avoid inline import() in generated d.ts files
  2007. var KeepAlive = KeepAliveImpl;
  2008. function matches(pattern, name) {
  2009. if (isArray(pattern)) {
  2010. return pattern.some(p => matches(p, name));
  2011. } else if (isString(pattern)) {
  2012. return pattern.split(',').includes(name);
  2013. } else if (isRegExp(pattern)) {
  2014. return pattern.test(name);
  2015. }
  2016. /* istanbul ignore next */
  2017. return false;
  2018. }
  2019. function onActivated(hook, target) {
  2020. registerKeepAliveHook(hook, "a" /* LifecycleHooks.ACTIVATED */, target);
  2021. }
  2022. function onDeactivated(hook, target) {
  2023. registerKeepAliveHook(hook, "da" /* LifecycleHooks.DEACTIVATED */, target);
  2024. }
  2025. function registerKeepAliveHook(hook, type) {
  2026. var target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : currentInstance;
  2027. // cache the deactivate branch check wrapper for injected hooks so the same
  2028. // hook can be properly deduped by the scheduler. "__wdc" stands for "with
  2029. // deactivation check".
  2030. var wrappedHook = hook.__wdc || (hook.__wdc = () => {
  2031. // only fire the hook if the target instance is NOT in a deactivated branch.
  2032. var current = target;
  2033. while (current) {
  2034. if (current.isDeactivated) {
  2035. return;
  2036. }
  2037. current = current.parent;
  2038. }
  2039. return hook();
  2040. });
  2041. injectHook(type, wrappedHook, target);
  2042. // In addition to registering it on the target instance, we walk up the parent
  2043. // chain and register it on all ancestor instances that are keep-alive roots.
  2044. // This avoids the need to walk the entire component tree when invoking these
  2045. // hooks, and more importantly, avoids the need to track child components in
  2046. // arrays.
  2047. if (target) {
  2048. var current = target.parent;
  2049. while (current && current.parent) {
  2050. if (isKeepAlive(current.parent.vnode)) {
  2051. injectToKeepAliveRoot(wrappedHook, type, target, current);
  2052. }
  2053. current = current.parent;
  2054. }
  2055. }
  2056. }
  2057. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  2058. // injectHook wraps the original for error handling, so make sure to remove
  2059. // the wrapped version.
  2060. var injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
  2061. onUnmounted(() => {
  2062. remove(keepAliveRoot[type], injected);
  2063. }, target);
  2064. }
  2065. function resetShapeFlag(vnode) {
  2066. // bitwise operations to remove keep alive flags
  2067. vnode.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
  2068. vnode.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
  2069. }
  2070. function getInnerChild(vnode) {
  2071. return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
  2072. }
  2073. function injectHook(type, hook) {
  2074. var target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : currentInstance;
  2075. var prepend = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2076. if (target) {
  2077. // fixed by xxxxxx
  2078. if (isRootHook(type) && target !== target.root) {
  2079. target = target.root;
  2080. if (isRootImmediateHook(type)) {
  2081. // 作用域应该是组件还是页面?目前绑定的是页面
  2082. var proxy = target.proxy;
  2083. callWithAsyncErrorHandling(hook.bind(proxy), target, type, ON_LOAD === type ? [proxy.$page.options] : []);
  2084. }
  2085. }
  2086. var hooks = target[type] || (target[type] = []);
  2087. // cache the error handling wrapper for injected hooks so the same hook
  2088. // can be properly deduped by the scheduler. "__weh" stands for "with error
  2089. // handling".
  2090. var wrappedHook = hook.__weh || (hook.__weh = function () {
  2091. if (target.isUnmounted) {
  2092. return;
  2093. }
  2094. // disable tracking inside all lifecycle hooks
  2095. // since they can potentially be called inside effects.
  2096. pauseTracking();
  2097. // Set currentInstance during hook invocation.
  2098. // This assumes the hook does not synchronously trigger other hooks, which
  2099. // can only be false when the user does something really funky.
  2100. setCurrentInstance(target);
  2101. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  2102. args[_key2] = arguments[_key2];
  2103. }
  2104. var res = callWithAsyncErrorHandling(hook, target, type, args);
  2105. unsetCurrentInstance();
  2106. resetTracking();
  2107. return res;
  2108. });
  2109. if (prepend) {
  2110. hooks.unshift(wrappedHook);
  2111. } else {
  2112. hooks.push(wrappedHook);
  2113. }
  2114. return wrappedHook;
  2115. }
  2116. }
  2117. var createHook = lifecycle => function (hook) {
  2118. var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : currentInstance;
  2119. return (
  2120. // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
  2121. (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) && injectHook(lifecycle, function () {
  2122. return hook(...arguments);
  2123. }, target)
  2124. );
  2125. };
  2126. var onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
  2127. var onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
  2128. var onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
  2129. var onUpdated = createHook("u" /* LifecycleHooks.UPDATED */);
  2130. var onBeforeUnmount = createHook("bum" /* LifecycleHooks.BEFORE_UNMOUNT */);
  2131. var onUnmounted = createHook("um" /* LifecycleHooks.UNMOUNTED */);
  2132. var onServerPrefetch = createHook("sp" /* LifecycleHooks.SERVER_PREFETCH */);
  2133. var onRenderTriggered = createHook("rtg" /* LifecycleHooks.RENDER_TRIGGERED */);
  2134. var onRenderTracked = createHook("rtc" /* LifecycleHooks.RENDER_TRACKED */);
  2135. function onErrorCaptured(hook) {
  2136. var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : currentInstance;
  2137. injectHook("ec" /* LifecycleHooks.ERROR_CAPTURED */, hook, target);
  2138. }
  2139. /**
  2140. * Adds directives to a VNode.
  2141. */
  2142. function withDirectives(vnode, directives) {
  2143. var internalInstance = currentRenderingInstance;
  2144. if (internalInstance === null) {
  2145. return vnode;
  2146. }
  2147. var instance = getExposeProxy(internalInstance) || internalInstance.proxy;
  2148. var bindings = vnode.dirs || (vnode.dirs = []);
  2149. for (var i = 0; i < directives.length; i++) {
  2150. var [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  2151. if (dir) {
  2152. if (isFunction(dir)) {
  2153. dir = {
  2154. mounted: dir,
  2155. updated: dir
  2156. };
  2157. }
  2158. if (dir.deep) {
  2159. traverse(value);
  2160. }
  2161. bindings.push({
  2162. dir,
  2163. instance,
  2164. value,
  2165. oldValue: void 0,
  2166. arg,
  2167. modifiers
  2168. });
  2169. }
  2170. }
  2171. return vnode;
  2172. }
  2173. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  2174. var bindings = vnode.dirs;
  2175. var oldBindings = prevVNode && prevVNode.dirs;
  2176. for (var i = 0; i < bindings.length; i++) {
  2177. var binding = bindings[i];
  2178. if (oldBindings) {
  2179. binding.oldValue = oldBindings[i].value;
  2180. }
  2181. var hook = binding.dir[name];
  2182. if (hook) {
  2183. // disable tracking inside all lifecycle hooks
  2184. // since they can potentially be called inside effects.
  2185. pauseTracking();
  2186. callWithAsyncErrorHandling(hook, instance, 8 /* ErrorCodes.DIRECTIVE_HOOK */, [vnode.el, binding, vnode, prevVNode]);
  2187. resetTracking();
  2188. }
  2189. }
  2190. }
  2191. var COMPONENTS = 'components';
  2192. var DIRECTIVES = 'directives';
  2193. /**
  2194. * @private
  2195. */
  2196. function resolveComponent(name, maybeSelfReference) {
  2197. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
  2198. }
  2199. var NULL_DYNAMIC_COMPONENT = Symbol();
  2200. /**
  2201. * @private
  2202. */
  2203. function resolveDynamicComponent(component) {
  2204. if (isString(component)) {
  2205. return resolveAsset(COMPONENTS, component, false) || component;
  2206. } else {
  2207. // invalid types will fallthrough to createVNode and raise warning
  2208. return component || NULL_DYNAMIC_COMPONENT;
  2209. }
  2210. }
  2211. /**
  2212. * @private
  2213. */
  2214. function resolveDirective(name) {
  2215. return resolveAsset(DIRECTIVES, name);
  2216. }
  2217. // implementation
  2218. function resolveAsset(type, name) {
  2219. var warnMissing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  2220. var maybeSelfReference = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2221. var instance = currentRenderingInstance || currentInstance;
  2222. if (instance) {
  2223. var Component = instance.type;
  2224. // explicit self name has highest priority
  2225. if (type === COMPONENTS) {
  2226. var selfName = getComponentName(Component, false /* do not include inferred name to avoid breaking existing code */);
  2227. if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
  2228. return Component;
  2229. }
  2230. }
  2231. var res =
  2232. // local registration
  2233. // check instance[type] first which is resolved for options API
  2234. resolve(instance[type] || Component[type], name) ||
  2235. // global registration
  2236. resolve(instance.appContext[type], name);
  2237. if (!res && maybeSelfReference) {
  2238. // fallback to implicit self-reference
  2239. return Component;
  2240. }
  2241. return res;
  2242. }
  2243. }
  2244. function resolve(registry, name) {
  2245. return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
  2246. }
  2247. /**
  2248. * Actual implementation
  2249. */
  2250. function renderList(source, renderItem, cache, index) {
  2251. var ret;
  2252. var cached = cache && cache[index];
  2253. if (isArray(source) || isString(source)) {
  2254. ret = new Array(source.length);
  2255. for (var i = 0, l = source.length; i < l; i++) {
  2256. ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
  2257. }
  2258. } else if (typeof source === 'number') {
  2259. ret = new Array(source);
  2260. for (var _i2 = 0; _i2 < source; _i2++) {
  2261. ret[_i2] = renderItem(_i2 + 1, _i2, undefined, cached && cached[_i2]);
  2262. }
  2263. } else if (isObject(source)) {
  2264. if (source[Symbol.iterator]) {
  2265. ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
  2266. } else {
  2267. var keys = Object.keys(source);
  2268. ret = new Array(keys.length);
  2269. for (var _i3 = 0, _l = keys.length; _i3 < _l; _i3++) {
  2270. var key = keys[_i3];
  2271. ret[_i3] = renderItem(source[key], key, _i3, cached && cached[_i3]);
  2272. }
  2273. }
  2274. } else {
  2275. ret = [];
  2276. }
  2277. if (cache) {
  2278. cache[index] = ret;
  2279. }
  2280. return ret;
  2281. }
  2282. /**
  2283. * Compiler runtime helper for creating dynamic slots object
  2284. * @private
  2285. */
  2286. function createSlots(slots, dynamicSlots) {
  2287. var _loop = function (i) {
  2288. var slot = dynamicSlots[i];
  2289. // array of dynamic slot generated by <template v-for="..." #[...]>
  2290. if (isArray(slot)) {
  2291. for (var j = 0; j < slot.length; j++) {
  2292. slots[slot[j].name] = slot[j].fn;
  2293. }
  2294. } else if (slot) {
  2295. // conditional single slot generated by <template v-if="..." #foo>
  2296. slots[slot.name] = slot.key ? function () {
  2297. var res = slot.fn(...arguments);
  2298. // attach branch key so each conditional branch is considered a
  2299. // different fragment
  2300. if (res) res.key = slot.key;
  2301. return res;
  2302. } : slot.fn;
  2303. }
  2304. };
  2305. for (var i = 0; i < dynamicSlots.length; i++) {
  2306. _loop(i);
  2307. }
  2308. return slots;
  2309. }
  2310. /**
  2311. * Compiler runtime helper for rendering `<slot/>`
  2312. * @private
  2313. */
  2314. function renderSlot(slots, name) {
  2315. var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  2316. var
  2317. // this is not a user-facing function, so the fallback is always generated by
  2318. // the compiler and guaranteed to be a function returning an array
  2319. fallback = arguments.length > 3 ? arguments[3] : undefined;
  2320. var noSlotted = arguments.length > 4 ? arguments[4] : undefined;
  2321. if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
  2322. if (name !== 'default') props.name = name;
  2323. return createVNode('slot', props, fallback && fallback());
  2324. }
  2325. var slot = slots[name];
  2326. // a compiled slot disables block tracking by default to avoid manual
  2327. // invocation interfering with template-based block tracking, but in
  2328. // `renderSlot` we can be sure that it's template-based so we can force
  2329. // enable it.
  2330. if (slot && slot._c) {
  2331. slot._d = false;
  2332. }
  2333. openBlock();
  2334. var validSlotContent = slot && ensureValidVNode(slot(props));
  2335. var rendered = createBlock(Fragment, {
  2336. key: props.key ||
  2337. // slot content array of a dynamic conditional slot may have a branch
  2338. // key attached in the `createSlots` helper, respect that
  2339. validSlotContent && validSlotContent.key || "_".concat(name)
  2340. }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* SlotFlags.STABLE */ ? 64 /* PatchFlags.STABLE_FRAGMENT */ : -2 /* PatchFlags.BAIL */);
  2341. if (!noSlotted && rendered.scopeId) {
  2342. rendered.slotScopeIds = [rendered.scopeId + '-s'];
  2343. }
  2344. if (slot && slot._c) {
  2345. slot._d = true;
  2346. }
  2347. return rendered;
  2348. }
  2349. function ensureValidVNode(vnodes) {
  2350. return vnodes.some(child => {
  2351. if (!isVNode(child)) return true;
  2352. if (child.type === Comment) return false;
  2353. if (child.type === Fragment && !ensureValidVNode(child.children)) return false;
  2354. return true;
  2355. }) ? vnodes : null;
  2356. }
  2357. /**
  2358. * For prefixing keys in v-on="obj" with "on"
  2359. * @private
  2360. */
  2361. function toHandlers(obj, preserveCaseIfNecessary) {
  2362. var ret = {};
  2363. for (var key in obj) {
  2364. ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? "on:".concat(key) : toHandlerKey(key)] = obj[key];
  2365. }
  2366. return ret;
  2367. }
  2368. /**
  2369. * #2437 In Vue 3, functional components do not have a public instance proxy but
  2370. * they exist in the internal parent chain. For code that relies on traversing
  2371. * public $parent chains, skip functional ones and go to the parent instead.
  2372. */
  2373. var getPublicInstance = i => {
  2374. if (!i) return null;
  2375. if (isStatefulComponent(i)) return getExposeProxy(i) || i.proxy;
  2376. return getPublicInstance(i.parent);
  2377. };
  2378. var publicPropertiesMap =
  2379. // Move PURE marker to new line to workaround compiler discarding it
  2380. // due to type annotation
  2381. /*#__PURE__*/
  2382. extend(Object.create(null), {
  2383. $: i => i,
  2384. $el: i => i.vnode.el,
  2385. $data: i => i.data,
  2386. $props: i => i.props,
  2387. $attrs: i => i.attrs,
  2388. $slots: i => i.slots,
  2389. $refs: i => i.refs,
  2390. $parent: i => getPublicInstance(i.parent),
  2391. $root: i => getPublicInstance(i.root),
  2392. $emit: i => i.emit,
  2393. $options: i => resolveMergedOptions(i),
  2394. $forceUpdate: i => i.f || (i.f = () => queueJob(i.update)),
  2395. $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy)),
  2396. $watch: i => instanceWatch.bind(i)
  2397. });
  2398. var hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
  2399. var PublicInstanceProxyHandlers = {
  2400. get(_ref7, key) {
  2401. var {
  2402. _: instance
  2403. } = _ref7;
  2404. var {
  2405. ctx,
  2406. setupState,
  2407. data,
  2408. props,
  2409. accessCache,
  2410. type,
  2411. appContext
  2412. } = instance;
  2413. // data / props / ctx
  2414. // This getter gets called for every property access on the render context
  2415. // during render and is a major hotspot. The most expensive part of this
  2416. // is the multiple hasOwn() calls. It's much faster to do a simple property
  2417. // access on a plain object, so we use an accessCache object (with null
  2418. // prototype) to memoize what access type a key corresponds to.
  2419. var normalizedProps;
  2420. if (key[0] !== '$') {
  2421. var n = accessCache[key];
  2422. if (n !== undefined) {
  2423. switch (n) {
  2424. case 1 /* AccessTypes.SETUP */:
  2425. return setupState[key];
  2426. case 2 /* AccessTypes.DATA */:
  2427. return data[key];
  2428. case 4 /* AccessTypes.CONTEXT */:
  2429. return ctx[key];
  2430. case 3 /* AccessTypes.PROPS */:
  2431. return props[key];
  2432. // default: just fallthrough
  2433. }
  2434. } else if (hasSetupBinding(setupState, key)) {
  2435. accessCache[key] = 1 /* AccessTypes.SETUP */;
  2436. return setupState[key];
  2437. } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  2438. accessCache[key] = 2 /* AccessTypes.DATA */;
  2439. return data[key];
  2440. } else if (
  2441. // only cache other properties when instance has declared (thus stable)
  2442. // props
  2443. (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)) {
  2444. accessCache[key] = 3 /* AccessTypes.PROPS */;
  2445. return props[key];
  2446. } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  2447. accessCache[key] = 4 /* AccessTypes.CONTEXT */;
  2448. return ctx[key];
  2449. } else if (shouldCacheAccess) {
  2450. accessCache[key] = 0 /* AccessTypes.OTHER */;
  2451. }
  2452. }
  2453. var publicGetter = publicPropertiesMap[key];
  2454. var cssModule, globalProperties;
  2455. // public $xxx properties
  2456. if (publicGetter) {
  2457. if (key === '$attrs') {
  2458. track(instance, "get" /* TrackOpTypes.GET */, key);
  2459. }
  2460. return publicGetter(instance);
  2461. } else if (
  2462. // css module (injected by vue-loader)
  2463. (cssModule = type.__cssModules) && (cssModule = cssModule[key])) {
  2464. return cssModule;
  2465. } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  2466. // user may set custom properties to `this` that start with `$`
  2467. accessCache[key] = 4 /* AccessTypes.CONTEXT */;
  2468. return ctx[key];
  2469. } else if (
  2470. // global properties
  2471. globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) {
  2472. {
  2473. return globalProperties[key];
  2474. }
  2475. } else ;
  2476. },
  2477. set(_ref8, key, value) {
  2478. var {
  2479. _: instance
  2480. } = _ref8;
  2481. var {
  2482. data,
  2483. setupState,
  2484. ctx
  2485. } = instance;
  2486. if (hasSetupBinding(setupState, key)) {
  2487. setupState[key] = value;
  2488. return true;
  2489. } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  2490. data[key] = value;
  2491. return true;
  2492. } else if (hasOwn(instance.props, key)) {
  2493. return false;
  2494. }
  2495. if (key[0] === '$' && key.slice(1) in instance) {
  2496. return false;
  2497. } else {
  2498. {
  2499. ctx[key] = value;
  2500. }
  2501. }
  2502. return true;
  2503. },
  2504. has(_ref9, key) {
  2505. var {
  2506. _: {
  2507. data,
  2508. setupState,
  2509. accessCache,
  2510. ctx,
  2511. appContext,
  2512. propsOptions
  2513. }
  2514. } = _ref9;
  2515. var normalizedProps;
  2516. return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key);
  2517. },
  2518. defineProperty(target, key, descriptor) {
  2519. if (descriptor.get != null) {
  2520. // invalidate key cache of a getter based property #5417
  2521. target._.accessCache[key] = 0;
  2522. } else if (hasOwn(descriptor, 'value')) {
  2523. this.set(target, key, descriptor.value, null);
  2524. }
  2525. return Reflect.defineProperty(target, key, descriptor);
  2526. }
  2527. };
  2528. var RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/extend({}, PublicInstanceProxyHandlers, {
  2529. get(target, key) {
  2530. // fast path for unscopables when using `with` block
  2531. if (key === Symbol.unscopables) {
  2532. return;
  2533. }
  2534. return PublicInstanceProxyHandlers.get(target, key, target);
  2535. },
  2536. has(_, key) {
  2537. var has = key[0] !== '_' && !isGloballyWhitelisted(key);
  2538. return has;
  2539. }
  2540. });
  2541. var shouldCacheAccess = true;
  2542. function applyOptions(instance) {
  2543. var options = resolveMergedOptions(instance);
  2544. var publicThis = instance.proxy;
  2545. var ctx = instance.ctx;
  2546. // do not cache property access on public proxy during state initialization
  2547. shouldCacheAccess = false;
  2548. // call beforeCreate first before accessing other options since
  2549. // the hook may mutate resolved options (#2791)
  2550. if (options.beforeCreate) {
  2551. callHook(options.beforeCreate, instance, "bc" /* LifecycleHooks.BEFORE_CREATE */);
  2552. }
  2553. var {
  2554. // state
  2555. data: dataOptions,
  2556. computed: computedOptions,
  2557. methods,
  2558. watch: watchOptions,
  2559. provide: provideOptions,
  2560. inject: injectOptions,
  2561. // lifecycle
  2562. created,
  2563. beforeMount,
  2564. mounted,
  2565. beforeUpdate,
  2566. updated,
  2567. activated,
  2568. deactivated,
  2569. beforeDestroy,
  2570. beforeUnmount,
  2571. destroyed,
  2572. unmounted,
  2573. render,
  2574. renderTracked,
  2575. renderTriggered,
  2576. errorCaptured,
  2577. serverPrefetch,
  2578. // public API
  2579. expose,
  2580. inheritAttrs,
  2581. // assets
  2582. components,
  2583. directives,
  2584. filters
  2585. } = options;
  2586. var checkDuplicateProperties = null;
  2587. // options initialization order (to be consistent with Vue 2):
  2588. // - props (already done outside of this function)
  2589. // - inject
  2590. // - methods
  2591. // - data (deferred since it relies on `this` access)
  2592. // - computed
  2593. // - watch (deferred since it relies on `this` access)
  2594. if (injectOptions) {
  2595. resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
  2596. }
  2597. if (methods) {
  2598. for (var key in methods) {
  2599. var methodHandler = methods[key];
  2600. if (isFunction(methodHandler)) {
  2601. // In dev mode, we use the `createRenderContext` function to define
  2602. // methods to the proxy target, and those are read-only but
  2603. // reconfigurable, so it needs to be redefined here
  2604. {
  2605. ctx[key] = methodHandler.bind(publicThis);
  2606. }
  2607. }
  2608. }
  2609. }
  2610. if (dataOptions) {
  2611. var data = dataOptions.call(publicThis, publicThis);
  2612. if (!isObject(data)) ;else {
  2613. instance.data = reactive(data);
  2614. }
  2615. }
  2616. // state initialization complete at this point - start caching access
  2617. shouldCacheAccess = true;
  2618. if (computedOptions) {
  2619. var _loop2 = function (_key3) {
  2620. var opt = computedOptions[_key3];
  2621. var get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
  2622. var set = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : NOOP;
  2623. var c = computed({
  2624. get,
  2625. set
  2626. });
  2627. Object.defineProperty(ctx, _key3, {
  2628. enumerable: true,
  2629. configurable: true,
  2630. get: () => c.value,
  2631. set: v => c.value = v
  2632. });
  2633. };
  2634. for (var _key3 in computedOptions) {
  2635. _loop2(_key3);
  2636. }
  2637. }
  2638. if (watchOptions) {
  2639. for (var _key4 in watchOptions) {
  2640. createWatcher(watchOptions[_key4], ctx, publicThis, _key4);
  2641. }
  2642. }
  2643. if (provideOptions) {
  2644. var provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
  2645. Reflect.ownKeys(provides).forEach(key => {
  2646. provide(key, provides[key]);
  2647. });
  2648. }
  2649. if (created) {
  2650. callHook(created, instance, "c" /* LifecycleHooks.CREATED */);
  2651. }
  2652. function registerLifecycleHook(register, hook) {
  2653. if (isArray(hook)) {
  2654. hook.forEach(_hook => register(_hook.bind(publicThis)));
  2655. } else if (hook) {
  2656. register(hook.bind(publicThis));
  2657. }
  2658. }
  2659. registerLifecycleHook(onBeforeMount, beforeMount);
  2660. registerLifecycleHook(onMounted, mounted);
  2661. registerLifecycleHook(onBeforeUpdate, beforeUpdate);
  2662. registerLifecycleHook(onUpdated, updated);
  2663. registerLifecycleHook(onActivated, activated);
  2664. registerLifecycleHook(onDeactivated, deactivated);
  2665. registerLifecycleHook(onErrorCaptured, errorCaptured);
  2666. registerLifecycleHook(onRenderTracked, renderTracked);
  2667. registerLifecycleHook(onRenderTriggered, renderTriggered);
  2668. registerLifecycleHook(onBeforeUnmount, beforeUnmount);
  2669. registerLifecycleHook(onUnmounted, unmounted);
  2670. registerLifecycleHook(onServerPrefetch, serverPrefetch);
  2671. if (isArray(expose)) {
  2672. if (expose.length) {
  2673. var exposed = instance.exposed || (instance.exposed = {});
  2674. expose.forEach(key => {
  2675. Object.defineProperty(exposed, key, {
  2676. get: () => publicThis[key],
  2677. set: val => publicThis[key] = val
  2678. });
  2679. });
  2680. } else if (!instance.exposed) {
  2681. instance.exposed = {};
  2682. }
  2683. }
  2684. // options that are handled when creating the instance but also need to be
  2685. // applied from mixins
  2686. if (render && instance.render === NOOP) {
  2687. instance.render = render;
  2688. }
  2689. if (inheritAttrs != null) {
  2690. instance.inheritAttrs = inheritAttrs;
  2691. }
  2692. // asset options.
  2693. if (components) instance.components = components;
  2694. if (directives) instance.directives = directives;
  2695. // fixed by xxxxxx
  2696. var customApplyOptions = instance.appContext.config.globalProperties.$applyOptions;
  2697. if (customApplyOptions) {
  2698. customApplyOptions(options, instance, publicThis);
  2699. }
  2700. }
  2701. function resolveInjections(injectOptions, ctx) {
  2702. var checkDuplicateProperties = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : NOOP;
  2703. var unwrapRef = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2704. if (isArray(injectOptions)) {
  2705. injectOptions = normalizeInject(injectOptions);
  2706. }
  2707. var _loop3 = function (key) {
  2708. var opt = injectOptions[key];
  2709. var injected = void 0;
  2710. if (isObject(opt)) {
  2711. if ('default' in opt) {
  2712. injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
  2713. } else {
  2714. injected = inject(opt.from || key);
  2715. }
  2716. } else {
  2717. injected = inject(opt);
  2718. }
  2719. if (isRef(injected)) {
  2720. // TODO remove the check in 3.3
  2721. if (unwrapRef) {
  2722. Object.defineProperty(ctx, key, {
  2723. enumerable: true,
  2724. configurable: true,
  2725. get: () => injected.value,
  2726. set: v => injected.value = v
  2727. });
  2728. } else {
  2729. ctx[key] = injected;
  2730. }
  2731. } else {
  2732. ctx[key] = injected;
  2733. }
  2734. };
  2735. for (var key in injectOptions) {
  2736. _loop3(key);
  2737. }
  2738. }
  2739. function callHook(hook, instance, type) {
  2740. callWithAsyncErrorHandling(isArray(hook) ? hook.map(h => h.bind(instance.proxy)) : hook.bind(instance.proxy), instance, type);
  2741. }
  2742. function createWatcher(raw, ctx, publicThis, key) {
  2743. var getter = key.includes('.') ? createPathGetter(publicThis, key) : () => publicThis[key];
  2744. if (isString(raw)) {
  2745. var handler = ctx[raw];
  2746. if (isFunction(handler)) {
  2747. watch(getter, handler);
  2748. }
  2749. } else if (isFunction(raw)) {
  2750. watch(getter, raw.bind(publicThis));
  2751. } else if (isObject(raw)) {
  2752. if (isArray(raw)) {
  2753. raw.forEach(r => createWatcher(r, ctx, publicThis, key));
  2754. } else {
  2755. var _handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
  2756. if (isFunction(_handler)) {
  2757. watch(getter, _handler, raw);
  2758. }
  2759. }
  2760. } else ;
  2761. }
  2762. /**
  2763. * Resolve merged options and cache it on the component.
  2764. * This is done only once per-component since the merging does not involve
  2765. * instances.
  2766. */
  2767. function resolveMergedOptions(instance) {
  2768. var base = instance.type;
  2769. var {
  2770. mixins,
  2771. extends: extendsOptions
  2772. } = base;
  2773. var {
  2774. mixins: globalMixins,
  2775. optionsCache: cache,
  2776. config: {
  2777. optionMergeStrategies
  2778. }
  2779. } = instance.appContext;
  2780. var cached = cache.get(base);
  2781. var resolved;
  2782. if (cached) {
  2783. resolved = cached;
  2784. } else if (!globalMixins.length && !mixins && !extendsOptions) {
  2785. {
  2786. resolved = base;
  2787. }
  2788. } else {
  2789. resolved = {};
  2790. if (globalMixins.length) {
  2791. globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
  2792. }
  2793. mergeOptions(resolved, base, optionMergeStrategies);
  2794. }
  2795. if (isObject(base)) {
  2796. cache.set(base, resolved);
  2797. }
  2798. return resolved;
  2799. }
  2800. function mergeOptions(to, from, strats) {
  2801. var asMixin = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2802. var {
  2803. mixins,
  2804. extends: extendsOptions
  2805. } = from;
  2806. if (extendsOptions) {
  2807. mergeOptions(to, extendsOptions, strats, true);
  2808. }
  2809. if (mixins) {
  2810. mixins.forEach(m => mergeOptions(to, m, strats, true));
  2811. }
  2812. for (var key in from) {
  2813. if (asMixin && key === 'expose') ;else {
  2814. var strat = internalOptionMergeStrats[key] || strats && strats[key];
  2815. to[key] = strat ? strat(to[key], from[key]) : from[key];
  2816. }
  2817. }
  2818. return to;
  2819. }
  2820. var internalOptionMergeStrats = {
  2821. data: mergeDataFn,
  2822. props: mergeObjectOptions,
  2823. emits: mergeObjectOptions,
  2824. // objects
  2825. methods: mergeObjectOptions,
  2826. computed: mergeObjectOptions,
  2827. // lifecycle
  2828. beforeCreate: mergeAsArray,
  2829. created: mergeAsArray,
  2830. beforeMount: mergeAsArray,
  2831. mounted: mergeAsArray,
  2832. beforeUpdate: mergeAsArray,
  2833. updated: mergeAsArray,
  2834. beforeDestroy: mergeAsArray,
  2835. beforeUnmount: mergeAsArray,
  2836. destroyed: mergeAsArray,
  2837. unmounted: mergeAsArray,
  2838. activated: mergeAsArray,
  2839. deactivated: mergeAsArray,
  2840. errorCaptured: mergeAsArray,
  2841. serverPrefetch: mergeAsArray,
  2842. // assets
  2843. components: mergeObjectOptions,
  2844. directives: mergeObjectOptions,
  2845. // watch
  2846. watch: mergeWatchOptions,
  2847. // provide / inject
  2848. provide: mergeDataFn,
  2849. inject: mergeInject
  2850. };
  2851. function mergeDataFn(to, from) {
  2852. if (!from) {
  2853. return to;
  2854. }
  2855. if (!to) {
  2856. return from;
  2857. }
  2858. return function mergedDataFn() {
  2859. return extend(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
  2860. };
  2861. }
  2862. function mergeInject(to, from) {
  2863. return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  2864. }
  2865. function normalizeInject(raw) {
  2866. if (isArray(raw)) {
  2867. var res = {};
  2868. for (var i = 0; i < raw.length; i++) {
  2869. res[raw[i]] = raw[i];
  2870. }
  2871. return res;
  2872. }
  2873. return raw;
  2874. }
  2875. function mergeAsArray(to, from) {
  2876. return to ? [...new Set([].concat(to, from))] : from;
  2877. }
  2878. function mergeObjectOptions(to, from) {
  2879. return to ? extend(extend(Object.create(null), to), from) : from;
  2880. }
  2881. function mergeWatchOptions(to, from) {
  2882. if (!to) return from;
  2883. if (!from) return to;
  2884. var merged = extend(Object.create(null), to);
  2885. for (var key in from) {
  2886. merged[key] = mergeAsArray(to[key], from[key]);
  2887. }
  2888. return merged;
  2889. }
  2890. function initProps(instance, rawProps, isStateful) {
  2891. var isSSR = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2892. var props = {};
  2893. var attrs = {};
  2894. def(attrs, InternalObjectKey, 1);
  2895. instance.propsDefaults = Object.create(null);
  2896. setFullProps(instance, rawProps, props, attrs);
  2897. // ensure all declared prop keys are present
  2898. for (var key in instance.propsOptions[0]) {
  2899. if (!(key in props)) {
  2900. props[key] = undefined;
  2901. }
  2902. }
  2903. if (isStateful) {
  2904. // stateful
  2905. instance.props = isSSR ? props : shallowReactive(props);
  2906. } else {
  2907. if (!instance.type.props) {
  2908. // functional w/ optional props, props === attrs
  2909. instance.props = attrs;
  2910. } else {
  2911. // functional w/ declared props
  2912. instance.props = props;
  2913. }
  2914. }
  2915. instance.attrs = attrs;
  2916. }
  2917. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  2918. var {
  2919. props,
  2920. attrs,
  2921. vnode: {
  2922. patchFlag
  2923. }
  2924. } = instance;
  2925. var rawCurrentProps = toRaw(props);
  2926. var [options] = instance.propsOptions;
  2927. var hasAttrsChanged = false;
  2928. if (
  2929. // always force full diff in dev
  2930. // - #1942 if hmr is enabled with sfc component
  2931. // - vite#872 non-sfc component used by sfc component
  2932. (optimized || patchFlag > 0) && !(patchFlag & 16 /* PatchFlags.FULL_PROPS */)) {
  2933. if (patchFlag & 8 /* PatchFlags.PROPS */) {
  2934. // Compiler-generated props & no keys change, just set the updated
  2935. // the props.
  2936. var propsToUpdate = instance.vnode.dynamicProps;
  2937. for (var i = 0; i < propsToUpdate.length; i++) {
  2938. var key = propsToUpdate[i];
  2939. // skip if the prop key is a declared emit event listener
  2940. if (isEmitListener(instance.emitsOptions, key)) {
  2941. continue;
  2942. }
  2943. // PROPS flag guarantees rawProps to be non-null
  2944. var value = rawProps[key];
  2945. if (options) {
  2946. // attr / props separation was done on init and will be consistent
  2947. // in this code path, so just check if attrs have it.
  2948. if (hasOwn(attrs, key)) {
  2949. if (value !== attrs[key]) {
  2950. attrs[key] = value;
  2951. hasAttrsChanged = true;
  2952. }
  2953. } else {
  2954. var camelizedKey = camelize(key);
  2955. props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
  2956. }
  2957. } else {
  2958. if (value !== attrs[key]) {
  2959. attrs[key] = value;
  2960. hasAttrsChanged = true;
  2961. }
  2962. }
  2963. }
  2964. }
  2965. } else {
  2966. // full props update.
  2967. if (setFullProps(instance, rawProps, props, attrs)) {
  2968. hasAttrsChanged = true;
  2969. }
  2970. // in case of dynamic props, check if we need to delete keys from
  2971. // the props object
  2972. var kebabKey;
  2973. for (var _key5 in rawCurrentProps) {
  2974. if (!rawProps ||
  2975. // for camelCase
  2976. !hasOwn(rawProps, _key5) && (
  2977. // it's possible the original props was passed in as kebab-case
  2978. // and converted to camelCase (#955)
  2979. (kebabKey = hyphenate(_key5)) === _key5 || !hasOwn(rawProps, kebabKey))) {
  2980. if (options) {
  2981. if (rawPrevProps && (
  2982. // for camelCase
  2983. rawPrevProps[_key5] !== undefined ||
  2984. // for kebab-case
  2985. rawPrevProps[kebabKey] !== undefined)) {
  2986. props[_key5] = resolvePropValue(options, rawCurrentProps, _key5, undefined, instance, true /* isAbsent */);
  2987. }
  2988. } else {
  2989. delete props[_key5];
  2990. }
  2991. }
  2992. }
  2993. // in the case of functional component w/o props declaration, props and
  2994. // attrs point to the same object so it should already have been updated.
  2995. if (attrs !== rawCurrentProps) {
  2996. for (var _key6 in attrs) {
  2997. if (!rawProps || !hasOwn(rawProps, _key6) && !false) {
  2998. delete attrs[_key6];
  2999. hasAttrsChanged = true;
  3000. }
  3001. }
  3002. }
  3003. }
  3004. // trigger updates for $attrs in case it's used in component slots
  3005. if (hasAttrsChanged) {
  3006. trigger(instance, "set" /* TriggerOpTypes.SET */, '$attrs');
  3007. }
  3008. }
  3009. function setFullProps(instance, rawProps, props, attrs) {
  3010. var [options, needCastKeys] = instance.propsOptions;
  3011. var hasAttrsChanged = false;
  3012. var rawCastValues;
  3013. if (rawProps) {
  3014. for (var key in rawProps) {
  3015. // key, ref are reserved and never passed down
  3016. if (isReservedProp(key)) {
  3017. continue;
  3018. }
  3019. var value = rawProps[key];
  3020. // prop option names are camelized during normalization, so to support
  3021. // kebab -> camel conversion here we need to camelize the key.
  3022. var camelKey = void 0;
  3023. if (options && hasOwn(options, camelKey = camelize(key))) {
  3024. if (!needCastKeys || !needCastKeys.includes(camelKey)) {
  3025. props[camelKey] = value;
  3026. } else {
  3027. (rawCastValues || (rawCastValues = {}))[camelKey] = value;
  3028. }
  3029. } else if (!isEmitListener(instance.emitsOptions, key)) {
  3030. if (!(key in attrs) || value !== attrs[key]) {
  3031. attrs[key] = value;
  3032. hasAttrsChanged = true;
  3033. }
  3034. }
  3035. }
  3036. }
  3037. if (needCastKeys) {
  3038. var rawCurrentProps = toRaw(props);
  3039. var castValues = rawCastValues || EMPTY_OBJ;
  3040. for (var i = 0; i < needCastKeys.length; i++) {
  3041. var _key7 = needCastKeys[i];
  3042. props[_key7] = resolvePropValue(options, rawCurrentProps, _key7, castValues[_key7], instance, !hasOwn(castValues, _key7));
  3043. }
  3044. }
  3045. return hasAttrsChanged;
  3046. }
  3047. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  3048. var opt = options[key];
  3049. if (opt != null) {
  3050. var hasDefault = hasOwn(opt, 'default');
  3051. // default values
  3052. if (hasDefault && value === undefined) {
  3053. var defaultValue = opt.default;
  3054. if (opt.type !== Function && isFunction(defaultValue)) {
  3055. var {
  3056. propsDefaults
  3057. } = instance;
  3058. if (key in propsDefaults) {
  3059. value = propsDefaults[key];
  3060. } else {
  3061. setCurrentInstance(instance);
  3062. value = propsDefaults[key] = defaultValue.call(null, props);
  3063. unsetCurrentInstance();
  3064. }
  3065. } else {
  3066. value = defaultValue;
  3067. }
  3068. }
  3069. // boolean casting
  3070. if (opt[0 /* BooleanFlags.shouldCast */]) {
  3071. if (isAbsent && !hasDefault) {
  3072. value = false;
  3073. } else if (opt[1 /* BooleanFlags.shouldCastTrue */] && (value === '' || value === hyphenate(key))) {
  3074. value = true;
  3075. }
  3076. }
  3077. }
  3078. return value;
  3079. }
  3080. function normalizePropsOptions(comp, appContext) {
  3081. var asMixin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3082. var cache = appContext.propsCache;
  3083. var cached = cache.get(comp);
  3084. if (cached) {
  3085. return cached;
  3086. }
  3087. var raw = comp.props;
  3088. var normalized = {};
  3089. var needCastKeys = [];
  3090. // apply mixin/extends props
  3091. var hasExtends = false;
  3092. if (!isFunction(comp)) {
  3093. var extendProps = raw => {
  3094. hasExtends = true;
  3095. var [props, keys] = normalizePropsOptions(raw, appContext, true);
  3096. extend(normalized, props);
  3097. if (keys) needCastKeys.push(...keys);
  3098. };
  3099. if (!asMixin && appContext.mixins.length) {
  3100. appContext.mixins.forEach(extendProps);
  3101. }
  3102. if (comp.extends) {
  3103. extendProps(comp.extends);
  3104. }
  3105. if (comp.mixins) {
  3106. comp.mixins.forEach(extendProps);
  3107. }
  3108. }
  3109. if (!raw && !hasExtends) {
  3110. if (isObject(comp)) {
  3111. cache.set(comp, EMPTY_ARR);
  3112. }
  3113. return EMPTY_ARR;
  3114. }
  3115. if (isArray(raw)) {
  3116. for (var i = 0; i < raw.length; i++) {
  3117. var normalizedKey = camelize(raw[i]);
  3118. if (validatePropName(normalizedKey)) {
  3119. normalized[normalizedKey] = EMPTY_OBJ;
  3120. }
  3121. }
  3122. } else if (raw) {
  3123. for (var key in raw) {
  3124. var _normalizedKey = camelize(key);
  3125. if (validatePropName(_normalizedKey)) {
  3126. var opt = raw[key];
  3127. var prop = normalized[_normalizedKey] = isArray(opt) || isFunction(opt) ? {
  3128. type: opt
  3129. } : Object.assign({}, opt);
  3130. if (prop) {
  3131. var booleanIndex = getTypeIndex(Boolean, prop.type);
  3132. var stringIndex = getTypeIndex(String, prop.type);
  3133. prop[0 /* BooleanFlags.shouldCast */] = booleanIndex > -1;
  3134. prop[1 /* BooleanFlags.shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex;
  3135. // if the prop needs boolean casting or default value
  3136. if (booleanIndex > -1 || hasOwn(prop, 'default')) {
  3137. needCastKeys.push(_normalizedKey);
  3138. }
  3139. }
  3140. }
  3141. }
  3142. }
  3143. var res = [normalized, needCastKeys];
  3144. if (isObject(comp)) {
  3145. cache.set(comp, res);
  3146. }
  3147. return res;
  3148. }
  3149. function validatePropName(key) {
  3150. if (key[0] !== '$') {
  3151. return true;
  3152. }
  3153. return false;
  3154. }
  3155. // use function string name to check type constructors
  3156. // so that it works across vms / iframes.
  3157. function getType(ctor) {
  3158. var match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
  3159. return match ? match[2] : ctor === null ? 'null' : '';
  3160. }
  3161. function isSameType(a, b) {
  3162. return getType(a) === getType(b);
  3163. }
  3164. function getTypeIndex(type, expectedTypes) {
  3165. if (isArray(expectedTypes)) {
  3166. return expectedTypes.findIndex(t => isSameType(t, type));
  3167. } else if (isFunction(expectedTypes)) {
  3168. return isSameType(expectedTypes, type) ? 0 : -1;
  3169. }
  3170. return -1;
  3171. }
  3172. var isInternalKey = key => key[0] === '_' || key === '$stable';
  3173. var normalizeSlotValue = value => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
  3174. var normalizeSlot = (key, rawSlot, ctx) => {
  3175. if (rawSlot._n) {
  3176. // already normalized - #5353
  3177. return rawSlot;
  3178. }
  3179. var normalized = withCtx(function () {
  3180. if ("production" !== 'production' && currentInstance) ;
  3181. return normalizeSlotValue(rawSlot(...arguments));
  3182. }, ctx);
  3183. normalized._c = false;
  3184. return normalized;
  3185. };
  3186. var normalizeObjectSlots = (rawSlots, slots, instance) => {
  3187. var ctx = rawSlots._ctx;
  3188. for (var key in rawSlots) {
  3189. if (isInternalKey(key)) continue;
  3190. var value = rawSlots[key];
  3191. if (isFunction(value)) {
  3192. slots[key] = normalizeSlot(key, value, ctx);
  3193. } else if (value != null) {
  3194. (function () {
  3195. var normalized = normalizeSlotValue(value);
  3196. slots[key] = () => normalized;
  3197. })();
  3198. }
  3199. }
  3200. };
  3201. var normalizeVNodeSlots = (instance, children) => {
  3202. var normalized = normalizeSlotValue(children);
  3203. instance.slots.default = () => normalized;
  3204. };
  3205. var initSlots = (instance, children) => {
  3206. if (instance.vnode.shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */) {
  3207. var type = children._;
  3208. if (type) {
  3209. // users can get the shallow readonly version of the slots object through `this.$slots`,
  3210. // we should avoid the proxy object polluting the slots of the internal instance
  3211. instance.slots = toRaw(children);
  3212. // make compiler marker non-enumerable
  3213. def(children, '_', type);
  3214. } else {
  3215. normalizeObjectSlots(children, instance.slots = {});
  3216. }
  3217. } else {
  3218. instance.slots = {};
  3219. if (children) {
  3220. normalizeVNodeSlots(instance, children);
  3221. }
  3222. }
  3223. def(instance.slots, InternalObjectKey, 1);
  3224. };
  3225. var updateSlots = (instance, children, optimized) => {
  3226. var {
  3227. vnode,
  3228. slots
  3229. } = instance;
  3230. var needDeletionCheck = true;
  3231. var deletionComparisonTarget = EMPTY_OBJ;
  3232. if (vnode.shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */) {
  3233. var type = children._;
  3234. if (type) {
  3235. // compiled slots.
  3236. if (optimized && type === 1 /* SlotFlags.STABLE */) {
  3237. // compiled AND stable.
  3238. // no need to update, and skip stale slots removal.
  3239. needDeletionCheck = false;
  3240. } else {
  3241. // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
  3242. // normalization.
  3243. extend(slots, children);
  3244. // #2893
  3245. // when rendering the optimized slots by manually written render function,
  3246. // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
  3247. // i.e. let the `renderSlot` create the bailed Fragment
  3248. if (!optimized && type === 1 /* SlotFlags.STABLE */) {
  3249. delete slots._;
  3250. }
  3251. }
  3252. } else {
  3253. needDeletionCheck = !children.$stable;
  3254. normalizeObjectSlots(children, slots);
  3255. }
  3256. deletionComparisonTarget = children;
  3257. } else if (children) {
  3258. // non slot object children (direct value) passed to a component
  3259. normalizeVNodeSlots(instance, children);
  3260. deletionComparisonTarget = {
  3261. default: 1
  3262. };
  3263. }
  3264. // delete stale slots
  3265. if (needDeletionCheck) {
  3266. for (var key in slots) {
  3267. if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
  3268. delete slots[key];
  3269. }
  3270. }
  3271. }
  3272. };
  3273. function createAppContext() {
  3274. return {
  3275. app: null,
  3276. config: {
  3277. isNativeTag: NO,
  3278. performance: false,
  3279. globalProperties: {},
  3280. optionMergeStrategies: {},
  3281. errorHandler: undefined,
  3282. warnHandler: undefined,
  3283. compilerOptions: {}
  3284. },
  3285. mixins: [],
  3286. components: {},
  3287. directives: {},
  3288. provides: Object.create(null),
  3289. optionsCache: new WeakMap(),
  3290. propsCache: new WeakMap(),
  3291. emitsCache: new WeakMap()
  3292. };
  3293. }
  3294. var uid$1 = 0;
  3295. function createAppAPI(render, hydrate) {
  3296. return function createApp(rootComponent) {
  3297. var rootProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3298. if (!isFunction(rootComponent)) {
  3299. rootComponent = Object.assign({}, rootComponent);
  3300. }
  3301. if (rootProps != null && !isObject(rootProps)) {
  3302. rootProps = null;
  3303. }
  3304. var context = createAppContext();
  3305. var installedPlugins = new Set();
  3306. var isMounted = false;
  3307. var app = context.app = {
  3308. _uid: uid$1++,
  3309. _component: rootComponent,
  3310. _props: rootProps,
  3311. _container: null,
  3312. _context: context,
  3313. _instance: null,
  3314. version,
  3315. get config() {
  3316. return context.config;
  3317. },
  3318. set config(v) {},
  3319. use(plugin) {
  3320. for (var _len3 = arguments.length, options = new Array(_len3 > 1 ? _len3 - 1 : 0), _key8 = 1; _key8 < _len3; _key8++) {
  3321. options[_key8 - 1] = arguments[_key8];
  3322. }
  3323. if (installedPlugins.has(plugin)) ;else if (plugin && isFunction(plugin.install)) {
  3324. installedPlugins.add(plugin);
  3325. plugin.install(app, ...options);
  3326. } else if (isFunction(plugin)) {
  3327. installedPlugins.add(plugin);
  3328. plugin(app, ...options);
  3329. } else ;
  3330. return app;
  3331. },
  3332. mixin(mixin) {
  3333. {
  3334. if (!context.mixins.includes(mixin)) {
  3335. context.mixins.push(mixin);
  3336. }
  3337. }
  3338. return app;
  3339. },
  3340. component(name, component) {
  3341. if (!component) {
  3342. return context.components[name];
  3343. }
  3344. context.components[name] = component;
  3345. return app;
  3346. },
  3347. directive(name, directive) {
  3348. if (!directive) {
  3349. return context.directives[name];
  3350. }
  3351. context.directives[name] = directive;
  3352. return app;
  3353. },
  3354. mount(rootContainer, isHydrate, isSVG) {
  3355. if (!isMounted) {
  3356. var vnode = createVNode(rootComponent, rootProps);
  3357. // store app context on the root VNode.
  3358. // this will be set on the root instance on initial mount.
  3359. vnode.appContext = context;
  3360. if (isHydrate && hydrate) {
  3361. hydrate(vnode, rootContainer);
  3362. } else {
  3363. render(vnode, rootContainer, isSVG);
  3364. }
  3365. isMounted = true;
  3366. app._container = rootContainer;
  3367. rootContainer.__vue_app__ = app;
  3368. // fixed by xxxxxx (始终暴露,因为 onError 要访问)
  3369. app._instance = vnode.component;
  3370. return getExposeProxy(vnode.component) || vnode.component.proxy;
  3371. }
  3372. },
  3373. unmount() {
  3374. if (isMounted) {
  3375. render(null, app._container);
  3376. delete app._container.__vue_app__;
  3377. }
  3378. },
  3379. provide(key, value) {
  3380. context.provides[key] = value;
  3381. return app;
  3382. }
  3383. };
  3384. return app;
  3385. };
  3386. }
  3387. /**
  3388. * Function for handling a template ref
  3389. */
  3390. function setRef(rawRef, oldRawRef, parentSuspense, vnode) {
  3391. var isUnmount = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  3392. if (isArray(rawRef)) {
  3393. rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
  3394. return;
  3395. }
  3396. if (isAsyncWrapper(vnode) && !isUnmount) {
  3397. // when mounting async components, nothing needs to be done,
  3398. // because the template ref is forwarded to inner component
  3399. return;
  3400. }
  3401. var refValue = vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */ ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el;
  3402. var value = isUnmount ? null : refValue;
  3403. var {
  3404. i: owner,
  3405. r: ref
  3406. } = rawRef;
  3407. var oldRef = oldRawRef && oldRawRef.r;
  3408. var refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
  3409. var setupState = owner.setupState;
  3410. // dynamic ref changed. unset old ref
  3411. if (oldRef != null && oldRef !== ref) {
  3412. if (isString(oldRef)) {
  3413. refs[oldRef] = null;
  3414. if (hasOwn(setupState, oldRef)) {
  3415. setupState[oldRef] = null;
  3416. }
  3417. } else if (isRef(oldRef)) {
  3418. oldRef.value = null;
  3419. }
  3420. }
  3421. if (isFunction(ref)) {
  3422. callWithErrorHandling(ref, owner, 12 /* ErrorCodes.FUNCTION_REF */, [value, refs]);
  3423. } else {
  3424. var _isString = isString(ref);
  3425. var _isRef = isRef(ref);
  3426. if (_isString || _isRef) {
  3427. var doSet = () => {
  3428. if (rawRef.f) {
  3429. var existing = _isString ? hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
  3430. if (isUnmount) {
  3431. isArray(existing) && remove(existing, refValue);
  3432. } else {
  3433. if (!isArray(existing)) {
  3434. if (_isString) {
  3435. refs[ref] = [refValue];
  3436. if (hasOwn(setupState, ref)) {
  3437. setupState[ref] = refs[ref];
  3438. }
  3439. } else {
  3440. ref.value = [refValue];
  3441. if (rawRef.k) refs[rawRef.k] = ref.value;
  3442. }
  3443. } else if (!existing.includes(refValue)) {
  3444. existing.push(refValue);
  3445. }
  3446. }
  3447. } else if (_isString) {
  3448. refs[ref] = value;
  3449. if (hasOwn(setupState, ref)) {
  3450. setupState[ref] = value;
  3451. }
  3452. } else if (_isRef) {
  3453. ref.value = value;
  3454. if (rawRef.k) refs[rawRef.k] = value;
  3455. } else ;
  3456. };
  3457. if (value) {
  3458. doSet.id = -1;
  3459. queuePostRenderEffect(doSet, parentSuspense);
  3460. } else {
  3461. doSet();
  3462. }
  3463. }
  3464. }
  3465. }
  3466. var hasMismatch = false;
  3467. var isSVGContainer = container => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
  3468. var isComment = node => node.nodeType === 8 /* DOMNodeTypes.COMMENT */;
  3469. // Note: hydration is DOM-specific
  3470. // But we have to place it in core due to tight coupling with core - splitting
  3471. // it out creates a ton of unnecessary complexity.
  3472. // Hydration also depends on some renderer internal logic which needs to be
  3473. // passed in via arguments.
  3474. function createHydrationFunctions(rendererInternals) {
  3475. var {
  3476. mt: mountComponent,
  3477. p: patch,
  3478. o: {
  3479. patchProp,
  3480. createText,
  3481. nextSibling,
  3482. parentNode,
  3483. remove,
  3484. insert,
  3485. createComment
  3486. }
  3487. } = rendererInternals;
  3488. var hydrate = (vnode, container) => {
  3489. if (!container.hasChildNodes()) {
  3490. patch(null, vnode, container);
  3491. flushPostFlushCbs();
  3492. container._vnode = vnode;
  3493. return;
  3494. }
  3495. hasMismatch = false;
  3496. hydrateNode(container.firstChild, vnode, null, null, null);
  3497. flushPostFlushCbs();
  3498. container._vnode = vnode;
  3499. if (hasMismatch && !false) {
  3500. // this error should show up in production
  3501. console.error("Hydration completed but contains mismatches.");
  3502. }
  3503. };
  3504. var hydrateNode = function (node, vnode, parentComponent, parentSuspense, slotScopeIds) {
  3505. var optimized = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
  3506. var isFragmentStart = isComment(node) && node.data === '[';
  3507. var onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
  3508. var {
  3509. type,
  3510. ref,
  3511. shapeFlag,
  3512. patchFlag
  3513. } = vnode;
  3514. var domType = node.nodeType;
  3515. vnode.el = node;
  3516. if (patchFlag === -2 /* PatchFlags.BAIL */) {
  3517. optimized = false;
  3518. vnode.dynamicChildren = null;
  3519. }
  3520. var nextNode = null;
  3521. switch (type) {
  3522. case Text:
  3523. if (domType !== 3 /* DOMNodeTypes.TEXT */) {
  3524. // #5728 empty text node inside a slot can cause hydration failure
  3525. // because the server rendered HTML won't contain a text node
  3526. if (vnode.children === '') {
  3527. insert(vnode.el = createText(''), parentNode(node), node);
  3528. nextNode = node;
  3529. } else {
  3530. nextNode = onMismatch();
  3531. }
  3532. } else {
  3533. if (node.data !== vnode.children) {
  3534. hasMismatch = true;
  3535. node.data = vnode.children;
  3536. }
  3537. nextNode = nextSibling(node);
  3538. }
  3539. break;
  3540. case Comment:
  3541. if (domType !== 8 /* DOMNodeTypes.COMMENT */ || isFragmentStart) {
  3542. nextNode = onMismatch();
  3543. } else {
  3544. nextNode = nextSibling(node);
  3545. }
  3546. break;
  3547. case Static:
  3548. if (isFragmentStart) {
  3549. // entire template is static but SSRed as a fragment
  3550. node = nextSibling(node);
  3551. domType = node.nodeType;
  3552. }
  3553. if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
  3554. // determine anchor, adopt content
  3555. nextNode = node;
  3556. // if the static vnode has its content stripped during build,
  3557. // adopt it from the server-rendered HTML.
  3558. var needToAdoptContent = !vnode.children.length;
  3559. for (var i = 0; i < vnode.staticCount; i++) {
  3560. if (needToAdoptContent) vnode.children += nextNode.nodeType === 1 /* DOMNodeTypes.ELEMENT */ ? nextNode.outerHTML : nextNode.data;
  3561. if (i === vnode.staticCount - 1) {
  3562. vnode.anchor = nextNode;
  3563. }
  3564. nextNode = nextSibling(nextNode);
  3565. }
  3566. return isFragmentStart ? nextSibling(nextNode) : nextNode;
  3567. } else {
  3568. onMismatch();
  3569. }
  3570. break;
  3571. case Fragment:
  3572. if (!isFragmentStart) {
  3573. nextNode = onMismatch();
  3574. } else {
  3575. nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  3576. }
  3577. break;
  3578. default:
  3579. if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
  3580. if (domType !== 1 /* DOMNodeTypes.ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
  3581. nextNode = onMismatch();
  3582. } else {
  3583. nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  3584. }
  3585. } else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  3586. // when setting up the render effect, if the initial vnode already
  3587. // has .el set, the component will perform hydration instead of mount
  3588. // on its sub-tree.
  3589. vnode.slotScopeIds = slotScopeIds;
  3590. var container = parentNode(node);
  3591. mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
  3592. // component may be async, so in the case of fragments we cannot rely
  3593. // on component's rendered output to determine the end of the fragment
  3594. // instead, we do a lookahead to find the end anchor node.
  3595. nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
  3596. // #4293 teleport as component root
  3597. if (nextNode && isComment(nextNode) && nextNode.data === 'teleport end') {
  3598. nextNode = nextSibling(nextNode);
  3599. }
  3600. // #3787
  3601. // if component is async, it may get moved / unmounted before its
  3602. // inner component is loaded, so we need to give it a placeholder
  3603. // vnode that matches its adopted DOM.
  3604. if (isAsyncWrapper(vnode)) {
  3605. var subTree;
  3606. if (isFragmentStart) {
  3607. subTree = createVNode(Fragment);
  3608. subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
  3609. } else {
  3610. subTree = node.nodeType === 3 ? createTextVNode('') : createVNode('div');
  3611. }
  3612. subTree.el = node;
  3613. vnode.component.subTree = subTree;
  3614. }
  3615. } else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  3616. if (domType !== 8 /* DOMNodeTypes.COMMENT */) {
  3617. nextNode = onMismatch();
  3618. } else {
  3619. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
  3620. }
  3621. } else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  3622. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
  3623. } else ;
  3624. }
  3625. if (ref != null) {
  3626. setRef(ref, null, parentSuspense, vnode);
  3627. }
  3628. return nextNode;
  3629. };
  3630. var hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  3631. optimized = optimized || !!vnode.dynamicChildren;
  3632. var {
  3633. type,
  3634. props,
  3635. patchFlag,
  3636. shapeFlag,
  3637. dirs
  3638. } = vnode;
  3639. // #4006 for form elements with non-string v-model value bindings
  3640. // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
  3641. var forcePatchValue = type === 'input' && dirs || type === 'option';
  3642. // skip props & children if this is hoisted static nodes
  3643. // #5405 in dev, always hydrate children for HMR
  3644. if (forcePatchValue || patchFlag !== -1 /* PatchFlags.HOISTED */) {
  3645. if (dirs) {
  3646. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  3647. }
  3648. // props
  3649. if (props) {
  3650. if (forcePatchValue || !optimized || patchFlag & (16 /* PatchFlags.FULL_PROPS */ | 32 /* PatchFlags.HYDRATE_EVENTS */)) {
  3651. for (var key in props) {
  3652. if (forcePatchValue && key.endsWith('value') || isOn(key) && !isReservedProp(key)) {
  3653. patchProp(el, key, null, props[key], false, undefined, parentComponent);
  3654. }
  3655. }
  3656. } else if (props.onClick) {
  3657. // Fast path for click listeners (which is most often) to avoid
  3658. // iterating through props.
  3659. patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
  3660. }
  3661. }
  3662. // vnode / directive hooks
  3663. var vnodeHooks;
  3664. if (vnodeHooks = props && props.onVnodeBeforeMount) {
  3665. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  3666. }
  3667. if (dirs) {
  3668. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  3669. }
  3670. if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
  3671. queueEffectWithSuspense(() => {
  3672. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  3673. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  3674. }, parentSuspense);
  3675. }
  3676. // children
  3677. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */ &&
  3678. // skip if element has innerHTML / textContent
  3679. !(props && (props.innerHTML || props.textContent))) {
  3680. var next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
  3681. while (next) {
  3682. hasMismatch = true;
  3683. // The SSRed DOM contains more nodes than it should. Remove them.
  3684. var cur = next;
  3685. next = next.nextSibling;
  3686. remove(cur);
  3687. }
  3688. } else if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  3689. if (el.textContent !== vnode.children) {
  3690. hasMismatch = true;
  3691. el.textContent = vnode.children;
  3692. }
  3693. }
  3694. }
  3695. return el.nextSibling;
  3696. };
  3697. var hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  3698. optimized = optimized || !!parentVNode.dynamicChildren;
  3699. var children = parentVNode.children;
  3700. var l = children.length;
  3701. for (var i = 0; i < l; i++) {
  3702. var vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
  3703. if (node) {
  3704. node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  3705. } else if (vnode.type === Text && !vnode.children) {
  3706. continue;
  3707. } else {
  3708. hasMismatch = true;
  3709. // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
  3710. patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  3711. }
  3712. }
  3713. return node;
  3714. };
  3715. var hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  3716. var {
  3717. slotScopeIds: fragmentSlotScopeIds
  3718. } = vnode;
  3719. if (fragmentSlotScopeIds) {
  3720. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
  3721. }
  3722. var container = parentNode(node);
  3723. var next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
  3724. if (next && isComment(next) && next.data === ']') {
  3725. return nextSibling(vnode.anchor = next);
  3726. } else {
  3727. // fragment didn't hydrate successfully, since we didn't get a end anchor
  3728. // back. This should have led to node/children mismatch warnings.
  3729. hasMismatch = true;
  3730. // since the anchor is missing, we need to create one and insert it
  3731. insert(vnode.anchor = createComment("]"), container, next);
  3732. return next;
  3733. }
  3734. };
  3735. var handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  3736. hasMismatch = true;
  3737. vnode.el = null;
  3738. if (isFragment) {
  3739. // remove excessive fragment nodes
  3740. var end = locateClosingAsyncAnchor(node);
  3741. while (true) {
  3742. var _next = nextSibling(node);
  3743. if (_next && _next !== end) {
  3744. remove(_next);
  3745. } else {
  3746. break;
  3747. }
  3748. }
  3749. }
  3750. var next = nextSibling(node);
  3751. var container = parentNode(node);
  3752. remove(node);
  3753. patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  3754. return next;
  3755. };
  3756. var locateClosingAsyncAnchor = node => {
  3757. var match = 0;
  3758. while (node) {
  3759. node = nextSibling(node);
  3760. if (node && isComment(node)) {
  3761. if (node.data === '[') match++;
  3762. if (node.data === ']') {
  3763. if (match === 0) {
  3764. return nextSibling(node);
  3765. } else {
  3766. match--;
  3767. }
  3768. }
  3769. }
  3770. }
  3771. return node;
  3772. };
  3773. return [hydrate, hydrateNode];
  3774. }
  3775. var queuePostRenderEffect = queueEffectWithSuspense;
  3776. /**
  3777. * The createRenderer function accepts two generic arguments:
  3778. * HostNode and HostElement, corresponding to Node and Element types in the
  3779. * host environment. For example, for runtime-dom, HostNode would be the DOM
  3780. * `Node` interface and HostElement would be the DOM `Element` interface.
  3781. *
  3782. * Custom renderers can pass in the platform specific types like this:
  3783. *
  3784. * ``` js
  3785. * const { render, createApp } = createRenderer<Node, Element>({
  3786. * patchProp,
  3787. * ...nodeOps
  3788. * })
  3789. * ```
  3790. */
  3791. function createRenderer(options) {
  3792. return baseCreateRenderer(options);
  3793. }
  3794. // Separate API for creating hydration-enabled renderer.
  3795. // Hydration logic is only used when calling this function, making it
  3796. // tree-shakable.
  3797. function createHydrationRenderer(options) {
  3798. return baseCreateRenderer(options, createHydrationFunctions);
  3799. }
  3800. // implementation
  3801. function baseCreateRenderer(options, createHydrationFns) {
  3802. var target = getGlobalThis();
  3803. target.__VUE__ = true;
  3804. var {
  3805. insert: hostInsert,
  3806. remove: hostRemove,
  3807. patchProp: hostPatchProp,
  3808. forcePatchProp: hostForcePatchProp,
  3809. // fixed by xxxxxx
  3810. createElement: hostCreateElement,
  3811. createText: hostCreateText,
  3812. createComment: hostCreateComment,
  3813. setText: hostSetText,
  3814. setElementText: hostSetElementText,
  3815. parentNode: hostParentNode,
  3816. nextSibling: hostNextSibling,
  3817. setScopeId: hostSetScopeId = NOOP,
  3818. insertStaticContent: hostInsertStaticContent
  3819. } = options;
  3820. // Note: functions inside this closure should use `const xxx = () => {}`
  3821. // style in order to prevent being inlined by minifiers.
  3822. var patch = function (n1, n2, container) {
  3823. var anchor = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  3824. var parentComponent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  3825. var parentSuspense = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  3826. var isSVG = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  3827. var slotScopeIds = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  3828. var optimized = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : !!n2.dynamicChildren;
  3829. if (n1 === n2) {
  3830. return;
  3831. }
  3832. // patching & not same type, unmount old tree
  3833. if (n1 && !isSameVNodeType(n1, n2)) {
  3834. anchor = getNextHostNode(n1);
  3835. unmount(n1, parentComponent, parentSuspense, true);
  3836. n1 = null;
  3837. }
  3838. if (n2.patchFlag === -2 /* PatchFlags.BAIL */) {
  3839. optimized = false;
  3840. n2.dynamicChildren = null;
  3841. }
  3842. var {
  3843. type,
  3844. ref,
  3845. shapeFlag
  3846. } = n2;
  3847. switch (type) {
  3848. case Text:
  3849. processText(n1, n2, container, anchor);
  3850. break;
  3851. case Comment:
  3852. processCommentNode(n1, n2, container, anchor);
  3853. break;
  3854. case Static:
  3855. if (n1 == null) {
  3856. mountStaticNode(n2, container, anchor, isSVG);
  3857. }
  3858. break;
  3859. case Fragment:
  3860. processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  3861. break;
  3862. default:
  3863. if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
  3864. processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  3865. } else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  3866. processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  3867. } else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  3868. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  3869. } else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  3870. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  3871. } else ;
  3872. }
  3873. // set ref
  3874. if (ref != null && parentComponent) {
  3875. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
  3876. }
  3877. };
  3878. var processText = (n1, n2, container, anchor) => {
  3879. if (n1 == null) {
  3880. hostInsert(n2.el = hostCreateText(n2.children), container, anchor);
  3881. } else {
  3882. var el = n2.el = n1.el;
  3883. if (n2.children !== n1.children) {
  3884. hostSetText(el, n2.children);
  3885. }
  3886. }
  3887. };
  3888. var processCommentNode = (n1, n2, container, anchor) => {
  3889. if (n1 == null) {
  3890. hostInsert(n2.el = hostCreateComment(n2.children || ''), container, anchor);
  3891. } else {
  3892. // there's no support for dynamic comments
  3893. n2.el = n1.el;
  3894. }
  3895. };
  3896. var mountStaticNode = (n2, container, anchor, isSVG) => {
  3897. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG, n2.el, n2.anchor);
  3898. };
  3899. var moveStaticNode = (_ref10, container, nextSibling) => {
  3900. var {
  3901. el,
  3902. anchor
  3903. } = _ref10;
  3904. var next;
  3905. while (el && el !== anchor) {
  3906. next = hostNextSibling(el);
  3907. hostInsert(el, container, nextSibling);
  3908. el = next;
  3909. }
  3910. hostInsert(anchor, container, nextSibling);
  3911. };
  3912. var removeStaticNode = _ref11 => {
  3913. var {
  3914. el,
  3915. anchor
  3916. } = _ref11;
  3917. var next;
  3918. while (el && el !== anchor) {
  3919. next = hostNextSibling(el);
  3920. hostRemove(el);
  3921. el = next;
  3922. }
  3923. hostRemove(anchor);
  3924. };
  3925. var processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  3926. isSVG = isSVG || n2.type === 'svg';
  3927. if (n1 == null) {
  3928. mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  3929. } else {
  3930. patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  3931. }
  3932. };
  3933. var mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  3934. var el;
  3935. var vnodeHook;
  3936. var {
  3937. type,
  3938. props,
  3939. shapeFlag,
  3940. transition,
  3941. dirs
  3942. } = vnode;
  3943. el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
  3944. // mount children first, since some props may rely on child content
  3945. // being already rendered, e.g. `<select value>`
  3946. if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  3947. hostSetElementText(el, vnode.children);
  3948. } else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  3949. mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
  3950. }
  3951. if (dirs) {
  3952. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  3953. }
  3954. // scopeId
  3955. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
  3956. // props
  3957. if (props) {
  3958. for (var key in props) {
  3959. if (key !== 'value' && !isReservedProp(key)) {
  3960. hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren,
  3961. // fixed by xxxxxx
  3962. vnode.hostInstance);
  3963. }
  3964. }
  3965. /**
  3966. * Special case for setting value on DOM elements:
  3967. * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
  3968. * - it needs to be forced (#1471)
  3969. * #2353 proposes adding another renderer option to configure this, but
  3970. * the properties affects are so finite it is worth special casing it
  3971. * here to reduce the complexity. (Special casing it also should not
  3972. * affect non-DOM renderers)
  3973. */
  3974. if ('value' in props) {
  3975. // fixed by xxxxxx
  3976. hostPatchProp(el, 'value', null, props.value, false, [], parentComponent, null, undefined,
  3977. // fixed by xxxxxx
  3978. vnode.hostInstance);
  3979. }
  3980. if (vnodeHook = props.onVnodeBeforeMount) {
  3981. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  3982. }
  3983. }
  3984. if (dirs) {
  3985. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  3986. }
  3987. // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
  3988. // #1689 For inside suspense + suspense resolved case, just call it
  3989. var needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
  3990. if (needCallTransitionHooks) {
  3991. transition.beforeEnter(el);
  3992. }
  3993. hostInsert(el, container, anchor);
  3994. if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
  3995. queuePostRenderEffect(() => {
  3996. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  3997. needCallTransitionHooks && transition.enter(el);
  3998. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  3999. }, parentSuspense);
  4000. }
  4001. };
  4002. var setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  4003. if (scopeId) {
  4004. hostSetScopeId(el, scopeId);
  4005. }
  4006. if (slotScopeIds) {
  4007. for (var i = 0; i < slotScopeIds.length; i++) {
  4008. hostSetScopeId(el, slotScopeIds[i]);
  4009. }
  4010. }
  4011. if (parentComponent) {
  4012. var subTree = parentComponent.subTree;
  4013. if (vnode === subTree) {
  4014. var parentVNode = parentComponent.vnode;
  4015. setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
  4016. }
  4017. }
  4018. };
  4019. var mountChildren = function (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) {
  4020. var start = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 0;
  4021. for (var i = start; i < children.length; i++) {
  4022. var child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
  4023. patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4024. }
  4025. };
  4026. var patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  4027. var el = n2.el = n1.el;
  4028. var {
  4029. patchFlag,
  4030. dynamicChildren,
  4031. dirs
  4032. } = n2;
  4033. // #1426 take the old vnode's patch flag into account since user may clone a
  4034. // compiler-generated vnode, which de-opts to FULL_PROPS
  4035. patchFlag |= n1.patchFlag & 16 /* PatchFlags.FULL_PROPS */;
  4036. var oldProps = n1.props || EMPTY_OBJ;
  4037. var newProps = n2.props || EMPTY_OBJ;
  4038. var vnodeHook;
  4039. // disable recurse in beforeUpdate hooks
  4040. parentComponent && toggleRecurse(parentComponent, false);
  4041. if (vnodeHook = newProps.onVnodeBeforeUpdate) {
  4042. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  4043. }
  4044. if (dirs) {
  4045. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
  4046. }
  4047. parentComponent && toggleRecurse(parentComponent, true);
  4048. var areChildrenSVG = isSVG && n2.type !== 'foreignObject';
  4049. if (dynamicChildren) {
  4050. patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
  4051. } else if (!optimized) {
  4052. // full diff
  4053. patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
  4054. }
  4055. if (patchFlag > 0) {
  4056. // the presence of a patchFlag means this element's render code was
  4057. // generated by the compiler and can take the fast path.
  4058. // in this path old node and new node are guaranteed to have the same shape
  4059. // (i.e. at the exact same position in the source template)
  4060. if (patchFlag & 16 /* PatchFlags.FULL_PROPS */) {
  4061. // element props contain dynamic keys, full diff needed
  4062. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  4063. } else {
  4064. // class
  4065. // this flag is matched when the element has dynamic class bindings.
  4066. if (patchFlag & 2 /* PatchFlags.CLASS */) {
  4067. if (oldProps.class !== newProps.class) {
  4068. // fixed by xxxxxx
  4069. hostPatchProp(el, 'class', null, newProps.class, isSVG, [], parentComponent, null, undefined,
  4070. // fixed by xxxxxx
  4071. n2.hostInstance);
  4072. }
  4073. }
  4074. // style
  4075. // this flag is matched when the element has dynamic style bindings
  4076. if (patchFlag & 4 /* PatchFlags.STYLE */) {
  4077. // fixed by xxxxxx
  4078. hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG, [], parentComponent, null, undefined,
  4079. // fixed by xxxxxx
  4080. n2.hostInstance);
  4081. }
  4082. // props
  4083. // This flag is matched when the element has dynamic prop/attr bindings
  4084. // other than class and style. The keys of dynamic prop/attrs are saved for
  4085. // faster iteration.
  4086. // Note dynamic keys like :[foo]="bar" will cause this optimization to
  4087. // bail out and go through a full diff because we need to unset the old key
  4088. if (patchFlag & 8 /* PatchFlags.PROPS */) {
  4089. // if the flag is present then dynamicProps must be non-null
  4090. var propsToUpdate = n2.dynamicProps;
  4091. for (var i = 0; i < propsToUpdate.length; i++) {
  4092. var key = propsToUpdate[i];
  4093. var prev = oldProps[key];
  4094. var next = newProps[key];
  4095. // #1471 force patch value
  4096. if (next !== prev || key === 'value' || hostForcePatchProp && hostForcePatchProp(el, key) // fixed by xxxxxx
  4097. ) {
  4098. hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren,
  4099. // fixed by xxxxxx
  4100. n2.hostInstance);
  4101. }
  4102. }
  4103. }
  4104. }
  4105. // text
  4106. // This flag is matched when the element has only dynamic text children.
  4107. if (patchFlag & 1 /* PatchFlags.TEXT */) {
  4108. if (n1.children !== n2.children) {
  4109. hostSetElementText(el, n2.children);
  4110. }
  4111. }
  4112. } else if (!optimized && dynamicChildren == null) {
  4113. // unoptimized, full diff
  4114. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  4115. }
  4116. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  4117. queuePostRenderEffect(() => {
  4118. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  4119. dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
  4120. }, parentSuspense);
  4121. }
  4122. };
  4123. // The fast path for blocks.
  4124. var patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
  4125. for (var i = 0; i < newChildren.length; i++) {
  4126. var oldVNode = oldChildren[i];
  4127. var newVNode = newChildren[i];
  4128. // Determine the container (parent element) for the patch.
  4129. var container =
  4130. // oldVNode may be an errored async setup() component inside Suspense
  4131. // which will not have a mounted element
  4132. oldVNode.el && (
  4133. // - In the case of a Fragment, we need to provide the actual parent
  4134. // of the Fragment itself so it can move its children.
  4135. oldVNode.type === Fragment ||
  4136. // - In the case of different nodes, there is going to be a replacement
  4137. // which also requires the correct parent container
  4138. !isSameVNodeType(oldVNode, newVNode) ||
  4139. // - In the case of a component, it could contain anything.
  4140. oldVNode.shapeFlag & (6 /* ShapeFlags.COMPONENT */ | 64 /* ShapeFlags.TELEPORT */)) ? hostParentNode(oldVNode.el) :
  4141. // In other cases, the parent container is not actually used so we
  4142. // just pass the block element here to avoid a DOM parentNode call.
  4143. fallbackContainer;
  4144. patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
  4145. }
  4146. };
  4147. var patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  4148. if (oldProps !== newProps) {
  4149. if (oldProps !== EMPTY_OBJ) {
  4150. for (var key in oldProps) {
  4151. if (!isReservedProp(key) && !(key in newProps)) {
  4152. hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren,
  4153. // fixed by xxxxxx
  4154. vnode.hostInstance);
  4155. }
  4156. }
  4157. }
  4158. for (var _key9 in newProps) {
  4159. // empty string is not valid prop
  4160. if (isReservedProp(_key9)) continue;
  4161. var next = newProps[_key9];
  4162. var prev = oldProps[_key9];
  4163. // defer patching value
  4164. if (next !== prev && _key9 !== 'value' || hostForcePatchProp && hostForcePatchProp(el, _key9) // fixed by xxxxxx
  4165. ) {
  4166. hostPatchProp(el, _key9, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren,
  4167. // fixed by xxxxxx
  4168. vnode.hostInstance);
  4169. }
  4170. }
  4171. if ('value' in newProps) {
  4172. // fixed by xxxxxx
  4173. hostPatchProp(el, 'value', oldProps.value, newProps.value, false, [], parentComponent, null, undefined,
  4174. // fixed by xxxxxx
  4175. vnode.hostInstance);
  4176. }
  4177. }
  4178. };
  4179. var processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  4180. var fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText('');
  4181. var fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText('');
  4182. var {
  4183. patchFlag,
  4184. dynamicChildren,
  4185. slotScopeIds: fragmentSlotScopeIds
  4186. } = n2;
  4187. // check if this is a slot fragment with :slotted scope ids
  4188. if (fragmentSlotScopeIds) {
  4189. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
  4190. }
  4191. if (n1 == null) {
  4192. hostInsert(fragmentStartAnchor, container, anchor);
  4193. hostInsert(fragmentEndAnchor, container, anchor);
  4194. // a fragment can only have array children
  4195. // since they are either generated by the compiler, or implicitly created
  4196. // from arrays.
  4197. mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4198. } else {
  4199. if (patchFlag > 0 && patchFlag & 64 /* PatchFlags.STABLE_FRAGMENT */ && dynamicChildren &&
  4200. // #2715 the previous fragment could've been a BAILed one as a result
  4201. // of renderSlot() with no valid children
  4202. n1.dynamicChildren) {
  4203. // a stable fragment (template root or <template v-for>) doesn't need to
  4204. // patch children order, but it may contain dynamicChildren.
  4205. patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
  4206. if (
  4207. // #2080 if the stable fragment has a key, it's a <template v-for> that may
  4208. // get moved around. Make sure all root level vnodes inherit el.
  4209. // #2134 or if it's a component root, it may also get moved around
  4210. // as the component is being moved.
  4211. n2.key != null || parentComponent && n2 === parentComponent.subTree) {
  4212. traverseStaticChildren(n1, n2, true /* shallow */);
  4213. }
  4214. } else {
  4215. // keyed / unkeyed, or manual fragments.
  4216. // for keyed & unkeyed, since they are compiler generated from v-for,
  4217. // each child is guaranteed to be a block so the fragment will never
  4218. // have dynamicChildren.
  4219. patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4220. }
  4221. }
  4222. };
  4223. var processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  4224. n2.slotScopeIds = slotScopeIds;
  4225. if (n1 == null) {
  4226. if (n2.shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
  4227. parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
  4228. } else {
  4229. mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  4230. }
  4231. } else {
  4232. updateComponent(n1, n2, optimized);
  4233. }
  4234. };
  4235. var mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  4236. var instance = initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense);
  4237. // inject renderer internals for keepAlive
  4238. if (isKeepAlive(initialVNode)) {
  4239. instance.ctx.renderer = internals;
  4240. }
  4241. // resolve props and slots for setup context
  4242. {
  4243. setupComponent(instance);
  4244. }
  4245. // setup() is async. This component relies on async logic to be resolved
  4246. // before proceeding
  4247. if (instance.asyncDep) {
  4248. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  4249. // Give it a placeholder if this is not hydration
  4250. // TODO handle self-defined fallback
  4251. if (!initialVNode.el) {
  4252. var placeholder = instance.subTree = createVNode(Comment);
  4253. processCommentNode(null, placeholder, container, anchor);
  4254. }
  4255. return;
  4256. }
  4257. setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
  4258. };
  4259. var updateComponent = (n1, n2, optimized) => {
  4260. var instance = n2.component = n1.component;
  4261. if (shouldUpdateComponent(n1, n2, optimized)) {
  4262. if (instance.asyncDep && !instance.asyncResolved) {
  4263. updateComponentPreRender(instance, n2, optimized);
  4264. return;
  4265. } else {
  4266. // normal update
  4267. instance.next = n2;
  4268. // in case the child component is also queued, remove it to avoid
  4269. // double updating the same child component in the same flush.
  4270. invalidateJob(instance.update);
  4271. // instance.update is the reactive effect.
  4272. instance.update();
  4273. }
  4274. } else {
  4275. // no update needed. just copy over properties
  4276. n2.el = n1.el;
  4277. instance.vnode = n2;
  4278. }
  4279. };
  4280. var setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  4281. var componentUpdateFn = () => {
  4282. if (!instance.isMounted) {
  4283. var vnodeHook;
  4284. var {
  4285. el,
  4286. props
  4287. } = initialVNode;
  4288. var {
  4289. bm,
  4290. m,
  4291. parent
  4292. } = instance;
  4293. var isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
  4294. toggleRecurse(instance, false);
  4295. // beforeMount hook
  4296. if (bm) {
  4297. invokeArrayFns(bm);
  4298. }
  4299. // onVnodeBeforeMount
  4300. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
  4301. invokeVNodeHook(vnodeHook, parent, initialVNode);
  4302. }
  4303. toggleRecurse(instance, true);
  4304. if (el && hydrateNode) {
  4305. // vnode has adopted host node - perform hydration instead of mount.
  4306. var hydrateSubTree = () => {
  4307. instance.subTree = renderComponentRoot(instance);
  4308. hydrateNode(el, instance.subTree, instance, parentSuspense, null);
  4309. };
  4310. if (isAsyncWrapperVNode) {
  4311. initialVNode.type.__asyncLoader().then(
  4312. // note: we are moving the render call into an async callback,
  4313. // which means it won't track dependencies - but it's ok because
  4314. // a server-rendered async wrapper is already in resolved state
  4315. // and it will never need to change.
  4316. () => !instance.isUnmounted && hydrateSubTree());
  4317. } else {
  4318. hydrateSubTree();
  4319. }
  4320. } else {
  4321. var subTree = instance.subTree = renderComponentRoot(instance);
  4322. patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
  4323. initialVNode.el = subTree.el;
  4324. }
  4325. // mounted hook
  4326. if (m) {
  4327. queuePostRenderEffect(m, parentSuspense);
  4328. }
  4329. // onVnodeMounted
  4330. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
  4331. var scopedInitialVNode = initialVNode;
  4332. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
  4333. }
  4334. // activated hook for keep-alive roots.
  4335. // #1742 activated hook must be accessed after first render
  4336. // since the hook may be injected by a child keep-alive
  4337. if (initialVNode.shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */ || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
  4338. instance.a && queuePostRenderEffect(instance.a, parentSuspense);
  4339. }
  4340. instance.isMounted = true;
  4341. // #2458: deference mount-only object parameters to prevent memleaks
  4342. initialVNode = container = anchor = null;
  4343. } else {
  4344. // updateComponent
  4345. // This is triggered by mutation of component's own state (next: null)
  4346. // OR parent calling processComponent (next: VNode)
  4347. var {
  4348. next,
  4349. bu,
  4350. u,
  4351. parent: _parent,
  4352. vnode
  4353. } = instance;
  4354. var originNext = next;
  4355. var _vnodeHook;
  4356. // Disallow component effect recursion during pre-lifecycle hooks.
  4357. toggleRecurse(instance, false);
  4358. if (next) {
  4359. next.el = vnode.el;
  4360. updateComponentPreRender(instance, next, optimized);
  4361. } else {
  4362. next = vnode;
  4363. }
  4364. // beforeUpdate hook
  4365. if (bu) {
  4366. invokeArrayFns(bu);
  4367. }
  4368. // onVnodeBeforeUpdate
  4369. if (_vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
  4370. invokeVNodeHook(_vnodeHook, _parent, next, vnode);
  4371. }
  4372. toggleRecurse(instance, true);
  4373. var nextTree = renderComponentRoot(instance);
  4374. var prevTree = instance.subTree;
  4375. instance.subTree = nextTree;
  4376. patch(prevTree, nextTree,
  4377. // parent may have changed if it's in a teleport
  4378. hostParentNode(prevTree.el),
  4379. // anchor may have changed if it's in a fragment
  4380. getNextHostNode(prevTree), instance, parentSuspense, isSVG);
  4381. next.el = nextTree.el;
  4382. if (originNext === null) {
  4383. // self-triggered update. In case of HOC, update parent component
  4384. // vnode el. HOC is indicated by parent instance's subTree pointing
  4385. // to child component's vnode
  4386. updateHOCHostEl(instance, nextTree.el);
  4387. }
  4388. // updated hook
  4389. if (u) {
  4390. queuePostRenderEffect(u, parentSuspense);
  4391. }
  4392. // onVnodeUpdated
  4393. if (_vnodeHook = next.props && next.props.onVnodeUpdated) {
  4394. queuePostRenderEffect(() => invokeVNodeHook(_vnodeHook, _parent, next, vnode), parentSuspense);
  4395. }
  4396. }
  4397. };
  4398. // create reactive effect for rendering
  4399. var effect = instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(update), instance.scope // track it in component's effect scope
  4400. );
  4401. var update = instance.update = () => effect.run();
  4402. update.id = instance.uid;
  4403. // allowRecurse
  4404. // #1801, #2043 component render effects should allow recursive updates
  4405. toggleRecurse(instance, true);
  4406. update();
  4407. };
  4408. var updateComponentPreRender = (instance, nextVNode, optimized) => {
  4409. nextVNode.component = instance;
  4410. var prevProps = instance.vnode.props;
  4411. instance.vnode = nextVNode;
  4412. instance.next = null;
  4413. updateProps(instance, nextVNode.props, prevProps, optimized);
  4414. updateSlots(instance, nextVNode.children, optimized);
  4415. pauseTracking();
  4416. // props update may have triggered pre-flush watchers.
  4417. // flush them before the render update.
  4418. flushPreFlushCbs();
  4419. resetTracking();
  4420. };
  4421. var patchChildren = function (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds) {
  4422. var optimized = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
  4423. var c1 = n1 && n1.children;
  4424. var prevShapeFlag = n1 ? n1.shapeFlag : 0;
  4425. var c2 = n2.children;
  4426. var {
  4427. patchFlag,
  4428. shapeFlag
  4429. } = n2;
  4430. // fast path
  4431. if (patchFlag > 0) {
  4432. if (patchFlag & 128 /* PatchFlags.KEYED_FRAGMENT */) {
  4433. // this could be either fully-keyed or mixed (some keyed some not)
  4434. // presence of patchFlag means children are guaranteed to be arrays
  4435. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4436. return;
  4437. } else if (patchFlag & 256 /* PatchFlags.UNKEYED_FRAGMENT */) {
  4438. // unkeyed
  4439. patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4440. return;
  4441. }
  4442. }
  4443. // children has 3 possibilities: text, array or no children.
  4444. if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  4445. // text children fast path
  4446. if (prevShapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  4447. unmountChildren(c1, parentComponent, parentSuspense);
  4448. }
  4449. if (c2 !== c1) {
  4450. hostSetElementText(container, c2);
  4451. }
  4452. } else {
  4453. if (prevShapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  4454. // prev children was array
  4455. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  4456. // two arrays, cannot assume anything, do full diff
  4457. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4458. } else {
  4459. // no new children, just unmount old
  4460. unmountChildren(c1, parentComponent, parentSuspense, true);
  4461. }
  4462. } else {
  4463. // prev children was text OR null
  4464. // new children is array OR null
  4465. if (prevShapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  4466. hostSetElementText(container, '');
  4467. }
  4468. // mount new if array
  4469. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  4470. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4471. }
  4472. }
  4473. }
  4474. };
  4475. var patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  4476. c1 = c1 || EMPTY_ARR;
  4477. c2 = c2 || EMPTY_ARR;
  4478. var oldLength = c1.length;
  4479. var newLength = c2.length;
  4480. var commonLength = Math.min(oldLength, newLength);
  4481. var i;
  4482. for (i = 0; i < commonLength; i++) {
  4483. var nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  4484. patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4485. }
  4486. if (oldLength > newLength) {
  4487. // remove old
  4488. unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
  4489. } else {
  4490. // mount new
  4491. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
  4492. }
  4493. };
  4494. // can be all-keyed or mixed
  4495. var patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  4496. var i = 0;
  4497. var l2 = c2.length;
  4498. var e1 = c1.length - 1; // prev ending index
  4499. var e2 = l2 - 1; // next ending index
  4500. // 1. sync from start
  4501. // (a b) c
  4502. // (a b) d e
  4503. while (i <= e1 && i <= e2) {
  4504. var n1 = c1[i];
  4505. var n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  4506. if (isSameVNodeType(n1, n2)) {
  4507. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4508. } else {
  4509. break;
  4510. }
  4511. i++;
  4512. }
  4513. // 2. sync from end
  4514. // a (b c)
  4515. // d e (b c)
  4516. while (i <= e1 && i <= e2) {
  4517. var _n = c1[e1];
  4518. var _n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
  4519. if (isSameVNodeType(_n, _n2)) {
  4520. patch(_n, _n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4521. } else {
  4522. break;
  4523. }
  4524. e1--;
  4525. e2--;
  4526. }
  4527. // 3. common sequence + mount
  4528. // (a b)
  4529. // (a b) c
  4530. // i = 2, e1 = 1, e2 = 2
  4531. // (a b)
  4532. // c (a b)
  4533. // i = 0, e1 = -1, e2 = 0
  4534. if (i > e1) {
  4535. if (i <= e2) {
  4536. var nextPos = e2 + 1;
  4537. var anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  4538. while (i <= e2) {
  4539. patch(null, c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4540. i++;
  4541. }
  4542. }
  4543. }
  4544. // 4. common sequence + unmount
  4545. // (a b) c
  4546. // (a b)
  4547. // i = 2, e1 = 2, e2 = 1
  4548. // a (b c)
  4549. // (b c)
  4550. // i = 0, e1 = 0, e2 = -1
  4551. else if (i > e2) {
  4552. while (i <= e1) {
  4553. unmount(c1[i], parentComponent, parentSuspense, true);
  4554. i++;
  4555. }
  4556. }
  4557. // 5. unknown sequence
  4558. // [i ... e1 + 1]: a b [c d e] f g
  4559. // [i ... e2 + 1]: a b [e d c h] f g
  4560. // i = 2, e1 = 4, e2 = 5
  4561. else {
  4562. var s1 = i; // prev starting index
  4563. var s2 = i; // next starting index
  4564. // 5.1 build key:index map for newChildren
  4565. var keyToNewIndexMap = new Map();
  4566. for (i = s2; i <= e2; i++) {
  4567. var nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  4568. if (nextChild.key != null) {
  4569. keyToNewIndexMap.set(nextChild.key, i);
  4570. }
  4571. }
  4572. // 5.2 loop through old children left to be patched and try to patch
  4573. // matching nodes & remove nodes that are no longer present
  4574. var j;
  4575. var patched = 0;
  4576. var toBePatched = e2 - s2 + 1;
  4577. var moved = false;
  4578. // used to track whether any node has moved
  4579. var maxNewIndexSoFar = 0;
  4580. // works as Map<newIndex, oldIndex>
  4581. // Note that oldIndex is offset by +1
  4582. // and oldIndex = 0 is a special value indicating the new node has
  4583. // no corresponding old node.
  4584. // used for determining longest stable subsequence
  4585. var newIndexToOldIndexMap = new Array(toBePatched);
  4586. for (i = 0; i < toBePatched; i++) {
  4587. newIndexToOldIndexMap[i] = 0;
  4588. }
  4589. for (i = s1; i <= e1; i++) {
  4590. var prevChild = c1[i];
  4591. if (patched >= toBePatched) {
  4592. // all new children have been patched so this can only be a removal
  4593. unmount(prevChild, parentComponent, parentSuspense, true);
  4594. continue;
  4595. }
  4596. var newIndex = void 0;
  4597. if (prevChild.key != null) {
  4598. newIndex = keyToNewIndexMap.get(prevChild.key);
  4599. } else {
  4600. // key-less node, try to locate a key-less node of the same type
  4601. for (j = s2; j <= e2; j++) {
  4602. if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
  4603. newIndex = j;
  4604. break;
  4605. }
  4606. }
  4607. }
  4608. if (newIndex === undefined) {
  4609. unmount(prevChild, parentComponent, parentSuspense, true);
  4610. } else {
  4611. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  4612. if (newIndex >= maxNewIndexSoFar) {
  4613. maxNewIndexSoFar = newIndex;
  4614. } else {
  4615. moved = true;
  4616. }
  4617. patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4618. patched++;
  4619. }
  4620. }
  4621. // 5.3 move and mount
  4622. // generate longest stable subsequence only when nodes have moved
  4623. var increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
  4624. j = increasingNewIndexSequence.length - 1;
  4625. // looping backwards so that we can use last patched node as anchor
  4626. for (i = toBePatched - 1; i >= 0; i--) {
  4627. var nextIndex = s2 + i;
  4628. var _nextChild = c2[nextIndex];
  4629. var _anchor2 = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  4630. if (newIndexToOldIndexMap[i] === 0) {
  4631. // mount new
  4632. patch(null, _nextChild, container, _anchor2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  4633. } else if (moved) {
  4634. // move if:
  4635. // There is no stable subsequence (e.g. a reverse)
  4636. // OR current node is not among the stable sequence
  4637. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  4638. move(_nextChild, container, _anchor2, 2 /* MoveType.REORDER */);
  4639. } else {
  4640. j--;
  4641. }
  4642. }
  4643. }
  4644. }
  4645. };
  4646. var move = function (vnode, container, anchor, moveType) {
  4647. var parentSuspense = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  4648. var {
  4649. el,
  4650. type,
  4651. transition,
  4652. children,
  4653. shapeFlag
  4654. } = vnode;
  4655. if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  4656. move(vnode.component.subTree, container, anchor, moveType);
  4657. return;
  4658. }
  4659. if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  4660. vnode.suspense.move(container, anchor, moveType);
  4661. return;
  4662. }
  4663. if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  4664. type.move(vnode, container, anchor, internals);
  4665. return;
  4666. }
  4667. if (type === Fragment) {
  4668. hostInsert(el, container, anchor);
  4669. for (var i = 0; i < children.length; i++) {
  4670. move(children[i], container, anchor, moveType);
  4671. }
  4672. hostInsert(vnode.anchor, container, anchor);
  4673. return;
  4674. }
  4675. if (type === Static) {
  4676. moveStaticNode(vnode, container, anchor);
  4677. return;
  4678. }
  4679. // single nodes
  4680. var needTransition = moveType !== 2 /* MoveType.REORDER */ && shapeFlag & 1 /* ShapeFlags.ELEMENT */ && transition;
  4681. if (needTransition) {
  4682. if (moveType === 0 /* MoveType.ENTER */) {
  4683. transition.beforeEnter(el);
  4684. hostInsert(el, container, anchor);
  4685. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  4686. } else {
  4687. var {
  4688. leave,
  4689. delayLeave,
  4690. afterLeave
  4691. } = transition;
  4692. var _remove = () => hostInsert(el, container, anchor);
  4693. var performLeave = () => {
  4694. leave(el, () => {
  4695. _remove();
  4696. afterLeave && afterLeave();
  4697. });
  4698. };
  4699. if (delayLeave) {
  4700. delayLeave(el, _remove, performLeave);
  4701. } else {
  4702. performLeave();
  4703. }
  4704. }
  4705. } else {
  4706. hostInsert(el, container, anchor);
  4707. }
  4708. };
  4709. var unmount = function (vnode, parentComponent, parentSuspense) {
  4710. var doRemove = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  4711. var optimized = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  4712. var {
  4713. type,
  4714. props,
  4715. ref,
  4716. children,
  4717. dynamicChildren,
  4718. shapeFlag,
  4719. patchFlag,
  4720. dirs
  4721. } = vnode;
  4722. // unset ref
  4723. if (ref != null) {
  4724. setRef(ref, null, parentSuspense, vnode, true);
  4725. }
  4726. if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
  4727. parentComponent.ctx.deactivate(vnode);
  4728. return;
  4729. }
  4730. var shouldInvokeDirs = shapeFlag & 1 /* ShapeFlags.ELEMENT */ && dirs;
  4731. var shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
  4732. var vnodeHook;
  4733. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
  4734. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  4735. }
  4736. if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  4737. unmountComponent(vnode.component, parentSuspense, doRemove);
  4738. } else {
  4739. if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  4740. vnode.suspense.unmount(parentSuspense, doRemove);
  4741. return;
  4742. }
  4743. if (shouldInvokeDirs) {
  4744. invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
  4745. }
  4746. if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  4747. vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
  4748. } else if (dynamicChildren && (
  4749. // #1153: fast path should not be taken for non-stable (v-for) fragments
  4750. type !== Fragment || patchFlag > 0 && patchFlag & 64 /* PatchFlags.STABLE_FRAGMENT */)) {
  4751. // fast path for block nodes: only need to unmount dynamic children.
  4752. unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
  4753. } else if (type === Fragment && patchFlag & (128 /* PatchFlags.KEYED_FRAGMENT */ | 256 /* PatchFlags.UNKEYED_FRAGMENT */) || !optimized && shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  4754. unmountChildren(children, parentComponent, parentSuspense);
  4755. }
  4756. if (doRemove) {
  4757. remove(vnode);
  4758. }
  4759. }
  4760. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
  4761. queuePostRenderEffect(() => {
  4762. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  4763. shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
  4764. }, parentSuspense);
  4765. }
  4766. };
  4767. var remove = vnode => {
  4768. var {
  4769. type,
  4770. el,
  4771. anchor,
  4772. transition
  4773. } = vnode;
  4774. if (type === Fragment) {
  4775. {
  4776. removeFragment(el, anchor);
  4777. }
  4778. return;
  4779. }
  4780. if (type === Static) {
  4781. removeStaticNode(vnode);
  4782. return;
  4783. }
  4784. var performRemove = () => {
  4785. hostRemove(el);
  4786. if (transition && !transition.persisted && transition.afterLeave) {
  4787. transition.afterLeave();
  4788. }
  4789. };
  4790. if (vnode.shapeFlag & 1 /* ShapeFlags.ELEMENT */ && transition && !transition.persisted) {
  4791. var {
  4792. leave,
  4793. delayLeave
  4794. } = transition;
  4795. var performLeave = () => leave(el, performRemove);
  4796. if (delayLeave) {
  4797. delayLeave(vnode.el, performRemove, performLeave);
  4798. } else {
  4799. performLeave();
  4800. }
  4801. } else {
  4802. performRemove();
  4803. }
  4804. };
  4805. var removeFragment = (cur, end) => {
  4806. // For fragments, directly remove all contained DOM nodes.
  4807. // (fragment child nodes cannot have transition)
  4808. var next;
  4809. while (cur !== end) {
  4810. next = hostNextSibling(cur);
  4811. hostRemove(cur);
  4812. cur = next;
  4813. }
  4814. hostRemove(end);
  4815. };
  4816. var unmountComponent = (instance, parentSuspense, doRemove) => {
  4817. var {
  4818. bum,
  4819. scope,
  4820. update,
  4821. subTree,
  4822. um
  4823. } = instance;
  4824. // beforeUnmount hook
  4825. if (bum) {
  4826. invokeArrayFns(bum);
  4827. }
  4828. // stop effects in component scope
  4829. scope.stop();
  4830. // update may be null if a component is unmounted before its async
  4831. // setup has resolved.
  4832. if (update) {
  4833. // so that scheduler will no longer invoke it
  4834. update.active = false;
  4835. unmount(subTree, instance, parentSuspense, doRemove);
  4836. }
  4837. // unmounted hook
  4838. if (um) {
  4839. queuePostRenderEffect(um, parentSuspense);
  4840. }
  4841. queuePostRenderEffect(() => {
  4842. instance.isUnmounted = true;
  4843. }, parentSuspense);
  4844. // A component with async dep inside a pending suspense is unmounted before
  4845. // its async dep resolves. This should remove the dep from the suspense, and
  4846. // cause the suspense to resolve immediately if that was the last dep.
  4847. if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
  4848. parentSuspense.deps--;
  4849. if (parentSuspense.deps === 0) {
  4850. parentSuspense.resolve();
  4851. }
  4852. }
  4853. };
  4854. var unmountChildren = function (children, parentComponent, parentSuspense) {
  4855. var doRemove = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  4856. var optimized = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  4857. var start = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  4858. for (var i = start; i < children.length; i++) {
  4859. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  4860. }
  4861. };
  4862. var getNextHostNode = vnode => {
  4863. if (vnode.shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  4864. return getNextHostNode(vnode.component.subTree);
  4865. }
  4866. if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  4867. return vnode.suspense.next();
  4868. }
  4869. return hostNextSibling(vnode.anchor || vnode.el);
  4870. };
  4871. var render = (vnode, container, isSVG) => {
  4872. if (vnode == null) {
  4873. if (container._vnode) {
  4874. unmount(container._vnode, null, null, true);
  4875. }
  4876. } else {
  4877. patch(container._vnode || null, vnode, container, null, null, null, isSVG);
  4878. }
  4879. flushPreFlushCbs();
  4880. flushPostFlushCbs();
  4881. container._vnode = vnode;
  4882. };
  4883. var internals = {
  4884. p: patch,
  4885. um: unmount,
  4886. m: move,
  4887. r: remove,
  4888. mt: mountComponent,
  4889. mc: mountChildren,
  4890. pc: patchChildren,
  4891. pbc: patchBlockChildren,
  4892. n: getNextHostNode,
  4893. o: options
  4894. };
  4895. var hydrate;
  4896. var hydrateNode;
  4897. if (createHydrationFns) {
  4898. [hydrate, hydrateNode] = createHydrationFns(internals);
  4899. }
  4900. return {
  4901. render,
  4902. hydrate,
  4903. createApp: createAppAPI(render, hydrate)
  4904. };
  4905. }
  4906. function toggleRecurse(_ref12, allowed) {
  4907. var {
  4908. effect,
  4909. update
  4910. } = _ref12;
  4911. effect.allowRecurse = update.allowRecurse = allowed;
  4912. }
  4913. /**
  4914. * #1156
  4915. * When a component is HMR-enabled, we need to make sure that all static nodes
  4916. * inside a block also inherit the DOM element from the previous tree so that
  4917. * HMR updates (which are full updates) can retrieve the element for patching.
  4918. *
  4919. * #2080
  4920. * Inside keyed `template` fragment static children, if a fragment is moved,
  4921. * the children will always be moved. Therefore, in order to ensure correct move
  4922. * position, el should be inherited from previous nodes.
  4923. */
  4924. function traverseStaticChildren(n1, n2) {
  4925. var shallow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4926. var ch1 = n1.children;
  4927. var ch2 = n2.children;
  4928. if (isArray(ch1) && isArray(ch2)) {
  4929. for (var i = 0; i < ch1.length; i++) {
  4930. // this is only called in the optimized path so array children are
  4931. // guaranteed to be vnodes
  4932. var c1 = ch1[i];
  4933. var c2 = ch2[i];
  4934. if (c2.shapeFlag & 1 /* ShapeFlags.ELEMENT */ && !c2.dynamicChildren) {
  4935. if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* PatchFlags.HYDRATE_EVENTS */) {
  4936. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  4937. c2.el = c1.el;
  4938. }
  4939. if (!shallow) traverseStaticChildren(c1, c2);
  4940. }
  4941. // #6852 also inherit for text nodes
  4942. if (c2.type === Text) {
  4943. c2.el = c1.el;
  4944. }
  4945. }
  4946. }
  4947. }
  4948. // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
  4949. function getSequence(arr) {
  4950. var p = arr.slice();
  4951. var result = [0];
  4952. var i, j, u, v, c;
  4953. var len = arr.length;
  4954. for (i = 0; i < len; i++) {
  4955. var arrI = arr[i];
  4956. if (arrI !== 0) {
  4957. j = result[result.length - 1];
  4958. if (arr[j] < arrI) {
  4959. p[i] = j;
  4960. result.push(i);
  4961. continue;
  4962. }
  4963. u = 0;
  4964. v = result.length - 1;
  4965. while (u < v) {
  4966. c = u + v >> 1;
  4967. if (arr[result[c]] < arrI) {
  4968. u = c + 1;
  4969. } else {
  4970. v = c;
  4971. }
  4972. }
  4973. if (arrI < arr[result[u]]) {
  4974. if (u > 0) {
  4975. p[i] = result[u - 1];
  4976. }
  4977. result[u] = i;
  4978. }
  4979. }
  4980. }
  4981. u = result.length;
  4982. v = result[u - 1];
  4983. while (u-- > 0) {
  4984. result[u] = v;
  4985. v = p[v];
  4986. }
  4987. return result;
  4988. }
  4989. var isTeleport = type => type.__isTeleport;
  4990. var isTeleportDisabled = props => props && (props.disabled || props.disabled === '');
  4991. var isTargetSVG = target => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
  4992. var resolveTarget = (props, select) => {
  4993. var targetSelector = props && props.to;
  4994. if (isString(targetSelector)) {
  4995. if (!select) {
  4996. return null;
  4997. } else {
  4998. var target = select(targetSelector);
  4999. return target;
  5000. }
  5001. } else {
  5002. return targetSelector;
  5003. }
  5004. };
  5005. var TeleportImpl = {
  5006. __isTeleport: true,
  5007. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
  5008. var {
  5009. mc: mountChildren,
  5010. pc: patchChildren,
  5011. pbc: patchBlockChildren,
  5012. o: {
  5013. insert,
  5014. querySelector,
  5015. createText,
  5016. createComment
  5017. }
  5018. } = internals;
  5019. var disabled = isTeleportDisabled(n2.props);
  5020. var {
  5021. shapeFlag,
  5022. children,
  5023. dynamicChildren
  5024. } = n2;
  5025. if (n1 == null) {
  5026. // insert anchors in the main view
  5027. var placeholder = n2.el = createText('');
  5028. var mainAnchor = n2.anchor = createText('');
  5029. insert(placeholder, container, anchor);
  5030. insert(mainAnchor, container, anchor);
  5031. var target = n2.target = resolveTarget(n2.props, querySelector);
  5032. var targetAnchor = n2.targetAnchor = createText('');
  5033. if (target) {
  5034. insert(targetAnchor, target);
  5035. // #2652 we could be teleporting from a non-SVG tree into an SVG tree
  5036. isSVG = isSVG || isTargetSVG(target);
  5037. }
  5038. var mount = (container, anchor) => {
  5039. // Teleport *always* has Array children. This is enforced in both the
  5040. // compiler and vnode children normalization.
  5041. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  5042. mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  5043. }
  5044. };
  5045. if (disabled) {
  5046. mount(container, mainAnchor);
  5047. } else if (target) {
  5048. mount(target, targetAnchor);
  5049. }
  5050. } else {
  5051. // update content
  5052. n2.el = n1.el;
  5053. var _mainAnchor = n2.anchor = n1.anchor;
  5054. var _target = n2.target = n1.target;
  5055. var _targetAnchor = n2.targetAnchor = n1.targetAnchor;
  5056. var wasDisabled = isTeleportDisabled(n1.props);
  5057. var currentContainer = wasDisabled ? container : _target;
  5058. var currentAnchor = wasDisabled ? _mainAnchor : _targetAnchor;
  5059. isSVG = isSVG || isTargetSVG(_target);
  5060. if (dynamicChildren) {
  5061. // fast path when the teleport happens to be a block root
  5062. patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
  5063. // even in block tree mode we need to make sure all root-level nodes
  5064. // in the teleport inherit previous DOM references so that they can
  5065. // be moved in future patches.
  5066. traverseStaticChildren(n1, n2, true);
  5067. } else if (!optimized) {
  5068. patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
  5069. }
  5070. if (disabled) {
  5071. if (!wasDisabled) {
  5072. // enabled -> disabled
  5073. // move into main container
  5074. moveTeleport(n2, container, _mainAnchor, internals, 1 /* TeleportMoveTypes.TOGGLE */);
  5075. }
  5076. } else {
  5077. // target changed
  5078. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  5079. var nextTarget = n2.target = resolveTarget(n2.props, querySelector);
  5080. if (nextTarget) {
  5081. moveTeleport(n2, nextTarget, null, internals, 0 /* TeleportMoveTypes.TARGET_CHANGE */);
  5082. }
  5083. } else if (wasDisabled) {
  5084. // disabled -> enabled
  5085. // move into teleport target
  5086. moveTeleport(n2, _target, _targetAnchor, internals, 1 /* TeleportMoveTypes.TOGGLE */);
  5087. }
  5088. }
  5089. }
  5090. updateCssVars(n2);
  5091. },
  5092. remove(vnode, parentComponent, parentSuspense, optimized, _ref13, doRemove) {
  5093. var {
  5094. um: unmount,
  5095. o: {
  5096. remove: hostRemove
  5097. }
  5098. } = _ref13;
  5099. var {
  5100. shapeFlag,
  5101. children,
  5102. anchor,
  5103. targetAnchor,
  5104. target,
  5105. props
  5106. } = vnode;
  5107. if (target) {
  5108. hostRemove(targetAnchor);
  5109. }
  5110. // an unmounted teleport should always remove its children if not disabled
  5111. if (doRemove || !isTeleportDisabled(props)) {
  5112. hostRemove(anchor);
  5113. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  5114. for (var i = 0; i < children.length; i++) {
  5115. var child = children[i];
  5116. unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
  5117. }
  5118. }
  5119. }
  5120. },
  5121. move: moveTeleport,
  5122. hydrate: hydrateTeleport
  5123. };
  5124. function moveTeleport(vnode, container, parentAnchor, _ref14) {
  5125. var {
  5126. o: {
  5127. insert
  5128. },
  5129. m: move
  5130. } = _ref14;
  5131. var moveType = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 2;
  5132. // move target anchor if this is a target change.
  5133. if (moveType === 0 /* TeleportMoveTypes.TARGET_CHANGE */) {
  5134. insert(vnode.targetAnchor, container, parentAnchor);
  5135. }
  5136. var {
  5137. el,
  5138. anchor,
  5139. shapeFlag,
  5140. children,
  5141. props
  5142. } = vnode;
  5143. var isReorder = moveType === 2 /* TeleportMoveTypes.REORDER */;
  5144. // move main view anchor if this is a re-order.
  5145. if (isReorder) {
  5146. insert(el, container, parentAnchor);
  5147. }
  5148. // if this is a re-order and teleport is enabled (content is in target)
  5149. // do not move children. So the opposite is: only move children if this
  5150. // is not a reorder, or the teleport is disabled
  5151. if (!isReorder || isTeleportDisabled(props)) {
  5152. // Teleport has either Array children or no children.
  5153. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  5154. for (var i = 0; i < children.length; i++) {
  5155. move(children[i], container, parentAnchor, 2 /* MoveType.REORDER */);
  5156. }
  5157. }
  5158. }
  5159. // move main view anchor if this is a re-order.
  5160. if (isReorder) {
  5161. insert(anchor, container, parentAnchor);
  5162. }
  5163. }
  5164. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, _ref15, hydrateChildren) {
  5165. var {
  5166. o: {
  5167. nextSibling,
  5168. parentNode,
  5169. querySelector
  5170. }
  5171. } = _ref15;
  5172. var target = vnode.target = resolveTarget(vnode.props, querySelector);
  5173. if (target) {
  5174. // if multiple teleports rendered to the same target element, we need to
  5175. // pick up from where the last teleport finished instead of the first node
  5176. var targetNode = target._lpa || target.firstChild;
  5177. if (vnode.shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  5178. if (isTeleportDisabled(vnode.props)) {
  5179. vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
  5180. vnode.targetAnchor = targetNode;
  5181. } else {
  5182. vnode.anchor = nextSibling(node);
  5183. // lookahead until we find the target anchor
  5184. // we cannot rely on return value of hydrateChildren() because there
  5185. // could be nested teleports
  5186. var targetAnchor = targetNode;
  5187. while (targetAnchor) {
  5188. targetAnchor = nextSibling(targetAnchor);
  5189. if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === 'teleport anchor') {
  5190. vnode.targetAnchor = targetAnchor;
  5191. target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  5192. break;
  5193. }
  5194. }
  5195. hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
  5196. }
  5197. }
  5198. updateCssVars(vnode);
  5199. }
  5200. return vnode.anchor && nextSibling(vnode.anchor);
  5201. }
  5202. // Force-casted public typing for h and TSX props inference
  5203. var Teleport = TeleportImpl;
  5204. function updateCssVars(vnode) {
  5205. // presence of .ut method indicates owner component uses css vars.
  5206. // code path here can assume browser environment.
  5207. var ctx = vnode.ctx;
  5208. if (ctx && ctx.ut) {
  5209. var node = vnode.children[0].el;
  5210. while (node !== vnode.targetAnchor) {
  5211. if (node.nodeType === 1) node.setAttribute('data-v-owner', ctx.uid);
  5212. node = node.nextSibling;
  5213. }
  5214. ctx.ut();
  5215. }
  5216. }
  5217. var Fragment = Symbol(undefined);
  5218. var Text = Symbol(undefined);
  5219. var Comment = Symbol(undefined);
  5220. var Static = Symbol(undefined);
  5221. // Since v-if and v-for are the two possible ways node structure can dynamically
  5222. // change, once we consider v-if branches and each v-for fragment a block, we
  5223. // can divide a template into nested blocks, and within each block the node
  5224. // structure would be stable. This allows us to skip most children diffing
  5225. // and only worry about the dynamic nodes (indicated by patch flags).
  5226. var blockStack = [];
  5227. var currentBlock = null;
  5228. /**
  5229. * Open a block.
  5230. * This must be called before `createBlock`. It cannot be part of `createBlock`
  5231. * because the children of the block are evaluated before `createBlock` itself
  5232. * is called. The generated code typically looks like this:
  5233. *
  5234. * ```js
  5235. * function render() {
  5236. * return (openBlock(),createBlock('div', null, [...]))
  5237. * }
  5238. * ```
  5239. * disableTracking is true when creating a v-for fragment block, since a v-for
  5240. * fragment always diffs its children.
  5241. *
  5242. * @private
  5243. */
  5244. function openBlock() {
  5245. var disableTracking = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5246. blockStack.push(currentBlock = disableTracking ? null : []);
  5247. }
  5248. function closeBlock() {
  5249. blockStack.pop();
  5250. currentBlock = blockStack[blockStack.length - 1] || null;
  5251. }
  5252. // Whether we should be tracking dynamic child nodes inside a block.
  5253. // Only tracks when this value is > 0
  5254. // We are not using a simple boolean because this value may need to be
  5255. // incremented/decremented by nested usage of v-once (see below)
  5256. var isBlockTreeEnabled = 1;
  5257. /**
  5258. * Block tracking sometimes needs to be disabled, for example during the
  5259. * creation of a tree that needs to be cached by v-once. The compiler generates
  5260. * code like this:
  5261. *
  5262. * ``` js
  5263. * _cache[1] || (
  5264. * setBlockTracking(-1),
  5265. * _cache[1] = createVNode(...),
  5266. * setBlockTracking(1),
  5267. * _cache[1]
  5268. * )
  5269. * ```
  5270. *
  5271. * @private
  5272. */
  5273. function setBlockTracking(value) {
  5274. isBlockTreeEnabled += value;
  5275. }
  5276. function setupBlock(vnode) {
  5277. // save current block children on the block vnode
  5278. vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
  5279. // close block
  5280. closeBlock();
  5281. // a block is always going to be patched, so track it as a child of its
  5282. // parent block
  5283. if (isBlockTreeEnabled > 0 && currentBlock) {
  5284. currentBlock.push(vnode);
  5285. }
  5286. return vnode;
  5287. }
  5288. /**
  5289. * @private
  5290. */
  5291. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  5292. return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true /* isBlock */));
  5293. }
  5294. /**
  5295. * Create a block root vnode. Takes the same exact arguments as `createVNode`.
  5296. * A block root keeps track of dynamic nodes within the block in the
  5297. * `dynamicChildren` array.
  5298. *
  5299. * @private
  5300. */
  5301. function createBlock(type, props, children, patchFlag, dynamicProps) {
  5302. return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */));
  5303. }
  5304. function isVNode(value) {
  5305. return value ? value.__v_isVNode === true : false;
  5306. }
  5307. function isSameVNodeType(n1, n2) {
  5308. return n1.type === n2.type && n1.key === n2.key;
  5309. }
  5310. /**
  5311. * Internal API for registering an arguments transform for createVNode
  5312. * used for creating stubs in the test-utils
  5313. * It is *internal* but needs to be exposed for test-utils to pick up proper
  5314. * typings
  5315. */
  5316. function transformVNodeArgs(transformer) {}
  5317. var InternalObjectKey = "__vInternal";
  5318. var normalizeKey = _ref16 => {
  5319. var {
  5320. key
  5321. } = _ref16;
  5322. return key != null ? key : null;
  5323. };
  5324. var normalizeRef = _ref17 => {
  5325. var {
  5326. ref,
  5327. ref_key,
  5328. ref_for
  5329. } = _ref17;
  5330. return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? {
  5331. i: currentRenderingInstance,
  5332. r: ref,
  5333. k: ref_key,
  5334. f: !!ref_for
  5335. } : ref : null;
  5336. };
  5337. function createBaseVNode(type) {
  5338. var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5339. var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5340. var patchFlag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  5341. var dynamicProps = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  5342. var shapeFlag = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : type === Fragment ? 0 : 1;
  5343. var isBlockNode = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  5344. var needFullChildrenNormalization = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
  5345. var vnode = {
  5346. __v_isVNode: true,
  5347. __v_skip: true,
  5348. type,
  5349. props,
  5350. key: props && normalizeKey(props),
  5351. ref: props && normalizeRef(props),
  5352. scopeId: currentScopeId,
  5353. slotScopeIds: null,
  5354. children,
  5355. component: null,
  5356. suspense: null,
  5357. ssContent: null,
  5358. ssFallback: null,
  5359. dirs: null,
  5360. transition: null,
  5361. el: null,
  5362. anchor: null,
  5363. target: null,
  5364. targetAnchor: null,
  5365. staticCount: 0,
  5366. shapeFlag,
  5367. patchFlag,
  5368. dynamicProps,
  5369. dynamicChildren: null,
  5370. appContext: null,
  5371. // fixed by xxxxxx
  5372. hostInstance: currentRenderingInstance,
  5373. ctx: currentRenderingInstance
  5374. };
  5375. if (needFullChildrenNormalization) {
  5376. normalizeChildren(vnode, children);
  5377. // normalize suspense children
  5378. if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  5379. type.normalize(vnode);
  5380. }
  5381. } else if (children) {
  5382. // compiled element vnode - if children is passed, only possible types are
  5383. // string or Array.
  5384. vnode.shapeFlag |= isString(children) ? 8 /* ShapeFlags.TEXT_CHILDREN */ : 16 /* ShapeFlags.ARRAY_CHILDREN */;
  5385. }
  5386. // track vnode for block tree
  5387. if (isBlockTreeEnabled > 0 &&
  5388. // avoid a block node from tracking itself
  5389. !isBlockNode &&
  5390. // has current parent block
  5391. currentBlock && (
  5392. // presence of a patch flag indicates this node needs patching on updates.
  5393. // component nodes also should always be patched, because even if the
  5394. // component doesn't need to update, it needs to persist the instance on to
  5395. // the next vnode so that it can be properly unmounted later.
  5396. vnode.patchFlag > 0 || shapeFlag & 6 /* ShapeFlags.COMPONENT */) &&
  5397. // the EVENTS flag is only for hydration and if it is the only flag, the
  5398. // vnode should not be considered dynamic due to handler caching.
  5399. vnode.patchFlag !== 32 /* PatchFlags.HYDRATE_EVENTS */) {
  5400. currentBlock.push(vnode);
  5401. }
  5402. return vnode;
  5403. }
  5404. var createVNode = _createVNode;
  5405. function _createVNode(type) {
  5406. var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5407. var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5408. var patchFlag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  5409. var dynamicProps = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  5410. var isBlockNode = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
  5411. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  5412. type = Comment;
  5413. }
  5414. if (isVNode(type)) {
  5415. // createVNode receiving an existing vnode. This happens in cases like
  5416. // <component :is="vnode"/>
  5417. // #2078 make sure to merge refs during the clone instead of overwriting it
  5418. var cloned = cloneVNode(type, props, true /* mergeRef: true */);
  5419. if (children) {
  5420. normalizeChildren(cloned, children);
  5421. }
  5422. if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
  5423. if (cloned.shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  5424. currentBlock[currentBlock.indexOf(type)] = cloned;
  5425. } else {
  5426. currentBlock.push(cloned);
  5427. }
  5428. }
  5429. cloned.patchFlag |= -2 /* PatchFlags.BAIL */;
  5430. return cloned;
  5431. }
  5432. // class component normalization.
  5433. if (isClassComponent(type)) {
  5434. type = type.__vccOpts;
  5435. }
  5436. // class & style normalization.
  5437. if (props) {
  5438. // for reactive or proxy objects, we need to clone it to enable mutation.
  5439. props = guardReactiveProps(props);
  5440. var {
  5441. class: klass,
  5442. style
  5443. } = props;
  5444. if (klass && !isString(klass)) {
  5445. props.class = normalizeClass(klass);
  5446. }
  5447. if (isObject(style)) {
  5448. // reactive state objects need to be cloned since they are likely to be
  5449. // mutated
  5450. if (isProxy(style) && !isArray(style)) {
  5451. style = extend({}, style);
  5452. }
  5453. props.style = normalizeStyle(style);
  5454. }
  5455. }
  5456. // encode the vnode type information into a bitmap
  5457. var shapeFlag = isString(type) ? 1 /* ShapeFlags.ELEMENT */ : isSuspense(type) ? 128 /* ShapeFlags.SUSPENSE */ : isTeleport(type) ? 64 /* ShapeFlags.TELEPORT */ : isObject(type) ? 4 /* ShapeFlags.STATEFUL_COMPONENT */ : isFunction(type) ? 2 /* ShapeFlags.FUNCTIONAL_COMPONENT */ : 0;
  5458. return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
  5459. }
  5460. function guardReactiveProps(props) {
  5461. if (!props) return null;
  5462. return isProxy(props) || InternalObjectKey in props ? extend({}, props) : props;
  5463. }
  5464. function cloneVNode(vnode, extraProps) {
  5465. var mergeRef = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5466. // This is intentionally NOT using spread or extend to avoid the runtime
  5467. // key enumeration cost.
  5468. var {
  5469. props,
  5470. ref,
  5471. patchFlag,
  5472. children
  5473. } = vnode;
  5474. var mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  5475. var cloned = {
  5476. __v_isVNode: true,
  5477. __v_skip: true,
  5478. type: vnode.type,
  5479. props: mergedProps,
  5480. key: mergedProps && normalizeKey(mergedProps),
  5481. ref: extraProps && extraProps.ref ?
  5482. // #2078 in the case of <component :is="vnode" ref="extra"/>
  5483. // if the vnode itself already has a ref, cloneVNode will need to merge
  5484. // the refs so the single vnode can be set on multiple refs
  5485. mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps) : ref,
  5486. scopeId: vnode.scopeId,
  5487. slotScopeIds: vnode.slotScopeIds,
  5488. children: children,
  5489. target: vnode.target,
  5490. targetAnchor: vnode.targetAnchor,
  5491. staticCount: vnode.staticCount,
  5492. shapeFlag: vnode.shapeFlag,
  5493. // if the vnode is cloned with extra props, we can no longer assume its
  5494. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  5495. // note: preserve flag for fragments since they use the flag for children
  5496. // fast paths only.
  5497. patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 // hoisted node
  5498. ? 16 /* PatchFlags.FULL_PROPS */ : patchFlag | 16 /* PatchFlags.FULL_PROPS */ : patchFlag,
  5499. dynamicProps: vnode.dynamicProps,
  5500. dynamicChildren: vnode.dynamicChildren,
  5501. appContext: vnode.appContext,
  5502. // fixed by xxxxxx
  5503. hostInstance: vnode.hostInstance,
  5504. dirs: vnode.dirs,
  5505. transition: vnode.transition,
  5506. // These should technically only be non-null on mounted VNodes. However,
  5507. // they *should* be copied for kept-alive vnodes. So we just always copy
  5508. // them since them being non-null during a mount doesn't affect the logic as
  5509. // they will simply be overwritten.
  5510. component: vnode.component,
  5511. suspense: vnode.suspense,
  5512. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  5513. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  5514. el: vnode.el,
  5515. anchor: vnode.anchor,
  5516. ctx: vnode.ctx,
  5517. ce: vnode.ce
  5518. };
  5519. return cloned;
  5520. }
  5521. /**
  5522. * @private
  5523. */
  5524. function createTextVNode() {
  5525. var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
  5526. var flag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  5527. return createVNode(Text, null, text, flag);
  5528. }
  5529. /**
  5530. * @private
  5531. */
  5532. function createStaticVNode(content, numberOfNodes) {
  5533. // A static vnode can contain multiple stringified elements, and the number
  5534. // of elements is necessary for hydration.
  5535. var vnode = createVNode(Static, null, content);
  5536. vnode.staticCount = numberOfNodes;
  5537. return vnode;
  5538. }
  5539. /**
  5540. * @private
  5541. */
  5542. function createCommentVNode() {
  5543. var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  5544. var asBlock = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5545. return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text);
  5546. }
  5547. function normalizeVNode(child) {
  5548. if (child == null || typeof child === 'boolean') {
  5549. // empty placeholder
  5550. return createVNode(Comment);
  5551. } else if (isArray(child)) {
  5552. // fragment
  5553. return createVNode(Fragment, null,
  5554. // #3666, avoid reference pollution when reusing vnode
  5555. child.slice());
  5556. } else if (typeof child === 'object') {
  5557. // already vnode, this should be the most common since compiled templates
  5558. // always produce all-vnode children arrays
  5559. return cloneIfMounted(child);
  5560. } else {
  5561. // strings and numbers
  5562. return createVNode(Text, null, String(child));
  5563. }
  5564. }
  5565. // optimized normalization for template-compiled render fns
  5566. function cloneIfMounted(child) {
  5567. return child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */ || child.memo ? child : cloneVNode(child);
  5568. }
  5569. function normalizeChildren(vnode, children) {
  5570. var type = 0;
  5571. var {
  5572. shapeFlag
  5573. } = vnode;
  5574. if (children == null) {
  5575. children = null;
  5576. } else if (isArray(children)) {
  5577. type = 16 /* ShapeFlags.ARRAY_CHILDREN */;
  5578. } else if (typeof children === 'object') {
  5579. if (shapeFlag & (1 /* ShapeFlags.ELEMENT */ | 64 /* ShapeFlags.TELEPORT */)) {
  5580. // Normalize slot to plain children for plain element and Teleport
  5581. var slot = children.default;
  5582. if (slot) {
  5583. // _c marker is added by withCtx() indicating this is a compiled slot
  5584. slot._c && (slot._d = false);
  5585. normalizeChildren(vnode, slot());
  5586. slot._c && (slot._d = true);
  5587. }
  5588. return;
  5589. } else {
  5590. type = 32 /* ShapeFlags.SLOTS_CHILDREN */;
  5591. var slotFlag = children._;
  5592. if (!slotFlag && !(InternalObjectKey in children)) {
  5593. children._ctx = currentRenderingInstance;
  5594. } else if (slotFlag === 3 /* SlotFlags.FORWARDED */ && currentRenderingInstance) {
  5595. // a child component receives forwarded slots from the parent.
  5596. // its slot type is determined by its parent's slot type.
  5597. if (currentRenderingInstance.slots._ === 1 /* SlotFlags.STABLE */) {
  5598. children._ = 1 /* SlotFlags.STABLE */;
  5599. } else {
  5600. children._ = 2 /* SlotFlags.DYNAMIC */;
  5601. vnode.patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
  5602. }
  5603. }
  5604. }
  5605. } else if (isFunction(children)) {
  5606. children = {
  5607. default: children,
  5608. _ctx: currentRenderingInstance
  5609. };
  5610. type = 32 /* ShapeFlags.SLOTS_CHILDREN */;
  5611. } else {
  5612. children = String(children);
  5613. // force teleport children to array so it can be moved around
  5614. if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  5615. type = 16 /* ShapeFlags.ARRAY_CHILDREN */;
  5616. children = [createTextVNode(children)];
  5617. } else {
  5618. type = 8 /* ShapeFlags.TEXT_CHILDREN */;
  5619. }
  5620. }
  5621. vnode.children = children;
  5622. vnode.shapeFlag |= type;
  5623. }
  5624. function mergeProps() {
  5625. var ret = {};
  5626. for (var i = 0; i < arguments.length; i++) {
  5627. var toMerge = i < 0 || arguments.length <= i ? undefined : arguments[i];
  5628. for (var key in toMerge) {
  5629. if (key === 'class') {
  5630. if (ret.class !== toMerge.class) {
  5631. ret.class = normalizeClass([ret.class, toMerge.class]);
  5632. }
  5633. } else if (key === 'style') {
  5634. ret.style = normalizeStyle([ret.style, toMerge.style]);
  5635. } else if (isOn(key)) {
  5636. var existing = ret[key];
  5637. var incoming = toMerge[key];
  5638. if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
  5639. ret[key] = existing ? [].concat(existing, incoming) : incoming;
  5640. }
  5641. } else if (key !== '') {
  5642. ret[key] = toMerge[key];
  5643. }
  5644. }
  5645. }
  5646. return ret;
  5647. }
  5648. function invokeVNodeHook(hook, instance, vnode) {
  5649. var prevVNode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  5650. callWithAsyncErrorHandling(hook, instance, 7 /* ErrorCodes.VNODE_HOOK */, [vnode, prevVNode]);
  5651. }
  5652. var emptyAppContext = createAppContext();
  5653. var uid = 0;
  5654. function createComponentInstance(vnode, parent, suspense) {
  5655. var type = vnode.type;
  5656. // inherit parent app context - or - if root, adopt from root vnode
  5657. var appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  5658. var instance = {
  5659. uid: uid++,
  5660. vnode,
  5661. type,
  5662. parent,
  5663. appContext,
  5664. root: null,
  5665. next: null,
  5666. subTree: null,
  5667. effect: null,
  5668. update: null,
  5669. scope: new EffectScope(true /* detached */),
  5670. render: null,
  5671. proxy: null,
  5672. exposed: null,
  5673. exposeProxy: null,
  5674. withProxy: null,
  5675. provides: parent ? parent.provides : Object.create(appContext.provides),
  5676. accessCache: null,
  5677. renderCache: [],
  5678. // local resolved assets
  5679. components: null,
  5680. directives: null,
  5681. // resolved props and emits options
  5682. propsOptions: normalizePropsOptions(type, appContext),
  5683. emitsOptions: normalizeEmitsOptions(type, appContext),
  5684. // emit
  5685. emit: null,
  5686. emitted: null,
  5687. // props default value
  5688. propsDefaults: EMPTY_OBJ,
  5689. // inheritAttrs
  5690. inheritAttrs: type.inheritAttrs,
  5691. // state
  5692. ctx: EMPTY_OBJ,
  5693. data: EMPTY_OBJ,
  5694. props: EMPTY_OBJ,
  5695. attrs: EMPTY_OBJ,
  5696. slots: EMPTY_OBJ,
  5697. refs: EMPTY_OBJ,
  5698. setupState: EMPTY_OBJ,
  5699. setupContext: null,
  5700. // suspense related
  5701. suspense,
  5702. suspenseId: suspense ? suspense.pendingId : 0,
  5703. asyncDep: null,
  5704. asyncResolved: false,
  5705. // lifecycle hooks
  5706. // not using enums here because it results in computed properties
  5707. isMounted: false,
  5708. isUnmounted: false,
  5709. isDeactivated: false,
  5710. bc: null,
  5711. c: null,
  5712. bm: null,
  5713. m: null,
  5714. bu: null,
  5715. u: null,
  5716. um: null,
  5717. bum: null,
  5718. da: null,
  5719. a: null,
  5720. rtg: null,
  5721. rtc: null,
  5722. ec: null,
  5723. sp: null
  5724. };
  5725. {
  5726. instance.ctx = {
  5727. _: instance
  5728. };
  5729. }
  5730. instance.root = parent ? parent.root : instance;
  5731. instance.emit = emit.bind(null, instance);
  5732. // apply custom element special handling
  5733. if (vnode.ce) {
  5734. vnode.ce(instance);
  5735. }
  5736. return instance;
  5737. }
  5738. var currentInstance = null;
  5739. var getCurrentInstance = () => currentInstance || currentRenderingInstance;
  5740. var setCurrentInstance = instance => {
  5741. currentInstance = instance;
  5742. instance.scope.on();
  5743. };
  5744. var unsetCurrentInstance = () => {
  5745. currentInstance && currentInstance.scope.off();
  5746. currentInstance = null;
  5747. };
  5748. function isStatefulComponent(instance) {
  5749. return instance.vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */;
  5750. }
  5751. var isInSSRComponentSetup = false;
  5752. function setupComponent(instance) {
  5753. var isSSR = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5754. isInSSRComponentSetup = isSSR;
  5755. var {
  5756. props,
  5757. children
  5758. } = instance.vnode;
  5759. var isStateful = isStatefulComponent(instance);
  5760. initProps(instance, props, isStateful, isSSR);
  5761. initSlots(instance, children);
  5762. var setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : undefined;
  5763. isInSSRComponentSetup = false;
  5764. return setupResult;
  5765. }
  5766. function setupStatefulComponent(instance, isSSR) {
  5767. var Component = instance.type;
  5768. // 0. create render proxy property access cache
  5769. instance.accessCache = Object.create(null);
  5770. // 1. create public instance / render proxy
  5771. // also mark it raw so it's never observed
  5772. instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
  5773. // 2. call setup()
  5774. var {
  5775. setup
  5776. } = Component;
  5777. if (setup) {
  5778. var setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
  5779. setCurrentInstance(instance);
  5780. pauseTracking();
  5781. var setupResult = callWithErrorHandling(setup, instance, 0 /* ErrorCodes.SETUP_FUNCTION */, [instance.props, setupContext]);
  5782. resetTracking();
  5783. unsetCurrentInstance();
  5784. if (isPromise(setupResult)) {
  5785. setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
  5786. if (isSSR) {
  5787. // return the promise so server-renderer can wait on it
  5788. return setupResult.then(resolvedResult => {
  5789. handleSetupResult(instance, resolvedResult, isSSR);
  5790. }).catch(e => {
  5791. handleError(e, instance, 0 /* ErrorCodes.SETUP_FUNCTION */);
  5792. });
  5793. } else {
  5794. // async setup returned Promise.
  5795. // bail here and wait for re-entry.
  5796. instance.asyncDep = setupResult;
  5797. }
  5798. } else {
  5799. handleSetupResult(instance, setupResult, isSSR);
  5800. }
  5801. } else {
  5802. finishComponentSetup(instance, isSSR);
  5803. }
  5804. }
  5805. function handleSetupResult(instance, setupResult, isSSR) {
  5806. if (isFunction(setupResult)) {
  5807. // setup returned an inline render function
  5808. {
  5809. instance.render = setupResult;
  5810. }
  5811. } else if (isObject(setupResult)) {
  5812. instance.setupState = proxyRefs(setupResult);
  5813. } else ;
  5814. finishComponentSetup(instance, isSSR);
  5815. }
  5816. var compile;
  5817. var installWithProxy;
  5818. /**
  5819. * For runtime-dom to register the compiler.
  5820. * Note the exported method uses any to avoid d.ts relying on the compiler types.
  5821. */
  5822. function registerRuntimeCompiler(_compile) {
  5823. compile = _compile;
  5824. installWithProxy = i => {
  5825. if (i.render._rc) {
  5826. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  5827. }
  5828. };
  5829. }
  5830. // dev only
  5831. var isRuntimeOnly = () => !compile;
  5832. function finishComponentSetup(instance, isSSR, skipOptions) {
  5833. var Component = instance.type;
  5834. // template / render function normalization
  5835. // could be already set when returned from setup()
  5836. if (!instance.render) {
  5837. // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
  5838. // is done by server-renderer
  5839. if (!isSSR && compile && !Component.render) {
  5840. var template = Component.template || resolveMergedOptions(instance).template;
  5841. if (template) {
  5842. var {
  5843. isCustomElement,
  5844. compilerOptions
  5845. } = instance.appContext.config;
  5846. var {
  5847. delimiters,
  5848. compilerOptions: componentCompilerOptions
  5849. } = Component;
  5850. var finalCompilerOptions = extend(extend({
  5851. isCustomElement,
  5852. delimiters
  5853. }, compilerOptions), componentCompilerOptions);
  5854. Component.render = compile(template, finalCompilerOptions);
  5855. }
  5856. }
  5857. instance.render = Component.render || NOOP;
  5858. // for runtime-compiled render functions using `with` blocks, the render
  5859. // proxy used needs a different `has` handler which is more performant and
  5860. // also only allows a whitelist of globals to fallthrough.
  5861. if (installWithProxy) {
  5862. installWithProxy(instance);
  5863. }
  5864. }
  5865. // support for 2.x options
  5866. {
  5867. setCurrentInstance(instance);
  5868. pauseTracking();
  5869. applyOptions(instance);
  5870. resetTracking();
  5871. unsetCurrentInstance();
  5872. }
  5873. }
  5874. function createAttrsProxy(instance) {
  5875. return new Proxy(instance.attrs, {
  5876. get(target, key) {
  5877. track(instance, "get" /* TrackOpTypes.GET */, '$attrs');
  5878. return target[key];
  5879. }
  5880. });
  5881. }
  5882. function createSetupContext(instance) {
  5883. var expose = exposed => {
  5884. instance.exposed = exposed || {};
  5885. };
  5886. var attrs;
  5887. {
  5888. return {
  5889. get attrs() {
  5890. return attrs || (attrs = createAttrsProxy(instance));
  5891. },
  5892. slots: instance.slots,
  5893. emit: instance.emit,
  5894. expose
  5895. };
  5896. }
  5897. }
  5898. function getExposeProxy(instance) {
  5899. if (instance.exposed) {
  5900. return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  5901. get(target, key) {
  5902. if (key in target) {
  5903. return target[key];
  5904. } else if (key in publicPropertiesMap) {
  5905. return publicPropertiesMap[key](instance);
  5906. }
  5907. },
  5908. has(target, key) {
  5909. return key in target || key in publicPropertiesMap;
  5910. }
  5911. }));
  5912. }
  5913. }
  5914. function getComponentName(Component) {
  5915. var includeInferred = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  5916. return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
  5917. }
  5918. function isClassComponent(value) {
  5919. return isFunction(value) && '__vccOpts' in value;
  5920. }
  5921. var computed = (getterOrOptions, debugOptions) => {
  5922. // @ts-ignore
  5923. return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
  5924. };
  5925. // implementation
  5926. function defineProps() {
  5927. return null;
  5928. }
  5929. // implementation
  5930. function defineEmits() {
  5931. return null;
  5932. }
  5933. /**
  5934. * Vue `<script setup>` compiler macro for declaring a component's exposed
  5935. * instance properties when it is accessed by a parent component via template
  5936. * refs.
  5937. *
  5938. * `<script setup>` components are closed by default - i.e. variables inside
  5939. * the `<script setup>` scope is not exposed to parent unless explicitly exposed
  5940. * via `defineExpose`.
  5941. *
  5942. * This is only usable inside `<script setup>`, is compiled away in the
  5943. * output and should **not** be actually called at runtime.
  5944. */
  5945. function defineExpose(exposed) {}
  5946. /**
  5947. * Vue `<script setup>` compiler macro for providing props default values when
  5948. * using type-based `defineProps` declaration.
  5949. *
  5950. * Example usage:
  5951. * ```ts
  5952. * withDefaults(defineProps<{
  5953. * size?: number
  5954. * labels?: string[]
  5955. * }>(), {
  5956. * size: 3,
  5957. * labels: () => ['default label']
  5958. * })
  5959. * ```
  5960. *
  5961. * This is only usable inside `<script setup>`, is compiled away in the output
  5962. * and should **not** be actually called at runtime.
  5963. */
  5964. function withDefaults(props, defaults) {
  5965. return null;
  5966. }
  5967. function useSlots() {
  5968. return getContext().slots;
  5969. }
  5970. function useAttrs() {
  5971. return getContext().attrs;
  5972. }
  5973. function getContext() {
  5974. var i = getCurrentInstance();
  5975. return i.setupContext || (i.setupContext = createSetupContext(i));
  5976. }
  5977. /**
  5978. * Runtime helper for merging default declarations. Imported by compiled code
  5979. * only.
  5980. * @internal
  5981. */
  5982. function mergeDefaults(raw, defaults) {
  5983. var props = isArray(raw) ? raw.reduce((normalized, p) => (normalized[p] = {}, normalized), {}) : raw;
  5984. for (var key in defaults) {
  5985. var opt = props[key];
  5986. if (opt) {
  5987. if (isArray(opt) || isFunction(opt)) {
  5988. props[key] = {
  5989. type: opt,
  5990. default: defaults[key]
  5991. };
  5992. } else {
  5993. opt.default = defaults[key];
  5994. }
  5995. } else if (opt === null) {
  5996. props[key] = {
  5997. default: defaults[key]
  5998. };
  5999. } else ;
  6000. }
  6001. return props;
  6002. }
  6003. /**
  6004. * Used to create a proxy for the rest element when destructuring props with
  6005. * defineProps().
  6006. * @internal
  6007. */
  6008. function createPropsRestProxy(props, excludedKeys) {
  6009. var ret = {};
  6010. var _loop4 = function (key) {
  6011. if (!excludedKeys.includes(key)) {
  6012. Object.defineProperty(ret, key, {
  6013. enumerable: true,
  6014. get: () => props[key]
  6015. });
  6016. }
  6017. };
  6018. for (var key in props) {
  6019. _loop4(key);
  6020. }
  6021. return ret;
  6022. }
  6023. /**
  6024. * `<script setup>` helper for persisting the current instance context over
  6025. * async/await flows.
  6026. *
  6027. * `@vue/compiler-sfc` converts the following:
  6028. *
  6029. * ```ts
  6030. * const x = await foo()
  6031. * ```
  6032. *
  6033. * into:
  6034. *
  6035. * ```ts
  6036. * let __temp, __restore
  6037. * const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
  6038. * ```
  6039. * @internal
  6040. */
  6041. function withAsyncContext(getAwaitable) {
  6042. var ctx = getCurrentInstance();
  6043. var awaitable = getAwaitable();
  6044. unsetCurrentInstance();
  6045. if (isPromise(awaitable)) {
  6046. awaitable = awaitable.catch(e => {
  6047. setCurrentInstance(ctx);
  6048. throw e;
  6049. });
  6050. }
  6051. return [awaitable, () => setCurrentInstance(ctx)];
  6052. }
  6053. // Actual implementation
  6054. function h(type, propsOrChildren, children) {
  6055. var l = arguments.length;
  6056. if (l === 2) {
  6057. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  6058. // single vnode without props
  6059. if (isVNode(propsOrChildren)) {
  6060. return createVNode(type, null, [propsOrChildren]);
  6061. }
  6062. // props without children
  6063. return createVNode(type, propsOrChildren);
  6064. } else {
  6065. // omit props
  6066. return createVNode(type, null, propsOrChildren);
  6067. }
  6068. } else {
  6069. if (l > 3) {
  6070. children = Array.prototype.slice.call(arguments, 2);
  6071. } else if (l === 3 && isVNode(children)) {
  6072. children = [children];
  6073. }
  6074. return createVNode(type, propsOrChildren, children);
  6075. }
  6076. }
  6077. var ssrContextKey = Symbol("");
  6078. var useSSRContext = () => {
  6079. {
  6080. var ctx = inject(ssrContextKey);
  6081. return ctx;
  6082. }
  6083. };
  6084. function initCustomFormatter() {
  6085. /* eslint-disable no-restricted-globals */
  6086. {
  6087. return;
  6088. }
  6089. }
  6090. function withMemo(memo, render, cache, index) {
  6091. var cached = cache[index];
  6092. if (cached && isMemoSame(cached, memo)) {
  6093. return cached;
  6094. }
  6095. var ret = render();
  6096. // shallow clone
  6097. ret.memo = memo.slice();
  6098. return cache[index] = ret;
  6099. }
  6100. function isMemoSame(cached, memo) {
  6101. var prev = cached.memo;
  6102. if (prev.length != memo.length) {
  6103. return false;
  6104. }
  6105. for (var i = 0; i < prev.length; i++) {
  6106. if (hasChanged(prev[i], memo[i])) {
  6107. return false;
  6108. }
  6109. }
  6110. // make sure to let parent block track it when returning cached
  6111. if (isBlockTreeEnabled > 0 && currentBlock) {
  6112. currentBlock.push(cached);
  6113. }
  6114. return true;
  6115. }
  6116. // Core API ------------------------------------------------------------------
  6117. var version = "3.2.47";
  6118. /**
  6119. * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
  6120. * @internal
  6121. */
  6122. var ssrUtils = null;
  6123. /**
  6124. * @internal only exposed in compat builds
  6125. */
  6126. var resolveFilter = null;
  6127. /**
  6128. * @internal only exposed in compat builds.
  6129. */
  6130. var compatUtils = null;
  6131. var nodeOps = {
  6132. insert: (child, parent, anchor) => {
  6133. if (!anchor) {
  6134. return parent.appendChild(child);
  6135. }
  6136. return parent.insertBefore(child, anchor);
  6137. },
  6138. remove: child => {
  6139. var parent = child.parentNode;
  6140. if (parent) {
  6141. parent.removeChild(child);
  6142. }
  6143. },
  6144. createElement: tag => {
  6145. return document.createElement(tag);
  6146. },
  6147. createText: text => document.createText(text),
  6148. createComment: text => document.createComment(text),
  6149. setText: (node, text) => {
  6150. node.setAttr('value', text);
  6151. },
  6152. setElementText: (el, text) => {
  6153. el.setAttr('value', text);
  6154. },
  6155. parentNode: node => node.parentNode,
  6156. nextSibling: node => node.nextSibling
  6157. };
  6158. function each(obj) {
  6159. return Object.keys(obj);
  6160. }
  6161. function useCssStyles(componentStyles) {
  6162. var normalized = {};
  6163. if (!isArray(componentStyles)) {
  6164. return normalized;
  6165. }
  6166. componentStyles.forEach(componentStyle => {
  6167. each(componentStyle).forEach(className => {
  6168. var parentStyles = componentStyle[className];
  6169. var normalizedStyles = normalized[className] || (normalized[className] = {});
  6170. each(parentStyles).forEach(parentSelector => {
  6171. var parentStyle = parentStyles[parentSelector];
  6172. var normalizedStyle = normalizedStyles[parentSelector] || (normalizedStyles[parentSelector] = {});
  6173. each(parentStyle).forEach(name => {
  6174. if (name[0] === '!') {
  6175. // 如果以包含important属性,则移除非important
  6176. normalizedStyle[name] = parentStyle[name];
  6177. delete normalizedStyle[name.slice(1)];
  6178. } else {
  6179. // 当前属性非important,且不存在同名important属性
  6180. if (!hasOwn(normalizedStyle, '!' + name)) {
  6181. normalizedStyle[name] = parentStyle[name];
  6182. }
  6183. }
  6184. });
  6185. });
  6186. });
  6187. });
  6188. return normalized;
  6189. }
  6190. function hasClass(calssName, el) {
  6191. var classList = el && el.classList;
  6192. return classList && classList.includes(calssName);
  6193. }
  6194. var TYPE_RE = /[+~> ]$/;
  6195. var PROPERTY_PARENT_NODE = 'parentNode';
  6196. var PROPERTY_PREVIOUS_SIBLING = 'previousSibling';
  6197. function isMatchParentSelector(parentSelector, el) {
  6198. var classArray = parentSelector.split('.');
  6199. for (var i = classArray.length - 1; i > 0; i--) {
  6200. var item = classArray[i];
  6201. var type = item[item.length - 1];
  6202. var className = item.replace(TYPE_RE, '');
  6203. if (type === '~' || type === ' ') {
  6204. var property = type === '~' ? PROPERTY_PREVIOUS_SIBLING : PROPERTY_PARENT_NODE;
  6205. while (el) {
  6206. el = el[property];
  6207. if (hasClass(className, el)) {
  6208. break;
  6209. }
  6210. }
  6211. if (!el) {
  6212. return false;
  6213. }
  6214. } else {
  6215. if (type === '>') {
  6216. el = el && el[PROPERTY_PARENT_NODE];
  6217. } else if (type === '+') {
  6218. el = el && el[PROPERTY_PREVIOUS_SIBLING];
  6219. }
  6220. if (!hasClass(className, el)) {
  6221. return false;
  6222. }
  6223. }
  6224. }
  6225. return true;
  6226. }
  6227. var WEIGHT_IMPORTANT = 1000;
  6228. function parseClassName(_ref18, parentStyles, el) {
  6229. var {
  6230. styles,
  6231. weights
  6232. } = _ref18;
  6233. each(parentStyles).forEach(parentSelector => {
  6234. if (parentSelector && el) {
  6235. if (!isMatchParentSelector(parentSelector, el)) {
  6236. return;
  6237. }
  6238. }
  6239. var classWeight = parentSelector.split('.').length;
  6240. var style = parentStyles[parentSelector];
  6241. each(style).forEach(name => {
  6242. var value = style[name];
  6243. var isImportant = name[0] === '!';
  6244. if (isImportant) {
  6245. name = name.slice(1);
  6246. }
  6247. var oldWeight = weights[name] || 0;
  6248. var weight = classWeight + (isImportant ? WEIGHT_IMPORTANT : 0);
  6249. if (weight >= oldWeight) {
  6250. weights[name] = weight;
  6251. styles[name] = value;
  6252. }
  6253. });
  6254. });
  6255. }
  6256. function parseClassListWithStyleSheet(classList, stylesheet) {
  6257. var el = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6258. var context = {
  6259. styles: {},
  6260. weights: {}
  6261. };
  6262. classList.forEach(className => {
  6263. var parentStyles = stylesheet[className];
  6264. if (parentStyles) {
  6265. parseClassName(context, parentStyles, el);
  6266. }
  6267. });
  6268. return context.styles;
  6269. }
  6270. function parseClassStyles(el) {
  6271. return parseClassListWithStyleSheet(el.classList, el.styleSheet, el);
  6272. }
  6273. function parseClassList(classList, instance) {
  6274. var el = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6275. return parseClassListWithStyleSheet(classList, parseStyleSheet(instance), el);
  6276. }
  6277. function parseStyleSheet(_ref19) {
  6278. var {
  6279. type,
  6280. appContext
  6281. } = _ref19;
  6282. var component = type;
  6283. if (!component.__styles) {
  6284. // nvue 和 vue 混合开发时,__globalStyles注入的是未处理过的
  6285. if (appContext && isArray(appContext.provides.__globalStyles)) {
  6286. appContext.provides.__globalStyles = useCssStyles(appContext.provides.__globalStyles);
  6287. }
  6288. if (component.mpType === 'page' && appContext) {
  6289. // 如果是页面组件,则直接使用全局样式
  6290. component.__styles = appContext.provides.__globalStyles;
  6291. } else {
  6292. var styles = [];
  6293. if (appContext) {
  6294. // 全局样式,包括 app.css 以及 page.css
  6295. styles.push(appContext.provides.__globalStyles);
  6296. }
  6297. if (isArray(component.styles)) {
  6298. component.styles.forEach(style => styles.push(style));
  6299. }
  6300. component.__styles = useCssStyles(styles);
  6301. }
  6302. }
  6303. return component.__styles;
  6304. }
  6305. function patchAttr(el, key, value) {
  6306. var instance = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  6307. if (instance) {
  6308. [key, value] = transformAttr(el, key, value, instance);
  6309. }
  6310. el.setAttr(key, value);
  6311. }
  6312. var ATTR_HOVER_CLASS = 'hoverClass';
  6313. var ATTR_PLACEHOLDER_CLASS = 'placeholderClass';
  6314. var ATTR_PLACEHOLDER_STYLE = 'placeholderStyle';
  6315. var ATTR_INDICATOR_CLASS = 'indicatorClass';
  6316. var ATTR_INDICATOR_STYLE = 'indicatorStyle';
  6317. var ATTR_MASK_CLASS = 'maskClass';
  6318. var ATTR_MASK_STYLE = 'maskStyle';
  6319. var CLASS_AND_STYLES = {
  6320. view: {
  6321. class: [ATTR_HOVER_CLASS],
  6322. style: []
  6323. },
  6324. button: {
  6325. class: [ATTR_HOVER_CLASS],
  6326. style: []
  6327. },
  6328. navigator: {
  6329. class: [ATTR_HOVER_CLASS],
  6330. style: []
  6331. },
  6332. 'u-input': {
  6333. class: [ATTR_PLACEHOLDER_CLASS],
  6334. style: [ATTR_PLACEHOLDER_STYLE]
  6335. },
  6336. 'u-textarea': {
  6337. class: [ATTR_PLACEHOLDER_CLASS],
  6338. style: [ATTR_PLACEHOLDER_STYLE]
  6339. },
  6340. 'picker-view': {
  6341. class: [ATTR_INDICATOR_CLASS, ATTR_MASK_CLASS],
  6342. style: [ATTR_INDICATOR_STYLE, ATTR_MASK_STYLE]
  6343. }
  6344. };
  6345. function transformAttr(el, key, value, instance) {
  6346. if (!value) {
  6347. return [key, value];
  6348. }
  6349. var opts = CLASS_AND_STYLES[el.type];
  6350. if (opts) {
  6351. var camelized = camelize(key);
  6352. if (opts['class'].indexOf(camelized) > -1) {
  6353. return [camelized, parseClassList([value], instance, el)];
  6354. }
  6355. if (opts['style'].indexOf(key) > -1) {
  6356. if (isString(value)) {
  6357. return [camelized, parseStringStyle(value)];
  6358. }
  6359. return [camelized, normalizeStyle(value)];
  6360. }
  6361. }
  6362. return [key, value];
  6363. }
  6364. /**
  6365. * 当前仅 patch 到 el 中,真正更新则是在 el 中
  6366. * @param el
  6367. * @param pre
  6368. * @param next
  6369. * @param instance
  6370. * @returns
  6371. */
  6372. function patchClass(el, pre, next) {
  6373. var instance = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  6374. if (!instance) {
  6375. return;
  6376. }
  6377. var classList = next ? next.split(' ') : [];
  6378. el.setClassList(classList);
  6379. el.setStyleSheet(parseStyleSheet(instance));
  6380. }
  6381. function addEventListener(el, event, handler, options) {
  6382. el.addEvent(event, handler);
  6383. }
  6384. function removeEventListener(el, event) {
  6385. el.removeEvent(event);
  6386. }
  6387. function patchEvent(el, rawName, prevValue, nextValue) {
  6388. var instance = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  6389. // vei = vue event invokers
  6390. var invokers = el._vei || (el._vei = {});
  6391. var existingInvoker = invokers[rawName];
  6392. if (nextValue && existingInvoker) {
  6393. // patch
  6394. existingInvoker.value = nextValue;
  6395. } else {
  6396. var [name, options] = parseName(rawName);
  6397. if (nextValue) {
  6398. // add
  6399. var invoker = invokers[rawName] = createInvoker(nextValue, instance);
  6400. addEventListener(el, name, invoker);
  6401. } else if (existingInvoker) {
  6402. // remove
  6403. removeEventListener(el, name);
  6404. invokers[rawName] = undefined;
  6405. }
  6406. }
  6407. }
  6408. var optionsModifierRE = /(?:Once|Passive|Capture)$/;
  6409. function formatEventName(name) {
  6410. if (name === 'on-post-message') {
  6411. return 'onPostMessage';
  6412. }
  6413. return name;
  6414. }
  6415. function parseName(name) {
  6416. var options;
  6417. if (optionsModifierRE.test(name)) {
  6418. options = {};
  6419. var m;
  6420. while (m = name.match(optionsModifierRE)) {
  6421. name = name.slice(0, name.length - m[0].length);
  6422. options[m[0].toLowerCase()] = true;
  6423. }
  6424. }
  6425. var event = name[2] === ':' ? name.slice(3) : name.slice(2);
  6426. return [formatEventName(hyphenate(event)), options];
  6427. }
  6428. function createInvoker(initialValue, instance) {
  6429. var invoker = e => {
  6430. callWithAsyncErrorHandling(invoker.value, instance, 5 /* ErrorCodes.NATIVE_EVENT_HANDLER */, [e]);
  6431. };
  6432. invoker.value = initialValue;
  6433. var modifiers = new Set();
  6434. // 合并 modifiers
  6435. if (isArray(invoker.value)) {
  6436. invoker.value.forEach(v => {
  6437. if (v.modifiers) {
  6438. v.modifiers.forEach(m => {
  6439. modifiers.add(m);
  6440. });
  6441. }
  6442. });
  6443. } else {
  6444. if (invoker.value.modifiers) {
  6445. invoker.value.modifiers.forEach(m => {
  6446. modifiers.add(m);
  6447. });
  6448. }
  6449. }
  6450. invoker.modifiers = [...modifiers];
  6451. return invoker;
  6452. }
  6453. function patchStyle(el, prev, next) {
  6454. if (!next) {
  6455. // TODO remove styles
  6456. // el.setStyles({})
  6457. return;
  6458. }
  6459. if (isString(next)) {
  6460. next = parseStringStyle(next);
  6461. }
  6462. var batchedStyles = {};
  6463. var isPrevObj = prev && !isString(prev);
  6464. if (isPrevObj) {
  6465. for (var key in prev) {
  6466. if (next[key] == null) {
  6467. batchedStyles[camelize(key)] = '';
  6468. }
  6469. }
  6470. for (var _key10 in next) {
  6471. var value = next[_key10];
  6472. if (value !== prev[_key10]) {
  6473. batchedStyles[camelize(_key10)] = value;
  6474. }
  6475. }
  6476. } else {
  6477. for (var _key11 in next) {
  6478. batchedStyles[camelize(_key11)] = next[_key11];
  6479. }
  6480. }
  6481. el.setStyles(batchedStyles);
  6482. }
  6483. var vModelTags = ['u-input', 'u-textarea'];
  6484. var patchProp = function (el, key, prevValue, nextValue) {
  6485. var isSVG = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  6486. var prevChildren = arguments.length > 5 ? arguments[5] : undefined;
  6487. var parentComponent = arguments.length > 6 ? arguments[6] : undefined;
  6488. var parentSuspense = arguments.length > 7 ? arguments[7] : undefined;
  6489. var unmountChildren = arguments.length > 8 ? arguments[8] : undefined;
  6490. var hostInstance = arguments.length > 9 ? arguments[9] : undefined;
  6491. if (key === 'class') {
  6492. patchClass(el, prevValue, nextValue, hostInstance || parentComponent);
  6493. } else if (key === 'style') {
  6494. patchStyle(el, prevValue, nextValue);
  6495. } else if (isOn(key)) {
  6496. // ignore v-model listeners
  6497. if (!isModelListener(key)) {
  6498. patchEvent(el, key, prevValue, nextValue, parentComponent);
  6499. }
  6500. } else if (key === 'modelValue' && vModelTags.includes(el.type)) {
  6501. // v-model 时,原生 input 和 textarea 接收的是 value
  6502. el.setAttrs({
  6503. modelValue: nextValue,
  6504. value: nextValue
  6505. });
  6506. } else {
  6507. patchAttr(el, key, nextValue, parentComponent);
  6508. }
  6509. };
  6510. function useCssModule() {
  6511. var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '$style';
  6512. /* istanbul ignore else */
  6513. {
  6514. var instance = getCurrentInstance();
  6515. if (!instance) {
  6516. return EMPTY_OBJ;
  6517. }
  6518. var modules = instance.type.__cssModules;
  6519. if (!modules) {
  6520. return EMPTY_OBJ;
  6521. }
  6522. var mod = modules[name];
  6523. if (!mod) {
  6524. return EMPTY_OBJ;
  6525. }
  6526. return mod;
  6527. }
  6528. }
  6529. /**
  6530. * Runtime helper for SFC's CSS variable injection feature.
  6531. * @private
  6532. */
  6533. function useCssVars(getter) {
  6534. var instance = getCurrentInstance();
  6535. /* istanbul ignore next */
  6536. if (!instance) {
  6537. return;
  6538. }
  6539. var setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
  6540. onMounted(() => watchEffect(setVars, {
  6541. flush: 'post'
  6542. }));
  6543. onUpdated(setVars);
  6544. }
  6545. function setVarsOnVNode(vnode, vars) {
  6546. if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  6547. var suspense = vnode.suspense;
  6548. vnode = suspense.activeBranch;
  6549. if (suspense.pendingBranch && !suspense.isHydrating) {
  6550. suspense.effects.push(() => {
  6551. setVarsOnVNode(suspense.activeBranch, vars);
  6552. });
  6553. }
  6554. }
  6555. // drill down HOCs until it's a non-component vnode
  6556. while (vnode.component) {
  6557. vnode = vnode.component.subTree;
  6558. }
  6559. if (vnode.shapeFlag & 1 /* ShapeFlags.ELEMENT */ && vnode.el) {
  6560. var style = vnode.el.style;
  6561. for (var key in vars) {
  6562. style.setProperty("--".concat(key), vars[key]);
  6563. }
  6564. } else if (vnode.type === Fragment) {
  6565. vnode.children.forEach(c => setVarsOnVNode(c, vars));
  6566. }
  6567. }
  6568. var systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
  6569. var modifierGuards = {
  6570. stop: e => e.stopPropagation(),
  6571. prevent: e => e.preventDefault(),
  6572. self: e => e.target !== e.currentTarget,
  6573. ctrl: e => !e.ctrlKey,
  6574. shift: e => !e.shiftKey,
  6575. alt: e => !e.altKey,
  6576. meta: e => !e.metaKey,
  6577. left: e => 'button' in e && e.button !== 0,
  6578. middle: e => 'button' in e && e.button !== 1,
  6579. right: e => 'button' in e && e.button !== 2,
  6580. exact: (e, modifiers) => systemModifiers.some(m => e["".concat(m, "Key")] && !modifiers.includes(m))
  6581. };
  6582. /**
  6583. * @private
  6584. */
  6585. var withModifiers = (fn, modifiers) => {
  6586. return function (event) {
  6587. for (var i = 0; i < modifiers.length; i++) {
  6588. var guard = modifierGuards[modifiers[i]];
  6589. if (guard && guard(event, modifiers)) return;
  6590. }
  6591. for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key12 = 1; _key12 < _len4; _key12++) {
  6592. args[_key12 - 1] = arguments[_key12];
  6593. }
  6594. return fn(event, ...args);
  6595. };
  6596. };
  6597. /**
  6598. * @private
  6599. */
  6600. var withKeys = (fn, modifiers) => {
  6601. return event => {
  6602. if (!('key' in event)) {
  6603. return;
  6604. }
  6605. var eventKey = hyphenate(event.key);
  6606. if (modifiers.some(k => k === eventKey)) {
  6607. return fn(event);
  6608. }
  6609. };
  6610. };
  6611. var rendererOptions = extend({
  6612. patchProp
  6613. }, nodeOps);
  6614. // lazy create the renderer - this makes core renderer logic tree-shakable
  6615. // in case the user only imports reactivity utilities from Vue.
  6616. var renderer;
  6617. function ensureRenderer() {
  6618. return renderer || (renderer = createRenderer(rendererOptions));
  6619. }
  6620. // use explicit type casts here to avoid import() calls in rolled-up d.ts
  6621. var render = function () {
  6622. ensureRenderer().render(...arguments);
  6623. };
  6624. var createApp = function () {
  6625. var app = ensureRenderer().createApp(...arguments);
  6626. var {
  6627. mount
  6628. } = app;
  6629. app.mount = container => {
  6630. return mount(container);
  6631. };
  6632. return app;
  6633. };
  6634. export { BaseTransition, BaseTransitionPropsValidators, Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compatUtils, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, defineEmits, defineExpose, defineProps, devtools, getCurrentInstance, getTransitionRawChildren, guardReactiveProps, h, handleError, initCustomFormatter, inject, injectHook, isInSSRComponentSetup, isMemoSame, isRuntimeOnly, isVNode, mergeDefaults, mergeProps, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onServerPrefetch, onUnmounted, onUpdated, openBlock, parseClassList, parseClassStyles, popScopeId, provide, pushScopeId, queuePostFlushCb, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, ssrContextKey, ssrUtils, toHandlers, transformVNodeArgs, useAttrs, useCssModule, useCssStyles, useCssVars, useSSRContext, useSlots, useTransitionState, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };