vue.runtime.esm.prod.js 236 KB

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