vue.runtime.global.js 348 KB

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