a7688d4984d118bb7fc1b94b6cd483c222313141d39943acbeb5227e658f783ea975f00f7ed99b8c4c4d2a859db86dc72de1774b85056bc367a42f5e4c4947 189 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605
  1. /**
  2. * @vue/compiler-dom v3.5.21
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. // @__NO_SIDE_EFFECTS__
  7. function makeMap(str) {
  8. const map = /* @__PURE__ */ Object.create(null);
  9. for (const key of str.split(",")) map[key] = 1;
  10. return (val) => val in map;
  11. }
  12. const EMPTY_OBJ = Object.freeze({}) ;
  13. const NOOP = () => {
  14. };
  15. const NO = () => false;
  16. const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
  17. (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
  18. const extend = Object.assign;
  19. const isArray = Array.isArray;
  20. const isString = (val) => typeof val === "string";
  21. const isSymbol = (val) => typeof val === "symbol";
  22. const isObject = (val) => val !== null && typeof val === "object";
  23. const isReservedProp = /* @__PURE__ */ makeMap(
  24. // the leading comma is intentional so empty string "" is also included
  25. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  26. );
  27. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  28. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  29. );
  30. const cacheStringFunction = (fn) => {
  31. const cache = /* @__PURE__ */ Object.create(null);
  32. return ((str) => {
  33. const hit = cache[str];
  34. return hit || (cache[str] = fn(str));
  35. });
  36. };
  37. const camelizeRE = /-\w/g;
  38. const camelize = cacheStringFunction(
  39. (str) => {
  40. return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
  41. }
  42. );
  43. const capitalize = cacheStringFunction((str) => {
  44. return str.charAt(0).toUpperCase() + str.slice(1);
  45. });
  46. const toHandlerKey = cacheStringFunction(
  47. (str) => {
  48. const s = str ? `on${capitalize(str)}` : ``;
  49. return s;
  50. }
  51. );
  52. const PatchFlagNames = {
  53. [1]: `TEXT`,
  54. [2]: `CLASS`,
  55. [4]: `STYLE`,
  56. [8]: `PROPS`,
  57. [16]: `FULL_PROPS`,
  58. [32]: `NEED_HYDRATION`,
  59. [64]: `STABLE_FRAGMENT`,
  60. [128]: `KEYED_FRAGMENT`,
  61. [256]: `UNKEYED_FRAGMENT`,
  62. [512]: `NEED_PATCH`,
  63. [1024]: `DYNAMIC_SLOTS`,
  64. [2048]: `DEV_ROOT_FRAGMENT`,
  65. [-1]: `CACHED`,
  66. [-2]: `BAIL`
  67. };
  68. const slotFlagsText = {
  69. [1]: "STABLE",
  70. [2]: "DYNAMIC",
  71. [3]: "FORWARDED"
  72. };
  73. const range = 2;
  74. function generateCodeFrame(source, start = 0, end = source.length) {
  75. start = Math.max(0, Math.min(start, source.length));
  76. end = Math.max(0, Math.min(end, source.length));
  77. if (start > end) return "";
  78. let lines = source.split(/(\r?\n)/);
  79. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  80. lines = lines.filter((_, idx) => idx % 2 === 0);
  81. let count = 0;
  82. const res = [];
  83. for (let i = 0; i < lines.length; i++) {
  84. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  85. if (count >= start) {
  86. for (let j = i - range; j <= i + range || end > count; j++) {
  87. if (j < 0 || j >= lines.length) continue;
  88. const line = j + 1;
  89. res.push(
  90. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  91. );
  92. const lineLength = lines[j].length;
  93. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  94. if (j === i) {
  95. const pad = start - (count - (lineLength + newLineSeqLength));
  96. const length = Math.max(
  97. 1,
  98. end > count ? lineLength - pad : end - start
  99. );
  100. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  101. } else if (j > i) {
  102. if (end > count) {
  103. const length = Math.max(Math.min(end - count, lineLength), 1);
  104. res.push(` | ` + "^".repeat(length));
  105. }
  106. count += lineLength + newLineSeqLength;
  107. }
  108. }
  109. break;
  110. }
  111. }
  112. return res.join("\n");
  113. }
  114. const listDelimiterRE = /;(?![^(]*\))/g;
  115. const propertyDelimiterRE = /:([^]+)/;
  116. const styleCommentRE = /\/\*[^]*?\*\//g;
  117. function parseStringStyle(cssText) {
  118. const ret = {};
  119. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  120. if (item) {
  121. const tmp = item.split(propertyDelimiterRE);
  122. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  123. }
  124. });
  125. return ret;
  126. }
  127. const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
  128. const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
  129. const MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
  130. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  131. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  132. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  133. const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
  134. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  135. const FRAGMENT = Symbol(`Fragment` );
  136. const TELEPORT = Symbol(`Teleport` );
  137. const SUSPENSE = Symbol(`Suspense` );
  138. const KEEP_ALIVE = Symbol(`KeepAlive` );
  139. const BASE_TRANSITION = Symbol(
  140. `BaseTransition`
  141. );
  142. const OPEN_BLOCK = Symbol(`openBlock` );
  143. const CREATE_BLOCK = Symbol(`createBlock` );
  144. const CREATE_ELEMENT_BLOCK = Symbol(
  145. `createElementBlock`
  146. );
  147. const CREATE_VNODE = Symbol(`createVNode` );
  148. const CREATE_ELEMENT_VNODE = Symbol(
  149. `createElementVNode`
  150. );
  151. const CREATE_COMMENT = Symbol(
  152. `createCommentVNode`
  153. );
  154. const CREATE_TEXT = Symbol(
  155. `createTextVNode`
  156. );
  157. const CREATE_STATIC = Symbol(
  158. `createStaticVNode`
  159. );
  160. const RESOLVE_COMPONENT = Symbol(
  161. `resolveComponent`
  162. );
  163. const RESOLVE_DYNAMIC_COMPONENT = Symbol(
  164. `resolveDynamicComponent`
  165. );
  166. const RESOLVE_DIRECTIVE = Symbol(
  167. `resolveDirective`
  168. );
  169. const RESOLVE_FILTER = Symbol(
  170. `resolveFilter`
  171. );
  172. const WITH_DIRECTIVES = Symbol(
  173. `withDirectives`
  174. );
  175. const RENDER_LIST = Symbol(`renderList` );
  176. const RENDER_SLOT = Symbol(`renderSlot` );
  177. const CREATE_SLOTS = Symbol(`createSlots` );
  178. const TO_DISPLAY_STRING = Symbol(
  179. `toDisplayString`
  180. );
  181. const MERGE_PROPS = Symbol(`mergeProps` );
  182. const NORMALIZE_CLASS = Symbol(
  183. `normalizeClass`
  184. );
  185. const NORMALIZE_STYLE = Symbol(
  186. `normalizeStyle`
  187. );
  188. const NORMALIZE_PROPS = Symbol(
  189. `normalizeProps`
  190. );
  191. const GUARD_REACTIVE_PROPS = Symbol(
  192. `guardReactiveProps`
  193. );
  194. const TO_HANDLERS = Symbol(`toHandlers` );
  195. const CAMELIZE = Symbol(`camelize` );
  196. const CAPITALIZE = Symbol(`capitalize` );
  197. const TO_HANDLER_KEY = Symbol(
  198. `toHandlerKey`
  199. );
  200. const SET_BLOCK_TRACKING = Symbol(
  201. `setBlockTracking`
  202. );
  203. const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
  204. const POP_SCOPE_ID = Symbol(`popScopeId` );
  205. const WITH_CTX = Symbol(`withCtx` );
  206. const UNREF = Symbol(`unref` );
  207. const IS_REF = Symbol(`isRef` );
  208. const WITH_MEMO = Symbol(`withMemo` );
  209. const IS_MEMO_SAME = Symbol(`isMemoSame` );
  210. const helperNameMap = {
  211. [FRAGMENT]: `Fragment`,
  212. [TELEPORT]: `Teleport`,
  213. [SUSPENSE]: `Suspense`,
  214. [KEEP_ALIVE]: `KeepAlive`,
  215. [BASE_TRANSITION]: `BaseTransition`,
  216. [OPEN_BLOCK]: `openBlock`,
  217. [CREATE_BLOCK]: `createBlock`,
  218. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  219. [CREATE_VNODE]: `createVNode`,
  220. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  221. [CREATE_COMMENT]: `createCommentVNode`,
  222. [CREATE_TEXT]: `createTextVNode`,
  223. [CREATE_STATIC]: `createStaticVNode`,
  224. [RESOLVE_COMPONENT]: `resolveComponent`,
  225. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  226. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  227. [RESOLVE_FILTER]: `resolveFilter`,
  228. [WITH_DIRECTIVES]: `withDirectives`,
  229. [RENDER_LIST]: `renderList`,
  230. [RENDER_SLOT]: `renderSlot`,
  231. [CREATE_SLOTS]: `createSlots`,
  232. [TO_DISPLAY_STRING]: `toDisplayString`,
  233. [MERGE_PROPS]: `mergeProps`,
  234. [NORMALIZE_CLASS]: `normalizeClass`,
  235. [NORMALIZE_STYLE]: `normalizeStyle`,
  236. [NORMALIZE_PROPS]: `normalizeProps`,
  237. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  238. [TO_HANDLERS]: `toHandlers`,
  239. [CAMELIZE]: `camelize`,
  240. [CAPITALIZE]: `capitalize`,
  241. [TO_HANDLER_KEY]: `toHandlerKey`,
  242. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  243. [PUSH_SCOPE_ID]: `pushScopeId`,
  244. [POP_SCOPE_ID]: `popScopeId`,
  245. [WITH_CTX]: `withCtx`,
  246. [UNREF]: `unref`,
  247. [IS_REF]: `isRef`,
  248. [WITH_MEMO]: `withMemo`,
  249. [IS_MEMO_SAME]: `isMemoSame`
  250. };
  251. function registerRuntimeHelpers(helpers) {
  252. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  253. helperNameMap[s] = helpers[s];
  254. });
  255. }
  256. const Namespaces = {
  257. "HTML": 0,
  258. "0": "HTML",
  259. "SVG": 1,
  260. "1": "SVG",
  261. "MATH_ML": 2,
  262. "2": "MATH_ML"
  263. };
  264. const NodeTypes = {
  265. "ROOT": 0,
  266. "0": "ROOT",
  267. "ELEMENT": 1,
  268. "1": "ELEMENT",
  269. "TEXT": 2,
  270. "2": "TEXT",
  271. "COMMENT": 3,
  272. "3": "COMMENT",
  273. "SIMPLE_EXPRESSION": 4,
  274. "4": "SIMPLE_EXPRESSION",
  275. "INTERPOLATION": 5,
  276. "5": "INTERPOLATION",
  277. "ATTRIBUTE": 6,
  278. "6": "ATTRIBUTE",
  279. "DIRECTIVE": 7,
  280. "7": "DIRECTIVE",
  281. "COMPOUND_EXPRESSION": 8,
  282. "8": "COMPOUND_EXPRESSION",
  283. "IF": 9,
  284. "9": "IF",
  285. "IF_BRANCH": 10,
  286. "10": "IF_BRANCH",
  287. "FOR": 11,
  288. "11": "FOR",
  289. "TEXT_CALL": 12,
  290. "12": "TEXT_CALL",
  291. "VNODE_CALL": 13,
  292. "13": "VNODE_CALL",
  293. "JS_CALL_EXPRESSION": 14,
  294. "14": "JS_CALL_EXPRESSION",
  295. "JS_OBJECT_EXPRESSION": 15,
  296. "15": "JS_OBJECT_EXPRESSION",
  297. "JS_PROPERTY": 16,
  298. "16": "JS_PROPERTY",
  299. "JS_ARRAY_EXPRESSION": 17,
  300. "17": "JS_ARRAY_EXPRESSION",
  301. "JS_FUNCTION_EXPRESSION": 18,
  302. "18": "JS_FUNCTION_EXPRESSION",
  303. "JS_CONDITIONAL_EXPRESSION": 19,
  304. "19": "JS_CONDITIONAL_EXPRESSION",
  305. "JS_CACHE_EXPRESSION": 20,
  306. "20": "JS_CACHE_EXPRESSION",
  307. "JS_BLOCK_STATEMENT": 21,
  308. "21": "JS_BLOCK_STATEMENT",
  309. "JS_TEMPLATE_LITERAL": 22,
  310. "22": "JS_TEMPLATE_LITERAL",
  311. "JS_IF_STATEMENT": 23,
  312. "23": "JS_IF_STATEMENT",
  313. "JS_ASSIGNMENT_EXPRESSION": 24,
  314. "24": "JS_ASSIGNMENT_EXPRESSION",
  315. "JS_SEQUENCE_EXPRESSION": 25,
  316. "25": "JS_SEQUENCE_EXPRESSION",
  317. "JS_RETURN_STATEMENT": 26,
  318. "26": "JS_RETURN_STATEMENT"
  319. };
  320. const ElementTypes = {
  321. "ELEMENT": 0,
  322. "0": "ELEMENT",
  323. "COMPONENT": 1,
  324. "1": "COMPONENT",
  325. "SLOT": 2,
  326. "2": "SLOT",
  327. "TEMPLATE": 3,
  328. "3": "TEMPLATE"
  329. };
  330. const ConstantTypes = {
  331. "NOT_CONSTANT": 0,
  332. "0": "NOT_CONSTANT",
  333. "CAN_SKIP_PATCH": 1,
  334. "1": "CAN_SKIP_PATCH",
  335. "CAN_CACHE": 2,
  336. "2": "CAN_CACHE",
  337. "CAN_STRINGIFY": 3,
  338. "3": "CAN_STRINGIFY"
  339. };
  340. const locStub = {
  341. start: { line: 1, column: 1, offset: 0 },
  342. end: { line: 1, column: 1, offset: 0 },
  343. source: ""
  344. };
  345. function createRoot(children, source = "") {
  346. return {
  347. type: 0,
  348. source,
  349. children,
  350. helpers: /* @__PURE__ */ new Set(),
  351. components: [],
  352. directives: [],
  353. hoists: [],
  354. imports: [],
  355. cached: [],
  356. temps: 0,
  357. codegenNode: void 0,
  358. loc: locStub
  359. };
  360. }
  361. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  362. if (context) {
  363. if (isBlock) {
  364. context.helper(OPEN_BLOCK);
  365. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  366. } else {
  367. context.helper(getVNodeHelper(context.inSSR, isComponent));
  368. }
  369. if (directives) {
  370. context.helper(WITH_DIRECTIVES);
  371. }
  372. }
  373. return {
  374. type: 13,
  375. tag,
  376. props,
  377. children,
  378. patchFlag,
  379. dynamicProps,
  380. directives,
  381. isBlock,
  382. disableTracking,
  383. isComponent,
  384. loc
  385. };
  386. }
  387. function createArrayExpression(elements, loc = locStub) {
  388. return {
  389. type: 17,
  390. loc,
  391. elements
  392. };
  393. }
  394. function createObjectExpression(properties, loc = locStub) {
  395. return {
  396. type: 15,
  397. loc,
  398. properties
  399. };
  400. }
  401. function createObjectProperty(key, value) {
  402. return {
  403. type: 16,
  404. loc: locStub,
  405. key: isString(key) ? createSimpleExpression(key, true) : key,
  406. value
  407. };
  408. }
  409. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  410. return {
  411. type: 4,
  412. loc,
  413. content,
  414. isStatic,
  415. constType: isStatic ? 3 : constType
  416. };
  417. }
  418. function createInterpolation(content, loc) {
  419. return {
  420. type: 5,
  421. loc,
  422. content: isString(content) ? createSimpleExpression(content, false, loc) : content
  423. };
  424. }
  425. function createCompoundExpression(children, loc = locStub) {
  426. return {
  427. type: 8,
  428. loc,
  429. children
  430. };
  431. }
  432. function createCallExpression(callee, args = [], loc = locStub) {
  433. return {
  434. type: 14,
  435. loc,
  436. callee,
  437. arguments: args
  438. };
  439. }
  440. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  441. return {
  442. type: 18,
  443. params,
  444. returns,
  445. newline,
  446. isSlot,
  447. loc
  448. };
  449. }
  450. function createConditionalExpression(test, consequent, alternate, newline = true) {
  451. return {
  452. type: 19,
  453. test,
  454. consequent,
  455. alternate,
  456. newline,
  457. loc: locStub
  458. };
  459. }
  460. function createCacheExpression(index, value, needPauseTracking = false, inVOnce = false) {
  461. return {
  462. type: 20,
  463. index,
  464. value,
  465. needPauseTracking,
  466. inVOnce,
  467. needArraySpread: false,
  468. loc: locStub
  469. };
  470. }
  471. function createBlockStatement(body) {
  472. return {
  473. type: 21,
  474. body,
  475. loc: locStub
  476. };
  477. }
  478. function createTemplateLiteral(elements) {
  479. return {
  480. type: 22,
  481. elements,
  482. loc: locStub
  483. };
  484. }
  485. function createIfStatement(test, consequent, alternate) {
  486. return {
  487. type: 23,
  488. test,
  489. consequent,
  490. alternate,
  491. loc: locStub
  492. };
  493. }
  494. function createAssignmentExpression(left, right) {
  495. return {
  496. type: 24,
  497. left,
  498. right,
  499. loc: locStub
  500. };
  501. }
  502. function createSequenceExpression(expressions) {
  503. return {
  504. type: 25,
  505. expressions,
  506. loc: locStub
  507. };
  508. }
  509. function createReturnStatement(returns) {
  510. return {
  511. type: 26,
  512. returns,
  513. loc: locStub
  514. };
  515. }
  516. function getVNodeHelper(ssr, isComponent) {
  517. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  518. }
  519. function getVNodeBlockHelper(ssr, isComponent) {
  520. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  521. }
  522. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  523. if (!node.isBlock) {
  524. node.isBlock = true;
  525. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  526. helper(OPEN_BLOCK);
  527. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  528. }
  529. }
  530. const defaultDelimitersOpen = new Uint8Array([123, 123]);
  531. const defaultDelimitersClose = new Uint8Array([125, 125]);
  532. function isTagStartChar(c) {
  533. return c >= 97 && c <= 122 || c >= 65 && c <= 90;
  534. }
  535. function isWhitespace(c) {
  536. return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
  537. }
  538. function isEndOfTagSection(c) {
  539. return c === 47 || c === 62 || isWhitespace(c);
  540. }
  541. function toCharCodes(str) {
  542. const ret = new Uint8Array(str.length);
  543. for (let i = 0; i < str.length; i++) {
  544. ret[i] = str.charCodeAt(i);
  545. }
  546. return ret;
  547. }
  548. const Sequences = {
  549. Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
  550. // CDATA[
  551. CdataEnd: new Uint8Array([93, 93, 62]),
  552. // ]]>
  553. CommentEnd: new Uint8Array([45, 45, 62]),
  554. // `-->`
  555. ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
  556. // `<\/script`
  557. StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
  558. // `</style`
  559. TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
  560. // `</title`
  561. TextareaEnd: new Uint8Array([
  562. 60,
  563. 47,
  564. 116,
  565. 101,
  566. 120,
  567. 116,
  568. 97,
  569. 114,
  570. 101,
  571. 97
  572. ])
  573. // `</textarea
  574. };
  575. class Tokenizer {
  576. constructor(stack, cbs) {
  577. this.stack = stack;
  578. this.cbs = cbs;
  579. /** The current state the tokenizer is in. */
  580. this.state = 1;
  581. /** The read buffer. */
  582. this.buffer = "";
  583. /** The beginning of the section that is currently being read. */
  584. this.sectionStart = 0;
  585. /** The index within the buffer that we are currently looking at. */
  586. this.index = 0;
  587. /** The start of the last entity. */
  588. this.entityStart = 0;
  589. /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
  590. this.baseState = 1;
  591. /** For special parsing behavior inside of script and style tags. */
  592. this.inRCDATA = false;
  593. /** For disabling RCDATA tags handling */
  594. this.inXML = false;
  595. /** For disabling interpolation parsing in v-pre */
  596. this.inVPre = false;
  597. /** Record newline positions for fast line / column calculation */
  598. this.newlines = [];
  599. this.mode = 0;
  600. this.delimiterOpen = defaultDelimitersOpen;
  601. this.delimiterClose = defaultDelimitersClose;
  602. this.delimiterIndex = -1;
  603. this.currentSequence = void 0;
  604. this.sequenceIndex = 0;
  605. }
  606. get inSFCRoot() {
  607. return this.mode === 2 && this.stack.length === 0;
  608. }
  609. reset() {
  610. this.state = 1;
  611. this.mode = 0;
  612. this.buffer = "";
  613. this.sectionStart = 0;
  614. this.index = 0;
  615. this.baseState = 1;
  616. this.inRCDATA = false;
  617. this.currentSequence = void 0;
  618. this.newlines.length = 0;
  619. this.delimiterOpen = defaultDelimitersOpen;
  620. this.delimiterClose = defaultDelimitersClose;
  621. }
  622. /**
  623. * Generate Position object with line / column information using recorded
  624. * newline positions. We know the index is always going to be an already
  625. * processed index, so all the newlines up to this index should have been
  626. * recorded.
  627. */
  628. getPos(index) {
  629. let line = 1;
  630. let column = index + 1;
  631. for (let i = this.newlines.length - 1; i >= 0; i--) {
  632. const newlineIndex = this.newlines[i];
  633. if (index > newlineIndex) {
  634. line = i + 2;
  635. column = index - newlineIndex;
  636. break;
  637. }
  638. }
  639. return {
  640. column,
  641. line,
  642. offset: index
  643. };
  644. }
  645. peek() {
  646. return this.buffer.charCodeAt(this.index + 1);
  647. }
  648. stateText(c) {
  649. if (c === 60) {
  650. if (this.index > this.sectionStart) {
  651. this.cbs.ontext(this.sectionStart, this.index);
  652. }
  653. this.state = 5;
  654. this.sectionStart = this.index;
  655. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  656. this.state = 2;
  657. this.delimiterIndex = 0;
  658. this.stateInterpolationOpen(c);
  659. }
  660. }
  661. stateInterpolationOpen(c) {
  662. if (c === this.delimiterOpen[this.delimiterIndex]) {
  663. if (this.delimiterIndex === this.delimiterOpen.length - 1) {
  664. const start = this.index + 1 - this.delimiterOpen.length;
  665. if (start > this.sectionStart) {
  666. this.cbs.ontext(this.sectionStart, start);
  667. }
  668. this.state = 3;
  669. this.sectionStart = start;
  670. } else {
  671. this.delimiterIndex++;
  672. }
  673. } else if (this.inRCDATA) {
  674. this.state = 32;
  675. this.stateInRCDATA(c);
  676. } else {
  677. this.state = 1;
  678. this.stateText(c);
  679. }
  680. }
  681. stateInterpolation(c) {
  682. if (c === this.delimiterClose[0]) {
  683. this.state = 4;
  684. this.delimiterIndex = 0;
  685. this.stateInterpolationClose(c);
  686. }
  687. }
  688. stateInterpolationClose(c) {
  689. if (c === this.delimiterClose[this.delimiterIndex]) {
  690. if (this.delimiterIndex === this.delimiterClose.length - 1) {
  691. this.cbs.oninterpolation(this.sectionStart, this.index + 1);
  692. if (this.inRCDATA) {
  693. this.state = 32;
  694. } else {
  695. this.state = 1;
  696. }
  697. this.sectionStart = this.index + 1;
  698. } else {
  699. this.delimiterIndex++;
  700. }
  701. } else {
  702. this.state = 3;
  703. this.stateInterpolation(c);
  704. }
  705. }
  706. stateSpecialStartSequence(c) {
  707. const isEnd = this.sequenceIndex === this.currentSequence.length;
  708. const isMatch = isEnd ? (
  709. // If we are at the end of the sequence, make sure the tag name has ended
  710. isEndOfTagSection(c)
  711. ) : (
  712. // Otherwise, do a case-insensitive comparison
  713. (c | 32) === this.currentSequence[this.sequenceIndex]
  714. );
  715. if (!isMatch) {
  716. this.inRCDATA = false;
  717. } else if (!isEnd) {
  718. this.sequenceIndex++;
  719. return;
  720. }
  721. this.sequenceIndex = 0;
  722. this.state = 6;
  723. this.stateInTagName(c);
  724. }
  725. /** Look for an end tag. For <title> and <textarea>, also decode entities. */
  726. stateInRCDATA(c) {
  727. if (this.sequenceIndex === this.currentSequence.length) {
  728. if (c === 62 || isWhitespace(c)) {
  729. const endOfText = this.index - this.currentSequence.length;
  730. if (this.sectionStart < endOfText) {
  731. const actualIndex = this.index;
  732. this.index = endOfText;
  733. this.cbs.ontext(this.sectionStart, endOfText);
  734. this.index = actualIndex;
  735. }
  736. this.sectionStart = endOfText + 2;
  737. this.stateInClosingTagName(c);
  738. this.inRCDATA = false;
  739. return;
  740. }
  741. this.sequenceIndex = 0;
  742. }
  743. if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
  744. this.sequenceIndex += 1;
  745. } else if (this.sequenceIndex === 0) {
  746. if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
  747. if (!this.inVPre && c === this.delimiterOpen[0]) {
  748. this.state = 2;
  749. this.delimiterIndex = 0;
  750. this.stateInterpolationOpen(c);
  751. }
  752. } else if (this.fastForwardTo(60)) {
  753. this.sequenceIndex = 1;
  754. }
  755. } else {
  756. this.sequenceIndex = Number(c === 60);
  757. }
  758. }
  759. stateCDATASequence(c) {
  760. if (c === Sequences.Cdata[this.sequenceIndex]) {
  761. if (++this.sequenceIndex === Sequences.Cdata.length) {
  762. this.state = 28;
  763. this.currentSequence = Sequences.CdataEnd;
  764. this.sequenceIndex = 0;
  765. this.sectionStart = this.index + 1;
  766. }
  767. } else {
  768. this.sequenceIndex = 0;
  769. this.state = 23;
  770. this.stateInDeclaration(c);
  771. }
  772. }
  773. /**
  774. * When we wait for one specific character, we can speed things up
  775. * by skipping through the buffer until we find it.
  776. *
  777. * @returns Whether the character was found.
  778. */
  779. fastForwardTo(c) {
  780. while (++this.index < this.buffer.length) {
  781. const cc = this.buffer.charCodeAt(this.index);
  782. if (cc === 10) {
  783. this.newlines.push(this.index);
  784. }
  785. if (cc === c) {
  786. return true;
  787. }
  788. }
  789. this.index = this.buffer.length - 1;
  790. return false;
  791. }
  792. /**
  793. * Comments and CDATA end with `-->` and `]]>`.
  794. *
  795. * Their common qualities are:
  796. * - Their end sequences have a distinct character they start with.
  797. * - That character is then repeated, so we have to check multiple repeats.
  798. * - All characters but the start character of the sequence can be skipped.
  799. */
  800. stateInCommentLike(c) {
  801. if (c === this.currentSequence[this.sequenceIndex]) {
  802. if (++this.sequenceIndex === this.currentSequence.length) {
  803. if (this.currentSequence === Sequences.CdataEnd) {
  804. this.cbs.oncdata(this.sectionStart, this.index - 2);
  805. } else {
  806. this.cbs.oncomment(this.sectionStart, this.index - 2);
  807. }
  808. this.sequenceIndex = 0;
  809. this.sectionStart = this.index + 1;
  810. this.state = 1;
  811. }
  812. } else if (this.sequenceIndex === 0) {
  813. if (this.fastForwardTo(this.currentSequence[0])) {
  814. this.sequenceIndex = 1;
  815. }
  816. } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
  817. this.sequenceIndex = 0;
  818. }
  819. }
  820. startSpecial(sequence, offset) {
  821. this.enterRCDATA(sequence, offset);
  822. this.state = 31;
  823. }
  824. enterRCDATA(sequence, offset) {
  825. this.inRCDATA = true;
  826. this.currentSequence = sequence;
  827. this.sequenceIndex = offset;
  828. }
  829. stateBeforeTagName(c) {
  830. if (c === 33) {
  831. this.state = 22;
  832. this.sectionStart = this.index + 1;
  833. } else if (c === 63) {
  834. this.state = 24;
  835. this.sectionStart = this.index + 1;
  836. } else if (isTagStartChar(c)) {
  837. this.sectionStart = this.index;
  838. if (this.mode === 0) {
  839. this.state = 6;
  840. } else if (this.inSFCRoot) {
  841. this.state = 34;
  842. } else if (!this.inXML) {
  843. if (c === 116) {
  844. this.state = 30;
  845. } else {
  846. this.state = c === 115 ? 29 : 6;
  847. }
  848. } else {
  849. this.state = 6;
  850. }
  851. } else if (c === 47) {
  852. this.state = 8;
  853. } else {
  854. this.state = 1;
  855. this.stateText(c);
  856. }
  857. }
  858. stateInTagName(c) {
  859. if (isEndOfTagSection(c)) {
  860. this.handleTagName(c);
  861. }
  862. }
  863. stateInSFCRootTagName(c) {
  864. if (isEndOfTagSection(c)) {
  865. const tag = this.buffer.slice(this.sectionStart, this.index);
  866. if (tag !== "template") {
  867. this.enterRCDATA(toCharCodes(`</` + tag), 0);
  868. }
  869. this.handleTagName(c);
  870. }
  871. }
  872. handleTagName(c) {
  873. this.cbs.onopentagname(this.sectionStart, this.index);
  874. this.sectionStart = -1;
  875. this.state = 11;
  876. this.stateBeforeAttrName(c);
  877. }
  878. stateBeforeClosingTagName(c) {
  879. if (isWhitespace(c)) ; else if (c === 62) {
  880. {
  881. this.cbs.onerr(14, this.index);
  882. }
  883. this.state = 1;
  884. this.sectionStart = this.index + 1;
  885. } else {
  886. this.state = isTagStartChar(c) ? 9 : 27;
  887. this.sectionStart = this.index;
  888. }
  889. }
  890. stateInClosingTagName(c) {
  891. if (c === 62 || isWhitespace(c)) {
  892. this.cbs.onclosetag(this.sectionStart, this.index);
  893. this.sectionStart = -1;
  894. this.state = 10;
  895. this.stateAfterClosingTagName(c);
  896. }
  897. }
  898. stateAfterClosingTagName(c) {
  899. if (c === 62) {
  900. this.state = 1;
  901. this.sectionStart = this.index + 1;
  902. }
  903. }
  904. stateBeforeAttrName(c) {
  905. if (c === 62) {
  906. this.cbs.onopentagend(this.index);
  907. if (this.inRCDATA) {
  908. this.state = 32;
  909. } else {
  910. this.state = 1;
  911. }
  912. this.sectionStart = this.index + 1;
  913. } else if (c === 47) {
  914. this.state = 7;
  915. if (this.peek() !== 62) {
  916. this.cbs.onerr(22, this.index);
  917. }
  918. } else if (c === 60 && this.peek() === 47) {
  919. this.cbs.onopentagend(this.index);
  920. this.state = 5;
  921. this.sectionStart = this.index;
  922. } else if (!isWhitespace(c)) {
  923. if (c === 61) {
  924. this.cbs.onerr(
  925. 19,
  926. this.index
  927. );
  928. }
  929. this.handleAttrStart(c);
  930. }
  931. }
  932. handleAttrStart(c) {
  933. if (c === 118 && this.peek() === 45) {
  934. this.state = 13;
  935. this.sectionStart = this.index;
  936. } else if (c === 46 || c === 58 || c === 64 || c === 35) {
  937. this.cbs.ondirname(this.index, this.index + 1);
  938. this.state = 14;
  939. this.sectionStart = this.index + 1;
  940. } else {
  941. this.state = 12;
  942. this.sectionStart = this.index;
  943. }
  944. }
  945. stateInSelfClosingTag(c) {
  946. if (c === 62) {
  947. this.cbs.onselfclosingtag(this.index);
  948. this.state = 1;
  949. this.sectionStart = this.index + 1;
  950. this.inRCDATA = false;
  951. } else if (!isWhitespace(c)) {
  952. this.state = 11;
  953. this.stateBeforeAttrName(c);
  954. }
  955. }
  956. stateInAttrName(c) {
  957. if (c === 61 || isEndOfTagSection(c)) {
  958. this.cbs.onattribname(this.sectionStart, this.index);
  959. this.handleAttrNameEnd(c);
  960. } else if (c === 34 || c === 39 || c === 60) {
  961. this.cbs.onerr(
  962. 17,
  963. this.index
  964. );
  965. }
  966. }
  967. stateInDirName(c) {
  968. if (c === 61 || isEndOfTagSection(c)) {
  969. this.cbs.ondirname(this.sectionStart, this.index);
  970. this.handleAttrNameEnd(c);
  971. } else if (c === 58) {
  972. this.cbs.ondirname(this.sectionStart, this.index);
  973. this.state = 14;
  974. this.sectionStart = this.index + 1;
  975. } else if (c === 46) {
  976. this.cbs.ondirname(this.sectionStart, this.index);
  977. this.state = 16;
  978. this.sectionStart = this.index + 1;
  979. }
  980. }
  981. stateInDirArg(c) {
  982. if (c === 61 || isEndOfTagSection(c)) {
  983. this.cbs.ondirarg(this.sectionStart, this.index);
  984. this.handleAttrNameEnd(c);
  985. } else if (c === 91) {
  986. this.state = 15;
  987. } else if (c === 46) {
  988. this.cbs.ondirarg(this.sectionStart, this.index);
  989. this.state = 16;
  990. this.sectionStart = this.index + 1;
  991. }
  992. }
  993. stateInDynamicDirArg(c) {
  994. if (c === 93) {
  995. this.state = 14;
  996. } else if (c === 61 || isEndOfTagSection(c)) {
  997. this.cbs.ondirarg(this.sectionStart, this.index + 1);
  998. this.handleAttrNameEnd(c);
  999. {
  1000. this.cbs.onerr(
  1001. 27,
  1002. this.index
  1003. );
  1004. }
  1005. }
  1006. }
  1007. stateInDirModifier(c) {
  1008. if (c === 61 || isEndOfTagSection(c)) {
  1009. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1010. this.handleAttrNameEnd(c);
  1011. } else if (c === 46) {
  1012. this.cbs.ondirmodifier(this.sectionStart, this.index);
  1013. this.sectionStart = this.index + 1;
  1014. }
  1015. }
  1016. handleAttrNameEnd(c) {
  1017. this.sectionStart = this.index;
  1018. this.state = 17;
  1019. this.cbs.onattribnameend(this.index);
  1020. this.stateAfterAttrName(c);
  1021. }
  1022. stateAfterAttrName(c) {
  1023. if (c === 61) {
  1024. this.state = 18;
  1025. } else if (c === 47 || c === 62) {
  1026. this.cbs.onattribend(0, this.sectionStart);
  1027. this.sectionStart = -1;
  1028. this.state = 11;
  1029. this.stateBeforeAttrName(c);
  1030. } else if (!isWhitespace(c)) {
  1031. this.cbs.onattribend(0, this.sectionStart);
  1032. this.handleAttrStart(c);
  1033. }
  1034. }
  1035. stateBeforeAttrValue(c) {
  1036. if (c === 34) {
  1037. this.state = 19;
  1038. this.sectionStart = this.index + 1;
  1039. } else if (c === 39) {
  1040. this.state = 20;
  1041. this.sectionStart = this.index + 1;
  1042. } else if (!isWhitespace(c)) {
  1043. this.sectionStart = this.index;
  1044. this.state = 21;
  1045. this.stateInAttrValueNoQuotes(c);
  1046. }
  1047. }
  1048. handleInAttrValue(c, quote) {
  1049. if (c === quote || this.fastForwardTo(quote)) {
  1050. this.cbs.onattribdata(this.sectionStart, this.index);
  1051. this.sectionStart = -1;
  1052. this.cbs.onattribend(
  1053. quote === 34 ? 3 : 2,
  1054. this.index + 1
  1055. );
  1056. this.state = 11;
  1057. }
  1058. }
  1059. stateInAttrValueDoubleQuotes(c) {
  1060. this.handleInAttrValue(c, 34);
  1061. }
  1062. stateInAttrValueSingleQuotes(c) {
  1063. this.handleInAttrValue(c, 39);
  1064. }
  1065. stateInAttrValueNoQuotes(c) {
  1066. if (isWhitespace(c) || c === 62) {
  1067. this.cbs.onattribdata(this.sectionStart, this.index);
  1068. this.sectionStart = -1;
  1069. this.cbs.onattribend(1, this.index);
  1070. this.state = 11;
  1071. this.stateBeforeAttrName(c);
  1072. } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
  1073. this.cbs.onerr(
  1074. 18,
  1075. this.index
  1076. );
  1077. } else ;
  1078. }
  1079. stateBeforeDeclaration(c) {
  1080. if (c === 91) {
  1081. this.state = 26;
  1082. this.sequenceIndex = 0;
  1083. } else {
  1084. this.state = c === 45 ? 25 : 23;
  1085. }
  1086. }
  1087. stateInDeclaration(c) {
  1088. if (c === 62 || this.fastForwardTo(62)) {
  1089. this.state = 1;
  1090. this.sectionStart = this.index + 1;
  1091. }
  1092. }
  1093. stateInProcessingInstruction(c) {
  1094. if (c === 62 || this.fastForwardTo(62)) {
  1095. this.cbs.onprocessinginstruction(this.sectionStart, this.index);
  1096. this.state = 1;
  1097. this.sectionStart = this.index + 1;
  1098. }
  1099. }
  1100. stateBeforeComment(c) {
  1101. if (c === 45) {
  1102. this.state = 28;
  1103. this.currentSequence = Sequences.CommentEnd;
  1104. this.sequenceIndex = 2;
  1105. this.sectionStart = this.index + 1;
  1106. } else {
  1107. this.state = 23;
  1108. }
  1109. }
  1110. stateInSpecialComment(c) {
  1111. if (c === 62 || this.fastForwardTo(62)) {
  1112. this.cbs.oncomment(this.sectionStart, this.index);
  1113. this.state = 1;
  1114. this.sectionStart = this.index + 1;
  1115. }
  1116. }
  1117. stateBeforeSpecialS(c) {
  1118. if (c === Sequences.ScriptEnd[3]) {
  1119. this.startSpecial(Sequences.ScriptEnd, 4);
  1120. } else if (c === Sequences.StyleEnd[3]) {
  1121. this.startSpecial(Sequences.StyleEnd, 4);
  1122. } else {
  1123. this.state = 6;
  1124. this.stateInTagName(c);
  1125. }
  1126. }
  1127. stateBeforeSpecialT(c) {
  1128. if (c === Sequences.TitleEnd[3]) {
  1129. this.startSpecial(Sequences.TitleEnd, 4);
  1130. } else if (c === Sequences.TextareaEnd[3]) {
  1131. this.startSpecial(Sequences.TextareaEnd, 4);
  1132. } else {
  1133. this.state = 6;
  1134. this.stateInTagName(c);
  1135. }
  1136. }
  1137. startEntity() {
  1138. }
  1139. stateInEntity() {
  1140. }
  1141. /**
  1142. * Iterates through the buffer, calling the function corresponding to the current state.
  1143. *
  1144. * States that are more likely to be hit are higher up, as a performance improvement.
  1145. */
  1146. parse(input) {
  1147. this.buffer = input;
  1148. while (this.index < this.buffer.length) {
  1149. const c = this.buffer.charCodeAt(this.index);
  1150. if (c === 10 && this.state !== 33) {
  1151. this.newlines.push(this.index);
  1152. }
  1153. switch (this.state) {
  1154. case 1: {
  1155. this.stateText(c);
  1156. break;
  1157. }
  1158. case 2: {
  1159. this.stateInterpolationOpen(c);
  1160. break;
  1161. }
  1162. case 3: {
  1163. this.stateInterpolation(c);
  1164. break;
  1165. }
  1166. case 4: {
  1167. this.stateInterpolationClose(c);
  1168. break;
  1169. }
  1170. case 31: {
  1171. this.stateSpecialStartSequence(c);
  1172. break;
  1173. }
  1174. case 32: {
  1175. this.stateInRCDATA(c);
  1176. break;
  1177. }
  1178. case 26: {
  1179. this.stateCDATASequence(c);
  1180. break;
  1181. }
  1182. case 19: {
  1183. this.stateInAttrValueDoubleQuotes(c);
  1184. break;
  1185. }
  1186. case 12: {
  1187. this.stateInAttrName(c);
  1188. break;
  1189. }
  1190. case 13: {
  1191. this.stateInDirName(c);
  1192. break;
  1193. }
  1194. case 14: {
  1195. this.stateInDirArg(c);
  1196. break;
  1197. }
  1198. case 15: {
  1199. this.stateInDynamicDirArg(c);
  1200. break;
  1201. }
  1202. case 16: {
  1203. this.stateInDirModifier(c);
  1204. break;
  1205. }
  1206. case 28: {
  1207. this.stateInCommentLike(c);
  1208. break;
  1209. }
  1210. case 27: {
  1211. this.stateInSpecialComment(c);
  1212. break;
  1213. }
  1214. case 11: {
  1215. this.stateBeforeAttrName(c);
  1216. break;
  1217. }
  1218. case 6: {
  1219. this.stateInTagName(c);
  1220. break;
  1221. }
  1222. case 34: {
  1223. this.stateInSFCRootTagName(c);
  1224. break;
  1225. }
  1226. case 9: {
  1227. this.stateInClosingTagName(c);
  1228. break;
  1229. }
  1230. case 5: {
  1231. this.stateBeforeTagName(c);
  1232. break;
  1233. }
  1234. case 17: {
  1235. this.stateAfterAttrName(c);
  1236. break;
  1237. }
  1238. case 20: {
  1239. this.stateInAttrValueSingleQuotes(c);
  1240. break;
  1241. }
  1242. case 18: {
  1243. this.stateBeforeAttrValue(c);
  1244. break;
  1245. }
  1246. case 8: {
  1247. this.stateBeforeClosingTagName(c);
  1248. break;
  1249. }
  1250. case 10: {
  1251. this.stateAfterClosingTagName(c);
  1252. break;
  1253. }
  1254. case 29: {
  1255. this.stateBeforeSpecialS(c);
  1256. break;
  1257. }
  1258. case 30: {
  1259. this.stateBeforeSpecialT(c);
  1260. break;
  1261. }
  1262. case 21: {
  1263. this.stateInAttrValueNoQuotes(c);
  1264. break;
  1265. }
  1266. case 7: {
  1267. this.stateInSelfClosingTag(c);
  1268. break;
  1269. }
  1270. case 23: {
  1271. this.stateInDeclaration(c);
  1272. break;
  1273. }
  1274. case 22: {
  1275. this.stateBeforeDeclaration(c);
  1276. break;
  1277. }
  1278. case 25: {
  1279. this.stateBeforeComment(c);
  1280. break;
  1281. }
  1282. case 24: {
  1283. this.stateInProcessingInstruction(c);
  1284. break;
  1285. }
  1286. case 33: {
  1287. this.stateInEntity();
  1288. break;
  1289. }
  1290. }
  1291. this.index++;
  1292. }
  1293. this.cleanup();
  1294. this.finish();
  1295. }
  1296. /**
  1297. * Remove data that has already been consumed from the buffer.
  1298. */
  1299. cleanup() {
  1300. if (this.sectionStart !== this.index) {
  1301. if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
  1302. this.cbs.ontext(this.sectionStart, this.index);
  1303. this.sectionStart = this.index;
  1304. } else if (this.state === 19 || this.state === 20 || this.state === 21) {
  1305. this.cbs.onattribdata(this.sectionStart, this.index);
  1306. this.sectionStart = this.index;
  1307. }
  1308. }
  1309. }
  1310. finish() {
  1311. this.handleTrailingData();
  1312. this.cbs.onend();
  1313. }
  1314. /** Handle any trailing data. */
  1315. handleTrailingData() {
  1316. const endIndex = this.buffer.length;
  1317. if (this.sectionStart >= endIndex) {
  1318. return;
  1319. }
  1320. if (this.state === 28) {
  1321. if (this.currentSequence === Sequences.CdataEnd) {
  1322. this.cbs.oncdata(this.sectionStart, endIndex);
  1323. } else {
  1324. this.cbs.oncomment(this.sectionStart, endIndex);
  1325. }
  1326. } else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) ; else {
  1327. this.cbs.ontext(this.sectionStart, endIndex);
  1328. }
  1329. }
  1330. emitCodePoint(cp, consumed) {
  1331. }
  1332. }
  1333. const CompilerDeprecationTypes = {
  1334. "COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
  1335. "COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
  1336. "COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
  1337. "COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
  1338. "COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
  1339. "COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
  1340. "COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
  1341. "COMPILER_FILTERS": "COMPILER_FILTERS"
  1342. };
  1343. const deprecationData = {
  1344. ["COMPILER_IS_ON_ELEMENT"]: {
  1345. message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
  1346. link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
  1347. },
  1348. ["COMPILER_V_BIND_SYNC"]: {
  1349. message: (key) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${key}.sync\` should be changed to \`v-model:${key}\`.`,
  1350. link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
  1351. },
  1352. ["COMPILER_V_BIND_OBJECT_ORDER"]: {
  1353. message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
  1354. link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
  1355. },
  1356. ["COMPILER_V_ON_NATIVE"]: {
  1357. message: `.native modifier for v-on has been removed as is no longer necessary.`,
  1358. link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
  1359. },
  1360. ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
  1361. message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
  1362. link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
  1363. },
  1364. ["COMPILER_NATIVE_TEMPLATE"]: {
  1365. message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
  1366. },
  1367. ["COMPILER_INLINE_TEMPLATE"]: {
  1368. message: `"inline-template" has been removed in Vue 3.`,
  1369. link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
  1370. },
  1371. ["COMPILER_FILTERS"]: {
  1372. message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
  1373. link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
  1374. }
  1375. };
  1376. function getCompatValue(key, { compatConfig }) {
  1377. const value = compatConfig && compatConfig[key];
  1378. if (key === "MODE") {
  1379. return value || 3;
  1380. } else {
  1381. return value;
  1382. }
  1383. }
  1384. function isCompatEnabled(key, context) {
  1385. const mode = getCompatValue("MODE", context);
  1386. const value = getCompatValue(key, context);
  1387. return mode === 3 ? value === true : value !== false;
  1388. }
  1389. function checkCompatEnabled(key, context, loc, ...args) {
  1390. const enabled = isCompatEnabled(key, context);
  1391. if (enabled) {
  1392. warnDeprecation(key, context, loc, ...args);
  1393. }
  1394. return enabled;
  1395. }
  1396. function warnDeprecation(key, context, loc, ...args) {
  1397. const val = getCompatValue(key, context);
  1398. if (val === "suppress-warning") {
  1399. return;
  1400. }
  1401. const { message, link } = deprecationData[key];
  1402. const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
  1403. Details: ${link}` : ``}`;
  1404. const err = new SyntaxError(msg);
  1405. err.code = key;
  1406. if (loc) err.loc = loc;
  1407. context.onWarn(err);
  1408. }
  1409. function defaultOnError(error) {
  1410. throw error;
  1411. }
  1412. function defaultOnWarn(msg) {
  1413. console.warn(`[Vue warn] ${msg.message}`);
  1414. }
  1415. function createCompilerError(code, loc, messages, additionalMessage) {
  1416. const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
  1417. const error = new SyntaxError(String(msg));
  1418. error.code = code;
  1419. error.loc = loc;
  1420. return error;
  1421. }
  1422. const ErrorCodes = {
  1423. "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
  1424. "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
  1425. "CDATA_IN_HTML_CONTENT": 1,
  1426. "1": "CDATA_IN_HTML_CONTENT",
  1427. "DUPLICATE_ATTRIBUTE": 2,
  1428. "2": "DUPLICATE_ATTRIBUTE",
  1429. "END_TAG_WITH_ATTRIBUTES": 3,
  1430. "3": "END_TAG_WITH_ATTRIBUTES",
  1431. "END_TAG_WITH_TRAILING_SOLIDUS": 4,
  1432. "4": "END_TAG_WITH_TRAILING_SOLIDUS",
  1433. "EOF_BEFORE_TAG_NAME": 5,
  1434. "5": "EOF_BEFORE_TAG_NAME",
  1435. "EOF_IN_CDATA": 6,
  1436. "6": "EOF_IN_CDATA",
  1437. "EOF_IN_COMMENT": 7,
  1438. "7": "EOF_IN_COMMENT",
  1439. "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
  1440. "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
  1441. "EOF_IN_TAG": 9,
  1442. "9": "EOF_IN_TAG",
  1443. "INCORRECTLY_CLOSED_COMMENT": 10,
  1444. "10": "INCORRECTLY_CLOSED_COMMENT",
  1445. "INCORRECTLY_OPENED_COMMENT": 11,
  1446. "11": "INCORRECTLY_OPENED_COMMENT",
  1447. "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
  1448. "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
  1449. "MISSING_ATTRIBUTE_VALUE": 13,
  1450. "13": "MISSING_ATTRIBUTE_VALUE",
  1451. "MISSING_END_TAG_NAME": 14,
  1452. "14": "MISSING_END_TAG_NAME",
  1453. "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
  1454. "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
  1455. "NESTED_COMMENT": 16,
  1456. "16": "NESTED_COMMENT",
  1457. "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
  1458. "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
  1459. "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
  1460. "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
  1461. "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
  1462. "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
  1463. "UNEXPECTED_NULL_CHARACTER": 20,
  1464. "20": "UNEXPECTED_NULL_CHARACTER",
  1465. "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
  1466. "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
  1467. "UNEXPECTED_SOLIDUS_IN_TAG": 22,
  1468. "22": "UNEXPECTED_SOLIDUS_IN_TAG",
  1469. "X_INVALID_END_TAG": 23,
  1470. "23": "X_INVALID_END_TAG",
  1471. "X_MISSING_END_TAG": 24,
  1472. "24": "X_MISSING_END_TAG",
  1473. "X_MISSING_INTERPOLATION_END": 25,
  1474. "25": "X_MISSING_INTERPOLATION_END",
  1475. "X_MISSING_DIRECTIVE_NAME": 26,
  1476. "26": "X_MISSING_DIRECTIVE_NAME",
  1477. "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
  1478. "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
  1479. "X_V_IF_NO_EXPRESSION": 28,
  1480. "28": "X_V_IF_NO_EXPRESSION",
  1481. "X_V_IF_SAME_KEY": 29,
  1482. "29": "X_V_IF_SAME_KEY",
  1483. "X_V_ELSE_NO_ADJACENT_IF": 30,
  1484. "30": "X_V_ELSE_NO_ADJACENT_IF",
  1485. "X_V_FOR_NO_EXPRESSION": 31,
  1486. "31": "X_V_FOR_NO_EXPRESSION",
  1487. "X_V_FOR_MALFORMED_EXPRESSION": 32,
  1488. "32": "X_V_FOR_MALFORMED_EXPRESSION",
  1489. "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
  1490. "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
  1491. "X_V_BIND_NO_EXPRESSION": 34,
  1492. "34": "X_V_BIND_NO_EXPRESSION",
  1493. "X_V_ON_NO_EXPRESSION": 35,
  1494. "35": "X_V_ON_NO_EXPRESSION",
  1495. "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
  1496. "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
  1497. "X_V_SLOT_MIXED_SLOT_USAGE": 37,
  1498. "37": "X_V_SLOT_MIXED_SLOT_USAGE",
  1499. "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
  1500. "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
  1501. "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
  1502. "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
  1503. "X_V_SLOT_MISPLACED": 40,
  1504. "40": "X_V_SLOT_MISPLACED",
  1505. "X_V_MODEL_NO_EXPRESSION": 41,
  1506. "41": "X_V_MODEL_NO_EXPRESSION",
  1507. "X_V_MODEL_MALFORMED_EXPRESSION": 42,
  1508. "42": "X_V_MODEL_MALFORMED_EXPRESSION",
  1509. "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
  1510. "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
  1511. "X_V_MODEL_ON_PROPS": 44,
  1512. "44": "X_V_MODEL_ON_PROPS",
  1513. "X_INVALID_EXPRESSION": 45,
  1514. "45": "X_INVALID_EXPRESSION",
  1515. "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
  1516. "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
  1517. "X_PREFIX_ID_NOT_SUPPORTED": 47,
  1518. "47": "X_PREFIX_ID_NOT_SUPPORTED",
  1519. "X_MODULE_MODE_NOT_SUPPORTED": 48,
  1520. "48": "X_MODULE_MODE_NOT_SUPPORTED",
  1521. "X_CACHE_HANDLER_NOT_SUPPORTED": 49,
  1522. "49": "X_CACHE_HANDLER_NOT_SUPPORTED",
  1523. "X_SCOPE_ID_NOT_SUPPORTED": 50,
  1524. "50": "X_SCOPE_ID_NOT_SUPPORTED",
  1525. "X_VNODE_HOOKS": 51,
  1526. "51": "X_VNODE_HOOKS",
  1527. "X_V_BIND_INVALID_SAME_NAME_ARGUMENT": 52,
  1528. "52": "X_V_BIND_INVALID_SAME_NAME_ARGUMENT",
  1529. "__EXTEND_POINT__": 53,
  1530. "53": "__EXTEND_POINT__"
  1531. };
  1532. const errorMessages = {
  1533. // parse errors
  1534. [0]: "Illegal comment.",
  1535. [1]: "CDATA section is allowed only in XML context.",
  1536. [2]: "Duplicate attribute.",
  1537. [3]: "End tag cannot have attributes.",
  1538. [4]: "Illegal '/' in tags.",
  1539. [5]: "Unexpected EOF in tag.",
  1540. [6]: "Unexpected EOF in CDATA section.",
  1541. [7]: "Unexpected EOF in comment.",
  1542. [8]: "Unexpected EOF in script.",
  1543. [9]: "Unexpected EOF in tag.",
  1544. [10]: "Incorrectly closed comment.",
  1545. [11]: "Incorrectly opened comment.",
  1546. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  1547. [13]: "Attribute value was expected.",
  1548. [14]: "End tag name was expected.",
  1549. [15]: "Whitespace was expected.",
  1550. [16]: "Unexpected '<!--' in comment.",
  1551. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  1552. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  1553. [19]: "Attribute name cannot start with '='.",
  1554. [21]: "'<?' is allowed only in XML context.",
  1555. [20]: `Unexpected null character.`,
  1556. [22]: "Illegal '/' in tags.",
  1557. // Vue-specific parse errors
  1558. [23]: "Invalid end tag.",
  1559. [24]: "Element is missing end tag.",
  1560. [25]: "Interpolation end sign was not found.",
  1561. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  1562. [26]: "Legal directive name was expected.",
  1563. // transform errors
  1564. [28]: `v-if/v-else-if is missing expression.`,
  1565. [29]: `v-if/else branches must use unique keys.`,
  1566. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  1567. [31]: `v-for is missing expression.`,
  1568. [32]: `v-for has invalid expression.`,
  1569. [33]: `<template v-for> key should be placed on the <template> tag.`,
  1570. [34]: `v-bind is missing expression.`,
  1571. [52]: `v-bind with same-name shorthand only allows static argument.`,
  1572. [35]: `v-on is missing expression.`,
  1573. [36]: `Unexpected custom directive on <slot> outlet.`,
  1574. [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
  1575. [38]: `Duplicate slot names found. `,
  1576. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  1577. [40]: `v-slot can only be used on components or <template> tags.`,
  1578. [41]: `v-model is missing expression.`,
  1579. [42]: `v-model value must be a valid JavaScript member expression.`,
  1580. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  1581. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  1582. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  1583. [45]: `Error parsing JavaScript expression: `,
  1584. [46]: `<KeepAlive> expects exactly one child component.`,
  1585. [51]: `@vnode-* hooks in templates are no longer supported. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support has been removed in 3.4.`,
  1586. // generic errors
  1587. [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  1588. [48]: `ES module mode is not supported in this build of compiler.`,
  1589. [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  1590. [50]: `"scopeId" option is only supported in module mode.`,
  1591. // just to fulfill types
  1592. [53]: ``
  1593. };
  1594. function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
  1595. {
  1596. return;
  1597. }
  1598. }
  1599. function isReferencedIdentifier(id, parent, parentStack) {
  1600. {
  1601. return false;
  1602. }
  1603. }
  1604. function isInDestructureAssignment(parent, parentStack) {
  1605. if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
  1606. let i = parentStack.length;
  1607. while (i--) {
  1608. const p = parentStack[i];
  1609. if (p.type === "AssignmentExpression") {
  1610. return true;
  1611. } else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
  1612. break;
  1613. }
  1614. }
  1615. }
  1616. return false;
  1617. }
  1618. function isInNewExpression(parentStack) {
  1619. let i = parentStack.length;
  1620. while (i--) {
  1621. const p = parentStack[i];
  1622. if (p.type === "NewExpression") {
  1623. return true;
  1624. } else if (p.type !== "MemberExpression") {
  1625. break;
  1626. }
  1627. }
  1628. return false;
  1629. }
  1630. function walkFunctionParams(node, onIdent) {
  1631. for (const p of node.params) {
  1632. for (const id of extractIdentifiers(p)) {
  1633. onIdent(id);
  1634. }
  1635. }
  1636. }
  1637. function walkBlockDeclarations(block, onIdent) {
  1638. for (const stmt of block.body) {
  1639. if (stmt.type === "VariableDeclaration") {
  1640. if (stmt.declare) continue;
  1641. for (const decl of stmt.declarations) {
  1642. for (const id of extractIdentifiers(decl.id)) {
  1643. onIdent(id);
  1644. }
  1645. }
  1646. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  1647. if (stmt.declare || !stmt.id) continue;
  1648. onIdent(stmt.id);
  1649. } else if (isForStatement(stmt)) {
  1650. walkForStatement(stmt, true, onIdent);
  1651. }
  1652. }
  1653. }
  1654. function isForStatement(stmt) {
  1655. return stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement";
  1656. }
  1657. function walkForStatement(stmt, isVar, onIdent) {
  1658. const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
  1659. if (variable && variable.type === "VariableDeclaration" && (variable.kind === "var" ? isVar : !isVar)) {
  1660. for (const decl of variable.declarations) {
  1661. for (const id of extractIdentifiers(decl.id)) {
  1662. onIdent(id);
  1663. }
  1664. }
  1665. }
  1666. }
  1667. function extractIdentifiers(param, nodes = []) {
  1668. switch (param.type) {
  1669. case "Identifier":
  1670. nodes.push(param);
  1671. break;
  1672. case "MemberExpression":
  1673. let object = param;
  1674. while (object.type === "MemberExpression") {
  1675. object = object.object;
  1676. }
  1677. nodes.push(object);
  1678. break;
  1679. case "ObjectPattern":
  1680. for (const prop of param.properties) {
  1681. if (prop.type === "RestElement") {
  1682. extractIdentifiers(prop.argument, nodes);
  1683. } else {
  1684. extractIdentifiers(prop.value, nodes);
  1685. }
  1686. }
  1687. break;
  1688. case "ArrayPattern":
  1689. param.elements.forEach((element) => {
  1690. if (element) extractIdentifiers(element, nodes);
  1691. });
  1692. break;
  1693. case "RestElement":
  1694. extractIdentifiers(param.argument, nodes);
  1695. break;
  1696. case "AssignmentPattern":
  1697. extractIdentifiers(param.left, nodes);
  1698. break;
  1699. }
  1700. return nodes;
  1701. }
  1702. const isFunctionType = (node) => {
  1703. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  1704. };
  1705. const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
  1706. const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
  1707. const TS_NODE_TYPES = [
  1708. "TSAsExpression",
  1709. // foo as number
  1710. "TSTypeAssertion",
  1711. // (<number>foo)
  1712. "TSNonNullExpression",
  1713. // foo!
  1714. "TSInstantiationExpression",
  1715. // foo<string>
  1716. "TSSatisfiesExpression"
  1717. // foo satisfies T
  1718. ];
  1719. function unwrapTSNode(node) {
  1720. if (TS_NODE_TYPES.includes(node.type)) {
  1721. return unwrapTSNode(node.expression);
  1722. } else {
  1723. return node;
  1724. }
  1725. }
  1726. const isStaticExp = (p) => p.type === 4 && p.isStatic;
  1727. function isCoreComponent(tag) {
  1728. switch (tag) {
  1729. case "Teleport":
  1730. case "teleport":
  1731. return TELEPORT;
  1732. case "Suspense":
  1733. case "suspense":
  1734. return SUSPENSE;
  1735. case "KeepAlive":
  1736. case "keep-alive":
  1737. return KEEP_ALIVE;
  1738. case "BaseTransition":
  1739. case "base-transition":
  1740. return BASE_TRANSITION;
  1741. }
  1742. }
  1743. const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
  1744. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  1745. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  1746. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  1747. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  1748. const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
  1749. const isMemberExpressionBrowser = (exp) => {
  1750. const path = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
  1751. let state = 0 /* inMemberExp */;
  1752. let stateStack = [];
  1753. let currentOpenBracketCount = 0;
  1754. let currentOpenParensCount = 0;
  1755. let currentStringType = null;
  1756. for (let i = 0; i < path.length; i++) {
  1757. const char = path.charAt(i);
  1758. switch (state) {
  1759. case 0 /* inMemberExp */:
  1760. if (char === "[") {
  1761. stateStack.push(state);
  1762. state = 1 /* inBrackets */;
  1763. currentOpenBracketCount++;
  1764. } else if (char === "(") {
  1765. stateStack.push(state);
  1766. state = 2 /* inParens */;
  1767. currentOpenParensCount++;
  1768. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  1769. return false;
  1770. }
  1771. break;
  1772. case 1 /* inBrackets */:
  1773. if (char === `'` || char === `"` || char === "`") {
  1774. stateStack.push(state);
  1775. state = 3 /* inString */;
  1776. currentStringType = char;
  1777. } else if (char === `[`) {
  1778. currentOpenBracketCount++;
  1779. } else if (char === `]`) {
  1780. if (!--currentOpenBracketCount) {
  1781. state = stateStack.pop();
  1782. }
  1783. }
  1784. break;
  1785. case 2 /* inParens */:
  1786. if (char === `'` || char === `"` || char === "`") {
  1787. stateStack.push(state);
  1788. state = 3 /* inString */;
  1789. currentStringType = char;
  1790. } else if (char === `(`) {
  1791. currentOpenParensCount++;
  1792. } else if (char === `)`) {
  1793. if (i === path.length - 1) {
  1794. return false;
  1795. }
  1796. if (!--currentOpenParensCount) {
  1797. state = stateStack.pop();
  1798. }
  1799. }
  1800. break;
  1801. case 3 /* inString */:
  1802. if (char === currentStringType) {
  1803. state = stateStack.pop();
  1804. currentStringType = null;
  1805. }
  1806. break;
  1807. }
  1808. }
  1809. return !currentOpenBracketCount && !currentOpenParensCount;
  1810. };
  1811. const isMemberExpressionNode = NOOP ;
  1812. const isMemberExpression = isMemberExpressionBrowser ;
  1813. const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  1814. const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
  1815. const isFnExpressionNode = NOOP ;
  1816. const isFnExpression = isFnExpressionBrowser ;
  1817. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  1818. return advancePositionWithMutation(
  1819. {
  1820. offset: pos.offset,
  1821. line: pos.line,
  1822. column: pos.column
  1823. },
  1824. source,
  1825. numberOfCharacters
  1826. );
  1827. }
  1828. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  1829. let linesCount = 0;
  1830. let lastNewLinePos = -1;
  1831. for (let i = 0; i < numberOfCharacters; i++) {
  1832. if (source.charCodeAt(i) === 10) {
  1833. linesCount++;
  1834. lastNewLinePos = i;
  1835. }
  1836. }
  1837. pos.offset += numberOfCharacters;
  1838. pos.line += linesCount;
  1839. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  1840. return pos;
  1841. }
  1842. function assert(condition, msg) {
  1843. if (!condition) {
  1844. throw new Error(msg || `unexpected compiler condition`);
  1845. }
  1846. }
  1847. function findDir(node, name, allowEmpty = false) {
  1848. for (let i = 0; i < node.props.length; i++) {
  1849. const p = node.props[i];
  1850. if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
  1851. return p;
  1852. }
  1853. }
  1854. }
  1855. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  1856. for (let i = 0; i < node.props.length; i++) {
  1857. const p = node.props[i];
  1858. if (p.type === 6) {
  1859. if (dynamicOnly) continue;
  1860. if (p.name === name && (p.value || allowEmpty)) {
  1861. return p;
  1862. }
  1863. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  1864. return p;
  1865. }
  1866. }
  1867. }
  1868. function isStaticArgOf(arg, name) {
  1869. return !!(arg && isStaticExp(arg) && arg.content === name);
  1870. }
  1871. function hasDynamicKeyVBind(node) {
  1872. return node.props.some(
  1873. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  1874. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  1875. !p.arg.isStatic)
  1876. // v-bind:[foo]
  1877. );
  1878. }
  1879. function isText$1(node) {
  1880. return node.type === 5 || node.type === 2;
  1881. }
  1882. function isVPre(p) {
  1883. return p.type === 7 && p.name === "pre";
  1884. }
  1885. function isVSlot(p) {
  1886. return p.type === 7 && p.name === "slot";
  1887. }
  1888. function isTemplateNode(node) {
  1889. return node.type === 1 && node.tagType === 3;
  1890. }
  1891. function isSlotOutlet(node) {
  1892. return node.type === 1 && node.tagType === 2;
  1893. }
  1894. const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  1895. function getUnnormalizedProps(props, callPath = []) {
  1896. if (props && !isString(props) && props.type === 14) {
  1897. const callee = props.callee;
  1898. if (!isString(callee) && propsHelperSet.has(callee)) {
  1899. return getUnnormalizedProps(
  1900. props.arguments[0],
  1901. callPath.concat(props)
  1902. );
  1903. }
  1904. }
  1905. return [props, callPath];
  1906. }
  1907. function injectProp(node, prop, context) {
  1908. let propsWithInjection;
  1909. let props = node.type === 13 ? node.props : node.arguments[2];
  1910. let callPath = [];
  1911. let parentCall;
  1912. if (props && !isString(props) && props.type === 14) {
  1913. const ret = getUnnormalizedProps(props);
  1914. props = ret[0];
  1915. callPath = ret[1];
  1916. parentCall = callPath[callPath.length - 1];
  1917. }
  1918. if (props == null || isString(props)) {
  1919. propsWithInjection = createObjectExpression([prop]);
  1920. } else if (props.type === 14) {
  1921. const first = props.arguments[0];
  1922. if (!isString(first) && first.type === 15) {
  1923. if (!hasProp(prop, first)) {
  1924. first.properties.unshift(prop);
  1925. }
  1926. } else {
  1927. if (props.callee === TO_HANDLERS) {
  1928. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  1929. createObjectExpression([prop]),
  1930. props
  1931. ]);
  1932. } else {
  1933. props.arguments.unshift(createObjectExpression([prop]));
  1934. }
  1935. }
  1936. !propsWithInjection && (propsWithInjection = props);
  1937. } else if (props.type === 15) {
  1938. if (!hasProp(prop, props)) {
  1939. props.properties.unshift(prop);
  1940. }
  1941. propsWithInjection = props;
  1942. } else {
  1943. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  1944. createObjectExpression([prop]),
  1945. props
  1946. ]);
  1947. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  1948. parentCall = callPath[callPath.length - 2];
  1949. }
  1950. }
  1951. if (node.type === 13) {
  1952. if (parentCall) {
  1953. parentCall.arguments[0] = propsWithInjection;
  1954. } else {
  1955. node.props = propsWithInjection;
  1956. }
  1957. } else {
  1958. if (parentCall) {
  1959. parentCall.arguments[0] = propsWithInjection;
  1960. } else {
  1961. node.arguments[2] = propsWithInjection;
  1962. }
  1963. }
  1964. }
  1965. function hasProp(prop, props) {
  1966. let result = false;
  1967. if (prop.key.type === 4) {
  1968. const propKeyName = prop.key.content;
  1969. result = props.properties.some(
  1970. (p) => p.key.type === 4 && p.key.content === propKeyName
  1971. );
  1972. }
  1973. return result;
  1974. }
  1975. function toValidAssetId(name, type) {
  1976. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  1977. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  1978. })}`;
  1979. }
  1980. function hasScopeRef(node, ids) {
  1981. if (!node || Object.keys(ids).length === 0) {
  1982. return false;
  1983. }
  1984. switch (node.type) {
  1985. case 1:
  1986. for (let i = 0; i < node.props.length; i++) {
  1987. const p = node.props[i];
  1988. if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
  1989. return true;
  1990. }
  1991. }
  1992. return node.children.some((c) => hasScopeRef(c, ids));
  1993. case 11:
  1994. if (hasScopeRef(node.source, ids)) {
  1995. return true;
  1996. }
  1997. return node.children.some((c) => hasScopeRef(c, ids));
  1998. case 9:
  1999. return node.branches.some((b) => hasScopeRef(b, ids));
  2000. case 10:
  2001. if (hasScopeRef(node.condition, ids)) {
  2002. return true;
  2003. }
  2004. return node.children.some((c) => hasScopeRef(c, ids));
  2005. case 4:
  2006. return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
  2007. case 8:
  2008. return node.children.some((c) => isObject(c) && hasScopeRef(c, ids));
  2009. case 5:
  2010. case 12:
  2011. return hasScopeRef(node.content, ids);
  2012. case 2:
  2013. case 3:
  2014. case 20:
  2015. return false;
  2016. default:
  2017. return false;
  2018. }
  2019. }
  2020. function getMemoedVNodeCall(node) {
  2021. if (node.type === 14 && node.callee === WITH_MEMO) {
  2022. return node.arguments[1].returns;
  2023. } else {
  2024. return node;
  2025. }
  2026. }
  2027. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
  2028. const defaultParserOptions = {
  2029. parseMode: "base",
  2030. ns: 0,
  2031. delimiters: [`{{`, `}}`],
  2032. getNamespace: () => 0,
  2033. isVoidTag: NO,
  2034. isPreTag: NO,
  2035. isIgnoreNewlineTag: NO,
  2036. isCustomElement: NO,
  2037. onError: defaultOnError,
  2038. onWarn: defaultOnWarn,
  2039. comments: true,
  2040. prefixIdentifiers: false
  2041. };
  2042. let currentOptions = defaultParserOptions;
  2043. let currentRoot = null;
  2044. let currentInput = "";
  2045. let currentOpenTag = null;
  2046. let currentProp = null;
  2047. let currentAttrValue = "";
  2048. let currentAttrStartIndex = -1;
  2049. let currentAttrEndIndex = -1;
  2050. let inPre = 0;
  2051. let inVPre = false;
  2052. let currentVPreBoundary = null;
  2053. const stack = [];
  2054. const tokenizer = new Tokenizer(stack, {
  2055. onerr: emitError,
  2056. ontext(start, end) {
  2057. onText(getSlice(start, end), start, end);
  2058. },
  2059. ontextentity(char, start, end) {
  2060. onText(char, start, end);
  2061. },
  2062. oninterpolation(start, end) {
  2063. if (inVPre) {
  2064. return onText(getSlice(start, end), start, end);
  2065. }
  2066. let innerStart = start + tokenizer.delimiterOpen.length;
  2067. let innerEnd = end - tokenizer.delimiterClose.length;
  2068. while (isWhitespace(currentInput.charCodeAt(innerStart))) {
  2069. innerStart++;
  2070. }
  2071. while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
  2072. innerEnd--;
  2073. }
  2074. let exp = getSlice(innerStart, innerEnd);
  2075. if (exp.includes("&")) {
  2076. {
  2077. exp = currentOptions.decodeEntities(exp, false);
  2078. }
  2079. }
  2080. addNode({
  2081. type: 5,
  2082. content: createExp(exp, false, getLoc(innerStart, innerEnd)),
  2083. loc: getLoc(start, end)
  2084. });
  2085. },
  2086. onopentagname(start, end) {
  2087. const name = getSlice(start, end);
  2088. currentOpenTag = {
  2089. type: 1,
  2090. tag: name,
  2091. ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
  2092. tagType: 0,
  2093. // will be refined on tag close
  2094. props: [],
  2095. children: [],
  2096. loc: getLoc(start - 1, end),
  2097. codegenNode: void 0
  2098. };
  2099. },
  2100. onopentagend(end) {
  2101. endOpenTag(end);
  2102. },
  2103. onclosetag(start, end) {
  2104. const name = getSlice(start, end);
  2105. if (!currentOptions.isVoidTag(name)) {
  2106. let found = false;
  2107. for (let i = 0; i < stack.length; i++) {
  2108. const e = stack[i];
  2109. if (e.tag.toLowerCase() === name.toLowerCase()) {
  2110. found = true;
  2111. if (i > 0) {
  2112. emitError(24, stack[0].loc.start.offset);
  2113. }
  2114. for (let j = 0; j <= i; j++) {
  2115. const el = stack.shift();
  2116. onCloseTag(el, end, j < i);
  2117. }
  2118. break;
  2119. }
  2120. }
  2121. if (!found) {
  2122. emitError(23, backTrack(start, 60));
  2123. }
  2124. }
  2125. },
  2126. onselfclosingtag(end) {
  2127. const name = currentOpenTag.tag;
  2128. currentOpenTag.isSelfClosing = true;
  2129. endOpenTag(end);
  2130. if (stack[0] && stack[0].tag === name) {
  2131. onCloseTag(stack.shift(), end);
  2132. }
  2133. },
  2134. onattribname(start, end) {
  2135. currentProp = {
  2136. type: 6,
  2137. name: getSlice(start, end),
  2138. nameLoc: getLoc(start, end),
  2139. value: void 0,
  2140. loc: getLoc(start)
  2141. };
  2142. },
  2143. ondirname(start, end) {
  2144. const raw = getSlice(start, end);
  2145. const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
  2146. if (!inVPre && name === "") {
  2147. emitError(26, start);
  2148. }
  2149. if (inVPre || name === "") {
  2150. currentProp = {
  2151. type: 6,
  2152. name: raw,
  2153. nameLoc: getLoc(start, end),
  2154. value: void 0,
  2155. loc: getLoc(start)
  2156. };
  2157. } else {
  2158. currentProp = {
  2159. type: 7,
  2160. name,
  2161. rawName: raw,
  2162. exp: void 0,
  2163. arg: void 0,
  2164. modifiers: raw === "." ? [createSimpleExpression("prop")] : [],
  2165. loc: getLoc(start)
  2166. };
  2167. if (name === "pre") {
  2168. inVPre = tokenizer.inVPre = true;
  2169. currentVPreBoundary = currentOpenTag;
  2170. const props = currentOpenTag.props;
  2171. for (let i = 0; i < props.length; i++) {
  2172. if (props[i].type === 7) {
  2173. props[i] = dirToAttr(props[i]);
  2174. }
  2175. }
  2176. }
  2177. }
  2178. },
  2179. ondirarg(start, end) {
  2180. if (start === end) return;
  2181. const arg = getSlice(start, end);
  2182. if (inVPre && !isVPre(currentProp)) {
  2183. currentProp.name += arg;
  2184. setLocEnd(currentProp.nameLoc, end);
  2185. } else {
  2186. const isStatic = arg[0] !== `[`;
  2187. currentProp.arg = createExp(
  2188. isStatic ? arg : arg.slice(1, -1),
  2189. isStatic,
  2190. getLoc(start, end),
  2191. isStatic ? 3 : 0
  2192. );
  2193. }
  2194. },
  2195. ondirmodifier(start, end) {
  2196. const mod = getSlice(start, end);
  2197. if (inVPre && !isVPre(currentProp)) {
  2198. currentProp.name += "." + mod;
  2199. setLocEnd(currentProp.nameLoc, end);
  2200. } else if (currentProp.name === "slot") {
  2201. const arg = currentProp.arg;
  2202. if (arg) {
  2203. arg.content += "." + mod;
  2204. setLocEnd(arg.loc, end);
  2205. }
  2206. } else {
  2207. const exp = createSimpleExpression(mod, true, getLoc(start, end));
  2208. currentProp.modifiers.push(exp);
  2209. }
  2210. },
  2211. onattribdata(start, end) {
  2212. currentAttrValue += getSlice(start, end);
  2213. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  2214. currentAttrEndIndex = end;
  2215. },
  2216. onattribentity(char, start, end) {
  2217. currentAttrValue += char;
  2218. if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
  2219. currentAttrEndIndex = end;
  2220. },
  2221. onattribnameend(end) {
  2222. const start = currentProp.loc.start.offset;
  2223. const name = getSlice(start, end);
  2224. if (currentProp.type === 7) {
  2225. currentProp.rawName = name;
  2226. }
  2227. if (currentOpenTag.props.some(
  2228. (p) => (p.type === 7 ? p.rawName : p.name) === name
  2229. )) {
  2230. emitError(2, start);
  2231. }
  2232. },
  2233. onattribend(quote, end) {
  2234. if (currentOpenTag && currentProp) {
  2235. setLocEnd(currentProp.loc, end);
  2236. if (quote !== 0) {
  2237. if (currentAttrValue.includes("&")) {
  2238. currentAttrValue = currentOptions.decodeEntities(
  2239. currentAttrValue,
  2240. true
  2241. );
  2242. }
  2243. if (currentProp.type === 6) {
  2244. if (currentProp.name === "class") {
  2245. currentAttrValue = condense(currentAttrValue).trim();
  2246. }
  2247. if (quote === 1 && !currentAttrValue) {
  2248. emitError(13, end);
  2249. }
  2250. currentProp.value = {
  2251. type: 2,
  2252. content: currentAttrValue,
  2253. loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
  2254. };
  2255. if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
  2256. tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
  2257. }
  2258. } else {
  2259. let expParseMode = 0 /* Normal */;
  2260. currentProp.exp = createExp(
  2261. currentAttrValue,
  2262. false,
  2263. getLoc(currentAttrStartIndex, currentAttrEndIndex),
  2264. 0,
  2265. expParseMode
  2266. );
  2267. if (currentProp.name === "for") {
  2268. currentProp.forParseResult = parseForExpression(currentProp.exp);
  2269. }
  2270. let syncIndex = -1;
  2271. if (currentProp.name === "bind" && (syncIndex = currentProp.modifiers.findIndex(
  2272. (mod) => mod.content === "sync"
  2273. )) > -1 && checkCompatEnabled(
  2274. "COMPILER_V_BIND_SYNC",
  2275. currentOptions,
  2276. currentProp.loc,
  2277. currentProp.arg.loc.source
  2278. )) {
  2279. currentProp.name = "model";
  2280. currentProp.modifiers.splice(syncIndex, 1);
  2281. }
  2282. }
  2283. }
  2284. if (currentProp.type !== 7 || currentProp.name !== "pre") {
  2285. currentOpenTag.props.push(currentProp);
  2286. }
  2287. }
  2288. currentAttrValue = "";
  2289. currentAttrStartIndex = currentAttrEndIndex = -1;
  2290. },
  2291. oncomment(start, end) {
  2292. if (currentOptions.comments) {
  2293. addNode({
  2294. type: 3,
  2295. content: getSlice(start, end),
  2296. loc: getLoc(start - 4, end + 3)
  2297. });
  2298. }
  2299. },
  2300. onend() {
  2301. const end = currentInput.length;
  2302. if (tokenizer.state !== 1) {
  2303. switch (tokenizer.state) {
  2304. case 5:
  2305. case 8:
  2306. emitError(5, end);
  2307. break;
  2308. case 3:
  2309. case 4:
  2310. emitError(
  2311. 25,
  2312. tokenizer.sectionStart
  2313. );
  2314. break;
  2315. case 28:
  2316. if (tokenizer.currentSequence === Sequences.CdataEnd) {
  2317. emitError(6, end);
  2318. } else {
  2319. emitError(7, end);
  2320. }
  2321. break;
  2322. case 6:
  2323. case 7:
  2324. case 9:
  2325. case 11:
  2326. case 12:
  2327. case 13:
  2328. case 14:
  2329. case 15:
  2330. case 16:
  2331. case 17:
  2332. case 18:
  2333. case 19:
  2334. // "
  2335. case 20:
  2336. // '
  2337. case 21:
  2338. emitError(9, end);
  2339. break;
  2340. }
  2341. }
  2342. for (let index = 0; index < stack.length; index++) {
  2343. onCloseTag(stack[index], end - 1);
  2344. emitError(24, stack[index].loc.start.offset);
  2345. }
  2346. },
  2347. oncdata(start, end) {
  2348. if (stack[0].ns !== 0) {
  2349. onText(getSlice(start, end), start, end);
  2350. } else {
  2351. emitError(1, start - 9);
  2352. }
  2353. },
  2354. onprocessinginstruction(start) {
  2355. if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  2356. emitError(
  2357. 21,
  2358. start - 1
  2359. );
  2360. }
  2361. }
  2362. });
  2363. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  2364. const stripParensRE = /^\(|\)$/g;
  2365. function parseForExpression(input) {
  2366. const loc = input.loc;
  2367. const exp = input.content;
  2368. const inMatch = exp.match(forAliasRE);
  2369. if (!inMatch) return;
  2370. const [, LHS, RHS] = inMatch;
  2371. const createAliasExpression = (content, offset, asParam = false) => {
  2372. const start = loc.start.offset + offset;
  2373. const end = start + content.length;
  2374. return createExp(
  2375. content,
  2376. false,
  2377. getLoc(start, end),
  2378. 0,
  2379. asParam ? 1 /* Params */ : 0 /* Normal */
  2380. );
  2381. };
  2382. const result = {
  2383. source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
  2384. value: void 0,
  2385. key: void 0,
  2386. index: void 0,
  2387. finalized: false
  2388. };
  2389. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  2390. const trimmedOffset = LHS.indexOf(valueContent);
  2391. const iteratorMatch = valueContent.match(forIteratorRE);
  2392. if (iteratorMatch) {
  2393. valueContent = valueContent.replace(forIteratorRE, "").trim();
  2394. const keyContent = iteratorMatch[1].trim();
  2395. let keyOffset;
  2396. if (keyContent) {
  2397. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  2398. result.key = createAliasExpression(keyContent, keyOffset, true);
  2399. }
  2400. if (iteratorMatch[2]) {
  2401. const indexContent = iteratorMatch[2].trim();
  2402. if (indexContent) {
  2403. result.index = createAliasExpression(
  2404. indexContent,
  2405. exp.indexOf(
  2406. indexContent,
  2407. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  2408. ),
  2409. true
  2410. );
  2411. }
  2412. }
  2413. }
  2414. if (valueContent) {
  2415. result.value = createAliasExpression(valueContent, trimmedOffset, true);
  2416. }
  2417. return result;
  2418. }
  2419. function getSlice(start, end) {
  2420. return currentInput.slice(start, end);
  2421. }
  2422. function endOpenTag(end) {
  2423. if (tokenizer.inSFCRoot) {
  2424. currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
  2425. }
  2426. addNode(currentOpenTag);
  2427. const { tag, ns } = currentOpenTag;
  2428. if (ns === 0 && currentOptions.isPreTag(tag)) {
  2429. inPre++;
  2430. }
  2431. if (currentOptions.isVoidTag(tag)) {
  2432. onCloseTag(currentOpenTag, end);
  2433. } else {
  2434. stack.unshift(currentOpenTag);
  2435. if (ns === 1 || ns === 2) {
  2436. tokenizer.inXML = true;
  2437. }
  2438. }
  2439. currentOpenTag = null;
  2440. }
  2441. function onText(content, start, end) {
  2442. {
  2443. const tag = stack[0] && stack[0].tag;
  2444. if (tag !== "script" && tag !== "style" && content.includes("&")) {
  2445. content = currentOptions.decodeEntities(content, false);
  2446. }
  2447. }
  2448. const parent = stack[0] || currentRoot;
  2449. const lastNode = parent.children[parent.children.length - 1];
  2450. if (lastNode && lastNode.type === 2) {
  2451. lastNode.content += content;
  2452. setLocEnd(lastNode.loc, end);
  2453. } else {
  2454. parent.children.push({
  2455. type: 2,
  2456. content,
  2457. loc: getLoc(start, end)
  2458. });
  2459. }
  2460. }
  2461. function onCloseTag(el, end, isImplied = false) {
  2462. if (isImplied) {
  2463. setLocEnd(el.loc, backTrack(end, 60));
  2464. } else {
  2465. setLocEnd(el.loc, lookAhead(end, 62) + 1);
  2466. }
  2467. if (tokenizer.inSFCRoot) {
  2468. if (el.children.length) {
  2469. el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
  2470. } else {
  2471. el.innerLoc.end = extend({}, el.innerLoc.start);
  2472. }
  2473. el.innerLoc.source = getSlice(
  2474. el.innerLoc.start.offset,
  2475. el.innerLoc.end.offset
  2476. );
  2477. }
  2478. const { tag, ns, children } = el;
  2479. if (!inVPre) {
  2480. if (tag === "slot") {
  2481. el.tagType = 2;
  2482. } else if (isFragmentTemplate(el)) {
  2483. el.tagType = 3;
  2484. } else if (isComponent(el)) {
  2485. el.tagType = 1;
  2486. }
  2487. }
  2488. if (!tokenizer.inRCDATA) {
  2489. el.children = condenseWhitespace(children);
  2490. }
  2491. if (ns === 0 && currentOptions.isIgnoreNewlineTag(tag)) {
  2492. const first = children[0];
  2493. if (first && first.type === 2) {
  2494. first.content = first.content.replace(/^\r?\n/, "");
  2495. }
  2496. }
  2497. if (ns === 0 && currentOptions.isPreTag(tag)) {
  2498. inPre--;
  2499. }
  2500. if (currentVPreBoundary === el) {
  2501. inVPre = tokenizer.inVPre = false;
  2502. currentVPreBoundary = null;
  2503. }
  2504. if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  2505. tokenizer.inXML = false;
  2506. }
  2507. {
  2508. const props = el.props;
  2509. if (isCompatEnabled(
  2510. "COMPILER_V_IF_V_FOR_PRECEDENCE",
  2511. currentOptions
  2512. )) {
  2513. let hasIf = false;
  2514. let hasFor = false;
  2515. for (let i = 0; i < props.length; i++) {
  2516. const p = props[i];
  2517. if (p.type === 7) {
  2518. if (p.name === "if") {
  2519. hasIf = true;
  2520. } else if (p.name === "for") {
  2521. hasFor = true;
  2522. }
  2523. }
  2524. if (hasIf && hasFor) {
  2525. warnDeprecation(
  2526. "COMPILER_V_IF_V_FOR_PRECEDENCE",
  2527. currentOptions,
  2528. el.loc
  2529. );
  2530. break;
  2531. }
  2532. }
  2533. }
  2534. if (!tokenizer.inSFCRoot && isCompatEnabled(
  2535. "COMPILER_NATIVE_TEMPLATE",
  2536. currentOptions
  2537. ) && el.tag === "template" && !isFragmentTemplate(el)) {
  2538. warnDeprecation(
  2539. "COMPILER_NATIVE_TEMPLATE",
  2540. currentOptions,
  2541. el.loc
  2542. );
  2543. const parent = stack[0] || currentRoot;
  2544. const index = parent.children.indexOf(el);
  2545. parent.children.splice(index, 1, ...el.children);
  2546. }
  2547. const inlineTemplateProp = props.find(
  2548. (p) => p.type === 6 && p.name === "inline-template"
  2549. );
  2550. if (inlineTemplateProp && checkCompatEnabled(
  2551. "COMPILER_INLINE_TEMPLATE",
  2552. currentOptions,
  2553. inlineTemplateProp.loc
  2554. ) && el.children.length) {
  2555. inlineTemplateProp.value = {
  2556. type: 2,
  2557. content: getSlice(
  2558. el.children[0].loc.start.offset,
  2559. el.children[el.children.length - 1].loc.end.offset
  2560. ),
  2561. loc: inlineTemplateProp.loc
  2562. };
  2563. }
  2564. }
  2565. }
  2566. function lookAhead(index, c) {
  2567. let i = index;
  2568. while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1) i++;
  2569. return i;
  2570. }
  2571. function backTrack(index, c) {
  2572. let i = index;
  2573. while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
  2574. return i;
  2575. }
  2576. const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
  2577. function isFragmentTemplate({ tag, props }) {
  2578. if (tag === "template") {
  2579. for (let i = 0; i < props.length; i++) {
  2580. if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
  2581. return true;
  2582. }
  2583. }
  2584. }
  2585. return false;
  2586. }
  2587. function isComponent({ tag, props }) {
  2588. if (currentOptions.isCustomElement(tag)) {
  2589. return false;
  2590. }
  2591. if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
  2592. return true;
  2593. }
  2594. for (let i = 0; i < props.length; i++) {
  2595. const p = props[i];
  2596. if (p.type === 6) {
  2597. if (p.name === "is" && p.value) {
  2598. if (p.value.content.startsWith("vue:")) {
  2599. return true;
  2600. } else if (checkCompatEnabled(
  2601. "COMPILER_IS_ON_ELEMENT",
  2602. currentOptions,
  2603. p.loc
  2604. )) {
  2605. return true;
  2606. }
  2607. }
  2608. } else if (// :is on plain element - only treat as component in compat mode
  2609. p.name === "bind" && isStaticArgOf(p.arg, "is") && checkCompatEnabled(
  2610. "COMPILER_IS_ON_ELEMENT",
  2611. currentOptions,
  2612. p.loc
  2613. )) {
  2614. return true;
  2615. }
  2616. }
  2617. return false;
  2618. }
  2619. function isUpperCase(c) {
  2620. return c > 64 && c < 91;
  2621. }
  2622. const windowsNewlineRE = /\r\n/g;
  2623. function condenseWhitespace(nodes) {
  2624. const shouldCondense = currentOptions.whitespace !== "preserve";
  2625. let removedWhitespace = false;
  2626. for (let i = 0; i < nodes.length; i++) {
  2627. const node = nodes[i];
  2628. if (node.type === 2) {
  2629. if (!inPre) {
  2630. if (isAllWhitespace(node.content)) {
  2631. const prev = nodes[i - 1] && nodes[i - 1].type;
  2632. const next = nodes[i + 1] && nodes[i + 1].type;
  2633. if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
  2634. removedWhitespace = true;
  2635. nodes[i] = null;
  2636. } else {
  2637. node.content = " ";
  2638. }
  2639. } else if (shouldCondense) {
  2640. node.content = condense(node.content);
  2641. }
  2642. } else {
  2643. node.content = node.content.replace(windowsNewlineRE, "\n");
  2644. }
  2645. }
  2646. }
  2647. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  2648. }
  2649. function isAllWhitespace(str) {
  2650. for (let i = 0; i < str.length; i++) {
  2651. if (!isWhitespace(str.charCodeAt(i))) {
  2652. return false;
  2653. }
  2654. }
  2655. return true;
  2656. }
  2657. function hasNewlineChar(str) {
  2658. for (let i = 0; i < str.length; i++) {
  2659. const c = str.charCodeAt(i);
  2660. if (c === 10 || c === 13) {
  2661. return true;
  2662. }
  2663. }
  2664. return false;
  2665. }
  2666. function condense(str) {
  2667. let ret = "";
  2668. let prevCharIsWhitespace = false;
  2669. for (let i = 0; i < str.length; i++) {
  2670. if (isWhitespace(str.charCodeAt(i))) {
  2671. if (!prevCharIsWhitespace) {
  2672. ret += " ";
  2673. prevCharIsWhitespace = true;
  2674. }
  2675. } else {
  2676. ret += str[i];
  2677. prevCharIsWhitespace = false;
  2678. }
  2679. }
  2680. return ret;
  2681. }
  2682. function addNode(node) {
  2683. (stack[0] || currentRoot).children.push(node);
  2684. }
  2685. function getLoc(start, end) {
  2686. return {
  2687. start: tokenizer.getPos(start),
  2688. // @ts-expect-error allow late attachment
  2689. end: end == null ? end : tokenizer.getPos(end),
  2690. // @ts-expect-error allow late attachment
  2691. source: end == null ? end : getSlice(start, end)
  2692. };
  2693. }
  2694. function cloneLoc(loc) {
  2695. return getLoc(loc.start.offset, loc.end.offset);
  2696. }
  2697. function setLocEnd(loc, end) {
  2698. loc.end = tokenizer.getPos(end);
  2699. loc.source = getSlice(loc.start.offset, end);
  2700. }
  2701. function dirToAttr(dir) {
  2702. const attr = {
  2703. type: 6,
  2704. name: dir.rawName,
  2705. nameLoc: getLoc(
  2706. dir.loc.start.offset,
  2707. dir.loc.start.offset + dir.rawName.length
  2708. ),
  2709. value: void 0,
  2710. loc: dir.loc
  2711. };
  2712. if (dir.exp) {
  2713. const loc = dir.exp.loc;
  2714. if (loc.end.offset < dir.loc.end.offset) {
  2715. loc.start.offset--;
  2716. loc.start.column--;
  2717. loc.end.offset++;
  2718. loc.end.column++;
  2719. }
  2720. attr.value = {
  2721. type: 2,
  2722. content: dir.exp.content,
  2723. loc
  2724. };
  2725. }
  2726. return attr;
  2727. }
  2728. function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
  2729. const exp = createSimpleExpression(content, isStatic, loc, constType);
  2730. return exp;
  2731. }
  2732. function emitError(code, index, message) {
  2733. currentOptions.onError(
  2734. createCompilerError(code, getLoc(index, index), void 0, message)
  2735. );
  2736. }
  2737. function reset() {
  2738. tokenizer.reset();
  2739. currentOpenTag = null;
  2740. currentProp = null;
  2741. currentAttrValue = "";
  2742. currentAttrStartIndex = -1;
  2743. currentAttrEndIndex = -1;
  2744. stack.length = 0;
  2745. }
  2746. function baseParse(input, options) {
  2747. reset();
  2748. currentInput = input;
  2749. currentOptions = extend({}, defaultParserOptions);
  2750. if (options) {
  2751. let key;
  2752. for (key in options) {
  2753. if (options[key] != null) {
  2754. currentOptions[key] = options[key];
  2755. }
  2756. }
  2757. }
  2758. {
  2759. if (!currentOptions.decodeEntities) {
  2760. throw new Error(
  2761. `[@vue/compiler-core] decodeEntities option is required in browser builds.`
  2762. );
  2763. }
  2764. }
  2765. tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
  2766. tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
  2767. const delimiters = options && options.delimiters;
  2768. if (delimiters) {
  2769. tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
  2770. tokenizer.delimiterClose = toCharCodes(delimiters[1]);
  2771. }
  2772. const root = currentRoot = createRoot([], input);
  2773. tokenizer.parse(currentInput);
  2774. root.loc = getLoc(0, input.length);
  2775. root.children = condenseWhitespace(root.children);
  2776. currentRoot = null;
  2777. return root;
  2778. }
  2779. function cacheStatic(root, context) {
  2780. walk(
  2781. root,
  2782. void 0,
  2783. context,
  2784. // Root node is unfortunately non-hoistable due to potential parent
  2785. // fallthrough attributes.
  2786. !!getSingleElementRoot(root)
  2787. );
  2788. }
  2789. function getSingleElementRoot(root) {
  2790. const children = root.children.filter((x) => x.type !== 3);
  2791. return children.length === 1 && children[0].type === 1 && !isSlotOutlet(children[0]) ? children[0] : null;
  2792. }
  2793. function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
  2794. const { children } = node;
  2795. const toCache = [];
  2796. for (let i = 0; i < children.length; i++) {
  2797. const child = children[i];
  2798. if (child.type === 1 && child.tagType === 0) {
  2799. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  2800. if (constantType > 0) {
  2801. if (constantType >= 2) {
  2802. child.codegenNode.patchFlag = -1;
  2803. toCache.push(child);
  2804. continue;
  2805. }
  2806. } else {
  2807. const codegenNode = child.codegenNode;
  2808. if (codegenNode.type === 13) {
  2809. const flag = codegenNode.patchFlag;
  2810. if ((flag === void 0 || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  2811. const props = getNodeProps(child);
  2812. if (props) {
  2813. codegenNode.props = context.hoist(props);
  2814. }
  2815. }
  2816. if (codegenNode.dynamicProps) {
  2817. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  2818. }
  2819. }
  2820. }
  2821. } else if (child.type === 12) {
  2822. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  2823. if (constantType >= 2) {
  2824. if (child.codegenNode.type === 14 && child.codegenNode.arguments.length > 0) {
  2825. child.codegenNode.arguments.push(
  2826. -1 + (` /* ${PatchFlagNames[-1]} */` )
  2827. );
  2828. }
  2829. toCache.push(child);
  2830. continue;
  2831. }
  2832. }
  2833. if (child.type === 1) {
  2834. const isComponent = child.tagType === 1;
  2835. if (isComponent) {
  2836. context.scopes.vSlot++;
  2837. }
  2838. walk(child, node, context, false, inFor);
  2839. if (isComponent) {
  2840. context.scopes.vSlot--;
  2841. }
  2842. } else if (child.type === 11) {
  2843. walk(child, node, context, child.children.length === 1, true);
  2844. } else if (child.type === 9) {
  2845. for (let i2 = 0; i2 < child.branches.length; i2++) {
  2846. walk(
  2847. child.branches[i2],
  2848. node,
  2849. context,
  2850. child.branches[i2].children.length === 1,
  2851. inFor
  2852. );
  2853. }
  2854. }
  2855. }
  2856. let cachedAsArray = false;
  2857. if (toCache.length === children.length && node.type === 1) {
  2858. if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
  2859. node.codegenNode.children = getCacheExpression(
  2860. createArrayExpression(node.codegenNode.children)
  2861. );
  2862. cachedAsArray = true;
  2863. } else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
  2864. const slot = getSlotNode(node.codegenNode, "default");
  2865. if (slot) {
  2866. slot.returns = getCacheExpression(
  2867. createArrayExpression(slot.returns)
  2868. );
  2869. cachedAsArray = true;
  2870. }
  2871. } else if (node.tagType === 3 && parent && parent.type === 1 && parent.tagType === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !isArray(parent.codegenNode.children) && parent.codegenNode.children.type === 15) {
  2872. const slotName = findDir(node, "slot", true);
  2873. const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
  2874. if (slot) {
  2875. slot.returns = getCacheExpression(
  2876. createArrayExpression(slot.returns)
  2877. );
  2878. cachedAsArray = true;
  2879. }
  2880. }
  2881. }
  2882. if (!cachedAsArray) {
  2883. for (const child of toCache) {
  2884. child.codegenNode = context.cache(child.codegenNode);
  2885. }
  2886. }
  2887. function getCacheExpression(value) {
  2888. const exp = context.cache(value);
  2889. exp.needArraySpread = true;
  2890. return exp;
  2891. }
  2892. function getSlotNode(node2, name) {
  2893. if (node2.children && !isArray(node2.children) && node2.children.type === 15) {
  2894. const slot = node2.children.properties.find(
  2895. (p) => p.key === name || p.key.content === name
  2896. );
  2897. return slot && slot.value;
  2898. }
  2899. }
  2900. if (toCache.length && context.transformHoist) {
  2901. context.transformHoist(children, context, node);
  2902. }
  2903. }
  2904. function getConstantType(node, context) {
  2905. const { constantCache } = context;
  2906. switch (node.type) {
  2907. case 1:
  2908. if (node.tagType !== 0) {
  2909. return 0;
  2910. }
  2911. const cached = constantCache.get(node);
  2912. if (cached !== void 0) {
  2913. return cached;
  2914. }
  2915. const codegenNode = node.codegenNode;
  2916. if (codegenNode.type !== 13) {
  2917. return 0;
  2918. }
  2919. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject" && node.tag !== "math") {
  2920. return 0;
  2921. }
  2922. if (codegenNode.patchFlag === void 0) {
  2923. let returnType2 = 3;
  2924. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  2925. if (generatedPropsType === 0) {
  2926. constantCache.set(node, 0);
  2927. return 0;
  2928. }
  2929. if (generatedPropsType < returnType2) {
  2930. returnType2 = generatedPropsType;
  2931. }
  2932. for (let i = 0; i < node.children.length; i++) {
  2933. const childType = getConstantType(node.children[i], context);
  2934. if (childType === 0) {
  2935. constantCache.set(node, 0);
  2936. return 0;
  2937. }
  2938. if (childType < returnType2) {
  2939. returnType2 = childType;
  2940. }
  2941. }
  2942. if (returnType2 > 1) {
  2943. for (let i = 0; i < node.props.length; i++) {
  2944. const p = node.props[i];
  2945. if (p.type === 7 && p.name === "bind" && p.exp) {
  2946. const expType = getConstantType(p.exp, context);
  2947. if (expType === 0) {
  2948. constantCache.set(node, 0);
  2949. return 0;
  2950. }
  2951. if (expType < returnType2) {
  2952. returnType2 = expType;
  2953. }
  2954. }
  2955. }
  2956. }
  2957. if (codegenNode.isBlock) {
  2958. for (let i = 0; i < node.props.length; i++) {
  2959. const p = node.props[i];
  2960. if (p.type === 7) {
  2961. constantCache.set(node, 0);
  2962. return 0;
  2963. }
  2964. }
  2965. context.removeHelper(OPEN_BLOCK);
  2966. context.removeHelper(
  2967. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  2968. );
  2969. codegenNode.isBlock = false;
  2970. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  2971. }
  2972. constantCache.set(node, returnType2);
  2973. return returnType2;
  2974. } else {
  2975. constantCache.set(node, 0);
  2976. return 0;
  2977. }
  2978. case 2:
  2979. case 3:
  2980. return 3;
  2981. case 9:
  2982. case 11:
  2983. case 10:
  2984. return 0;
  2985. case 5:
  2986. case 12:
  2987. return getConstantType(node.content, context);
  2988. case 4:
  2989. return node.constType;
  2990. case 8:
  2991. let returnType = 3;
  2992. for (let i = 0; i < node.children.length; i++) {
  2993. const child = node.children[i];
  2994. if (isString(child) || isSymbol(child)) {
  2995. continue;
  2996. }
  2997. const childType = getConstantType(child, context);
  2998. if (childType === 0) {
  2999. return 0;
  3000. } else if (childType < returnType) {
  3001. returnType = childType;
  3002. }
  3003. }
  3004. return returnType;
  3005. case 20:
  3006. return 2;
  3007. default:
  3008. return 0;
  3009. }
  3010. }
  3011. const allowHoistedHelperSet = /* @__PURE__ */ new Set([
  3012. NORMALIZE_CLASS,
  3013. NORMALIZE_STYLE,
  3014. NORMALIZE_PROPS,
  3015. GUARD_REACTIVE_PROPS
  3016. ]);
  3017. function getConstantTypeOfHelperCall(value, context) {
  3018. if (value.type === 14 && !isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  3019. const arg = value.arguments[0];
  3020. if (arg.type === 4) {
  3021. return getConstantType(arg, context);
  3022. } else if (arg.type === 14) {
  3023. return getConstantTypeOfHelperCall(arg, context);
  3024. }
  3025. }
  3026. return 0;
  3027. }
  3028. function getGeneratedPropsConstantType(node, context) {
  3029. let returnType = 3;
  3030. const props = getNodeProps(node);
  3031. if (props && props.type === 15) {
  3032. const { properties } = props;
  3033. for (let i = 0; i < properties.length; i++) {
  3034. const { key, value } = properties[i];
  3035. const keyType = getConstantType(key, context);
  3036. if (keyType === 0) {
  3037. return keyType;
  3038. }
  3039. if (keyType < returnType) {
  3040. returnType = keyType;
  3041. }
  3042. let valueType;
  3043. if (value.type === 4) {
  3044. valueType = getConstantType(value, context);
  3045. } else if (value.type === 14) {
  3046. valueType = getConstantTypeOfHelperCall(value, context);
  3047. } else {
  3048. valueType = 0;
  3049. }
  3050. if (valueType === 0) {
  3051. return valueType;
  3052. }
  3053. if (valueType < returnType) {
  3054. returnType = valueType;
  3055. }
  3056. }
  3057. }
  3058. return returnType;
  3059. }
  3060. function getNodeProps(node) {
  3061. const codegenNode = node.codegenNode;
  3062. if (codegenNode.type === 13) {
  3063. return codegenNode.props;
  3064. }
  3065. }
  3066. function createTransformContext(root, {
  3067. filename = "",
  3068. prefixIdentifiers = false,
  3069. hoistStatic = false,
  3070. hmr = false,
  3071. cacheHandlers = false,
  3072. nodeTransforms = [],
  3073. directiveTransforms = {},
  3074. transformHoist = null,
  3075. isBuiltInComponent = NOOP,
  3076. isCustomElement = NOOP,
  3077. expressionPlugins = [],
  3078. scopeId = null,
  3079. slotted = true,
  3080. ssr = false,
  3081. inSSR = false,
  3082. ssrCssVars = ``,
  3083. bindingMetadata = EMPTY_OBJ,
  3084. inline = false,
  3085. isTS = false,
  3086. onError = defaultOnError,
  3087. onWarn = defaultOnWarn,
  3088. compatConfig
  3089. }) {
  3090. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  3091. const context = {
  3092. // options
  3093. filename,
  3094. selfName: nameMatch && capitalize(camelize(nameMatch[1])),
  3095. prefixIdentifiers,
  3096. hoistStatic,
  3097. hmr,
  3098. cacheHandlers,
  3099. nodeTransforms,
  3100. directiveTransforms,
  3101. transformHoist,
  3102. isBuiltInComponent,
  3103. isCustomElement,
  3104. expressionPlugins,
  3105. scopeId,
  3106. slotted,
  3107. ssr,
  3108. inSSR,
  3109. ssrCssVars,
  3110. bindingMetadata,
  3111. inline,
  3112. isTS,
  3113. onError,
  3114. onWarn,
  3115. compatConfig,
  3116. // state
  3117. root,
  3118. helpers: /* @__PURE__ */ new Map(),
  3119. components: /* @__PURE__ */ new Set(),
  3120. directives: /* @__PURE__ */ new Set(),
  3121. hoists: [],
  3122. imports: [],
  3123. cached: [],
  3124. constantCache: /* @__PURE__ */ new WeakMap(),
  3125. temps: 0,
  3126. identifiers: /* @__PURE__ */ Object.create(null),
  3127. scopes: {
  3128. vFor: 0,
  3129. vSlot: 0,
  3130. vPre: 0,
  3131. vOnce: 0
  3132. },
  3133. parent: null,
  3134. grandParent: null,
  3135. currentNode: root,
  3136. childIndex: 0,
  3137. inVOnce: false,
  3138. // methods
  3139. helper(name) {
  3140. const count = context.helpers.get(name) || 0;
  3141. context.helpers.set(name, count + 1);
  3142. return name;
  3143. },
  3144. removeHelper(name) {
  3145. const count = context.helpers.get(name);
  3146. if (count) {
  3147. const currentCount = count - 1;
  3148. if (!currentCount) {
  3149. context.helpers.delete(name);
  3150. } else {
  3151. context.helpers.set(name, currentCount);
  3152. }
  3153. }
  3154. },
  3155. helperString(name) {
  3156. return `_${helperNameMap[context.helper(name)]}`;
  3157. },
  3158. replaceNode(node) {
  3159. {
  3160. if (!context.currentNode) {
  3161. throw new Error(`Node being replaced is already removed.`);
  3162. }
  3163. if (!context.parent) {
  3164. throw new Error(`Cannot replace root node.`);
  3165. }
  3166. }
  3167. context.parent.children[context.childIndex] = context.currentNode = node;
  3168. },
  3169. removeNode(node) {
  3170. if (!context.parent) {
  3171. throw new Error(`Cannot remove root node.`);
  3172. }
  3173. const list = context.parent.children;
  3174. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  3175. if (removalIndex < 0) {
  3176. throw new Error(`node being removed is not a child of current parent`);
  3177. }
  3178. if (!node || node === context.currentNode) {
  3179. context.currentNode = null;
  3180. context.onNodeRemoved();
  3181. } else {
  3182. if (context.childIndex > removalIndex) {
  3183. context.childIndex--;
  3184. context.onNodeRemoved();
  3185. }
  3186. }
  3187. context.parent.children.splice(removalIndex, 1);
  3188. },
  3189. onNodeRemoved: NOOP,
  3190. addIdentifiers(exp) {
  3191. },
  3192. removeIdentifiers(exp) {
  3193. },
  3194. hoist(exp) {
  3195. if (isString(exp)) exp = createSimpleExpression(exp);
  3196. context.hoists.push(exp);
  3197. const identifier = createSimpleExpression(
  3198. `_hoisted_${context.hoists.length}`,
  3199. false,
  3200. exp.loc,
  3201. 2
  3202. );
  3203. identifier.hoisted = exp;
  3204. return identifier;
  3205. },
  3206. cache(exp, isVNode = false, inVOnce = false) {
  3207. const cacheExp = createCacheExpression(
  3208. context.cached.length,
  3209. exp,
  3210. isVNode,
  3211. inVOnce
  3212. );
  3213. context.cached.push(cacheExp);
  3214. return cacheExp;
  3215. }
  3216. };
  3217. {
  3218. context.filters = /* @__PURE__ */ new Set();
  3219. }
  3220. return context;
  3221. }
  3222. function transform(root, options) {
  3223. const context = createTransformContext(root, options);
  3224. traverseNode(root, context);
  3225. if (options.hoistStatic) {
  3226. cacheStatic(root, context);
  3227. }
  3228. if (!options.ssr) {
  3229. createRootCodegen(root, context);
  3230. }
  3231. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  3232. root.components = [...context.components];
  3233. root.directives = [...context.directives];
  3234. root.imports = context.imports;
  3235. root.hoists = context.hoists;
  3236. root.temps = context.temps;
  3237. root.cached = context.cached;
  3238. root.transformed = true;
  3239. {
  3240. root.filters = [...context.filters];
  3241. }
  3242. }
  3243. function createRootCodegen(root, context) {
  3244. const { helper } = context;
  3245. const { children } = root;
  3246. if (children.length === 1) {
  3247. const singleElementRootChild = getSingleElementRoot(root);
  3248. if (singleElementRootChild && singleElementRootChild.codegenNode) {
  3249. const codegenNode = singleElementRootChild.codegenNode;
  3250. if (codegenNode.type === 13) {
  3251. convertToBlock(codegenNode, context);
  3252. }
  3253. root.codegenNode = codegenNode;
  3254. } else {
  3255. root.codegenNode = children[0];
  3256. }
  3257. } else if (children.length > 1) {
  3258. let patchFlag = 64;
  3259. if (children.filter((c) => c.type !== 3).length === 1) {
  3260. patchFlag |= 2048;
  3261. }
  3262. root.codegenNode = createVNodeCall(
  3263. context,
  3264. helper(FRAGMENT),
  3265. void 0,
  3266. root.children,
  3267. patchFlag,
  3268. void 0,
  3269. void 0,
  3270. true,
  3271. void 0,
  3272. false
  3273. );
  3274. } else ;
  3275. }
  3276. function traverseChildren(parent, context) {
  3277. let i = 0;
  3278. const nodeRemoved = () => {
  3279. i--;
  3280. };
  3281. for (; i < parent.children.length; i++) {
  3282. const child = parent.children[i];
  3283. if (isString(child)) continue;
  3284. context.grandParent = context.parent;
  3285. context.parent = parent;
  3286. context.childIndex = i;
  3287. context.onNodeRemoved = nodeRemoved;
  3288. traverseNode(child, context);
  3289. }
  3290. }
  3291. function traverseNode(node, context) {
  3292. context.currentNode = node;
  3293. const { nodeTransforms } = context;
  3294. const exitFns = [];
  3295. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  3296. const onExit = nodeTransforms[i2](node, context);
  3297. if (onExit) {
  3298. if (isArray(onExit)) {
  3299. exitFns.push(...onExit);
  3300. } else {
  3301. exitFns.push(onExit);
  3302. }
  3303. }
  3304. if (!context.currentNode) {
  3305. return;
  3306. } else {
  3307. node = context.currentNode;
  3308. }
  3309. }
  3310. switch (node.type) {
  3311. case 3:
  3312. if (!context.ssr) {
  3313. context.helper(CREATE_COMMENT);
  3314. }
  3315. break;
  3316. case 5:
  3317. if (!context.ssr) {
  3318. context.helper(TO_DISPLAY_STRING);
  3319. }
  3320. break;
  3321. // for container types, further traverse downwards
  3322. case 9:
  3323. for (let i2 = 0; i2 < node.branches.length; i2++) {
  3324. traverseNode(node.branches[i2], context);
  3325. }
  3326. break;
  3327. case 10:
  3328. case 11:
  3329. case 1:
  3330. case 0:
  3331. traverseChildren(node, context);
  3332. break;
  3333. }
  3334. context.currentNode = node;
  3335. let i = exitFns.length;
  3336. while (i--) {
  3337. exitFns[i]();
  3338. }
  3339. }
  3340. function createStructuralDirectiveTransform(name, fn) {
  3341. const matches = isString(name) ? (n) => n === name : (n) => name.test(n);
  3342. return (node, context) => {
  3343. if (node.type === 1) {
  3344. const { props } = node;
  3345. if (node.tagType === 3 && props.some(isVSlot)) {
  3346. return;
  3347. }
  3348. const exitFns = [];
  3349. for (let i = 0; i < props.length; i++) {
  3350. const prop = props[i];
  3351. if (prop.type === 7 && matches(prop.name)) {
  3352. props.splice(i, 1);
  3353. i--;
  3354. const onExit = fn(node, prop, context);
  3355. if (onExit) exitFns.push(onExit);
  3356. }
  3357. }
  3358. return exitFns;
  3359. }
  3360. };
  3361. }
  3362. const PURE_ANNOTATION = `/*@__PURE__*/`;
  3363. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  3364. function createCodegenContext(ast, {
  3365. mode = "function",
  3366. prefixIdentifiers = mode === "module",
  3367. sourceMap = false,
  3368. filename = `template.vue.html`,
  3369. scopeId = null,
  3370. optimizeImports = false,
  3371. runtimeGlobalName = `Vue`,
  3372. runtimeModuleName = `vue`,
  3373. ssrRuntimeModuleName = "vue/server-renderer",
  3374. ssr = false,
  3375. isTS = false,
  3376. inSSR = false
  3377. }) {
  3378. const context = {
  3379. mode,
  3380. prefixIdentifiers,
  3381. sourceMap,
  3382. filename,
  3383. scopeId,
  3384. optimizeImports,
  3385. runtimeGlobalName,
  3386. runtimeModuleName,
  3387. ssrRuntimeModuleName,
  3388. ssr,
  3389. isTS,
  3390. inSSR,
  3391. source: ast.source,
  3392. code: ``,
  3393. column: 1,
  3394. line: 1,
  3395. offset: 0,
  3396. indentLevel: 0,
  3397. pure: false,
  3398. map: void 0,
  3399. helper(key) {
  3400. return `_${helperNameMap[key]}`;
  3401. },
  3402. push(code, newlineIndex = -2 /* None */, node) {
  3403. context.code += code;
  3404. },
  3405. indent() {
  3406. newline(++context.indentLevel);
  3407. },
  3408. deindent(withoutNewLine = false) {
  3409. if (withoutNewLine) {
  3410. --context.indentLevel;
  3411. } else {
  3412. newline(--context.indentLevel);
  3413. }
  3414. },
  3415. newline() {
  3416. newline(context.indentLevel);
  3417. }
  3418. };
  3419. function newline(n) {
  3420. context.push("\n" + ` `.repeat(n), 0 /* Start */);
  3421. }
  3422. return context;
  3423. }
  3424. function generate(ast, options = {}) {
  3425. const context = createCodegenContext(ast, options);
  3426. if (options.onContextCreated) options.onContextCreated(context);
  3427. const {
  3428. mode,
  3429. push,
  3430. prefixIdentifiers,
  3431. indent,
  3432. deindent,
  3433. newline,
  3434. scopeId,
  3435. ssr
  3436. } = context;
  3437. const helpers = Array.from(ast.helpers);
  3438. const hasHelpers = helpers.length > 0;
  3439. const useWithBlock = !prefixIdentifiers && mode !== "module";
  3440. const preambleContext = context;
  3441. {
  3442. genFunctionPreamble(ast, preambleContext);
  3443. }
  3444. const functionName = ssr ? `ssrRender` : `render`;
  3445. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  3446. const signature = args.join(", ");
  3447. {
  3448. push(`function ${functionName}(${signature}) {`);
  3449. }
  3450. indent();
  3451. if (useWithBlock) {
  3452. push(`with (_ctx) {`);
  3453. indent();
  3454. if (hasHelpers) {
  3455. push(
  3456. `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
  3457. `,
  3458. -1 /* End */
  3459. );
  3460. newline();
  3461. }
  3462. }
  3463. if (ast.components.length) {
  3464. genAssets(ast.components, "component", context);
  3465. if (ast.directives.length || ast.temps > 0) {
  3466. newline();
  3467. }
  3468. }
  3469. if (ast.directives.length) {
  3470. genAssets(ast.directives, "directive", context);
  3471. if (ast.temps > 0) {
  3472. newline();
  3473. }
  3474. }
  3475. if (ast.filters && ast.filters.length) {
  3476. newline();
  3477. genAssets(ast.filters, "filter", context);
  3478. newline();
  3479. }
  3480. if (ast.temps > 0) {
  3481. push(`let `);
  3482. for (let i = 0; i < ast.temps; i++) {
  3483. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  3484. }
  3485. }
  3486. if (ast.components.length || ast.directives.length || ast.temps) {
  3487. push(`
  3488. `, 0 /* Start */);
  3489. newline();
  3490. }
  3491. if (!ssr) {
  3492. push(`return `);
  3493. }
  3494. if (ast.codegenNode) {
  3495. genNode(ast.codegenNode, context);
  3496. } else {
  3497. push(`null`);
  3498. }
  3499. if (useWithBlock) {
  3500. deindent();
  3501. push(`}`);
  3502. }
  3503. deindent();
  3504. push(`}`);
  3505. return {
  3506. ast,
  3507. code: context.code,
  3508. preamble: ``,
  3509. map: context.map ? context.map.toJSON() : void 0
  3510. };
  3511. }
  3512. function genFunctionPreamble(ast, context) {
  3513. const {
  3514. ssr,
  3515. prefixIdentifiers,
  3516. push,
  3517. newline,
  3518. runtimeModuleName,
  3519. runtimeGlobalName,
  3520. ssrRuntimeModuleName
  3521. } = context;
  3522. const VueBinding = runtimeGlobalName;
  3523. const helpers = Array.from(ast.helpers);
  3524. if (helpers.length > 0) {
  3525. {
  3526. push(`const _Vue = ${VueBinding}
  3527. `, -1 /* End */);
  3528. if (ast.hoists.length) {
  3529. const staticHelpers = [
  3530. CREATE_VNODE,
  3531. CREATE_ELEMENT_VNODE,
  3532. CREATE_COMMENT,
  3533. CREATE_TEXT,
  3534. CREATE_STATIC
  3535. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  3536. push(`const { ${staticHelpers} } = _Vue
  3537. `, -1 /* End */);
  3538. }
  3539. }
  3540. }
  3541. genHoists(ast.hoists, context);
  3542. newline();
  3543. push(`return `);
  3544. }
  3545. function genAssets(assets, type, { helper, push, newline, isTS }) {
  3546. const resolver = helper(
  3547. type === "filter" ? RESOLVE_FILTER : type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  3548. );
  3549. for (let i = 0; i < assets.length; i++) {
  3550. let id = assets[i];
  3551. const maybeSelfReference = id.endsWith("__self");
  3552. if (maybeSelfReference) {
  3553. id = id.slice(0, -6);
  3554. }
  3555. push(
  3556. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  3557. );
  3558. if (i < assets.length - 1) {
  3559. newline();
  3560. }
  3561. }
  3562. }
  3563. function genHoists(hoists, context) {
  3564. if (!hoists.length) {
  3565. return;
  3566. }
  3567. context.pure = true;
  3568. const { push, newline } = context;
  3569. newline();
  3570. for (let i = 0; i < hoists.length; i++) {
  3571. const exp = hoists[i];
  3572. if (exp) {
  3573. push(`const _hoisted_${i + 1} = `);
  3574. genNode(exp, context);
  3575. newline();
  3576. }
  3577. }
  3578. context.pure = false;
  3579. }
  3580. function isText(n) {
  3581. return isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  3582. }
  3583. function genNodeListAsArray(nodes, context) {
  3584. const multilines = nodes.length > 3 || nodes.some((n) => isArray(n) || !isText(n));
  3585. context.push(`[`);
  3586. multilines && context.indent();
  3587. genNodeList(nodes, context, multilines);
  3588. multilines && context.deindent();
  3589. context.push(`]`);
  3590. }
  3591. function genNodeList(nodes, context, multilines = false, comma = true) {
  3592. const { push, newline } = context;
  3593. for (let i = 0; i < nodes.length; i++) {
  3594. const node = nodes[i];
  3595. if (isString(node)) {
  3596. push(node, -3 /* Unknown */);
  3597. } else if (isArray(node)) {
  3598. genNodeListAsArray(node, context);
  3599. } else {
  3600. genNode(node, context);
  3601. }
  3602. if (i < nodes.length - 1) {
  3603. if (multilines) {
  3604. comma && push(",");
  3605. newline();
  3606. } else {
  3607. comma && push(", ");
  3608. }
  3609. }
  3610. }
  3611. }
  3612. function genNode(node, context) {
  3613. if (isString(node)) {
  3614. context.push(node, -3 /* Unknown */);
  3615. return;
  3616. }
  3617. if (isSymbol(node)) {
  3618. context.push(context.helper(node));
  3619. return;
  3620. }
  3621. switch (node.type) {
  3622. case 1:
  3623. case 9:
  3624. case 11:
  3625. assert(
  3626. node.codegenNode != null,
  3627. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  3628. );
  3629. genNode(node.codegenNode, context);
  3630. break;
  3631. case 2:
  3632. genText(node, context);
  3633. break;
  3634. case 4:
  3635. genExpression(node, context);
  3636. break;
  3637. case 5:
  3638. genInterpolation(node, context);
  3639. break;
  3640. case 12:
  3641. genNode(node.codegenNode, context);
  3642. break;
  3643. case 8:
  3644. genCompoundExpression(node, context);
  3645. break;
  3646. case 3:
  3647. genComment(node, context);
  3648. break;
  3649. case 13:
  3650. genVNodeCall(node, context);
  3651. break;
  3652. case 14:
  3653. genCallExpression(node, context);
  3654. break;
  3655. case 15:
  3656. genObjectExpression(node, context);
  3657. break;
  3658. case 17:
  3659. genArrayExpression(node, context);
  3660. break;
  3661. case 18:
  3662. genFunctionExpression(node, context);
  3663. break;
  3664. case 19:
  3665. genConditionalExpression(node, context);
  3666. break;
  3667. case 20:
  3668. genCacheExpression(node, context);
  3669. break;
  3670. case 21:
  3671. genNodeList(node.body, context, true, false);
  3672. break;
  3673. // SSR only types
  3674. case 22:
  3675. break;
  3676. case 23:
  3677. break;
  3678. case 24:
  3679. break;
  3680. case 25:
  3681. break;
  3682. case 26:
  3683. break;
  3684. /* v8 ignore start */
  3685. case 10:
  3686. break;
  3687. default:
  3688. {
  3689. assert(false, `unhandled codegen node type: ${node.type}`);
  3690. const exhaustiveCheck = node;
  3691. return exhaustiveCheck;
  3692. }
  3693. }
  3694. }
  3695. function genText(node, context) {
  3696. context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
  3697. }
  3698. function genExpression(node, context) {
  3699. const { content, isStatic } = node;
  3700. context.push(
  3701. isStatic ? JSON.stringify(content) : content,
  3702. -3 /* Unknown */,
  3703. node
  3704. );
  3705. }
  3706. function genInterpolation(node, context) {
  3707. const { push, helper, pure } = context;
  3708. if (pure) push(PURE_ANNOTATION);
  3709. push(`${helper(TO_DISPLAY_STRING)}(`);
  3710. genNode(node.content, context);
  3711. push(`)`);
  3712. }
  3713. function genCompoundExpression(node, context) {
  3714. for (let i = 0; i < node.children.length; i++) {
  3715. const child = node.children[i];
  3716. if (isString(child)) {
  3717. context.push(child, -3 /* Unknown */);
  3718. } else {
  3719. genNode(child, context);
  3720. }
  3721. }
  3722. }
  3723. function genExpressionAsPropertyKey(node, context) {
  3724. const { push } = context;
  3725. if (node.type === 8) {
  3726. push(`[`);
  3727. genCompoundExpression(node, context);
  3728. push(`]`);
  3729. } else if (node.isStatic) {
  3730. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  3731. push(text, -2 /* None */, node);
  3732. } else {
  3733. push(`[${node.content}]`, -3 /* Unknown */, node);
  3734. }
  3735. }
  3736. function genComment(node, context) {
  3737. const { push, helper, pure } = context;
  3738. if (pure) {
  3739. push(PURE_ANNOTATION);
  3740. }
  3741. push(
  3742. `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
  3743. -3 /* Unknown */,
  3744. node
  3745. );
  3746. }
  3747. function genVNodeCall(node, context) {
  3748. const { push, helper, pure } = context;
  3749. const {
  3750. tag,
  3751. props,
  3752. children,
  3753. patchFlag,
  3754. dynamicProps,
  3755. directives,
  3756. isBlock,
  3757. disableTracking,
  3758. isComponent
  3759. } = node;
  3760. let patchFlagString;
  3761. if (patchFlag) {
  3762. {
  3763. if (patchFlag < 0) {
  3764. patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  3765. } else {
  3766. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  3767. patchFlagString = patchFlag + ` /* ${flagNames} */`;
  3768. }
  3769. }
  3770. }
  3771. if (directives) {
  3772. push(helper(WITH_DIRECTIVES) + `(`);
  3773. }
  3774. if (isBlock) {
  3775. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  3776. }
  3777. if (pure) {
  3778. push(PURE_ANNOTATION);
  3779. }
  3780. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
  3781. push(helper(callHelper) + `(`, -2 /* None */, node);
  3782. genNodeList(
  3783. genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
  3784. context
  3785. );
  3786. push(`)`);
  3787. if (isBlock) {
  3788. push(`)`);
  3789. }
  3790. if (directives) {
  3791. push(`, `);
  3792. genNode(directives, context);
  3793. push(`)`);
  3794. }
  3795. }
  3796. function genNullableArgs(args) {
  3797. let i = args.length;
  3798. while (i--) {
  3799. if (args[i] != null) break;
  3800. }
  3801. return args.slice(0, i + 1).map((arg) => arg || `null`);
  3802. }
  3803. function genCallExpression(node, context) {
  3804. const { push, helper, pure } = context;
  3805. const callee = isString(node.callee) ? node.callee : helper(node.callee);
  3806. if (pure) {
  3807. push(PURE_ANNOTATION);
  3808. }
  3809. push(callee + `(`, -2 /* None */, node);
  3810. genNodeList(node.arguments, context);
  3811. push(`)`);
  3812. }
  3813. function genObjectExpression(node, context) {
  3814. const { push, indent, deindent, newline } = context;
  3815. const { properties } = node;
  3816. if (!properties.length) {
  3817. push(`{}`, -2 /* None */, node);
  3818. return;
  3819. }
  3820. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  3821. push(multilines ? `{` : `{ `);
  3822. multilines && indent();
  3823. for (let i = 0; i < properties.length; i++) {
  3824. const { key, value } = properties[i];
  3825. genExpressionAsPropertyKey(key, context);
  3826. push(`: `);
  3827. genNode(value, context);
  3828. if (i < properties.length - 1) {
  3829. push(`,`);
  3830. newline();
  3831. }
  3832. }
  3833. multilines && deindent();
  3834. push(multilines ? `}` : ` }`);
  3835. }
  3836. function genArrayExpression(node, context) {
  3837. genNodeListAsArray(node.elements, context);
  3838. }
  3839. function genFunctionExpression(node, context) {
  3840. const { push, indent, deindent } = context;
  3841. const { params, returns, body, newline, isSlot } = node;
  3842. if (isSlot) {
  3843. push(`_${helperNameMap[WITH_CTX]}(`);
  3844. }
  3845. push(`(`, -2 /* None */, node);
  3846. if (isArray(params)) {
  3847. genNodeList(params, context);
  3848. } else if (params) {
  3849. genNode(params, context);
  3850. }
  3851. push(`) => `);
  3852. if (newline || body) {
  3853. push(`{`);
  3854. indent();
  3855. }
  3856. if (returns) {
  3857. if (newline) {
  3858. push(`return `);
  3859. }
  3860. if (isArray(returns)) {
  3861. genNodeListAsArray(returns, context);
  3862. } else {
  3863. genNode(returns, context);
  3864. }
  3865. } else if (body) {
  3866. genNode(body, context);
  3867. }
  3868. if (newline || body) {
  3869. deindent();
  3870. push(`}`);
  3871. }
  3872. if (isSlot) {
  3873. if (node.isNonScopedSlot) {
  3874. push(`, undefined, true`);
  3875. }
  3876. push(`)`);
  3877. }
  3878. }
  3879. function genConditionalExpression(node, context) {
  3880. const { test, consequent, alternate, newline: needNewline } = node;
  3881. const { push, indent, deindent, newline } = context;
  3882. if (test.type === 4) {
  3883. const needsParens = !isSimpleIdentifier(test.content);
  3884. needsParens && push(`(`);
  3885. genExpression(test, context);
  3886. needsParens && push(`)`);
  3887. } else {
  3888. push(`(`);
  3889. genNode(test, context);
  3890. push(`)`);
  3891. }
  3892. needNewline && indent();
  3893. context.indentLevel++;
  3894. needNewline || push(` `);
  3895. push(`? `);
  3896. genNode(consequent, context);
  3897. context.indentLevel--;
  3898. needNewline && newline();
  3899. needNewline || push(` `);
  3900. push(`: `);
  3901. const isNested = alternate.type === 19;
  3902. if (!isNested) {
  3903. context.indentLevel++;
  3904. }
  3905. genNode(alternate, context);
  3906. if (!isNested) {
  3907. context.indentLevel--;
  3908. }
  3909. needNewline && deindent(
  3910. true
  3911. /* without newline */
  3912. );
  3913. }
  3914. function genCacheExpression(node, context) {
  3915. const { push, helper, indent, deindent, newline } = context;
  3916. const { needPauseTracking, needArraySpread } = node;
  3917. if (needArraySpread) {
  3918. push(`[...(`);
  3919. }
  3920. push(`_cache[${node.index}] || (`);
  3921. if (needPauseTracking) {
  3922. indent();
  3923. push(`${helper(SET_BLOCK_TRACKING)}(-1`);
  3924. if (node.inVOnce) push(`, true`);
  3925. push(`),`);
  3926. newline();
  3927. push(`(`);
  3928. }
  3929. push(`_cache[${node.index}] = `);
  3930. genNode(node.value, context);
  3931. if (needPauseTracking) {
  3932. push(`).cacheIndex = ${node.index},`);
  3933. newline();
  3934. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  3935. newline();
  3936. push(`_cache[${node.index}]`);
  3937. deindent();
  3938. }
  3939. push(`)`);
  3940. if (needArraySpread) {
  3941. push(`)]`);
  3942. }
  3943. }
  3944. const prohibitedKeywordRE = new RegExp(
  3945. "\\b" + "arguments,await,break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,let,new,return,super,switch,throw,try,var,void,while,with,yield".split(",").join("\\b|\\b") + "\\b"
  3946. );
  3947. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  3948. function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
  3949. const exp = node.content;
  3950. if (!exp.trim()) {
  3951. return;
  3952. }
  3953. try {
  3954. new Function(
  3955. asRawStatements ? ` ${exp} ` : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`
  3956. );
  3957. } catch (e) {
  3958. let message = e.message;
  3959. const keywordMatch = exp.replace(stripStringRE, "").match(prohibitedKeywordRE);
  3960. if (keywordMatch) {
  3961. message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
  3962. }
  3963. context.onError(
  3964. createCompilerError(
  3965. 45,
  3966. node.loc,
  3967. void 0,
  3968. message
  3969. )
  3970. );
  3971. }
  3972. }
  3973. const transformExpression = (node, context) => {
  3974. if (node.type === 5) {
  3975. node.content = processExpression(
  3976. node.content,
  3977. context
  3978. );
  3979. } else if (node.type === 1) {
  3980. const memo = findDir(node, "memo");
  3981. for (let i = 0; i < node.props.length; i++) {
  3982. const dir = node.props[i];
  3983. if (dir.type === 7 && dir.name !== "for") {
  3984. const exp = dir.exp;
  3985. const arg = dir.arg;
  3986. if (exp && exp.type === 4 && !(dir.name === "on" && arg) && // key has been processed in transformFor(vMemo + vFor)
  3987. !(memo && arg && arg.type === 4 && arg.content === "key")) {
  3988. dir.exp = processExpression(
  3989. exp,
  3990. context,
  3991. // slot args must be processed as function params
  3992. dir.name === "slot"
  3993. );
  3994. }
  3995. if (arg && arg.type === 4 && !arg.isStatic) {
  3996. dir.arg = processExpression(arg, context);
  3997. }
  3998. }
  3999. }
  4000. }
  4001. };
  4002. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  4003. {
  4004. {
  4005. validateBrowserExpression(node, context, asParams, asRawStatements);
  4006. }
  4007. return node;
  4008. }
  4009. }
  4010. function stringifyExpression(exp) {
  4011. if (isString(exp)) {
  4012. return exp;
  4013. } else if (exp.type === 4) {
  4014. return exp.content;
  4015. } else {
  4016. return exp.children.map(stringifyExpression).join("");
  4017. }
  4018. }
  4019. const transformIf = createStructuralDirectiveTransform(
  4020. /^(?:if|else|else-if)$/,
  4021. (node, dir, context) => {
  4022. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  4023. const siblings = context.parent.children;
  4024. let i = siblings.indexOf(ifNode);
  4025. let key = 0;
  4026. while (i-- >= 0) {
  4027. const sibling = siblings[i];
  4028. if (sibling && sibling.type === 9) {
  4029. key += sibling.branches.length;
  4030. }
  4031. }
  4032. return () => {
  4033. if (isRoot) {
  4034. ifNode.codegenNode = createCodegenNodeForBranch(
  4035. branch,
  4036. key,
  4037. context
  4038. );
  4039. } else {
  4040. const parentCondition = getParentCondition(ifNode.codegenNode);
  4041. parentCondition.alternate = createCodegenNodeForBranch(
  4042. branch,
  4043. key + ifNode.branches.length - 1,
  4044. context
  4045. );
  4046. }
  4047. };
  4048. });
  4049. }
  4050. );
  4051. function processIf(node, dir, context, processCodegen) {
  4052. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  4053. const loc = dir.exp ? dir.exp.loc : node.loc;
  4054. context.onError(
  4055. createCompilerError(28, dir.loc)
  4056. );
  4057. dir.exp = createSimpleExpression(`true`, false, loc);
  4058. }
  4059. if (dir.exp) {
  4060. validateBrowserExpression(dir.exp, context);
  4061. }
  4062. if (dir.name === "if") {
  4063. const branch = createIfBranch(node, dir);
  4064. const ifNode = {
  4065. type: 9,
  4066. loc: cloneLoc(node.loc),
  4067. branches: [branch]
  4068. };
  4069. context.replaceNode(ifNode);
  4070. if (processCodegen) {
  4071. return processCodegen(ifNode, branch, true);
  4072. }
  4073. } else {
  4074. const siblings = context.parent.children;
  4075. const comments = [];
  4076. let i = siblings.indexOf(node);
  4077. while (i-- >= -1) {
  4078. const sibling = siblings[i];
  4079. if (sibling && sibling.type === 3) {
  4080. context.removeNode(sibling);
  4081. comments.unshift(sibling);
  4082. continue;
  4083. }
  4084. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  4085. context.removeNode(sibling);
  4086. continue;
  4087. }
  4088. if (sibling && sibling.type === 9) {
  4089. if ((dir.name === "else-if" || dir.name === "else") && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  4090. context.onError(
  4091. createCompilerError(30, node.loc)
  4092. );
  4093. }
  4094. context.removeNode();
  4095. const branch = createIfBranch(node, dir);
  4096. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  4097. !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
  4098. branch.children = [...comments, ...branch.children];
  4099. }
  4100. {
  4101. const key = branch.userKey;
  4102. if (key) {
  4103. sibling.branches.forEach(({ userKey }) => {
  4104. if (isSameKey(userKey, key)) {
  4105. context.onError(
  4106. createCompilerError(
  4107. 29,
  4108. branch.userKey.loc
  4109. )
  4110. );
  4111. }
  4112. });
  4113. }
  4114. }
  4115. sibling.branches.push(branch);
  4116. const onExit = processCodegen && processCodegen(sibling, branch, false);
  4117. traverseNode(branch, context);
  4118. if (onExit) onExit();
  4119. context.currentNode = null;
  4120. } else {
  4121. context.onError(
  4122. createCompilerError(30, node.loc)
  4123. );
  4124. }
  4125. break;
  4126. }
  4127. }
  4128. }
  4129. function createIfBranch(node, dir) {
  4130. const isTemplateIf = node.tagType === 3;
  4131. return {
  4132. type: 10,
  4133. loc: node.loc,
  4134. condition: dir.name === "else" ? void 0 : dir.exp,
  4135. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  4136. userKey: findProp(node, `key`),
  4137. isTemplateIf
  4138. };
  4139. }
  4140. function createCodegenNodeForBranch(branch, keyIndex, context) {
  4141. if (branch.condition) {
  4142. return createConditionalExpression(
  4143. branch.condition,
  4144. createChildrenCodegenNode(branch, keyIndex, context),
  4145. // make sure to pass in asBlock: true so that the comment node call
  4146. // closes the current block.
  4147. createCallExpression(context.helper(CREATE_COMMENT), [
  4148. '"v-if"' ,
  4149. "true"
  4150. ])
  4151. );
  4152. } else {
  4153. return createChildrenCodegenNode(branch, keyIndex, context);
  4154. }
  4155. }
  4156. function createChildrenCodegenNode(branch, keyIndex, context) {
  4157. const { helper } = context;
  4158. const keyProperty = createObjectProperty(
  4159. `key`,
  4160. createSimpleExpression(
  4161. `${keyIndex}`,
  4162. false,
  4163. locStub,
  4164. 2
  4165. )
  4166. );
  4167. const { children } = branch;
  4168. const firstChild = children[0];
  4169. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  4170. if (needFragmentWrapper) {
  4171. if (children.length === 1 && firstChild.type === 11) {
  4172. const vnodeCall = firstChild.codegenNode;
  4173. injectProp(vnodeCall, keyProperty, context);
  4174. return vnodeCall;
  4175. } else {
  4176. let patchFlag = 64;
  4177. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  4178. patchFlag |= 2048;
  4179. }
  4180. return createVNodeCall(
  4181. context,
  4182. helper(FRAGMENT),
  4183. createObjectExpression([keyProperty]),
  4184. children,
  4185. patchFlag,
  4186. void 0,
  4187. void 0,
  4188. true,
  4189. false,
  4190. false,
  4191. branch.loc
  4192. );
  4193. }
  4194. } else {
  4195. const ret = firstChild.codegenNode;
  4196. const vnodeCall = getMemoedVNodeCall(ret);
  4197. if (vnodeCall.type === 13) {
  4198. convertToBlock(vnodeCall, context);
  4199. }
  4200. injectProp(vnodeCall, keyProperty, context);
  4201. return ret;
  4202. }
  4203. }
  4204. function isSameKey(a, b) {
  4205. if (!a || a.type !== b.type) {
  4206. return false;
  4207. }
  4208. if (a.type === 6) {
  4209. if (a.value.content !== b.value.content) {
  4210. return false;
  4211. }
  4212. } else {
  4213. const exp = a.exp;
  4214. const branchExp = b.exp;
  4215. if (exp.type !== branchExp.type) {
  4216. return false;
  4217. }
  4218. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  4219. return false;
  4220. }
  4221. }
  4222. return true;
  4223. }
  4224. function getParentCondition(node) {
  4225. while (true) {
  4226. if (node.type === 19) {
  4227. if (node.alternate.type === 19) {
  4228. node = node.alternate;
  4229. } else {
  4230. return node;
  4231. }
  4232. } else if (node.type === 20) {
  4233. node = node.value;
  4234. }
  4235. }
  4236. }
  4237. const transformBind = (dir, _node, context) => {
  4238. const { modifiers, loc } = dir;
  4239. const arg = dir.arg;
  4240. let { exp } = dir;
  4241. if (exp && exp.type === 4 && !exp.content.trim()) {
  4242. {
  4243. exp = void 0;
  4244. }
  4245. }
  4246. if (!exp) {
  4247. if (arg.type !== 4 || !arg.isStatic) {
  4248. context.onError(
  4249. createCompilerError(
  4250. 52,
  4251. arg.loc
  4252. )
  4253. );
  4254. return {
  4255. props: [
  4256. createObjectProperty(arg, createSimpleExpression("", true, loc))
  4257. ]
  4258. };
  4259. }
  4260. transformBindShorthand(dir);
  4261. exp = dir.exp;
  4262. }
  4263. if (arg.type !== 4) {
  4264. arg.children.unshift(`(`);
  4265. arg.children.push(`) || ""`);
  4266. } else if (!arg.isStatic) {
  4267. arg.content = arg.content ? `${arg.content} || ""` : `""`;
  4268. }
  4269. if (modifiers.some((mod) => mod.content === "camel")) {
  4270. if (arg.type === 4) {
  4271. if (arg.isStatic) {
  4272. arg.content = camelize(arg.content);
  4273. } else {
  4274. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  4275. }
  4276. } else {
  4277. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  4278. arg.children.push(`)`);
  4279. }
  4280. }
  4281. if (!context.inSSR) {
  4282. if (modifiers.some((mod) => mod.content === "prop")) {
  4283. injectPrefix(arg, ".");
  4284. }
  4285. if (modifiers.some((mod) => mod.content === "attr")) {
  4286. injectPrefix(arg, "^");
  4287. }
  4288. }
  4289. return {
  4290. props: [createObjectProperty(arg, exp)]
  4291. };
  4292. };
  4293. const transformBindShorthand = (dir, context) => {
  4294. const arg = dir.arg;
  4295. const propName = camelize(arg.content);
  4296. dir.exp = createSimpleExpression(propName, false, arg.loc);
  4297. };
  4298. const injectPrefix = (arg, prefix) => {
  4299. if (arg.type === 4) {
  4300. if (arg.isStatic) {
  4301. arg.content = prefix + arg.content;
  4302. } else {
  4303. arg.content = `\`${prefix}\${${arg.content}}\``;
  4304. }
  4305. } else {
  4306. arg.children.unshift(`'${prefix}' + (`);
  4307. arg.children.push(`)`);
  4308. }
  4309. };
  4310. const transformFor = createStructuralDirectiveTransform(
  4311. "for",
  4312. (node, dir, context) => {
  4313. const { helper, removeHelper } = context;
  4314. return processFor(node, dir, context, (forNode) => {
  4315. const renderExp = createCallExpression(helper(RENDER_LIST), [
  4316. forNode.source
  4317. ]);
  4318. const isTemplate = isTemplateNode(node);
  4319. const memo = findDir(node, "memo");
  4320. const keyProp = findProp(node, `key`, false, true);
  4321. const isDirKey = keyProp && keyProp.type === 7;
  4322. if (isDirKey && !keyProp.exp) {
  4323. transformBindShorthand(keyProp);
  4324. }
  4325. let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
  4326. const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
  4327. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  4328. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  4329. forNode.codegenNode = createVNodeCall(
  4330. context,
  4331. helper(FRAGMENT),
  4332. void 0,
  4333. renderExp,
  4334. fragmentFlag,
  4335. void 0,
  4336. void 0,
  4337. true,
  4338. !isStableFragment,
  4339. false,
  4340. node.loc
  4341. );
  4342. return () => {
  4343. let childBlock;
  4344. const { children } = forNode;
  4345. if (isTemplate) {
  4346. node.children.some((c) => {
  4347. if (c.type === 1) {
  4348. const key = findProp(c, "key");
  4349. if (key) {
  4350. context.onError(
  4351. createCompilerError(
  4352. 33,
  4353. key.loc
  4354. )
  4355. );
  4356. return true;
  4357. }
  4358. }
  4359. });
  4360. }
  4361. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  4362. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  4363. if (slotOutlet) {
  4364. childBlock = slotOutlet.codegenNode;
  4365. if (isTemplate && keyProperty) {
  4366. injectProp(childBlock, keyProperty, context);
  4367. }
  4368. } else if (needFragmentWrapper) {
  4369. childBlock = createVNodeCall(
  4370. context,
  4371. helper(FRAGMENT),
  4372. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  4373. node.children,
  4374. 64,
  4375. void 0,
  4376. void 0,
  4377. true,
  4378. void 0,
  4379. false
  4380. );
  4381. } else {
  4382. childBlock = children[0].codegenNode;
  4383. if (isTemplate && keyProperty) {
  4384. injectProp(childBlock, keyProperty, context);
  4385. }
  4386. if (childBlock.isBlock !== !isStableFragment) {
  4387. if (childBlock.isBlock) {
  4388. removeHelper(OPEN_BLOCK);
  4389. removeHelper(
  4390. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  4391. );
  4392. } else {
  4393. removeHelper(
  4394. getVNodeHelper(context.inSSR, childBlock.isComponent)
  4395. );
  4396. }
  4397. }
  4398. childBlock.isBlock = !isStableFragment;
  4399. if (childBlock.isBlock) {
  4400. helper(OPEN_BLOCK);
  4401. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  4402. } else {
  4403. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  4404. }
  4405. }
  4406. if (memo) {
  4407. const loop = createFunctionExpression(
  4408. createForLoopParams(forNode.parseResult, [
  4409. createSimpleExpression(`_cached`)
  4410. ])
  4411. );
  4412. loop.body = createBlockStatement([
  4413. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  4414. createCompoundExpression([
  4415. `if (_cached`,
  4416. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  4417. ` && ${context.helperString(
  4418. IS_MEMO_SAME
  4419. )}(_cached, _memo)) return _cached`
  4420. ]),
  4421. createCompoundExpression([`const _item = `, childBlock]),
  4422. createSimpleExpression(`_item.memo = _memo`),
  4423. createSimpleExpression(`return _item`)
  4424. ]);
  4425. renderExp.arguments.push(
  4426. loop,
  4427. createSimpleExpression(`_cache`),
  4428. createSimpleExpression(String(context.cached.length))
  4429. );
  4430. context.cached.push(null);
  4431. } else {
  4432. renderExp.arguments.push(
  4433. createFunctionExpression(
  4434. createForLoopParams(forNode.parseResult),
  4435. childBlock,
  4436. true
  4437. )
  4438. );
  4439. }
  4440. };
  4441. });
  4442. }
  4443. );
  4444. function processFor(node, dir, context, processCodegen) {
  4445. if (!dir.exp) {
  4446. context.onError(
  4447. createCompilerError(31, dir.loc)
  4448. );
  4449. return;
  4450. }
  4451. const parseResult = dir.forParseResult;
  4452. if (!parseResult) {
  4453. context.onError(
  4454. createCompilerError(32, dir.loc)
  4455. );
  4456. return;
  4457. }
  4458. finalizeForParseResult(parseResult, context);
  4459. const { addIdentifiers, removeIdentifiers, scopes } = context;
  4460. const { source, value, key, index } = parseResult;
  4461. const forNode = {
  4462. type: 11,
  4463. loc: dir.loc,
  4464. source,
  4465. valueAlias: value,
  4466. keyAlias: key,
  4467. objectIndexAlias: index,
  4468. parseResult,
  4469. children: isTemplateNode(node) ? node.children : [node]
  4470. };
  4471. context.replaceNode(forNode);
  4472. scopes.vFor++;
  4473. const onExit = processCodegen && processCodegen(forNode);
  4474. return () => {
  4475. scopes.vFor--;
  4476. if (onExit) onExit();
  4477. };
  4478. }
  4479. function finalizeForParseResult(result, context) {
  4480. if (result.finalized) return;
  4481. {
  4482. validateBrowserExpression(result.source, context);
  4483. if (result.key) {
  4484. validateBrowserExpression(
  4485. result.key,
  4486. context,
  4487. true
  4488. );
  4489. }
  4490. if (result.index) {
  4491. validateBrowserExpression(
  4492. result.index,
  4493. context,
  4494. true
  4495. );
  4496. }
  4497. if (result.value) {
  4498. validateBrowserExpression(
  4499. result.value,
  4500. context,
  4501. true
  4502. );
  4503. }
  4504. }
  4505. result.finalized = true;
  4506. }
  4507. function createForLoopParams({ value, key, index }, memoArgs = []) {
  4508. return createParamsList([value, key, index, ...memoArgs]);
  4509. }
  4510. function createParamsList(args) {
  4511. let i = args.length;
  4512. while (i--) {
  4513. if (args[i]) break;
  4514. }
  4515. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  4516. }
  4517. const defaultFallback = createSimpleExpression(`undefined`, false);
  4518. const trackSlotScopes = (node, context) => {
  4519. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  4520. const vSlot = findDir(node, "slot");
  4521. if (vSlot) {
  4522. vSlot.exp;
  4523. context.scopes.vSlot++;
  4524. return () => {
  4525. context.scopes.vSlot--;
  4526. };
  4527. }
  4528. }
  4529. };
  4530. const trackVForSlotScopes = (node, context) => {
  4531. let vFor;
  4532. if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
  4533. const result = vFor.forParseResult;
  4534. if (result) {
  4535. finalizeForParseResult(result, context);
  4536. const { value, key, index } = result;
  4537. const { addIdentifiers, removeIdentifiers } = context;
  4538. value && addIdentifiers(value);
  4539. key && addIdentifiers(key);
  4540. index && addIdentifiers(index);
  4541. return () => {
  4542. value && removeIdentifiers(value);
  4543. key && removeIdentifiers(key);
  4544. index && removeIdentifiers(index);
  4545. };
  4546. }
  4547. }
  4548. };
  4549. const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
  4550. props,
  4551. children,
  4552. false,
  4553. true,
  4554. children.length ? children[0].loc : loc
  4555. );
  4556. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  4557. context.helper(WITH_CTX);
  4558. const { children, loc } = node;
  4559. const slotsProperties = [];
  4560. const dynamicSlots = [];
  4561. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  4562. const onComponentSlot = findDir(node, "slot", true);
  4563. if (onComponentSlot) {
  4564. const { arg, exp } = onComponentSlot;
  4565. if (arg && !isStaticExp(arg)) {
  4566. hasDynamicSlots = true;
  4567. }
  4568. slotsProperties.push(
  4569. createObjectProperty(
  4570. arg || createSimpleExpression("default", true),
  4571. buildSlotFn(exp, void 0, children, loc)
  4572. )
  4573. );
  4574. }
  4575. let hasTemplateSlots = false;
  4576. let hasNamedDefaultSlot = false;
  4577. const implicitDefaultChildren = [];
  4578. const seenSlotNames = /* @__PURE__ */ new Set();
  4579. let conditionalBranchIndex = 0;
  4580. for (let i = 0; i < children.length; i++) {
  4581. const slotElement = children[i];
  4582. let slotDir;
  4583. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  4584. if (slotElement.type !== 3) {
  4585. implicitDefaultChildren.push(slotElement);
  4586. }
  4587. continue;
  4588. }
  4589. if (onComponentSlot) {
  4590. context.onError(
  4591. createCompilerError(37, slotDir.loc)
  4592. );
  4593. break;
  4594. }
  4595. hasTemplateSlots = true;
  4596. const { children: slotChildren, loc: slotLoc } = slotElement;
  4597. const {
  4598. arg: slotName = createSimpleExpression(`default`, true),
  4599. exp: slotProps,
  4600. loc: dirLoc
  4601. } = slotDir;
  4602. let staticSlotName;
  4603. if (isStaticExp(slotName)) {
  4604. staticSlotName = slotName ? slotName.content : `default`;
  4605. } else {
  4606. hasDynamicSlots = true;
  4607. }
  4608. const vFor = findDir(slotElement, "for");
  4609. const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
  4610. let vIf;
  4611. let vElse;
  4612. if (vIf = findDir(slotElement, "if")) {
  4613. hasDynamicSlots = true;
  4614. dynamicSlots.push(
  4615. createConditionalExpression(
  4616. vIf.exp,
  4617. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  4618. defaultFallback
  4619. )
  4620. );
  4621. } else if (vElse = findDir(
  4622. slotElement,
  4623. /^else(?:-if)?$/,
  4624. true
  4625. /* allowEmpty */
  4626. )) {
  4627. let j = i;
  4628. let prev;
  4629. while (j--) {
  4630. prev = children[j];
  4631. if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
  4632. break;
  4633. }
  4634. }
  4635. if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
  4636. let conditional = dynamicSlots[dynamicSlots.length - 1];
  4637. while (conditional.alternate.type === 19) {
  4638. conditional = conditional.alternate;
  4639. }
  4640. conditional.alternate = vElse.exp ? createConditionalExpression(
  4641. vElse.exp,
  4642. buildDynamicSlot(
  4643. slotName,
  4644. slotFunction,
  4645. conditionalBranchIndex++
  4646. ),
  4647. defaultFallback
  4648. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  4649. } else {
  4650. context.onError(
  4651. createCompilerError(30, vElse.loc)
  4652. );
  4653. }
  4654. } else if (vFor) {
  4655. hasDynamicSlots = true;
  4656. const parseResult = vFor.forParseResult;
  4657. if (parseResult) {
  4658. finalizeForParseResult(parseResult, context);
  4659. dynamicSlots.push(
  4660. createCallExpression(context.helper(RENDER_LIST), [
  4661. parseResult.source,
  4662. createFunctionExpression(
  4663. createForLoopParams(parseResult),
  4664. buildDynamicSlot(slotName, slotFunction),
  4665. true
  4666. )
  4667. ])
  4668. );
  4669. } else {
  4670. context.onError(
  4671. createCompilerError(
  4672. 32,
  4673. vFor.loc
  4674. )
  4675. );
  4676. }
  4677. } else {
  4678. if (staticSlotName) {
  4679. if (seenSlotNames.has(staticSlotName)) {
  4680. context.onError(
  4681. createCompilerError(
  4682. 38,
  4683. dirLoc
  4684. )
  4685. );
  4686. continue;
  4687. }
  4688. seenSlotNames.add(staticSlotName);
  4689. if (staticSlotName === "default") {
  4690. hasNamedDefaultSlot = true;
  4691. }
  4692. }
  4693. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  4694. }
  4695. }
  4696. if (!onComponentSlot) {
  4697. const buildDefaultSlotProperty = (props, children2) => {
  4698. const fn = buildSlotFn(props, void 0, children2, loc);
  4699. if (context.compatConfig) {
  4700. fn.isNonScopedSlot = true;
  4701. }
  4702. return createObjectProperty(`default`, fn);
  4703. };
  4704. if (!hasTemplateSlots) {
  4705. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  4706. } else if (implicitDefaultChildren.length && // #3766
  4707. // with whitespace: 'preserve', whitespaces between slots will end up in
  4708. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  4709. implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  4710. if (hasNamedDefaultSlot) {
  4711. context.onError(
  4712. createCompilerError(
  4713. 39,
  4714. implicitDefaultChildren[0].loc
  4715. )
  4716. );
  4717. } else {
  4718. slotsProperties.push(
  4719. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  4720. );
  4721. }
  4722. }
  4723. }
  4724. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  4725. let slots = createObjectExpression(
  4726. slotsProperties.concat(
  4727. createObjectProperty(
  4728. `_`,
  4729. // 2 = compiled but dynamic = can skip normalization, but must run diff
  4730. // 1 = compiled and static = can skip normalization AND diff as optimized
  4731. createSimpleExpression(
  4732. slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
  4733. false
  4734. )
  4735. )
  4736. ),
  4737. loc
  4738. );
  4739. if (dynamicSlots.length) {
  4740. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  4741. slots,
  4742. createArrayExpression(dynamicSlots)
  4743. ]);
  4744. }
  4745. return {
  4746. slots,
  4747. hasDynamicSlots
  4748. };
  4749. }
  4750. function buildDynamicSlot(name, fn, index) {
  4751. const props = [
  4752. createObjectProperty(`name`, name),
  4753. createObjectProperty(`fn`, fn)
  4754. ];
  4755. if (index != null) {
  4756. props.push(
  4757. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  4758. );
  4759. }
  4760. return createObjectExpression(props);
  4761. }
  4762. function hasForwardedSlots(children) {
  4763. for (let i = 0; i < children.length; i++) {
  4764. const child = children[i];
  4765. switch (child.type) {
  4766. case 1:
  4767. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  4768. return true;
  4769. }
  4770. break;
  4771. case 9:
  4772. if (hasForwardedSlots(child.branches)) return true;
  4773. break;
  4774. case 10:
  4775. case 11:
  4776. if (hasForwardedSlots(child.children)) return true;
  4777. break;
  4778. }
  4779. }
  4780. return false;
  4781. }
  4782. function isNonWhitespaceContent(node) {
  4783. if (node.type !== 2 && node.type !== 12)
  4784. return true;
  4785. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  4786. }
  4787. const directiveImportMap = /* @__PURE__ */ new WeakMap();
  4788. const transformElement = (node, context) => {
  4789. return function postTransformElement() {
  4790. node = context.currentNode;
  4791. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  4792. return;
  4793. }
  4794. const { tag, props } = node;
  4795. const isComponent = node.tagType === 1;
  4796. let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
  4797. const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  4798. let vnodeProps;
  4799. let vnodeChildren;
  4800. let patchFlag = 0;
  4801. let vnodeDynamicProps;
  4802. let dynamicPropNames;
  4803. let vnodeDirectives;
  4804. let shouldUseBlock = (
  4805. // dynamic component may resolve to plain elements
  4806. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
  4807. // updates inside get proper isSVG flag at runtime. (#639, #643)
  4808. // This is technically web-specific, but splitting the logic out of core
  4809. // leads to too much unnecessary complexity.
  4810. (tag === "svg" || tag === "foreignObject" || tag === "math")
  4811. );
  4812. if (props.length > 0) {
  4813. const propsBuildResult = buildProps(
  4814. node,
  4815. context,
  4816. void 0,
  4817. isComponent,
  4818. isDynamicComponent
  4819. );
  4820. vnodeProps = propsBuildResult.props;
  4821. patchFlag = propsBuildResult.patchFlag;
  4822. dynamicPropNames = propsBuildResult.dynamicPropNames;
  4823. const directives = propsBuildResult.directives;
  4824. vnodeDirectives = directives && directives.length ? createArrayExpression(
  4825. directives.map((dir) => buildDirectiveArgs(dir, context))
  4826. ) : void 0;
  4827. if (propsBuildResult.shouldUseBlock) {
  4828. shouldUseBlock = true;
  4829. }
  4830. }
  4831. if (node.children.length > 0) {
  4832. if (vnodeTag === KEEP_ALIVE) {
  4833. shouldUseBlock = true;
  4834. patchFlag |= 1024;
  4835. if (node.children.length > 1) {
  4836. context.onError(
  4837. createCompilerError(46, {
  4838. start: node.children[0].loc.start,
  4839. end: node.children[node.children.length - 1].loc.end,
  4840. source: ""
  4841. })
  4842. );
  4843. }
  4844. }
  4845. const shouldBuildAsSlots = isComponent && // Teleport is not a real component and has dedicated runtime handling
  4846. vnodeTag !== TELEPORT && // explained above.
  4847. vnodeTag !== KEEP_ALIVE;
  4848. if (shouldBuildAsSlots) {
  4849. const { slots, hasDynamicSlots } = buildSlots(node, context);
  4850. vnodeChildren = slots;
  4851. if (hasDynamicSlots) {
  4852. patchFlag |= 1024;
  4853. }
  4854. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  4855. const child = node.children[0];
  4856. const type = child.type;
  4857. const hasDynamicTextChild = type === 5 || type === 8;
  4858. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  4859. patchFlag |= 1;
  4860. }
  4861. if (hasDynamicTextChild || type === 2) {
  4862. vnodeChildren = child;
  4863. } else {
  4864. vnodeChildren = node.children;
  4865. }
  4866. } else {
  4867. vnodeChildren = node.children;
  4868. }
  4869. }
  4870. if (dynamicPropNames && dynamicPropNames.length) {
  4871. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  4872. }
  4873. node.codegenNode = createVNodeCall(
  4874. context,
  4875. vnodeTag,
  4876. vnodeProps,
  4877. vnodeChildren,
  4878. patchFlag === 0 ? void 0 : patchFlag,
  4879. vnodeDynamicProps,
  4880. vnodeDirectives,
  4881. !!shouldUseBlock,
  4882. false,
  4883. isComponent,
  4884. node.loc
  4885. );
  4886. };
  4887. };
  4888. function resolveComponentType(node, context, ssr = false) {
  4889. let { tag } = node;
  4890. const isExplicitDynamic = isComponentTag(tag);
  4891. const isProp = findProp(
  4892. node,
  4893. "is",
  4894. false,
  4895. true
  4896. /* allow empty */
  4897. );
  4898. if (isProp) {
  4899. if (isExplicitDynamic || isCompatEnabled(
  4900. "COMPILER_IS_ON_ELEMENT",
  4901. context
  4902. )) {
  4903. let exp;
  4904. if (isProp.type === 6) {
  4905. exp = isProp.value && createSimpleExpression(isProp.value.content, true);
  4906. } else {
  4907. exp = isProp.exp;
  4908. if (!exp) {
  4909. exp = createSimpleExpression(`is`, false, isProp.arg.loc);
  4910. }
  4911. }
  4912. if (exp) {
  4913. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  4914. exp
  4915. ]);
  4916. }
  4917. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  4918. tag = isProp.value.content.slice(4);
  4919. }
  4920. }
  4921. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  4922. if (builtIn) {
  4923. if (!ssr) context.helper(builtIn);
  4924. return builtIn;
  4925. }
  4926. context.helper(RESOLVE_COMPONENT);
  4927. context.components.add(tag);
  4928. return toValidAssetId(tag, `component`);
  4929. }
  4930. function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
  4931. const { tag, loc: elementLoc, children } = node;
  4932. let properties = [];
  4933. const mergeArgs = [];
  4934. const runtimeDirectives = [];
  4935. const hasChildren = children.length > 0;
  4936. let shouldUseBlock = false;
  4937. let patchFlag = 0;
  4938. let hasRef = false;
  4939. let hasClassBinding = false;
  4940. let hasStyleBinding = false;
  4941. let hasHydrationEventBinding = false;
  4942. let hasDynamicKeys = false;
  4943. let hasVnodeHook = false;
  4944. const dynamicPropNames = [];
  4945. const pushMergeArg = (arg) => {
  4946. if (properties.length) {
  4947. mergeArgs.push(
  4948. createObjectExpression(dedupeProperties(properties), elementLoc)
  4949. );
  4950. properties = [];
  4951. }
  4952. if (arg) mergeArgs.push(arg);
  4953. };
  4954. const pushRefVForMarker = () => {
  4955. if (context.scopes.vFor > 0) {
  4956. properties.push(
  4957. createObjectProperty(
  4958. createSimpleExpression("ref_for", true),
  4959. createSimpleExpression("true")
  4960. )
  4961. );
  4962. }
  4963. };
  4964. const analyzePatchFlag = ({ key, value }) => {
  4965. if (isStaticExp(key)) {
  4966. const name = key.content;
  4967. const isEventHandler = isOn(name);
  4968. if (isEventHandler && (!isComponent || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  4969. // dedicated fast path.
  4970. name.toLowerCase() !== "onclick" && // omit v-model handlers
  4971. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  4972. !isReservedProp(name)) {
  4973. hasHydrationEventBinding = true;
  4974. }
  4975. if (isEventHandler && isReservedProp(name)) {
  4976. hasVnodeHook = true;
  4977. }
  4978. if (isEventHandler && value.type === 14) {
  4979. value = value.arguments[0];
  4980. }
  4981. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  4982. return;
  4983. }
  4984. if (name === "ref") {
  4985. hasRef = true;
  4986. } else if (name === "class") {
  4987. hasClassBinding = true;
  4988. } else if (name === "style") {
  4989. hasStyleBinding = true;
  4990. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  4991. dynamicPropNames.push(name);
  4992. }
  4993. if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  4994. dynamicPropNames.push(name);
  4995. }
  4996. } else {
  4997. hasDynamicKeys = true;
  4998. }
  4999. };
  5000. for (let i = 0; i < props.length; i++) {
  5001. const prop = props[i];
  5002. if (prop.type === 6) {
  5003. const { loc, name, nameLoc, value } = prop;
  5004. let isStatic = true;
  5005. if (name === "ref") {
  5006. hasRef = true;
  5007. pushRefVForMarker();
  5008. }
  5009. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || isCompatEnabled(
  5010. "COMPILER_IS_ON_ELEMENT",
  5011. context
  5012. ))) {
  5013. continue;
  5014. }
  5015. properties.push(
  5016. createObjectProperty(
  5017. createSimpleExpression(name, true, nameLoc),
  5018. createSimpleExpression(
  5019. value ? value.content : "",
  5020. isStatic,
  5021. value ? value.loc : loc
  5022. )
  5023. )
  5024. );
  5025. } else {
  5026. const { name, arg, exp, loc, modifiers } = prop;
  5027. const isVBind = name === "bind";
  5028. const isVOn = name === "on";
  5029. if (name === "slot") {
  5030. if (!isComponent) {
  5031. context.onError(
  5032. createCompilerError(40, loc)
  5033. );
  5034. }
  5035. continue;
  5036. }
  5037. if (name === "once" || name === "memo") {
  5038. continue;
  5039. }
  5040. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || isCompatEnabled(
  5041. "COMPILER_IS_ON_ELEMENT",
  5042. context
  5043. ))) {
  5044. continue;
  5045. }
  5046. if (isVOn && ssr) {
  5047. continue;
  5048. }
  5049. if (
  5050. // #938: elements with dynamic keys should be forced into blocks
  5051. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  5052. // before children
  5053. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  5054. ) {
  5055. shouldUseBlock = true;
  5056. }
  5057. if (isVBind && isStaticArgOf(arg, "ref")) {
  5058. pushRefVForMarker();
  5059. }
  5060. if (!arg && (isVBind || isVOn)) {
  5061. hasDynamicKeys = true;
  5062. if (exp) {
  5063. if (isVBind) {
  5064. {
  5065. pushMergeArg();
  5066. {
  5067. const hasOverridableKeys = mergeArgs.some((arg2) => {
  5068. if (arg2.type === 15) {
  5069. return arg2.properties.some(({ key }) => {
  5070. if (key.type !== 4 || !key.isStatic) {
  5071. return true;
  5072. }
  5073. return key.content !== "class" && key.content !== "style" && !isOn(key.content);
  5074. });
  5075. } else {
  5076. return true;
  5077. }
  5078. });
  5079. if (hasOverridableKeys) {
  5080. checkCompatEnabled(
  5081. "COMPILER_V_BIND_OBJECT_ORDER",
  5082. context,
  5083. loc
  5084. );
  5085. }
  5086. }
  5087. if (isCompatEnabled(
  5088. "COMPILER_V_BIND_OBJECT_ORDER",
  5089. context
  5090. )) {
  5091. mergeArgs.unshift(exp);
  5092. continue;
  5093. }
  5094. }
  5095. pushRefVForMarker();
  5096. pushMergeArg();
  5097. mergeArgs.push(exp);
  5098. } else {
  5099. pushMergeArg({
  5100. type: 14,
  5101. loc,
  5102. callee: context.helper(TO_HANDLERS),
  5103. arguments: isComponent ? [exp] : [exp, `true`]
  5104. });
  5105. }
  5106. } else {
  5107. context.onError(
  5108. createCompilerError(
  5109. isVBind ? 34 : 35,
  5110. loc
  5111. )
  5112. );
  5113. }
  5114. continue;
  5115. }
  5116. if (isVBind && modifiers.some((mod) => mod.content === "prop")) {
  5117. patchFlag |= 32;
  5118. }
  5119. const directiveTransform = context.directiveTransforms[name];
  5120. if (directiveTransform) {
  5121. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  5122. !ssr && props2.forEach(analyzePatchFlag);
  5123. if (isVOn && arg && !isStaticExp(arg)) {
  5124. pushMergeArg(createObjectExpression(props2, elementLoc));
  5125. } else {
  5126. properties.push(...props2);
  5127. }
  5128. if (needRuntime) {
  5129. runtimeDirectives.push(prop);
  5130. if (isSymbol(needRuntime)) {
  5131. directiveImportMap.set(prop, needRuntime);
  5132. }
  5133. }
  5134. } else if (!isBuiltInDirective(name)) {
  5135. runtimeDirectives.push(prop);
  5136. if (hasChildren) {
  5137. shouldUseBlock = true;
  5138. }
  5139. }
  5140. }
  5141. }
  5142. let propsExpression = void 0;
  5143. if (mergeArgs.length) {
  5144. pushMergeArg();
  5145. if (mergeArgs.length > 1) {
  5146. propsExpression = createCallExpression(
  5147. context.helper(MERGE_PROPS),
  5148. mergeArgs,
  5149. elementLoc
  5150. );
  5151. } else {
  5152. propsExpression = mergeArgs[0];
  5153. }
  5154. } else if (properties.length) {
  5155. propsExpression = createObjectExpression(
  5156. dedupeProperties(properties),
  5157. elementLoc
  5158. );
  5159. }
  5160. if (hasDynamicKeys) {
  5161. patchFlag |= 16;
  5162. } else {
  5163. if (hasClassBinding && !isComponent) {
  5164. patchFlag |= 2;
  5165. }
  5166. if (hasStyleBinding && !isComponent) {
  5167. patchFlag |= 4;
  5168. }
  5169. if (dynamicPropNames.length) {
  5170. patchFlag |= 8;
  5171. }
  5172. if (hasHydrationEventBinding) {
  5173. patchFlag |= 32;
  5174. }
  5175. }
  5176. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  5177. patchFlag |= 512;
  5178. }
  5179. if (!context.inSSR && propsExpression) {
  5180. switch (propsExpression.type) {
  5181. case 15:
  5182. let classKeyIndex = -1;
  5183. let styleKeyIndex = -1;
  5184. let hasDynamicKey = false;
  5185. for (let i = 0; i < propsExpression.properties.length; i++) {
  5186. const key = propsExpression.properties[i].key;
  5187. if (isStaticExp(key)) {
  5188. if (key.content === "class") {
  5189. classKeyIndex = i;
  5190. } else if (key.content === "style") {
  5191. styleKeyIndex = i;
  5192. }
  5193. } else if (!key.isHandlerKey) {
  5194. hasDynamicKey = true;
  5195. }
  5196. }
  5197. const classProp = propsExpression.properties[classKeyIndex];
  5198. const styleProp = propsExpression.properties[styleKeyIndex];
  5199. if (!hasDynamicKey) {
  5200. if (classProp && !isStaticExp(classProp.value)) {
  5201. classProp.value = createCallExpression(
  5202. context.helper(NORMALIZE_CLASS),
  5203. [classProp.value]
  5204. );
  5205. }
  5206. if (styleProp && // the static style is compiled into an object,
  5207. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  5208. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  5209. // v-bind:style with static literal object
  5210. styleProp.value.type === 17)) {
  5211. styleProp.value = createCallExpression(
  5212. context.helper(NORMALIZE_STYLE),
  5213. [styleProp.value]
  5214. );
  5215. }
  5216. } else {
  5217. propsExpression = createCallExpression(
  5218. context.helper(NORMALIZE_PROPS),
  5219. [propsExpression]
  5220. );
  5221. }
  5222. break;
  5223. case 14:
  5224. break;
  5225. default:
  5226. propsExpression = createCallExpression(
  5227. context.helper(NORMALIZE_PROPS),
  5228. [
  5229. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  5230. propsExpression
  5231. ])
  5232. ]
  5233. );
  5234. break;
  5235. }
  5236. }
  5237. return {
  5238. props: propsExpression,
  5239. directives: runtimeDirectives,
  5240. patchFlag,
  5241. dynamicPropNames,
  5242. shouldUseBlock
  5243. };
  5244. }
  5245. function dedupeProperties(properties) {
  5246. const knownProps = /* @__PURE__ */ new Map();
  5247. const deduped = [];
  5248. for (let i = 0; i < properties.length; i++) {
  5249. const prop = properties[i];
  5250. if (prop.key.type === 8 || !prop.key.isStatic) {
  5251. deduped.push(prop);
  5252. continue;
  5253. }
  5254. const name = prop.key.content;
  5255. const existing = knownProps.get(name);
  5256. if (existing) {
  5257. if (name === "style" || name === "class" || isOn(name)) {
  5258. mergeAsArray(existing, prop);
  5259. }
  5260. } else {
  5261. knownProps.set(name, prop);
  5262. deduped.push(prop);
  5263. }
  5264. }
  5265. return deduped;
  5266. }
  5267. function mergeAsArray(existing, incoming) {
  5268. if (existing.value.type === 17) {
  5269. existing.value.elements.push(incoming.value);
  5270. } else {
  5271. existing.value = createArrayExpression(
  5272. [existing.value, incoming.value],
  5273. existing.loc
  5274. );
  5275. }
  5276. }
  5277. function buildDirectiveArgs(dir, context) {
  5278. const dirArgs = [];
  5279. const runtime = directiveImportMap.get(dir);
  5280. if (runtime) {
  5281. dirArgs.push(context.helperString(runtime));
  5282. } else {
  5283. {
  5284. context.helper(RESOLVE_DIRECTIVE);
  5285. context.directives.add(dir.name);
  5286. dirArgs.push(toValidAssetId(dir.name, `directive`));
  5287. }
  5288. }
  5289. const { loc } = dir;
  5290. if (dir.exp) dirArgs.push(dir.exp);
  5291. if (dir.arg) {
  5292. if (!dir.exp) {
  5293. dirArgs.push(`void 0`);
  5294. }
  5295. dirArgs.push(dir.arg);
  5296. }
  5297. if (Object.keys(dir.modifiers).length) {
  5298. if (!dir.arg) {
  5299. if (!dir.exp) {
  5300. dirArgs.push(`void 0`);
  5301. }
  5302. dirArgs.push(`void 0`);
  5303. }
  5304. const trueExpression = createSimpleExpression(`true`, false, loc);
  5305. dirArgs.push(
  5306. createObjectExpression(
  5307. dir.modifiers.map(
  5308. (modifier) => createObjectProperty(modifier, trueExpression)
  5309. ),
  5310. loc
  5311. )
  5312. );
  5313. }
  5314. return createArrayExpression(dirArgs, dir.loc);
  5315. }
  5316. function stringifyDynamicPropNames(props) {
  5317. let propsNamesString = `[`;
  5318. for (let i = 0, l = props.length; i < l; i++) {
  5319. propsNamesString += JSON.stringify(props[i]);
  5320. if (i < l - 1) propsNamesString += ", ";
  5321. }
  5322. return propsNamesString + `]`;
  5323. }
  5324. function isComponentTag(tag) {
  5325. return tag === "component" || tag === "Component";
  5326. }
  5327. const transformSlotOutlet = (node, context) => {
  5328. if (isSlotOutlet(node)) {
  5329. const { children, loc } = node;
  5330. const { slotName, slotProps } = processSlotOutlet(node, context);
  5331. const slotArgs = [
  5332. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  5333. slotName,
  5334. "{}",
  5335. "undefined",
  5336. "true"
  5337. ];
  5338. let expectedLen = 2;
  5339. if (slotProps) {
  5340. slotArgs[2] = slotProps;
  5341. expectedLen = 3;
  5342. }
  5343. if (children.length) {
  5344. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  5345. expectedLen = 4;
  5346. }
  5347. if (context.scopeId && !context.slotted) {
  5348. expectedLen = 5;
  5349. }
  5350. slotArgs.splice(expectedLen);
  5351. node.codegenNode = createCallExpression(
  5352. context.helper(RENDER_SLOT),
  5353. slotArgs,
  5354. loc
  5355. );
  5356. }
  5357. };
  5358. function processSlotOutlet(node, context) {
  5359. let slotName = `"default"`;
  5360. let slotProps = void 0;
  5361. const nonNameProps = [];
  5362. for (let i = 0; i < node.props.length; i++) {
  5363. const p = node.props[i];
  5364. if (p.type === 6) {
  5365. if (p.value) {
  5366. if (p.name === "name") {
  5367. slotName = JSON.stringify(p.value.content);
  5368. } else {
  5369. p.name = camelize(p.name);
  5370. nonNameProps.push(p);
  5371. }
  5372. }
  5373. } else {
  5374. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  5375. if (p.exp) {
  5376. slotName = p.exp;
  5377. } else if (p.arg && p.arg.type === 4) {
  5378. const name = camelize(p.arg.content);
  5379. slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
  5380. }
  5381. } else {
  5382. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  5383. p.arg.content = camelize(p.arg.content);
  5384. }
  5385. nonNameProps.push(p);
  5386. }
  5387. }
  5388. }
  5389. if (nonNameProps.length > 0) {
  5390. const { props, directives } = buildProps(
  5391. node,
  5392. context,
  5393. nonNameProps,
  5394. false,
  5395. false
  5396. );
  5397. slotProps = props;
  5398. if (directives.length) {
  5399. context.onError(
  5400. createCompilerError(
  5401. 36,
  5402. directives[0].loc
  5403. )
  5404. );
  5405. }
  5406. }
  5407. return {
  5408. slotName,
  5409. slotProps
  5410. };
  5411. }
  5412. const transformOn$1 = (dir, node, context, augmentor) => {
  5413. const { loc, modifiers, arg } = dir;
  5414. if (!dir.exp && !modifiers.length) {
  5415. context.onError(createCompilerError(35, loc));
  5416. }
  5417. let eventName;
  5418. if (arg.type === 4) {
  5419. if (arg.isStatic) {
  5420. let rawName = arg.content;
  5421. if (rawName.startsWith("vnode")) {
  5422. context.onError(createCompilerError(51, arg.loc));
  5423. }
  5424. if (rawName.startsWith("vue:")) {
  5425. rawName = `vnode-${rawName.slice(4)}`;
  5426. }
  5427. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  5428. // for non-element and vnode lifecycle event listeners, auto convert
  5429. // it to camelCase. See issue #2249
  5430. toHandlerKey(camelize(rawName))
  5431. ) : (
  5432. // preserve case for plain element listeners that have uppercase
  5433. // letters, as these may be custom elements' custom events
  5434. `on:${rawName}`
  5435. );
  5436. eventName = createSimpleExpression(eventString, true, arg.loc);
  5437. } else {
  5438. eventName = createCompoundExpression([
  5439. `${context.helperString(TO_HANDLER_KEY)}(`,
  5440. arg,
  5441. `)`
  5442. ]);
  5443. }
  5444. } else {
  5445. eventName = arg;
  5446. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  5447. eventName.children.push(`)`);
  5448. }
  5449. let exp = dir.exp;
  5450. if (exp && !exp.content.trim()) {
  5451. exp = void 0;
  5452. }
  5453. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  5454. if (exp) {
  5455. const isMemberExp = isMemberExpression(exp);
  5456. const isInlineStatement = !(isMemberExp || isFnExpression(exp));
  5457. const hasMultipleStatements = exp.content.includes(`;`);
  5458. {
  5459. validateBrowserExpression(
  5460. exp,
  5461. context,
  5462. false,
  5463. hasMultipleStatements
  5464. );
  5465. }
  5466. if (isInlineStatement || shouldCache && isMemberExp) {
  5467. exp = createCompoundExpression([
  5468. `${isInlineStatement ? `$event` : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  5469. exp,
  5470. hasMultipleStatements ? `}` : `)`
  5471. ]);
  5472. }
  5473. }
  5474. let ret = {
  5475. props: [
  5476. createObjectProperty(
  5477. eventName,
  5478. exp || createSimpleExpression(`() => {}`, false, loc)
  5479. )
  5480. ]
  5481. };
  5482. if (augmentor) {
  5483. ret = augmentor(ret);
  5484. }
  5485. if (shouldCache) {
  5486. ret.props[0].value = context.cache(ret.props[0].value);
  5487. }
  5488. ret.props.forEach((p) => p.key.isHandlerKey = true);
  5489. return ret;
  5490. };
  5491. const transformText = (node, context) => {
  5492. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  5493. return () => {
  5494. const children = node.children;
  5495. let currentContainer = void 0;
  5496. let hasText = false;
  5497. for (let i = 0; i < children.length; i++) {
  5498. const child = children[i];
  5499. if (isText$1(child)) {
  5500. hasText = true;
  5501. for (let j = i + 1; j < children.length; j++) {
  5502. const next = children[j];
  5503. if (isText$1(next)) {
  5504. if (!currentContainer) {
  5505. currentContainer = children[i] = createCompoundExpression(
  5506. [child],
  5507. child.loc
  5508. );
  5509. }
  5510. currentContainer.children.push(` + `, next);
  5511. children.splice(j, 1);
  5512. j--;
  5513. } else {
  5514. currentContainer = void 0;
  5515. break;
  5516. }
  5517. }
  5518. }
  5519. }
  5520. if (!hasText || // if this is a plain element with a single text child, leave it
  5521. // as-is since the runtime has dedicated fast path for this by directly
  5522. // setting textContent of the element.
  5523. // for component root it's always normalized anyway.
  5524. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  5525. // custom directives can potentially add DOM elements arbitrarily,
  5526. // we need to avoid setting textContent of the element at runtime
  5527. // to avoid accidentally overwriting the DOM elements added
  5528. // by the user through custom directives.
  5529. !node.props.find(
  5530. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  5531. ) && // in compat mode, <template> tags with no special directives
  5532. // will be rendered as a fragment so its children must be
  5533. // converted into vnodes.
  5534. !(node.tag === "template"))) {
  5535. return;
  5536. }
  5537. for (let i = 0; i < children.length; i++) {
  5538. const child = children[i];
  5539. if (isText$1(child) || child.type === 8) {
  5540. const callArgs = [];
  5541. if (child.type !== 2 || child.content !== " ") {
  5542. callArgs.push(child);
  5543. }
  5544. if (!context.ssr && getConstantType(child, context) === 0) {
  5545. callArgs.push(
  5546. 1 + (` /* ${PatchFlagNames[1]} */` )
  5547. );
  5548. }
  5549. children[i] = {
  5550. type: 12,
  5551. content: child,
  5552. loc: child.loc,
  5553. codegenNode: createCallExpression(
  5554. context.helper(CREATE_TEXT),
  5555. callArgs
  5556. )
  5557. };
  5558. }
  5559. }
  5560. };
  5561. }
  5562. };
  5563. const seen$1 = /* @__PURE__ */ new WeakSet();
  5564. const transformOnce = (node, context) => {
  5565. if (node.type === 1 && findDir(node, "once", true)) {
  5566. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  5567. return;
  5568. }
  5569. seen$1.add(node);
  5570. context.inVOnce = true;
  5571. context.helper(SET_BLOCK_TRACKING);
  5572. return () => {
  5573. context.inVOnce = false;
  5574. const cur = context.currentNode;
  5575. if (cur.codegenNode) {
  5576. cur.codegenNode = context.cache(
  5577. cur.codegenNode,
  5578. true,
  5579. true
  5580. );
  5581. }
  5582. };
  5583. }
  5584. };
  5585. const transformModel$1 = (dir, node, context) => {
  5586. const { exp, arg } = dir;
  5587. if (!exp) {
  5588. context.onError(
  5589. createCompilerError(41, dir.loc)
  5590. );
  5591. return createTransformProps();
  5592. }
  5593. const rawExp = exp.loc.source.trim();
  5594. const expString = exp.type === 4 ? exp.content : rawExp;
  5595. const bindingType = context.bindingMetadata[rawExp];
  5596. if (bindingType === "props" || bindingType === "props-aliased") {
  5597. context.onError(createCompilerError(44, exp.loc));
  5598. return createTransformProps();
  5599. }
  5600. if (!expString.trim() || !isMemberExpression(exp) && true) {
  5601. context.onError(
  5602. createCompilerError(42, exp.loc)
  5603. );
  5604. return createTransformProps();
  5605. }
  5606. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  5607. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  5608. let assignmentExp;
  5609. const eventArg = context.isTS ? `($event: any)` : `$event`;
  5610. {
  5611. assignmentExp = createCompoundExpression([
  5612. `${eventArg} => ((`,
  5613. exp,
  5614. `) = $event)`
  5615. ]);
  5616. }
  5617. const props = [
  5618. // modelValue: foo
  5619. createObjectProperty(propName, dir.exp),
  5620. // "onUpdate:modelValue": $event => (foo = $event)
  5621. createObjectProperty(eventName, assignmentExp)
  5622. ];
  5623. if (dir.modifiers.length && node.tagType === 1) {
  5624. const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  5625. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  5626. props.push(
  5627. createObjectProperty(
  5628. modifiersKey,
  5629. createSimpleExpression(
  5630. `{ ${modifiers} }`,
  5631. false,
  5632. dir.loc,
  5633. 2
  5634. )
  5635. )
  5636. );
  5637. }
  5638. return createTransformProps(props);
  5639. };
  5640. function createTransformProps(props = []) {
  5641. return { props };
  5642. }
  5643. const validDivisionCharRE = /[\w).+\-_$\]]/;
  5644. const transformFilter = (node, context) => {
  5645. if (!isCompatEnabled("COMPILER_FILTERS", context)) {
  5646. return;
  5647. }
  5648. if (node.type === 5) {
  5649. rewriteFilter(node.content, context);
  5650. } else if (node.type === 1) {
  5651. node.props.forEach((prop) => {
  5652. if (prop.type === 7 && prop.name !== "for" && prop.exp) {
  5653. rewriteFilter(prop.exp, context);
  5654. }
  5655. });
  5656. }
  5657. };
  5658. function rewriteFilter(node, context) {
  5659. if (node.type === 4) {
  5660. parseFilter(node, context);
  5661. } else {
  5662. for (let i = 0; i < node.children.length; i++) {
  5663. const child = node.children[i];
  5664. if (typeof child !== "object") continue;
  5665. if (child.type === 4) {
  5666. parseFilter(child, context);
  5667. } else if (child.type === 8) {
  5668. rewriteFilter(node, context);
  5669. } else if (child.type === 5) {
  5670. rewriteFilter(child.content, context);
  5671. }
  5672. }
  5673. }
  5674. }
  5675. function parseFilter(node, context) {
  5676. const exp = node.content;
  5677. let inSingle = false;
  5678. let inDouble = false;
  5679. let inTemplateString = false;
  5680. let inRegex = false;
  5681. let curly = 0;
  5682. let square = 0;
  5683. let paren = 0;
  5684. let lastFilterIndex = 0;
  5685. let c, prev, i, expression, filters = [];
  5686. for (i = 0; i < exp.length; i++) {
  5687. prev = c;
  5688. c = exp.charCodeAt(i);
  5689. if (inSingle) {
  5690. if (c === 39 && prev !== 92) inSingle = false;
  5691. } else if (inDouble) {
  5692. if (c === 34 && prev !== 92) inDouble = false;
  5693. } else if (inTemplateString) {
  5694. if (c === 96 && prev !== 92) inTemplateString = false;
  5695. } else if (inRegex) {
  5696. if (c === 47 && prev !== 92) inRegex = false;
  5697. } else if (c === 124 && // pipe
  5698. exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) {
  5699. if (expression === void 0) {
  5700. lastFilterIndex = i + 1;
  5701. expression = exp.slice(0, i).trim();
  5702. } else {
  5703. pushFilter();
  5704. }
  5705. } else {
  5706. switch (c) {
  5707. case 34:
  5708. inDouble = true;
  5709. break;
  5710. // "
  5711. case 39:
  5712. inSingle = true;
  5713. break;
  5714. // '
  5715. case 96:
  5716. inTemplateString = true;
  5717. break;
  5718. // `
  5719. case 40:
  5720. paren++;
  5721. break;
  5722. // (
  5723. case 41:
  5724. paren--;
  5725. break;
  5726. // )
  5727. case 91:
  5728. square++;
  5729. break;
  5730. // [
  5731. case 93:
  5732. square--;
  5733. break;
  5734. // ]
  5735. case 123:
  5736. curly++;
  5737. break;
  5738. // {
  5739. case 125:
  5740. curly--;
  5741. break;
  5742. }
  5743. if (c === 47) {
  5744. let j = i - 1;
  5745. let p;
  5746. for (; j >= 0; j--) {
  5747. p = exp.charAt(j);
  5748. if (p !== " ") break;
  5749. }
  5750. if (!p || !validDivisionCharRE.test(p)) {
  5751. inRegex = true;
  5752. }
  5753. }
  5754. }
  5755. }
  5756. if (expression === void 0) {
  5757. expression = exp.slice(0, i).trim();
  5758. } else if (lastFilterIndex !== 0) {
  5759. pushFilter();
  5760. }
  5761. function pushFilter() {
  5762. filters.push(exp.slice(lastFilterIndex, i).trim());
  5763. lastFilterIndex = i + 1;
  5764. }
  5765. if (filters.length) {
  5766. warnDeprecation(
  5767. "COMPILER_FILTERS",
  5768. context,
  5769. node.loc
  5770. );
  5771. for (i = 0; i < filters.length; i++) {
  5772. expression = wrapFilter(expression, filters[i], context);
  5773. }
  5774. node.content = expression;
  5775. node.ast = void 0;
  5776. }
  5777. }
  5778. function wrapFilter(exp, filter, context) {
  5779. context.helper(RESOLVE_FILTER);
  5780. const i = filter.indexOf("(");
  5781. if (i < 0) {
  5782. context.filters.add(filter);
  5783. return `${toValidAssetId(filter, "filter")}(${exp})`;
  5784. } else {
  5785. const name = filter.slice(0, i);
  5786. const args = filter.slice(i + 1);
  5787. context.filters.add(name);
  5788. return `${toValidAssetId(name, "filter")}(${exp}${args !== ")" ? "," + args : args}`;
  5789. }
  5790. }
  5791. const seen = /* @__PURE__ */ new WeakSet();
  5792. const transformMemo = (node, context) => {
  5793. if (node.type === 1) {
  5794. const dir = findDir(node, "memo");
  5795. if (!dir || seen.has(node) || context.inSSR) {
  5796. return;
  5797. }
  5798. seen.add(node);
  5799. return () => {
  5800. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  5801. if (codegenNode && codegenNode.type === 13) {
  5802. if (node.tagType !== 1) {
  5803. convertToBlock(codegenNode, context);
  5804. }
  5805. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  5806. dir.exp,
  5807. createFunctionExpression(void 0, codegenNode),
  5808. `_cache`,
  5809. String(context.cached.length)
  5810. ]);
  5811. context.cached.push(null);
  5812. }
  5813. };
  5814. }
  5815. };
  5816. function getBaseTransformPreset(prefixIdentifiers) {
  5817. return [
  5818. [
  5819. transformOnce,
  5820. transformIf,
  5821. transformMemo,
  5822. transformFor,
  5823. ...[transformFilter] ,
  5824. ...[transformExpression] ,
  5825. transformSlotOutlet,
  5826. transformElement,
  5827. trackSlotScopes,
  5828. transformText
  5829. ],
  5830. {
  5831. on: transformOn$1,
  5832. bind: transformBind,
  5833. model: transformModel$1
  5834. }
  5835. ];
  5836. }
  5837. function baseCompile(source, options = {}) {
  5838. const onError = options.onError || defaultOnError;
  5839. const isModuleMode = options.mode === "module";
  5840. {
  5841. if (options.prefixIdentifiers === true) {
  5842. onError(createCompilerError(47));
  5843. } else if (isModuleMode) {
  5844. onError(createCompilerError(48));
  5845. }
  5846. }
  5847. const prefixIdentifiers = false;
  5848. if (options.cacheHandlers) {
  5849. onError(createCompilerError(49));
  5850. }
  5851. if (options.scopeId && !isModuleMode) {
  5852. onError(createCompilerError(50));
  5853. }
  5854. const resolvedOptions = extend({}, options, {
  5855. prefixIdentifiers
  5856. });
  5857. const ast = isString(source) ? baseParse(source, resolvedOptions) : source;
  5858. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
  5859. transform(
  5860. ast,
  5861. extend({}, resolvedOptions, {
  5862. nodeTransforms: [
  5863. ...nodeTransforms,
  5864. ...options.nodeTransforms || []
  5865. // user transforms
  5866. ],
  5867. directiveTransforms: extend(
  5868. {},
  5869. directiveTransforms,
  5870. options.directiveTransforms || {}
  5871. // user transforms
  5872. )
  5873. })
  5874. );
  5875. return generate(ast, resolvedOptions);
  5876. }
  5877. const BindingTypes = {
  5878. "DATA": "data",
  5879. "PROPS": "props",
  5880. "PROPS_ALIASED": "props-aliased",
  5881. "SETUP_LET": "setup-let",
  5882. "SETUP_CONST": "setup-const",
  5883. "SETUP_REACTIVE_CONST": "setup-reactive-const",
  5884. "SETUP_MAYBE_REF": "setup-maybe-ref",
  5885. "SETUP_REF": "setup-ref",
  5886. "OPTIONS": "options",
  5887. "LITERAL_CONST": "literal-const"
  5888. };
  5889. const noopDirectiveTransform = () => ({ props: [] });
  5890. const V_MODEL_RADIO = Symbol(`vModelRadio` );
  5891. const V_MODEL_CHECKBOX = Symbol(
  5892. `vModelCheckbox`
  5893. );
  5894. const V_MODEL_TEXT = Symbol(`vModelText` );
  5895. const V_MODEL_SELECT = Symbol(
  5896. `vModelSelect`
  5897. );
  5898. const V_MODEL_DYNAMIC = Symbol(
  5899. `vModelDynamic`
  5900. );
  5901. const V_ON_WITH_MODIFIERS = Symbol(
  5902. `vOnModifiersGuard`
  5903. );
  5904. const V_ON_WITH_KEYS = Symbol(
  5905. `vOnKeysGuard`
  5906. );
  5907. const V_SHOW = Symbol(`vShow` );
  5908. const TRANSITION = Symbol(`Transition` );
  5909. const TRANSITION_GROUP = Symbol(
  5910. `TransitionGroup`
  5911. );
  5912. registerRuntimeHelpers({
  5913. [V_MODEL_RADIO]: `vModelRadio`,
  5914. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  5915. [V_MODEL_TEXT]: `vModelText`,
  5916. [V_MODEL_SELECT]: `vModelSelect`,
  5917. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  5918. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  5919. [V_ON_WITH_KEYS]: `withKeys`,
  5920. [V_SHOW]: `vShow`,
  5921. [TRANSITION]: `Transition`,
  5922. [TRANSITION_GROUP]: `TransitionGroup`
  5923. });
  5924. let decoder;
  5925. function decodeHtmlBrowser(raw, asAttr = false) {
  5926. if (!decoder) {
  5927. decoder = document.createElement("div");
  5928. }
  5929. if (asAttr) {
  5930. decoder.innerHTML = `<div foo="${raw.replace(/"/g, "&quot;")}">`;
  5931. return decoder.children[0].getAttribute("foo");
  5932. } else {
  5933. decoder.innerHTML = raw;
  5934. return decoder.textContent;
  5935. }
  5936. }
  5937. const parserOptions = {
  5938. parseMode: "html",
  5939. isVoidTag,
  5940. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  5941. isPreTag: (tag) => tag === "pre",
  5942. isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
  5943. decodeEntities: decodeHtmlBrowser ,
  5944. isBuiltInComponent: (tag) => {
  5945. if (tag === "Transition" || tag === "transition") {
  5946. return TRANSITION;
  5947. } else if (tag === "TransitionGroup" || tag === "transition-group") {
  5948. return TRANSITION_GROUP;
  5949. }
  5950. },
  5951. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  5952. getNamespace(tag, parent, rootNamespace) {
  5953. let ns = parent ? parent.ns : rootNamespace;
  5954. if (parent && ns === 2) {
  5955. if (parent.tag === "annotation-xml") {
  5956. if (tag === "svg") {
  5957. return 1;
  5958. }
  5959. if (parent.props.some(
  5960. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  5961. )) {
  5962. ns = 0;
  5963. }
  5964. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  5965. ns = 0;
  5966. }
  5967. } else if (parent && ns === 1) {
  5968. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  5969. ns = 0;
  5970. }
  5971. }
  5972. if (ns === 0) {
  5973. if (tag === "svg") {
  5974. return 1;
  5975. }
  5976. if (tag === "math") {
  5977. return 2;
  5978. }
  5979. }
  5980. return ns;
  5981. }
  5982. };
  5983. const transformStyle = (node) => {
  5984. if (node.type === 1) {
  5985. node.props.forEach((p, i) => {
  5986. if (p.type === 6 && p.name === "style" && p.value) {
  5987. node.props[i] = {
  5988. type: 7,
  5989. name: `bind`,
  5990. arg: createSimpleExpression(`style`, true, p.loc),
  5991. exp: parseInlineCSS(p.value.content, p.loc),
  5992. modifiers: [],
  5993. loc: p.loc
  5994. };
  5995. }
  5996. });
  5997. }
  5998. };
  5999. const parseInlineCSS = (cssText, loc) => {
  6000. const normalized = parseStringStyle(cssText);
  6001. return createSimpleExpression(
  6002. JSON.stringify(normalized),
  6003. false,
  6004. loc,
  6005. 3
  6006. );
  6007. };
  6008. function createDOMCompilerError(code, loc) {
  6009. return createCompilerError(
  6010. code,
  6011. loc,
  6012. DOMErrorMessages
  6013. );
  6014. }
  6015. const DOMErrorCodes = {
  6016. "X_V_HTML_NO_EXPRESSION": 53,
  6017. "53": "X_V_HTML_NO_EXPRESSION",
  6018. "X_V_HTML_WITH_CHILDREN": 54,
  6019. "54": "X_V_HTML_WITH_CHILDREN",
  6020. "X_V_TEXT_NO_EXPRESSION": 55,
  6021. "55": "X_V_TEXT_NO_EXPRESSION",
  6022. "X_V_TEXT_WITH_CHILDREN": 56,
  6023. "56": "X_V_TEXT_WITH_CHILDREN",
  6024. "X_V_MODEL_ON_INVALID_ELEMENT": 57,
  6025. "57": "X_V_MODEL_ON_INVALID_ELEMENT",
  6026. "X_V_MODEL_ARG_ON_ELEMENT": 58,
  6027. "58": "X_V_MODEL_ARG_ON_ELEMENT",
  6028. "X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
  6029. "59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
  6030. "X_V_MODEL_UNNECESSARY_VALUE": 60,
  6031. "60": "X_V_MODEL_UNNECESSARY_VALUE",
  6032. "X_V_SHOW_NO_EXPRESSION": 61,
  6033. "61": "X_V_SHOW_NO_EXPRESSION",
  6034. "X_TRANSITION_INVALID_CHILDREN": 62,
  6035. "62": "X_TRANSITION_INVALID_CHILDREN",
  6036. "X_IGNORED_SIDE_EFFECT_TAG": 63,
  6037. "63": "X_IGNORED_SIDE_EFFECT_TAG",
  6038. "__EXTEND_POINT__": 64,
  6039. "64": "__EXTEND_POINT__"
  6040. };
  6041. const DOMErrorMessages = {
  6042. [53]: `v-html is missing expression.`,
  6043. [54]: `v-html will override element children.`,
  6044. [55]: `v-text is missing expression.`,
  6045. [56]: `v-text will override element children.`,
  6046. [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  6047. [58]: `v-model argument is not supported on plain elements.`,
  6048. [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  6049. [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  6050. [61]: `v-show is missing expression.`,
  6051. [62]: `<Transition> expects exactly one child element or component.`,
  6052. [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  6053. };
  6054. const transformVHtml = (dir, node, context) => {
  6055. const { exp, loc } = dir;
  6056. if (!exp) {
  6057. context.onError(
  6058. createDOMCompilerError(53, loc)
  6059. );
  6060. }
  6061. if (node.children.length) {
  6062. context.onError(
  6063. createDOMCompilerError(54, loc)
  6064. );
  6065. node.children.length = 0;
  6066. }
  6067. return {
  6068. props: [
  6069. createObjectProperty(
  6070. createSimpleExpression(`innerHTML`, true, loc),
  6071. exp || createSimpleExpression("", true)
  6072. )
  6073. ]
  6074. };
  6075. };
  6076. const transformVText = (dir, node, context) => {
  6077. const { exp, loc } = dir;
  6078. if (!exp) {
  6079. context.onError(
  6080. createDOMCompilerError(55, loc)
  6081. );
  6082. }
  6083. if (node.children.length) {
  6084. context.onError(
  6085. createDOMCompilerError(56, loc)
  6086. );
  6087. node.children.length = 0;
  6088. }
  6089. return {
  6090. props: [
  6091. createObjectProperty(
  6092. createSimpleExpression(`textContent`, true),
  6093. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  6094. context.helperString(TO_DISPLAY_STRING),
  6095. [exp],
  6096. loc
  6097. ) : createSimpleExpression("", true)
  6098. )
  6099. ]
  6100. };
  6101. };
  6102. const transformModel = (dir, node, context) => {
  6103. const baseResult = transformModel$1(dir, node, context);
  6104. if (!baseResult.props.length || node.tagType === 1) {
  6105. return baseResult;
  6106. }
  6107. if (dir.arg) {
  6108. context.onError(
  6109. createDOMCompilerError(
  6110. 58,
  6111. dir.arg.loc
  6112. )
  6113. );
  6114. }
  6115. function checkDuplicatedValue() {
  6116. const value = findDir(node, "bind");
  6117. if (value && isStaticArgOf(value.arg, "value")) {
  6118. context.onError(
  6119. createDOMCompilerError(
  6120. 60,
  6121. value.loc
  6122. )
  6123. );
  6124. }
  6125. }
  6126. const { tag } = node;
  6127. const isCustomElement = context.isCustomElement(tag);
  6128. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  6129. let directiveToUse = V_MODEL_TEXT;
  6130. let isInvalidType = false;
  6131. if (tag === "input" || isCustomElement) {
  6132. const type = findProp(node, `type`);
  6133. if (type) {
  6134. if (type.type === 7) {
  6135. directiveToUse = V_MODEL_DYNAMIC;
  6136. } else if (type.value) {
  6137. switch (type.value.content) {
  6138. case "radio":
  6139. directiveToUse = V_MODEL_RADIO;
  6140. break;
  6141. case "checkbox":
  6142. directiveToUse = V_MODEL_CHECKBOX;
  6143. break;
  6144. case "file":
  6145. isInvalidType = true;
  6146. context.onError(
  6147. createDOMCompilerError(
  6148. 59,
  6149. dir.loc
  6150. )
  6151. );
  6152. break;
  6153. default:
  6154. checkDuplicatedValue();
  6155. break;
  6156. }
  6157. }
  6158. } else if (hasDynamicKeyVBind(node)) {
  6159. directiveToUse = V_MODEL_DYNAMIC;
  6160. } else {
  6161. checkDuplicatedValue();
  6162. }
  6163. } else if (tag === "select") {
  6164. directiveToUse = V_MODEL_SELECT;
  6165. } else {
  6166. checkDuplicatedValue();
  6167. }
  6168. if (!isInvalidType) {
  6169. baseResult.needRuntime = context.helper(directiveToUse);
  6170. }
  6171. } else {
  6172. context.onError(
  6173. createDOMCompilerError(
  6174. 57,
  6175. dir.loc
  6176. )
  6177. );
  6178. }
  6179. baseResult.props = baseResult.props.filter(
  6180. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  6181. );
  6182. return baseResult;
  6183. };
  6184. const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
  6185. const isNonKeyModifier = /* @__PURE__ */ makeMap(
  6186. // event propagation management
  6187. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  6188. );
  6189. const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
  6190. const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
  6191. const resolveModifiers = (key, modifiers, context, loc) => {
  6192. const keyModifiers = [];
  6193. const nonKeyModifiers = [];
  6194. const eventOptionModifiers = [];
  6195. for (let i = 0; i < modifiers.length; i++) {
  6196. const modifier = modifiers[i].content;
  6197. if (modifier === "native" && checkCompatEnabled(
  6198. "COMPILER_V_ON_NATIVE",
  6199. context,
  6200. loc
  6201. )) {
  6202. eventOptionModifiers.push(modifier);
  6203. } else if (isEventOptionModifier(modifier)) {
  6204. eventOptionModifiers.push(modifier);
  6205. } else {
  6206. if (maybeKeyModifier(modifier)) {
  6207. if (isStaticExp(key)) {
  6208. if (isKeyboardEvent(key.content.toLowerCase())) {
  6209. keyModifiers.push(modifier);
  6210. } else {
  6211. nonKeyModifiers.push(modifier);
  6212. }
  6213. } else {
  6214. keyModifiers.push(modifier);
  6215. nonKeyModifiers.push(modifier);
  6216. }
  6217. } else {
  6218. if (isNonKeyModifier(modifier)) {
  6219. nonKeyModifiers.push(modifier);
  6220. } else {
  6221. keyModifiers.push(modifier);
  6222. }
  6223. }
  6224. }
  6225. }
  6226. return {
  6227. keyModifiers,
  6228. nonKeyModifiers,
  6229. eventOptionModifiers
  6230. };
  6231. };
  6232. const transformClick = (key, event) => {
  6233. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  6234. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  6235. `(`,
  6236. key,
  6237. `) === "onClick" ? "${event}" : (`,
  6238. key,
  6239. `)`
  6240. ]) : key;
  6241. };
  6242. const transformOn = (dir, node, context) => {
  6243. return transformOn$1(dir, node, context, (baseResult) => {
  6244. const { modifiers } = dir;
  6245. if (!modifiers.length) return baseResult;
  6246. let { key, value: handlerExp } = baseResult.props[0];
  6247. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  6248. if (nonKeyModifiers.includes("right")) {
  6249. key = transformClick(key, `onContextmenu`);
  6250. }
  6251. if (nonKeyModifiers.includes("middle")) {
  6252. key = transformClick(key, `onMouseup`);
  6253. }
  6254. if (nonKeyModifiers.length) {
  6255. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  6256. handlerExp,
  6257. JSON.stringify(nonKeyModifiers)
  6258. ]);
  6259. }
  6260. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  6261. (!isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
  6262. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  6263. handlerExp,
  6264. JSON.stringify(keyModifiers)
  6265. ]);
  6266. }
  6267. if (eventOptionModifiers.length) {
  6268. const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
  6269. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  6270. }
  6271. return {
  6272. props: [createObjectProperty(key, handlerExp)]
  6273. };
  6274. });
  6275. };
  6276. const transformShow = (dir, node, context) => {
  6277. const { exp, loc } = dir;
  6278. if (!exp) {
  6279. context.onError(
  6280. createDOMCompilerError(61, loc)
  6281. );
  6282. }
  6283. return {
  6284. props: [],
  6285. needRuntime: context.helper(V_SHOW)
  6286. };
  6287. };
  6288. const transformTransition = (node, context) => {
  6289. if (node.type === 1 && node.tagType === 1) {
  6290. const component = context.isBuiltInComponent(node.tag);
  6291. if (component === TRANSITION) {
  6292. return () => {
  6293. if (!node.children.length) {
  6294. return;
  6295. }
  6296. if (hasMultipleChildren(node)) {
  6297. context.onError(
  6298. createDOMCompilerError(
  6299. 62,
  6300. {
  6301. start: node.children[0].loc.start,
  6302. end: node.children[node.children.length - 1].loc.end,
  6303. source: ""
  6304. }
  6305. )
  6306. );
  6307. }
  6308. const child = node.children[0];
  6309. if (child.type === 1) {
  6310. for (const p of child.props) {
  6311. if (p.type === 7 && p.name === "show") {
  6312. node.props.push({
  6313. type: 6,
  6314. name: "persisted",
  6315. nameLoc: node.loc,
  6316. value: void 0,
  6317. loc: node.loc
  6318. });
  6319. }
  6320. }
  6321. }
  6322. };
  6323. }
  6324. }
  6325. };
  6326. function hasMultipleChildren(node) {
  6327. const children = node.children = node.children.filter(
  6328. (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
  6329. );
  6330. const child = children[0];
  6331. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  6332. }
  6333. const ignoreSideEffectTags = (node, context) => {
  6334. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  6335. context.onError(
  6336. createDOMCompilerError(
  6337. 63,
  6338. node.loc
  6339. )
  6340. );
  6341. context.removeNode();
  6342. }
  6343. };
  6344. function isValidHTMLNesting(parent, child) {
  6345. if (parent === "template") {
  6346. return true;
  6347. }
  6348. if (parent in onlyValidChildren) {
  6349. return onlyValidChildren[parent].has(child);
  6350. }
  6351. if (child in onlyValidParents) {
  6352. return onlyValidParents[child].has(parent);
  6353. }
  6354. if (parent in knownInvalidChildren) {
  6355. if (knownInvalidChildren[parent].has(child)) return false;
  6356. }
  6357. if (child in knownInvalidParents) {
  6358. if (knownInvalidParents[child].has(parent)) return false;
  6359. }
  6360. return true;
  6361. }
  6362. const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
  6363. const emptySet = /* @__PURE__ */ new Set([]);
  6364. const onlyValidChildren = {
  6365. head: /* @__PURE__ */ new Set([
  6366. "base",
  6367. "basefront",
  6368. "bgsound",
  6369. "link",
  6370. "meta",
  6371. "title",
  6372. "noscript",
  6373. "noframes",
  6374. "style",
  6375. "script",
  6376. "template"
  6377. ]),
  6378. optgroup: /* @__PURE__ */ new Set(["option"]),
  6379. select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
  6380. // table
  6381. table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
  6382. tr: /* @__PURE__ */ new Set(["td", "th"]),
  6383. colgroup: /* @__PURE__ */ new Set(["col"]),
  6384. tbody: /* @__PURE__ */ new Set(["tr"]),
  6385. thead: /* @__PURE__ */ new Set(["tr"]),
  6386. tfoot: /* @__PURE__ */ new Set(["tr"]),
  6387. // these elements can not have any children elements
  6388. script: emptySet,
  6389. iframe: emptySet,
  6390. option: emptySet,
  6391. textarea: emptySet,
  6392. style: emptySet,
  6393. title: emptySet
  6394. };
  6395. const onlyValidParents = {
  6396. // sections
  6397. html: emptySet,
  6398. body: /* @__PURE__ */ new Set(["html"]),
  6399. head: /* @__PURE__ */ new Set(["html"]),
  6400. // table
  6401. td: /* @__PURE__ */ new Set(["tr"]),
  6402. colgroup: /* @__PURE__ */ new Set(["table"]),
  6403. caption: /* @__PURE__ */ new Set(["table"]),
  6404. tbody: /* @__PURE__ */ new Set(["table"]),
  6405. tfoot: /* @__PURE__ */ new Set(["table"]),
  6406. col: /* @__PURE__ */ new Set(["colgroup"]),
  6407. th: /* @__PURE__ */ new Set(["tr"]),
  6408. thead: /* @__PURE__ */ new Set(["table"]),
  6409. tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
  6410. // data list
  6411. dd: /* @__PURE__ */ new Set(["dl", "div"]),
  6412. dt: /* @__PURE__ */ new Set(["dl", "div"]),
  6413. // other
  6414. figcaption: /* @__PURE__ */ new Set(["figure"]),
  6415. // li: new Set(["ul", "ol"]),
  6416. summary: /* @__PURE__ */ new Set(["details"]),
  6417. area: /* @__PURE__ */ new Set(["map"])
  6418. };
  6419. const knownInvalidChildren = {
  6420. p: /* @__PURE__ */ new Set([
  6421. "address",
  6422. "article",
  6423. "aside",
  6424. "blockquote",
  6425. "center",
  6426. "details",
  6427. "dialog",
  6428. "dir",
  6429. "div",
  6430. "dl",
  6431. "fieldset",
  6432. "figure",
  6433. "footer",
  6434. "form",
  6435. "h1",
  6436. "h2",
  6437. "h3",
  6438. "h4",
  6439. "h5",
  6440. "h6",
  6441. "header",
  6442. "hgroup",
  6443. "hr",
  6444. "li",
  6445. "main",
  6446. "nav",
  6447. "menu",
  6448. "ol",
  6449. "p",
  6450. "pre",
  6451. "section",
  6452. "table",
  6453. "ul"
  6454. ]),
  6455. svg: /* @__PURE__ */ new Set([
  6456. "b",
  6457. "blockquote",
  6458. "br",
  6459. "code",
  6460. "dd",
  6461. "div",
  6462. "dl",
  6463. "dt",
  6464. "em",
  6465. "embed",
  6466. "h1",
  6467. "h2",
  6468. "h3",
  6469. "h4",
  6470. "h5",
  6471. "h6",
  6472. "hr",
  6473. "i",
  6474. "img",
  6475. "li",
  6476. "menu",
  6477. "meta",
  6478. "ol",
  6479. "p",
  6480. "pre",
  6481. "ruby",
  6482. "s",
  6483. "small",
  6484. "span",
  6485. "strong",
  6486. "sub",
  6487. "sup",
  6488. "table",
  6489. "u",
  6490. "ul",
  6491. "var"
  6492. ])
  6493. };
  6494. const knownInvalidParents = {
  6495. a: /* @__PURE__ */ new Set(["a"]),
  6496. button: /* @__PURE__ */ new Set(["button"]),
  6497. dd: /* @__PURE__ */ new Set(["dd", "dt"]),
  6498. dt: /* @__PURE__ */ new Set(["dd", "dt"]),
  6499. form: /* @__PURE__ */ new Set(["form"]),
  6500. li: /* @__PURE__ */ new Set(["li"]),
  6501. h1: headings,
  6502. h2: headings,
  6503. h3: headings,
  6504. h4: headings,
  6505. h5: headings,
  6506. h6: headings
  6507. };
  6508. const validateHtmlNesting = (node, context) => {
  6509. if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
  6510. const error = new SyntaxError(
  6511. `<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
  6512. );
  6513. error.loc = node.loc;
  6514. context.onWarn(error);
  6515. }
  6516. };
  6517. const DOMNodeTransforms = [
  6518. transformStyle,
  6519. ...[transformTransition, validateHtmlNesting]
  6520. ];
  6521. const DOMDirectiveTransforms = {
  6522. cloak: noopDirectiveTransform,
  6523. html: transformVHtml,
  6524. text: transformVText,
  6525. model: transformModel,
  6526. // override compiler-core
  6527. on: transformOn,
  6528. // override compiler-core
  6529. show: transformShow
  6530. };
  6531. function compile(src, options = {}) {
  6532. return baseCompile(
  6533. src,
  6534. extend({}, parserOptions, options, {
  6535. nodeTransforms: [
  6536. // ignore <script> and <tag>
  6537. // this is not put inside DOMNodeTransforms because that list is used
  6538. // by compiler-ssr to generate vnode fallback branches
  6539. ignoreSideEffectTags,
  6540. ...DOMNodeTransforms,
  6541. ...options.nodeTransforms || []
  6542. ],
  6543. directiveTransforms: extend(
  6544. {},
  6545. DOMDirectiveTransforms,
  6546. options.directiveTransforms || {}
  6547. ),
  6548. transformHoist: null
  6549. })
  6550. );
  6551. }
  6552. function parse(template, options = {}) {
  6553. return baseParse(template, extend({}, parserOptions, options));
  6554. }
  6555. export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, Namespaces, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TRANSITION, TRANSITION_GROUP, TS_NODE_TYPES, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, locStub, noopDirectiveTransform, parse, parserOptions, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel$1 as transformModel, transformOn$1 as transformOn, transformStyle, traverseNode, unwrapTSNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };