nvue.runtime.esm.dev.js 280 KB

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