build.dev.js 249 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var he = _interopDefault(require('he'));
  5. /* */
  6. var emptyObject = Object.freeze({});
  7. // These helpers produce better VM code in JS engines due to their
  8. // explicitness and function inlining.
  9. function isUndef (v) {
  10. return v === undefined || v === null
  11. }
  12. function isDef (v) {
  13. return v !== undefined && v !== null
  14. }
  15. function isTrue (v) {
  16. return v === true
  17. }
  18. function isFalse (v) {
  19. return v === false
  20. }
  21. /**
  22. * Check if value is primitive.
  23. */
  24. function isPrimitive (value) {
  25. return (
  26. typeof value === 'string' ||
  27. typeof value === 'number' ||
  28. // $flow-disable-line
  29. typeof value === 'symbol' ||
  30. typeof value === 'boolean'
  31. )
  32. }
  33. /**
  34. * Quick object check - this is primarily used to tell
  35. * Objects from primitive values when we know the value
  36. * is a JSON-compliant type.
  37. */
  38. function isObject (obj) {
  39. return obj !== null && typeof obj === 'object'
  40. }
  41. /**
  42. * Get the raw type string of a value, e.g., [object Object].
  43. */
  44. var _toString = Object.prototype.toString;
  45. function toRawType (value) {
  46. return _toString.call(value).slice(8, -1)
  47. }
  48. /**
  49. * Strict object type check. Only returns true
  50. * for plain JavaScript objects.
  51. */
  52. function isPlainObject (obj) {
  53. return _toString.call(obj) === '[object Object]'
  54. }
  55. /**
  56. * Check if val is a valid array index.
  57. */
  58. function isValidArrayIndex (val) {
  59. var n = parseFloat(String(val));
  60. return n >= 0 && Math.floor(n) === n && isFinite(val)
  61. }
  62. function isPromise (val) {
  63. return (
  64. isDef(val) &&
  65. typeof val.then === 'function' &&
  66. typeof val.catch === 'function'
  67. )
  68. }
  69. /**
  70. * Convert a value to a string that is actually rendered.
  71. */
  72. function toString (val) {
  73. return val == null
  74. ? ''
  75. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  76. ? JSON.stringify(val, null, 2)
  77. : String(val)
  78. }
  79. /**
  80. * Convert an input value to a number for persistence.
  81. * If the conversion fails, return original string.
  82. */
  83. function toNumber (val) {
  84. var n = parseFloat(val);
  85. return isNaN(n) ? val : n
  86. }
  87. /**
  88. * Make a map and return a function for checking if a key
  89. * is in that map.
  90. */
  91. function makeMap (
  92. str,
  93. expectsLowerCase
  94. ) {
  95. var map = Object.create(null);
  96. var list = str.split(',');
  97. for (var i = 0; i < list.length; i++) {
  98. map[list[i]] = true;
  99. }
  100. return expectsLowerCase
  101. ? function (val) { return map[val.toLowerCase()]; }
  102. : function (val) { return map[val]; }
  103. }
  104. /**
  105. * Check if a tag is a built-in tag.
  106. */
  107. var isBuiltInTag = makeMap('slot,component', true);
  108. /**
  109. * Check if an attribute is a reserved attribute.
  110. */
  111. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  112. /**
  113. * Remove an item from an array.
  114. */
  115. function remove (arr, item) {
  116. if (arr.length) {
  117. var index = arr.indexOf(item);
  118. if (index > -1) {
  119. return arr.splice(index, 1)
  120. }
  121. }
  122. }
  123. /**
  124. * Check whether an object has the property.
  125. */
  126. var hasOwnProperty = Object.prototype.hasOwnProperty;
  127. function hasOwn (obj, key) {
  128. return hasOwnProperty.call(obj, key)
  129. }
  130. /**
  131. * Create a cached version of a pure function.
  132. */
  133. function cached (fn) {
  134. var cache = Object.create(null);
  135. return (function cachedFn (str) {
  136. var hit = cache[str];
  137. return hit || (cache[str] = fn(str))
  138. })
  139. }
  140. /**
  141. * Camelize a hyphen-delimited string.
  142. */
  143. var camelizeRE = /-(\w)/g;
  144. var camelize = cached(function (str) {
  145. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  146. });
  147. /**
  148. * Capitalize a string.
  149. */
  150. var capitalize = cached(function (str) {
  151. return str.charAt(0).toUpperCase() + str.slice(1)
  152. });
  153. /**
  154. * Hyphenate a camelCase string.
  155. */
  156. var hyphenateRE = /\B([A-Z])/g;
  157. var hyphenate = cached(function (str) {
  158. return str.replace(hyphenateRE, '-$1').toLowerCase()
  159. });
  160. /**
  161. * Simple bind polyfill for environments that do not support it,
  162. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  163. * since native bind is now performant enough in most browsers.
  164. * But removing it would mean breaking code that was able to run in
  165. * PhantomJS 1.x, so this must be kept for backward compatibility.
  166. */
  167. /* istanbul ignore next */
  168. function polyfillBind (fn, ctx) {
  169. function boundFn (a) {
  170. var l = arguments.length;
  171. return l
  172. ? l > 1
  173. ? fn.apply(ctx, arguments)
  174. : fn.call(ctx, a)
  175. : fn.call(ctx)
  176. }
  177. boundFn._length = fn.length;
  178. return boundFn
  179. }
  180. function nativeBind (fn, ctx) {
  181. return fn.bind(ctx)
  182. }
  183. var bind = Function.prototype.bind
  184. ? nativeBind
  185. : polyfillBind;
  186. /**
  187. * Mix properties into target object.
  188. */
  189. function extend (to, _from) {
  190. for (var key in _from) {
  191. to[key] = _from[key];
  192. }
  193. return to
  194. }
  195. /**
  196. * Merge an Array of Objects into a single Object.
  197. */
  198. function toObject (arr) {
  199. var res = {};
  200. for (var i = 0; i < arr.length; i++) {
  201. if (arr[i]) {
  202. extend(res, arr[i]);
  203. }
  204. }
  205. return res
  206. }
  207. /* eslint-disable no-unused-vars */
  208. /**
  209. * Perform no operation.
  210. * Stubbing args to make Flow happy without leaving useless transpiled code
  211. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  212. */
  213. function noop (a, b, c) {}
  214. /**
  215. * Always return false.
  216. */
  217. var no = function (a, b, c) { return false; };
  218. /* eslint-enable no-unused-vars */
  219. /**
  220. * Return the same value.
  221. */
  222. var identity = function (_) { return _; };
  223. /**
  224. * Generate a string containing static keys from compiler modules.
  225. */
  226. function genStaticKeys (modules) {
  227. return modules.reduce(function (keys, m) {
  228. return keys.concat(m.staticKeys || [])
  229. }, []).join(',')
  230. }
  231. /**
  232. * Check if two values are loosely equal - that is,
  233. * if they are plain objects, do they have the same shape?
  234. */
  235. function looseEqual (a, b) {
  236. if (a === b) { return true }
  237. var isObjectA = isObject(a);
  238. var isObjectB = isObject(b);
  239. if (isObjectA && isObjectB) {
  240. try {
  241. var isArrayA = Array.isArray(a);
  242. var isArrayB = Array.isArray(b);
  243. if (isArrayA && isArrayB) {
  244. return a.length === b.length && a.every(function (e, i) {
  245. return looseEqual(e, b[i])
  246. })
  247. } else if (a instanceof Date && b instanceof Date) {
  248. return a.getTime() === b.getTime()
  249. } else if (!isArrayA && !isArrayB) {
  250. var keysA = Object.keys(a);
  251. var keysB = Object.keys(b);
  252. return keysA.length === keysB.length && keysA.every(function (key) {
  253. return looseEqual(a[key], b[key])
  254. })
  255. } else {
  256. /* istanbul ignore next */
  257. return false
  258. }
  259. } catch (e) {
  260. /* istanbul ignore next */
  261. return false
  262. }
  263. } else if (!isObjectA && !isObjectB) {
  264. return String(a) === String(b)
  265. } else {
  266. return false
  267. }
  268. }
  269. /**
  270. * Return the first index at which a loosely equal value can be
  271. * found in the array (if value is a plain object, the array must
  272. * contain an object of the same shape), or -1 if it is not present.
  273. */
  274. function looseIndexOf (arr, val) {
  275. for (var i = 0; i < arr.length; i++) {
  276. if (looseEqual(arr[i], val)) { return i }
  277. }
  278. return -1
  279. }
  280. /**
  281. * Ensure a function is called only once.
  282. */
  283. function once (fn) {
  284. var called = false;
  285. return function () {
  286. if (!called) {
  287. called = true;
  288. fn.apply(this, arguments);
  289. }
  290. }
  291. }
  292. /* */
  293. var isAttr = makeMap(
  294. 'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
  295. 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
  296. 'checked,cite,class,code,codebase,color,cols,colspan,content,' +
  297. 'contenteditable,contextmenu,controls,coords,data,datetime,default,' +
  298. 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,for,' +
  299. 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
  300. 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
  301. 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
  302. 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
  303. 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
  304. 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
  305. 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
  306. 'target,title,usemap,value,width,wrap'
  307. );
  308. var unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/; // eslint-disable-line no-control-regex
  309. var isSSRUnsafeAttr = function (name) {
  310. return unsafeAttrCharRE.test(name)
  311. };
  312. /* istanbul ignore next */
  313. var isRenderableAttr = function (name) {
  314. return (
  315. isAttr(name) ||
  316. name.indexOf('data-') === 0 ||
  317. name.indexOf('aria-') === 0
  318. )
  319. };
  320. var propsToAttrMap = {
  321. acceptCharset: 'accept-charset',
  322. className: 'class',
  323. htmlFor: 'for',
  324. httpEquiv: 'http-equiv'
  325. };
  326. var ESC = {
  327. '<': '&lt;',
  328. '>': '&gt;',
  329. '"': '&quot;',
  330. '&': '&amp;'
  331. };
  332. function escape (s) {
  333. return s.replace(/[<>"&]/g, escapeChar)
  334. }
  335. function escapeChar (a) {
  336. return ESC[a] || a
  337. }
  338. var noUnitNumericStyleProps = {
  339. "animation-iteration-count": true,
  340. "border-image-outset": true,
  341. "border-image-slice": true,
  342. "border-image-width": true,
  343. "box-flex": true,
  344. "box-flex-group": true,
  345. "box-ordinal-group": true,
  346. "column-count": true,
  347. "columns": true,
  348. "flex": true,
  349. "flex-grow": true,
  350. "flex-positive": true,
  351. "flex-shrink": true,
  352. "flex-negative": true,
  353. "flex-order": true,
  354. "grid-row": true,
  355. "grid-row-end": true,
  356. "grid-row-span": true,
  357. "grid-row-start": true,
  358. "grid-column": true,
  359. "grid-column-end": true,
  360. "grid-column-span": true,
  361. "grid-column-start": true,
  362. "font-weight": true,
  363. "line-clamp": true,
  364. "line-height": true,
  365. "opacity": true,
  366. "order": true,
  367. "orphans": true,
  368. "tab-size": true,
  369. "widows": true,
  370. "z-index": true,
  371. "zoom": true,
  372. // SVG
  373. "fill-opacity": true,
  374. "flood-opacity": true,
  375. "stop-opacity": true,
  376. "stroke-dasharray": true,
  377. "stroke-dashoffset": true,
  378. "stroke-miterlimit": true,
  379. "stroke-opacity": true,
  380. "stroke-width": true
  381. };
  382. /* */
  383. // these are reserved for web because they are directly compiled away
  384. // during template compilation
  385. var isReservedAttr = makeMap('style,class');
  386. // attributes that should be using props for binding
  387. var acceptValue = makeMap('input,textarea,option,select,progress');
  388. var mustUseProp = function (tag, type, attr) {
  389. return (
  390. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  391. (attr === 'selected' && tag === 'option') ||
  392. (attr === 'checked' && tag === 'input') ||
  393. (attr === 'muted' && tag === 'video')
  394. )
  395. };
  396. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  397. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  398. var convertEnumeratedValue = function (key, value) {
  399. return isFalsyAttrValue(value) || value === 'false'
  400. ? 'false'
  401. // allow arbitrary string value for contenteditable
  402. : key === 'contenteditable' && isValidContentEditableValue(value)
  403. ? value
  404. : 'true'
  405. };
  406. var isBooleanAttr = makeMap(
  407. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  408. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  409. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  410. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  411. 'required,reversed,scoped,seamless,selected,sortable,' +
  412. 'truespeed,typemustmatch,visible'
  413. );
  414. var isFalsyAttrValue = function (val) {
  415. return val == null || val === false
  416. };
  417. /* */
  418. function renderAttrs (node) {
  419. var attrs = node.data.attrs;
  420. var res = '';
  421. var opts = node.parent && node.parent.componentOptions;
  422. if (isUndef(opts) || opts.Ctor.options.inheritAttrs !== false) {
  423. var parent = node.parent;
  424. while (isDef(parent)) {
  425. // Stop fallthrough in case parent has inheritAttrs option set to false
  426. if (parent.componentOptions && parent.componentOptions.Ctor.options.inheritAttrs === false) {
  427. break;
  428. }
  429. if (isDef(parent.data) && isDef(parent.data.attrs)) {
  430. attrs = extend(extend({}, attrs), parent.data.attrs);
  431. }
  432. parent = parent.parent;
  433. }
  434. }
  435. if (isUndef(attrs)) {
  436. return res
  437. }
  438. for (var key in attrs) {
  439. if (isSSRUnsafeAttr(key)) {
  440. continue
  441. }
  442. if (key === 'style') {
  443. // leave it to the style module
  444. continue
  445. }
  446. res += renderAttr(key, attrs[key]);
  447. }
  448. return res
  449. }
  450. function renderAttr (key, value) {
  451. if (isBooleanAttr(key)) {
  452. if (!isFalsyAttrValue(value)) {
  453. return (" " + key + "=\"" + key + "\"")
  454. }
  455. } else if (isEnumeratedAttr(key)) {
  456. return (" " + key + "=\"" + (escape(convertEnumeratedValue(key, value))) + "\"")
  457. } else if (!isFalsyAttrValue(value)) {
  458. return (" " + key + "=\"" + (escape(String(value))) + "\"")
  459. }
  460. return ''
  461. }
  462. /* */
  463. var VNode = function VNode (
  464. tag,
  465. data,
  466. children,
  467. text,
  468. elm,
  469. context,
  470. componentOptions,
  471. asyncFactory
  472. ) {
  473. this.tag = tag;
  474. this.data = data;
  475. this.children = children;
  476. this.text = text;
  477. this.elm = elm;
  478. this.ns = undefined;
  479. this.context = context;
  480. this.fnContext = undefined;
  481. this.fnOptions = undefined;
  482. this.fnScopeId = undefined;
  483. this.key = data && data.key;
  484. this.componentOptions = componentOptions;
  485. this.componentInstance = undefined;
  486. this.parent = undefined;
  487. this.raw = false;
  488. this.isStatic = false;
  489. this.isRootInsert = true;
  490. this.isComment = false;
  491. this.isCloned = false;
  492. this.isOnce = false;
  493. this.asyncFactory = asyncFactory;
  494. this.asyncMeta = undefined;
  495. this.isAsyncPlaceholder = false;
  496. };
  497. var prototypeAccessors = { child: { configurable: true } };
  498. // DEPRECATED: alias for componentInstance for backwards compat.
  499. /* istanbul ignore next */
  500. prototypeAccessors.child.get = function () {
  501. return this.componentInstance
  502. };
  503. Object.defineProperties( VNode.prototype, prototypeAccessors );
  504. var createEmptyVNode = function (text) {
  505. if ( text === void 0 ) text = '';
  506. var node = new VNode();
  507. node.text = text;
  508. node.isComment = true;
  509. return node
  510. };
  511. function createTextVNode (val) {
  512. return new VNode(undefined, undefined, undefined, String(val))
  513. }
  514. // optimized shallow clone
  515. // used for static nodes and slot nodes because they may be reused across
  516. // multiple renders, cloning them avoids errors when DOM manipulations rely
  517. // on their elm reference.
  518. function cloneVNode (vnode) {
  519. var cloned = new VNode(
  520. vnode.tag,
  521. vnode.data,
  522. // #7975
  523. // clone children array to avoid mutating original in case of cloning
  524. // a child.
  525. vnode.children && vnode.children.slice(),
  526. vnode.text,
  527. vnode.elm,
  528. vnode.context,
  529. vnode.componentOptions,
  530. vnode.asyncFactory
  531. );
  532. cloned.ns = vnode.ns;
  533. cloned.isStatic = vnode.isStatic;
  534. cloned.key = vnode.key;
  535. cloned.isComment = vnode.isComment;
  536. cloned.fnContext = vnode.fnContext;
  537. cloned.fnOptions = vnode.fnOptions;
  538. cloned.fnScopeId = vnode.fnScopeId;
  539. cloned.asyncMeta = vnode.asyncMeta;
  540. cloned.isCloned = true;
  541. return cloned
  542. }
  543. /* */
  544. function renderDOMProps (node) {
  545. var props = node.data.domProps;
  546. var res = '';
  547. var parent = node.parent;
  548. while (isDef(parent)) {
  549. if (parent.data && parent.data.domProps) {
  550. props = extend(extend({}, props), parent.data.domProps);
  551. }
  552. parent = parent.parent;
  553. }
  554. if (isUndef(props)) {
  555. return res
  556. }
  557. var attrs = node.data.attrs;
  558. for (var key in props) {
  559. if (key === 'innerHTML') {
  560. setText(node, props[key], true);
  561. } else if (key === 'textContent') {
  562. setText(node, props[key], false);
  563. } else if (key === 'value' && node.tag === 'textarea') {
  564. setText(node, toString(props[key]), false);
  565. } else {
  566. // $flow-disable-line (WTF?)
  567. var attr = propsToAttrMap[key] || key.toLowerCase();
  568. if (isRenderableAttr(attr) &&
  569. // avoid rendering double-bound props/attrs twice
  570. !(isDef(attrs) && isDef(attrs[attr]))
  571. ) {
  572. res += renderAttr(attr, props[key]);
  573. }
  574. }
  575. }
  576. return res
  577. }
  578. function setText (node, text, raw) {
  579. var child = new VNode(undefined, undefined, undefined, text);
  580. child.raw = raw;
  581. node.children = [child];
  582. }
  583. /* */
  584. /**
  585. * unicode letters used for parsing html tags, component names and property paths.
  586. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  587. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  588. */
  589. var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  590. /**
  591. * Define a property.
  592. */
  593. function def (obj, key, val, enumerable) {
  594. Object.defineProperty(obj, key, {
  595. value: val,
  596. enumerable: !!enumerable,
  597. writable: true,
  598. configurable: true
  599. });
  600. }
  601. /* */
  602. // can we use __proto__?
  603. var hasProto = '__proto__' in {};
  604. // Browser environment sniffing
  605. var inBrowser = typeof window !== 'undefined';
  606. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  607. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  608. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  609. var isIE = UA && /msie|trident/.test(UA);
  610. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  611. var isEdge = UA && UA.indexOf('edge/') > 0;
  612. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  613. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  614. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  615. var isPhantomJS = UA && /phantomjs/.test(UA);
  616. var isFF = UA && UA.match(/firefox\/(\d+)/);
  617. // Firefox has a "watch" function on Object.prototype...
  618. var nativeWatch = ({}).watch;
  619. if (inBrowser) {
  620. try {
  621. var opts = {};
  622. Object.defineProperty(opts, 'passive', ({
  623. get: function get () {
  624. }
  625. })); // https://github.com/facebook/flow/issues/285
  626. window.addEventListener('test-passive', null, opts);
  627. } catch (e) {}
  628. }
  629. // this needs to be lazy-evaled because vue may be required before
  630. // vue-server-renderer can set VUE_ENV
  631. var _isServer;
  632. var isServerRendering = function () {
  633. if (_isServer === undefined) {
  634. /* istanbul ignore if */
  635. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  636. // detect presence of vue-server-renderer and avoid
  637. // Webpack shimming the process
  638. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  639. } else {
  640. _isServer = false;
  641. }
  642. }
  643. return _isServer
  644. };
  645. // detect devtools
  646. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  647. /* istanbul ignore next */
  648. function isNative (Ctor) {
  649. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  650. }
  651. var hasSymbol =
  652. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  653. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  654. var _Set;
  655. /* istanbul ignore if */ // $flow-disable-line
  656. if (typeof Set !== 'undefined' && isNative(Set)) {
  657. // use native Set when available.
  658. _Set = Set;
  659. } else {
  660. // a non-standard Set polyfill that only works with primitive keys.
  661. _Set = /*@__PURE__*/(function () {
  662. function Set () {
  663. this.set = Object.create(null);
  664. }
  665. Set.prototype.has = function has (key) {
  666. return this.set[key] === true
  667. };
  668. Set.prototype.add = function add (key) {
  669. this.set[key] = true;
  670. };
  671. Set.prototype.clear = function clear () {
  672. this.set = Object.create(null);
  673. };
  674. return Set;
  675. }());
  676. }
  677. var SSR_ATTR = 'data-server-rendered';
  678. var ASSET_TYPES = [
  679. 'component',
  680. 'directive',
  681. 'filter'
  682. ];
  683. var LIFECYCLE_HOOKS = [
  684. 'beforeCreate',
  685. 'created',
  686. 'beforeMount',
  687. 'mounted',
  688. 'beforeUpdate',
  689. 'updated',
  690. 'beforeDestroy',
  691. 'destroyed',
  692. 'activated',
  693. 'deactivated',
  694. 'errorCaptured',
  695. 'serverPrefetch'
  696. ];
  697. /* */
  698. var config = ({
  699. /**
  700. * Option merge strategies (used in core/util/options)
  701. */
  702. // $flow-disable-line
  703. optionMergeStrategies: Object.create(null),
  704. /**
  705. * Whether to suppress warnings.
  706. */
  707. silent: false,
  708. /**
  709. * Show production mode tip message on boot?
  710. */
  711. productionTip: "development" !== 'production',
  712. /**
  713. * Whether to enable devtools
  714. */
  715. devtools: "development" !== 'production',
  716. /**
  717. * Whether to record perf
  718. */
  719. performance: false,
  720. /**
  721. * Error handler for watcher errors
  722. */
  723. errorHandler: null,
  724. /**
  725. * Warn handler for watcher warns
  726. */
  727. warnHandler: null,
  728. /**
  729. * Ignore certain custom elements
  730. */
  731. ignoredElements: [],
  732. /**
  733. * Custom user key aliases for v-on
  734. */
  735. // $flow-disable-line
  736. keyCodes: Object.create(null),
  737. /**
  738. * Check if a tag is reserved so that it cannot be registered as a
  739. * component. This is platform-dependent and may be overwritten.
  740. */
  741. isReservedTag: no,
  742. /**
  743. * Check if an attribute is reserved so that it cannot be used as a component
  744. * prop. This is platform-dependent and may be overwritten.
  745. */
  746. isReservedAttr: no,
  747. /**
  748. * Check if a tag is an unknown element.
  749. * Platform-dependent.
  750. */
  751. isUnknownElement: no,
  752. /**
  753. * Get the namespace of an element
  754. */
  755. getTagNamespace: noop,
  756. /**
  757. * Parse the real tag name for the specific platform.
  758. */
  759. parsePlatformTagName: identity,
  760. /**
  761. * Check if an attribute must be bound using property, e.g. value
  762. * Platform-dependent.
  763. */
  764. mustUseProp: no,
  765. /**
  766. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  767. * This will significantly reduce performance if set to false.
  768. */
  769. async: true,
  770. /**
  771. * Exposed for legacy reasons
  772. */
  773. _lifecycleHooks: LIFECYCLE_HOOKS
  774. });
  775. /* */
  776. var warn = noop;
  777. var tip = noop;
  778. var generateComponentTrace = (noop); // work around flow check
  779. var formatComponentName = (noop);
  780. {
  781. var hasConsole = typeof console !== 'undefined';
  782. var classifyRE = /(?:^|[-_])(\w)/g;
  783. var classify = function (str) { return str
  784. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  785. .replace(/[-_]/g, ''); };
  786. warn = function (msg, vm) {
  787. var trace = vm ? generateComponentTrace(vm) : '';
  788. if (hasConsole && (!config.silent)) {
  789. console.error(("[Vue warn]: " + msg + trace));
  790. }
  791. };
  792. tip = function (msg, vm) {
  793. if (hasConsole && (!config.silent)) {
  794. console.warn("[Vue tip]: " + msg + (
  795. vm ? generateComponentTrace(vm) : ''
  796. ));
  797. }
  798. };
  799. formatComponentName = function (vm, includeFile) {
  800. if (vm.$root === vm) {
  801. return '<Root>'
  802. }
  803. var options = typeof vm === 'function' && vm.cid != null
  804. ? vm.options
  805. : vm._isVue
  806. ? vm.$options || vm.constructor.options
  807. : vm;
  808. var name = options.name || options._componentTag;
  809. var file = options.__file;
  810. if (!name && file) {
  811. var match = file.match(/([^/\\]+)\.vue$/);
  812. name = match && match[1];
  813. }
  814. return (
  815. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  816. (file && includeFile !== false ? (" at " + file) : '')
  817. )
  818. };
  819. var repeat = function (str, n) {
  820. var res = '';
  821. while (n) {
  822. if (n % 2 === 1) { res += str; }
  823. if (n > 1) { str += str; }
  824. n >>= 1;
  825. }
  826. return res
  827. };
  828. generateComponentTrace = function (vm) {
  829. if (vm._isVue && vm.$parent) {
  830. var tree = [];
  831. var currentRecursiveSequence = 0;
  832. while (vm) {
  833. if (tree.length > 0) {
  834. var last = tree[tree.length - 1];
  835. if (last.constructor === vm.constructor) {
  836. currentRecursiveSequence++;
  837. vm = vm.$parent;
  838. continue
  839. } else if (currentRecursiveSequence > 0) {
  840. tree[tree.length - 1] = [last, currentRecursiveSequence];
  841. currentRecursiveSequence = 0;
  842. }
  843. }
  844. tree.push(vm);
  845. vm = vm.$parent;
  846. }
  847. return '\n\nfound in\n\n' + tree
  848. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  849. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  850. : formatComponentName(vm))); })
  851. .join('\n')
  852. } else {
  853. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  854. }
  855. };
  856. }
  857. /* */
  858. var uid = 0;
  859. /**
  860. * A dep is an observable that can have multiple
  861. * directives subscribing to it.
  862. */
  863. var Dep = function Dep () {
  864. this.id = uid++;
  865. this.subs = [];
  866. };
  867. Dep.prototype.addSub = function addSub (sub) {
  868. this.subs.push(sub);
  869. };
  870. Dep.prototype.removeSub = function removeSub (sub) {
  871. remove(this.subs, sub);
  872. };
  873. Dep.prototype.depend = function depend () {
  874. if (Dep.target) {
  875. Dep.target.addDep(this);
  876. }
  877. };
  878. Dep.prototype.notify = function notify () {
  879. // stabilize the subscriber list first
  880. var subs = this.subs.slice();
  881. for (var i = 0, l = subs.length; i < l; i++) {
  882. subs[i].update();
  883. }
  884. };
  885. // The current target watcher being evaluated.
  886. // This is globally unique because only one watcher
  887. // can be evaluated at a time.
  888. Dep.target = null;
  889. var targetStack = [];
  890. function pushTarget (target) {
  891. targetStack.push(target);
  892. Dep.target = target;
  893. }
  894. function popTarget () {
  895. targetStack.pop();
  896. Dep.target = targetStack[targetStack.length - 1];
  897. }
  898. /*
  899. * not type checking this file because flow doesn't play well with
  900. * dynamically accessing methods on Array prototype
  901. */
  902. var arrayProto = Array.prototype;
  903. var arrayMethods = Object.create(arrayProto);
  904. var methodsToPatch = [
  905. 'push',
  906. 'pop',
  907. 'shift',
  908. 'unshift',
  909. 'splice',
  910. 'sort',
  911. 'reverse'
  912. ];
  913. /**
  914. * Intercept mutating methods and emit events
  915. */
  916. methodsToPatch.forEach(function (method) {
  917. // cache original method
  918. var original = arrayProto[method];
  919. def(arrayMethods, method, function mutator () {
  920. var args = [], len = arguments.length;
  921. while ( len-- ) args[ len ] = arguments[ len ];
  922. var result = original.apply(this, args);
  923. var ob = this.__ob__;
  924. var inserted;
  925. switch (method) {
  926. case 'push':
  927. case 'unshift':
  928. inserted = args;
  929. break
  930. case 'splice':
  931. inserted = args.slice(2);
  932. break
  933. }
  934. if (inserted) { ob.observeArray(inserted); }
  935. // notify change
  936. ob.dep.notify();
  937. return result
  938. });
  939. });
  940. /* */
  941. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  942. /**
  943. * In some cases we may want to disable observation inside a component's
  944. * update computation.
  945. */
  946. var shouldObserve = true;
  947. function toggleObserving (value) {
  948. shouldObserve = value;
  949. }
  950. /**
  951. * Observer class that is attached to each observed
  952. * object. Once attached, the observer converts the target
  953. * object's property keys into getter/setters that
  954. * collect dependencies and dispatch updates.
  955. */
  956. var Observer = function Observer (value) {
  957. this.value = value;
  958. this.dep = new Dep();
  959. this.vmCount = 0;
  960. def(value, '__ob__', this);
  961. if (Array.isArray(value)) {
  962. if (hasProto) {
  963. protoAugment(value, arrayMethods);
  964. } else {
  965. copyAugment(value, arrayMethods, arrayKeys);
  966. }
  967. this.observeArray(value);
  968. } else {
  969. this.walk(value);
  970. }
  971. };
  972. /**
  973. * Walk through all properties and convert them into
  974. * getter/setters. This method should only be called when
  975. * value type is Object.
  976. */
  977. Observer.prototype.walk = function walk (obj) {
  978. var keys = Object.keys(obj);
  979. for (var i = 0; i < keys.length; i++) {
  980. defineReactive$$1(obj, keys[i]);
  981. }
  982. };
  983. /**
  984. * Observe a list of Array items.
  985. */
  986. Observer.prototype.observeArray = function observeArray (items) {
  987. for (var i = 0, l = items.length; i < l; i++) {
  988. observe(items[i]);
  989. }
  990. };
  991. // helpers
  992. /**
  993. * Augment a target Object or Array by intercepting
  994. * the prototype chain using __proto__
  995. */
  996. function protoAugment (target, src) {
  997. /* eslint-disable no-proto */
  998. target.__proto__ = src;
  999. /* eslint-enable no-proto */
  1000. }
  1001. /**
  1002. * Augment a target Object or Array by defining
  1003. * hidden properties.
  1004. */
  1005. /* istanbul ignore next */
  1006. function copyAugment (target, src, keys) {
  1007. for (var i = 0, l = keys.length; i < l; i++) {
  1008. var key = keys[i];
  1009. def(target, key, src[key]);
  1010. }
  1011. }
  1012. /**
  1013. * Attempt to create an observer instance for a value,
  1014. * returns the new observer if successfully observed,
  1015. * or the existing observer if the value already has one.
  1016. */
  1017. function observe (value, asRootData) {
  1018. if (!isObject(value) || value instanceof VNode) {
  1019. return
  1020. }
  1021. var ob;
  1022. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  1023. ob = value.__ob__;
  1024. } else if (
  1025. shouldObserve &&
  1026. !isServerRendering() &&
  1027. (Array.isArray(value) || isPlainObject(value)) &&
  1028. Object.isExtensible(value) &&
  1029. !value._isVue
  1030. ) {
  1031. ob = new Observer(value);
  1032. }
  1033. if (asRootData && ob) {
  1034. ob.vmCount++;
  1035. }
  1036. return ob
  1037. }
  1038. /**
  1039. * Define a reactive property on an Object.
  1040. */
  1041. function defineReactive$$1 (
  1042. obj,
  1043. key,
  1044. val,
  1045. customSetter,
  1046. shallow
  1047. ) {
  1048. var dep = new Dep();
  1049. var property = Object.getOwnPropertyDescriptor(obj, key);
  1050. if (property && property.configurable === false) {
  1051. return
  1052. }
  1053. // cater for pre-defined getter/setters
  1054. var getter = property && property.get;
  1055. var setter = property && property.set;
  1056. if ((!getter || setter) && arguments.length === 2) {
  1057. val = obj[key];
  1058. }
  1059. var childOb = !shallow && observe(val);
  1060. Object.defineProperty(obj, key, {
  1061. enumerable: true,
  1062. configurable: true,
  1063. get: function reactiveGetter () {
  1064. var value = getter ? getter.call(obj) : val;
  1065. if (Dep.target) {
  1066. dep.depend();
  1067. if (childOb) {
  1068. childOb.dep.depend();
  1069. if (Array.isArray(value)) {
  1070. dependArray(value);
  1071. }
  1072. }
  1073. }
  1074. return value
  1075. },
  1076. set: function reactiveSetter (newVal) {
  1077. var value = getter ? getter.call(obj) : val;
  1078. /* eslint-disable no-self-compare */
  1079. if (newVal === value || (newVal !== newVal && value !== value)) {
  1080. return
  1081. }
  1082. /* eslint-enable no-self-compare */
  1083. if (customSetter) {
  1084. customSetter();
  1085. }
  1086. // #7981: for accessor properties without setter
  1087. if (getter && !setter) { return }
  1088. if (setter) {
  1089. setter.call(obj, newVal);
  1090. } else {
  1091. val = newVal;
  1092. }
  1093. childOb = !shallow && observe(newVal);
  1094. dep.notify();
  1095. }
  1096. });
  1097. }
  1098. /**
  1099. * Set a property on an object. Adds the new property and
  1100. * triggers change notification if the property doesn't
  1101. * already exist.
  1102. */
  1103. function set (target, key, val) {
  1104. if (isUndef(target) || isPrimitive(target)
  1105. ) {
  1106. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  1107. }
  1108. if (Array.isArray(target) && isValidArrayIndex(key)) {
  1109. target.length = Math.max(target.length, key);
  1110. target.splice(key, 1, val);
  1111. return val
  1112. }
  1113. if (key in target && !(key in Object.prototype)) {
  1114. target[key] = val;
  1115. return val
  1116. }
  1117. var ob = (target).__ob__;
  1118. if (target._isVue || (ob && ob.vmCount)) {
  1119. warn(
  1120. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  1121. 'at runtime - declare it upfront in the data option.'
  1122. );
  1123. return val
  1124. }
  1125. if (!ob) {
  1126. target[key] = val;
  1127. return val
  1128. }
  1129. defineReactive$$1(ob.value, key, val);
  1130. ob.dep.notify();
  1131. return val
  1132. }
  1133. /**
  1134. * Collect dependencies on array elements when the array is touched, since
  1135. * we cannot intercept array element access like property getters.
  1136. */
  1137. function dependArray (value) {
  1138. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  1139. e = value[i];
  1140. e && e.__ob__ && e.__ob__.dep.depend();
  1141. if (Array.isArray(e)) {
  1142. dependArray(e);
  1143. }
  1144. }
  1145. }
  1146. /* */
  1147. /**
  1148. * Option overwriting strategies are functions that handle
  1149. * how to merge a parent option value and a child option
  1150. * value into the final value.
  1151. */
  1152. var strats = config.optionMergeStrategies;
  1153. /**
  1154. * Options with restrictions
  1155. */
  1156. {
  1157. strats.el = strats.propsData = function (parent, child, vm, key) {
  1158. if (!vm) {
  1159. warn(
  1160. "option \"" + key + "\" can only be used during instance " +
  1161. 'creation with the `new` keyword.'
  1162. );
  1163. }
  1164. return defaultStrat(parent, child)
  1165. };
  1166. }
  1167. /**
  1168. * Helper that recursively merges two data objects together.
  1169. */
  1170. function mergeData (to, from) {
  1171. if (!from) { return to }
  1172. var key, toVal, fromVal;
  1173. var keys = hasSymbol
  1174. ? Reflect.ownKeys(from)
  1175. : Object.keys(from);
  1176. for (var i = 0; i < keys.length; i++) {
  1177. key = keys[i];
  1178. // in case the object is already observed...
  1179. if (key === '__ob__') { continue }
  1180. toVal = to[key];
  1181. fromVal = from[key];
  1182. if (!hasOwn(to, key)) {
  1183. set(to, key, fromVal);
  1184. } else if (
  1185. toVal !== fromVal &&
  1186. isPlainObject(toVal) &&
  1187. isPlainObject(fromVal)
  1188. ) {
  1189. mergeData(toVal, fromVal);
  1190. }
  1191. }
  1192. return to
  1193. }
  1194. /**
  1195. * Data
  1196. */
  1197. function mergeDataOrFn (
  1198. parentVal,
  1199. childVal,
  1200. vm
  1201. ) {
  1202. if (!vm) {
  1203. // in a Vue.extend merge, both should be functions
  1204. if (!childVal) {
  1205. return parentVal
  1206. }
  1207. if (!parentVal) {
  1208. return childVal
  1209. }
  1210. // when parentVal & childVal are both present,
  1211. // we need to return a function that returns the
  1212. // merged result of both functions... no need to
  1213. // check if parentVal is a function here because
  1214. // it has to be a function to pass previous merges.
  1215. return function mergedDataFn () {
  1216. return mergeData(
  1217. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  1218. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  1219. )
  1220. }
  1221. } else {
  1222. return function mergedInstanceDataFn () {
  1223. // instance merge
  1224. var instanceData = typeof childVal === 'function'
  1225. ? childVal.call(vm, vm)
  1226. : childVal;
  1227. var defaultData = typeof parentVal === 'function'
  1228. ? parentVal.call(vm, vm)
  1229. : parentVal;
  1230. if (instanceData) {
  1231. return mergeData(instanceData, defaultData)
  1232. } else {
  1233. return defaultData
  1234. }
  1235. }
  1236. }
  1237. }
  1238. strats.data = function (
  1239. parentVal,
  1240. childVal,
  1241. vm
  1242. ) {
  1243. if (!vm) {
  1244. if (childVal && typeof childVal !== 'function') {
  1245. warn(
  1246. 'The "data" option should be a function ' +
  1247. 'that returns a per-instance value in component ' +
  1248. 'definitions.',
  1249. vm
  1250. );
  1251. return parentVal
  1252. }
  1253. return mergeDataOrFn(parentVal, childVal)
  1254. }
  1255. return mergeDataOrFn(parentVal, childVal, vm)
  1256. };
  1257. /**
  1258. * Hooks and props are merged as arrays.
  1259. */
  1260. function mergeHook (
  1261. parentVal,
  1262. childVal
  1263. ) {
  1264. var res = childVal
  1265. ? parentVal
  1266. ? parentVal.concat(childVal)
  1267. : Array.isArray(childVal)
  1268. ? childVal
  1269. : [childVal]
  1270. : parentVal;
  1271. return res
  1272. ? dedupeHooks(res)
  1273. : res
  1274. }
  1275. function dedupeHooks (hooks) {
  1276. var res = [];
  1277. for (var i = 0; i < hooks.length; i++) {
  1278. if (res.indexOf(hooks[i]) === -1) {
  1279. res.push(hooks[i]);
  1280. }
  1281. }
  1282. return res
  1283. }
  1284. LIFECYCLE_HOOKS.forEach(function (hook) {
  1285. strats[hook] = mergeHook;
  1286. });
  1287. /**
  1288. * Assets
  1289. *
  1290. * When a vm is present (instance creation), we need to do
  1291. * a three-way merge between constructor options, instance
  1292. * options and parent options.
  1293. */
  1294. function mergeAssets (
  1295. parentVal,
  1296. childVal,
  1297. vm,
  1298. key
  1299. ) {
  1300. var res = Object.create(parentVal || null);
  1301. if (childVal) {
  1302. assertObjectType(key, childVal, vm);
  1303. return extend(res, childVal)
  1304. } else {
  1305. return res
  1306. }
  1307. }
  1308. ASSET_TYPES.forEach(function (type) {
  1309. strats[type + 's'] = mergeAssets;
  1310. });
  1311. /**
  1312. * Watchers.
  1313. *
  1314. * Watchers hashes should not overwrite one
  1315. * another, so we merge them as arrays.
  1316. */
  1317. strats.watch = function (
  1318. parentVal,
  1319. childVal,
  1320. vm,
  1321. key
  1322. ) {
  1323. // work around Firefox's Object.prototype.watch...
  1324. if (parentVal === nativeWatch) { parentVal = undefined; }
  1325. if (childVal === nativeWatch) { childVal = undefined; }
  1326. /* istanbul ignore if */
  1327. if (!childVal) { return Object.create(parentVal || null) }
  1328. {
  1329. assertObjectType(key, childVal, vm);
  1330. }
  1331. if (!parentVal) { return childVal }
  1332. var ret = {};
  1333. extend(ret, parentVal);
  1334. for (var key$1 in childVal) {
  1335. var parent = ret[key$1];
  1336. var child = childVal[key$1];
  1337. if (parent && !Array.isArray(parent)) {
  1338. parent = [parent];
  1339. }
  1340. ret[key$1] = parent
  1341. ? parent.concat(child)
  1342. : Array.isArray(child) ? child : [child];
  1343. }
  1344. return ret
  1345. };
  1346. /**
  1347. * Other object hashes.
  1348. */
  1349. strats.props =
  1350. strats.methods =
  1351. strats.inject =
  1352. strats.computed = function (
  1353. parentVal,
  1354. childVal,
  1355. vm,
  1356. key
  1357. ) {
  1358. if (childVal && "development" !== 'production') {
  1359. assertObjectType(key, childVal, vm);
  1360. }
  1361. if (!parentVal) { return childVal }
  1362. var ret = Object.create(null);
  1363. extend(ret, parentVal);
  1364. if (childVal) { extend(ret, childVal); }
  1365. return ret
  1366. };
  1367. strats.provide = mergeDataOrFn;
  1368. /**
  1369. * Default strategy.
  1370. */
  1371. var defaultStrat = function (parentVal, childVal) {
  1372. return childVal === undefined
  1373. ? parentVal
  1374. : childVal
  1375. };
  1376. /**
  1377. * Validate component names
  1378. */
  1379. function checkComponents (options) {
  1380. for (var key in options.components) {
  1381. validateComponentName(key);
  1382. }
  1383. }
  1384. function validateComponentName (name) {
  1385. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  1386. warn(
  1387. 'Invalid component name: "' + name + '". Component names ' +
  1388. 'should conform to valid custom element name in html5 specification.'
  1389. );
  1390. }
  1391. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  1392. warn(
  1393. 'Do not use built-in or reserved HTML elements as component ' +
  1394. 'id: ' + name
  1395. );
  1396. }
  1397. }
  1398. /**
  1399. * Ensure all props option syntax are normalized into the
  1400. * Object-based format.
  1401. */
  1402. function normalizeProps (options, vm) {
  1403. var props = options.props;
  1404. if (!props) { return }
  1405. var res = {};
  1406. var i, val, name;
  1407. if (Array.isArray(props)) {
  1408. i = props.length;
  1409. while (i--) {
  1410. val = props[i];
  1411. if (typeof val === 'string') {
  1412. name = camelize(val);
  1413. res[name] = { type: null };
  1414. } else {
  1415. warn('props must be strings when using array syntax.');
  1416. }
  1417. }
  1418. } else if (isPlainObject(props)) {
  1419. for (var key in props) {
  1420. val = props[key];
  1421. name = camelize(key);
  1422. res[name] = isPlainObject(val)
  1423. ? val
  1424. : { type: val };
  1425. }
  1426. } else {
  1427. warn(
  1428. "Invalid value for option \"props\": expected an Array or an Object, " +
  1429. "but got " + (toRawType(props)) + ".",
  1430. vm
  1431. );
  1432. }
  1433. options.props = res;
  1434. }
  1435. /**
  1436. * Normalize all injections into Object-based format
  1437. */
  1438. function normalizeInject (options, vm) {
  1439. var inject = options.inject;
  1440. if (!inject) { return }
  1441. var normalized = options.inject = {};
  1442. if (Array.isArray(inject)) {
  1443. for (var i = 0; i < inject.length; i++) {
  1444. normalized[inject[i]] = { from: inject[i] };
  1445. }
  1446. } else if (isPlainObject(inject)) {
  1447. for (var key in inject) {
  1448. var val = inject[key];
  1449. normalized[key] = isPlainObject(val)
  1450. ? extend({ from: key }, val)
  1451. : { from: val };
  1452. }
  1453. } else {
  1454. warn(
  1455. "Invalid value for option \"inject\": expected an Array or an Object, " +
  1456. "but got " + (toRawType(inject)) + ".",
  1457. vm
  1458. );
  1459. }
  1460. }
  1461. /**
  1462. * Normalize raw function directives into object format.
  1463. */
  1464. function normalizeDirectives (options) {
  1465. var dirs = options.directives;
  1466. if (dirs) {
  1467. for (var key in dirs) {
  1468. var def$$1 = dirs[key];
  1469. if (typeof def$$1 === 'function') {
  1470. dirs[key] = { bind: def$$1, update: def$$1 };
  1471. }
  1472. }
  1473. }
  1474. }
  1475. function assertObjectType (name, value, vm) {
  1476. if (!isPlainObject(value)) {
  1477. warn(
  1478. "Invalid value for option \"" + name + "\": expected an Object, " +
  1479. "but got " + (toRawType(value)) + ".",
  1480. vm
  1481. );
  1482. }
  1483. }
  1484. /**
  1485. * Merge two option objects into a new one.
  1486. * Core utility used in both instantiation and inheritance.
  1487. */
  1488. function mergeOptions (
  1489. parent,
  1490. child,
  1491. vm
  1492. ) {
  1493. {
  1494. checkComponents(child);
  1495. }
  1496. if (typeof child === 'function') {
  1497. child = child.options;
  1498. }
  1499. normalizeProps(child, vm);
  1500. normalizeInject(child, vm);
  1501. normalizeDirectives(child);
  1502. // Apply extends and mixins on the child options,
  1503. // but only if it is a raw options object that isn't
  1504. // the result of another mergeOptions call.
  1505. // Only merged options has the _base property.
  1506. if (!child._base) {
  1507. if (child.extends) {
  1508. parent = mergeOptions(parent, child.extends, vm);
  1509. }
  1510. if (child.mixins) {
  1511. for (var i = 0, l = child.mixins.length; i < l; i++) {
  1512. parent = mergeOptions(parent, child.mixins[i], vm);
  1513. }
  1514. }
  1515. }
  1516. var options = {};
  1517. var key;
  1518. for (key in parent) {
  1519. mergeField(key);
  1520. }
  1521. for (key in child) {
  1522. if (!hasOwn(parent, key)) {
  1523. mergeField(key);
  1524. }
  1525. }
  1526. function mergeField (key) {
  1527. var strat = strats[key] || defaultStrat;
  1528. options[key] = strat(parent[key], child[key], vm, key);
  1529. }
  1530. return options
  1531. }
  1532. /**
  1533. * Resolve an asset.
  1534. * This function is used because child instances need access
  1535. * to assets defined in its ancestor chain.
  1536. */
  1537. function resolveAsset (
  1538. options,
  1539. type,
  1540. id,
  1541. warnMissing
  1542. ) {
  1543. /* istanbul ignore if */
  1544. if (typeof id !== 'string') {
  1545. return
  1546. }
  1547. var assets = options[type];
  1548. // check local registration variations first
  1549. if (hasOwn(assets, id)) { return assets[id] }
  1550. var camelizedId = camelize(id);
  1551. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  1552. var PascalCaseId = capitalize(camelizedId);
  1553. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  1554. // fallback to prototype chain
  1555. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  1556. if (warnMissing && !res) {
  1557. warn(
  1558. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  1559. options
  1560. );
  1561. }
  1562. return res
  1563. }
  1564. /* */
  1565. function validateProp (
  1566. key,
  1567. propOptions,
  1568. propsData,
  1569. vm
  1570. ) {
  1571. var prop = propOptions[key];
  1572. var absent = !hasOwn(propsData, key);
  1573. var value = propsData[key];
  1574. // boolean casting
  1575. var booleanIndex = getTypeIndex(Boolean, prop.type);
  1576. if (booleanIndex > -1) {
  1577. if (absent && !hasOwn(prop, 'default')) {
  1578. value = false;
  1579. } else if (value === '' || value === hyphenate(key)) {
  1580. // only cast empty string / same name to boolean if
  1581. // boolean has higher priority
  1582. var stringIndex = getTypeIndex(String, prop.type);
  1583. if (stringIndex < 0 || booleanIndex < stringIndex) {
  1584. value = true;
  1585. }
  1586. }
  1587. }
  1588. // check default value
  1589. if (value === undefined) {
  1590. value = getPropDefaultValue(vm, prop, key);
  1591. // since the default value is a fresh copy,
  1592. // make sure to observe it.
  1593. var prevShouldObserve = shouldObserve;
  1594. toggleObserving(true);
  1595. observe(value);
  1596. toggleObserving(prevShouldObserve);
  1597. }
  1598. {
  1599. assertProp(prop, key, value, vm, absent);
  1600. }
  1601. return value
  1602. }
  1603. /**
  1604. * Get the default value of a prop.
  1605. */
  1606. function getPropDefaultValue (vm, prop, key) {
  1607. // no default, return undefined
  1608. if (!hasOwn(prop, 'default')) {
  1609. return undefined
  1610. }
  1611. var def = prop.default;
  1612. // warn against non-factory defaults for Object & Array
  1613. if (isObject(def)) {
  1614. warn(
  1615. 'Invalid default value for prop "' + key + '": ' +
  1616. 'Props with type Object/Array must use a factory function ' +
  1617. 'to return the default value.',
  1618. vm
  1619. );
  1620. }
  1621. // the raw prop value was also undefined from previous render,
  1622. // return previous default value to avoid unnecessary watcher trigger
  1623. if (vm && vm.$options.propsData &&
  1624. vm.$options.propsData[key] === undefined &&
  1625. vm._props[key] !== undefined
  1626. ) {
  1627. return vm._props[key]
  1628. }
  1629. // call factory function for non-Function types
  1630. // a value is Function if its prototype is function even across different execution context
  1631. return typeof def === 'function' && getType(prop.type) !== 'Function'
  1632. ? def.call(vm)
  1633. : def
  1634. }
  1635. /**
  1636. * Assert whether a prop is valid.
  1637. */
  1638. function assertProp (
  1639. prop,
  1640. name,
  1641. value,
  1642. vm,
  1643. absent
  1644. ) {
  1645. if (prop.required && absent) {
  1646. warn(
  1647. 'Missing required prop: "' + name + '"',
  1648. vm
  1649. );
  1650. return
  1651. }
  1652. if (value == null && !prop.required) {
  1653. return
  1654. }
  1655. var type = prop.type;
  1656. var valid = !type || type === true;
  1657. var expectedTypes = [];
  1658. if (type) {
  1659. if (!Array.isArray(type)) {
  1660. type = [type];
  1661. }
  1662. for (var i = 0; i < type.length && !valid; i++) {
  1663. var assertedType = assertType(value, type[i], vm);
  1664. expectedTypes.push(assertedType.expectedType || '');
  1665. valid = assertedType.valid;
  1666. }
  1667. }
  1668. var haveExpectedTypes = expectedTypes.some(function (t) { return t; });
  1669. if (!valid && haveExpectedTypes) {
  1670. warn(
  1671. getInvalidTypeMessage(name, value, expectedTypes),
  1672. vm
  1673. );
  1674. return
  1675. }
  1676. var validator = prop.validator;
  1677. if (validator) {
  1678. if (!validator(value)) {
  1679. warn(
  1680. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  1681. vm
  1682. );
  1683. }
  1684. }
  1685. }
  1686. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  1687. function assertType (value, type, vm) {
  1688. var valid;
  1689. var expectedType = getType(type);
  1690. if (simpleCheckRE.test(expectedType)) {
  1691. var t = typeof value;
  1692. valid = t === expectedType.toLowerCase();
  1693. // for primitive wrapper objects
  1694. if (!valid && t === 'object') {
  1695. valid = value instanceof type;
  1696. }
  1697. } else if (expectedType === 'Object') {
  1698. valid = isPlainObject(value);
  1699. } else if (expectedType === 'Array') {
  1700. valid = Array.isArray(value);
  1701. } else {
  1702. try {
  1703. valid = value instanceof type;
  1704. } catch (e) {
  1705. warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  1706. valid = false;
  1707. }
  1708. }
  1709. return {
  1710. valid: valid,
  1711. expectedType: expectedType
  1712. }
  1713. }
  1714. var functionTypeCheckRE = /^\s*function (\w+)/;
  1715. /**
  1716. * Use function string name to check built-in types,
  1717. * because a simple equality check will fail when running
  1718. * across different vms / iframes.
  1719. */
  1720. function getType (fn) {
  1721. var match = fn && fn.toString().match(functionTypeCheckRE);
  1722. return match ? match[1] : ''
  1723. }
  1724. function isSameType (a, b) {
  1725. return getType(a) === getType(b)
  1726. }
  1727. function getTypeIndex (type, expectedTypes) {
  1728. if (!Array.isArray(expectedTypes)) {
  1729. return isSameType(expectedTypes, type) ? 0 : -1
  1730. }
  1731. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  1732. if (isSameType(expectedTypes[i], type)) {
  1733. return i
  1734. }
  1735. }
  1736. return -1
  1737. }
  1738. function getInvalidTypeMessage (name, value, expectedTypes) {
  1739. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  1740. " Expected " + (expectedTypes.map(capitalize).join(', '));
  1741. var expectedType = expectedTypes[0];
  1742. var receivedType = toRawType(value);
  1743. // check if we need to specify expected value
  1744. if (
  1745. expectedTypes.length === 1 &&
  1746. isExplicable(expectedType) &&
  1747. isExplicable(typeof value) &&
  1748. !isBoolean(expectedType, receivedType)
  1749. ) {
  1750. message += " with value " + (styleValue(value, expectedType));
  1751. }
  1752. message += ", got " + receivedType + " ";
  1753. // check if we need to specify received value
  1754. if (isExplicable(receivedType)) {
  1755. message += "with value " + (styleValue(value, receivedType)) + ".";
  1756. }
  1757. return message
  1758. }
  1759. function styleValue (value, type) {
  1760. if (type === 'String') {
  1761. return ("\"" + value + "\"")
  1762. } else if (type === 'Number') {
  1763. return ("" + (Number(value)))
  1764. } else {
  1765. return ("" + value)
  1766. }
  1767. }
  1768. var EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  1769. function isExplicable (value) {
  1770. return EXPLICABLE_TYPES.some(function (elem) { return value.toLowerCase() === elem; })
  1771. }
  1772. function isBoolean () {
  1773. var args = [], len = arguments.length;
  1774. while ( len-- ) args[ len ] = arguments[ len ];
  1775. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  1776. }
  1777. /* */
  1778. function handleError (err, vm, info) {
  1779. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  1780. // See: https://github.com/vuejs/vuex/issues/1505
  1781. pushTarget();
  1782. try {
  1783. if (vm) {
  1784. var cur = vm;
  1785. while ((cur = cur.$parent)) {
  1786. var hooks = cur.$options.errorCaptured;
  1787. if (hooks) {
  1788. for (var i = 0; i < hooks.length; i++) {
  1789. try {
  1790. var capture = hooks[i].call(cur, err, vm, info) === false;
  1791. if (capture) { return }
  1792. } catch (e) {
  1793. globalHandleError(e, cur, 'errorCaptured hook');
  1794. }
  1795. }
  1796. }
  1797. }
  1798. }
  1799. globalHandleError(err, vm, info);
  1800. } finally {
  1801. popTarget();
  1802. }
  1803. }
  1804. function invokeWithErrorHandling (
  1805. handler,
  1806. context,
  1807. args,
  1808. vm,
  1809. info
  1810. ) {
  1811. var res;
  1812. try {
  1813. res = args ? handler.apply(context, args) : handler.call(context);
  1814. if (res && !res._isVue && isPromise(res) && !res._handled) {
  1815. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  1816. // issue #9511
  1817. // avoid catch triggering multiple times when nested calls
  1818. res._handled = true;
  1819. }
  1820. } catch (e) {
  1821. handleError(e, vm, info);
  1822. }
  1823. return res
  1824. }
  1825. function globalHandleError (err, vm, info) {
  1826. logError(err, vm, info);
  1827. }
  1828. function logError (err, vm, info) {
  1829. {
  1830. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  1831. }
  1832. /* istanbul ignore else */
  1833. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  1834. console.error(err);
  1835. } else {
  1836. throw err
  1837. }
  1838. }
  1839. /* */
  1840. var callbacks = [];
  1841. function flushCallbacks () {
  1842. var copies = callbacks.slice(0);
  1843. callbacks.length = 0;
  1844. for (var i = 0; i < copies.length; i++) {
  1845. copies[i]();
  1846. }
  1847. }
  1848. // The nextTick behavior leverages the microtask queue, which can be accessed
  1849. // via either native Promise.then or MutationObserver.
  1850. // MutationObserver has wider support, however it is seriously bugged in
  1851. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  1852. // completely stops working after triggering a few times... so, if native
  1853. // Promise is available, we will use it:
  1854. /* istanbul ignore next, $flow-disable-line */
  1855. if (typeof Promise !== 'undefined' && isNative(Promise)) ; else if (!isIE && typeof MutationObserver !== 'undefined' && (
  1856. isNative(MutationObserver) ||
  1857. // PhantomJS and iOS 7.x
  1858. MutationObserver.toString() === '[object MutationObserverConstructor]'
  1859. )) {
  1860. // Use MutationObserver where native Promise is not available,
  1861. // e.g. PhantomJS, iOS7, Android 4.4
  1862. // (#6466 MutationObserver is unreliable in IE11)
  1863. var counter = 1;
  1864. var observer = new MutationObserver(flushCallbacks);
  1865. var textNode = document.createTextNode(String(counter));
  1866. observer.observe(textNode, {
  1867. characterData: true
  1868. });
  1869. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) ;
  1870. /* */
  1871. /* */
  1872. function genClassForVnode (vnode) {
  1873. var data = vnode.data;
  1874. var parentNode = vnode;
  1875. var childNode = vnode;
  1876. while (isDef(childNode.componentInstance)) {
  1877. childNode = childNode.componentInstance._vnode;
  1878. if (childNode && childNode.data) {
  1879. data = mergeClassData(childNode.data, data);
  1880. }
  1881. }
  1882. while (isDef(parentNode = parentNode.parent)) {
  1883. if (parentNode && parentNode.data) {
  1884. data = mergeClassData(data, parentNode.data);
  1885. }
  1886. }
  1887. return renderClass(data.staticClass, data.class)
  1888. }
  1889. function mergeClassData (child, parent) {
  1890. return {
  1891. staticClass: concat(child.staticClass, parent.staticClass),
  1892. class: isDef(child.class)
  1893. ? [child.class, parent.class]
  1894. : parent.class
  1895. }
  1896. }
  1897. function renderClass (
  1898. staticClass,
  1899. dynamicClass
  1900. ) {
  1901. if (isDef(staticClass) || isDef(dynamicClass)) {
  1902. return concat(staticClass, stringifyClass(dynamicClass))
  1903. }
  1904. /* istanbul ignore next */
  1905. return ''
  1906. }
  1907. function concat (a, b) {
  1908. return a ? b ? (a + ' ' + b) : a : (b || '')
  1909. }
  1910. function stringifyClass (value) {
  1911. if (Array.isArray(value)) {
  1912. return stringifyArray(value)
  1913. }
  1914. if (isObject(value)) {
  1915. return stringifyObject(value)
  1916. }
  1917. if (typeof value === 'string') {
  1918. return value
  1919. }
  1920. /* istanbul ignore next */
  1921. return ''
  1922. }
  1923. function stringifyArray (value) {
  1924. var res = '';
  1925. var stringified;
  1926. for (var i = 0, l = value.length; i < l; i++) {
  1927. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  1928. if (res) { res += ' '; }
  1929. res += stringified;
  1930. }
  1931. }
  1932. return res
  1933. }
  1934. function stringifyObject (value) {
  1935. var res = '';
  1936. for (var key in value) {
  1937. if (value[key]) {
  1938. if (res) { res += ' '; }
  1939. res += key;
  1940. }
  1941. }
  1942. return res
  1943. }
  1944. /* */
  1945. var isHTMLTag = makeMap(
  1946. 'html,body,base,head,link,meta,style,title,' +
  1947. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  1948. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  1949. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  1950. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  1951. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  1952. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  1953. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  1954. 'output,progress,select,textarea,' +
  1955. 'details,dialog,menu,menuitem,summary,' +
  1956. 'content,element,shadow,template,blockquote,iframe,tfoot'
  1957. );
  1958. // this map is intentionally selective, only covering SVG elements that may
  1959. // contain child elements.
  1960. var isSVG = makeMap(
  1961. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  1962. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  1963. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  1964. true
  1965. );
  1966. var isPreTag = function (tag) { return tag === 'pre'; };
  1967. var isReservedTag = function (tag) {
  1968. return isHTMLTag(tag) || isSVG(tag)
  1969. };
  1970. function getTagNamespace (tag) {
  1971. if (isSVG(tag)) {
  1972. return 'svg'
  1973. }
  1974. // basic support for MathML
  1975. // note it doesn't support other MathML elements being component roots
  1976. if (tag === 'math') {
  1977. return 'math'
  1978. }
  1979. }
  1980. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  1981. /* */
  1982. /* */
  1983. function renderClass$1 (node) {
  1984. var classList = genClassForVnode(node);
  1985. if (classList !== '') {
  1986. return (" class=\"" + (escape(classList)) + "\"")
  1987. }
  1988. }
  1989. /* */
  1990. var parseStyleText = cached(function (cssText) {
  1991. var res = {};
  1992. var listDelimiter = /;(?![^(]*\))/g;
  1993. var propertyDelimiter = /:(.+)/;
  1994. cssText.split(listDelimiter).forEach(function (item) {
  1995. if (item) {
  1996. var tmp = item.split(propertyDelimiter);
  1997. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  1998. }
  1999. });
  2000. return res
  2001. });
  2002. // merge static and dynamic style data on the same vnode
  2003. function normalizeStyleData (data) {
  2004. var style = normalizeStyleBinding(data.style);
  2005. // static style is pre-processed into an object during compilation
  2006. // and is always a fresh object, so it's safe to merge into it
  2007. return data.staticStyle
  2008. ? extend(data.staticStyle, style)
  2009. : style
  2010. }
  2011. // normalize possible array / string values into Object
  2012. function normalizeStyleBinding (bindingStyle) {
  2013. if (Array.isArray(bindingStyle)) {
  2014. return toObject(bindingStyle)
  2015. }
  2016. if (typeof bindingStyle === 'string') {
  2017. return parseStyleText(bindingStyle)
  2018. }
  2019. return bindingStyle
  2020. }
  2021. /**
  2022. * parent component style should be after child's
  2023. * so that parent component's style could override it
  2024. */
  2025. function getStyle (vnode, checkChild) {
  2026. var res = {};
  2027. var styleData;
  2028. if (checkChild) {
  2029. var childNode = vnode;
  2030. while (childNode.componentInstance) {
  2031. childNode = childNode.componentInstance._vnode;
  2032. if (
  2033. childNode && childNode.data &&
  2034. (styleData = normalizeStyleData(childNode.data))
  2035. ) {
  2036. extend(res, styleData);
  2037. }
  2038. }
  2039. }
  2040. if ((styleData = normalizeStyleData(vnode.data))) {
  2041. extend(res, styleData);
  2042. }
  2043. var parentNode = vnode;
  2044. while ((parentNode = parentNode.parent)) {
  2045. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  2046. extend(res, styleData);
  2047. }
  2048. }
  2049. return res
  2050. }
  2051. /* */
  2052. function genStyle (style) {
  2053. var styleText = '';
  2054. for (var key in style) {
  2055. var value = style[key];
  2056. var hyphenatedKey = hyphenate(key);
  2057. if (Array.isArray(value)) {
  2058. for (var i = 0, len = value.length; i < len; i++) {
  2059. styleText += normalizeValue(hyphenatedKey, value[i]);
  2060. }
  2061. } else {
  2062. styleText += normalizeValue(hyphenatedKey, value);
  2063. }
  2064. }
  2065. return styleText
  2066. }
  2067. function normalizeValue(key, value) {
  2068. if (
  2069. typeof value === 'string' ||
  2070. (typeof value === 'number' && noUnitNumericStyleProps[key]) ||
  2071. value === 0
  2072. ) {
  2073. return (key + ":" + value + ";")
  2074. } else {
  2075. // invalid values
  2076. return ""
  2077. }
  2078. }
  2079. function renderStyle (vnode) {
  2080. var styleText = genStyle(getStyle(vnode, false));
  2081. if (styleText !== '') {
  2082. return (" style=" + (JSON.stringify(escape(styleText))))
  2083. }
  2084. }
  2085. var modules = [
  2086. renderAttrs,
  2087. renderDOMProps,
  2088. renderClass$1,
  2089. renderStyle
  2090. ];
  2091. /* */
  2092. function show (node, dir) {
  2093. if (!dir.value) {
  2094. var style = node.data.style || (node.data.style = {});
  2095. if (Array.isArray(style)) {
  2096. style.push({ display: 'none' });
  2097. } else {
  2098. style.display = 'none';
  2099. }
  2100. }
  2101. }
  2102. /* */
  2103. // this is only applied for <select v-model> because it is the only edge case
  2104. // that must be done at runtime instead of compile time.
  2105. function model (node, dir) {
  2106. if (!node.children) { return }
  2107. var value = dir.value;
  2108. var isMultiple = node.data.attrs && node.data.attrs.multiple;
  2109. for (var i = 0, l = node.children.length; i < l; i++) {
  2110. var option = node.children[i];
  2111. if (option.tag === 'option') {
  2112. if (isMultiple) {
  2113. var selected =
  2114. Array.isArray(value) &&
  2115. (looseIndexOf(value, getValue(option)) > -1);
  2116. if (selected) {
  2117. setSelected(option);
  2118. }
  2119. } else {
  2120. if (looseEqual(value, getValue(option))) {
  2121. setSelected(option);
  2122. return
  2123. }
  2124. }
  2125. }
  2126. }
  2127. }
  2128. function getValue (option) {
  2129. var data = option.data || {};
  2130. return (
  2131. (data.attrs && data.attrs.value) ||
  2132. (data.domProps && data.domProps.value) ||
  2133. (option.children && option.children[0] && option.children[0].text)
  2134. )
  2135. }
  2136. function setSelected (option) {
  2137. var data = option.data || (option.data = {});
  2138. var attrs = data.attrs || (data.attrs = {});
  2139. attrs.selected = '';
  2140. }
  2141. var baseDirectives = {
  2142. show: show,
  2143. model: model
  2144. };
  2145. /* */
  2146. var isUnaryTag = makeMap(
  2147. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  2148. 'link,meta,param,source,track,wbr'
  2149. );
  2150. // Elements that you can, intentionally, leave open
  2151. // (and which close themselves)
  2152. var canBeLeftOpenTag = makeMap(
  2153. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  2154. );
  2155. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  2156. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  2157. var isNonPhrasingTag = makeMap(
  2158. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  2159. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  2160. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  2161. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  2162. 'title,tr,track'
  2163. );
  2164. /* */
  2165. var MAX_STACK_DEPTH = 800;
  2166. var noop$1 = function (_) { return _; };
  2167. var defer = typeof process !== 'undefined' && process.nextTick
  2168. ? process.nextTick
  2169. : typeof Promise !== 'undefined'
  2170. ? function (fn) { return Promise.resolve().then(fn); }
  2171. : typeof setTimeout !== 'undefined'
  2172. ? setTimeout
  2173. : noop$1;
  2174. if (defer === noop$1) {
  2175. throw new Error(
  2176. 'Your JavaScript runtime does not support any asynchronous primitives ' +
  2177. 'that are required by vue-server-renderer. Please use a polyfill for ' +
  2178. 'either Promise or setTimeout.'
  2179. )
  2180. }
  2181. function createWriteFunction (
  2182. write,
  2183. onError
  2184. ) {
  2185. var stackDepth = 0;
  2186. var cachedWrite = function (text, next) {
  2187. if (text && cachedWrite.caching) {
  2188. cachedWrite.cacheBuffer[cachedWrite.cacheBuffer.length - 1] += text;
  2189. }
  2190. var waitForNext = write(text, next);
  2191. if (waitForNext !== true) {
  2192. if (stackDepth >= MAX_STACK_DEPTH) {
  2193. defer(function () {
  2194. try { next(); } catch (e) {
  2195. onError(e);
  2196. }
  2197. });
  2198. } else {
  2199. stackDepth++;
  2200. next();
  2201. stackDepth--;
  2202. }
  2203. }
  2204. };
  2205. cachedWrite.caching = false;
  2206. cachedWrite.cacheBuffer = [];
  2207. cachedWrite.componentBuffer = [];
  2208. return cachedWrite
  2209. }
  2210. /* */
  2211. /**
  2212. * Original RenderStream implementation by Sasha Aickin (@aickin)
  2213. * Licensed under the Apache License, Version 2.0
  2214. * http://www.apache.org/licenses/LICENSE-2.0
  2215. *
  2216. * Modified by Evan You (@yyx990803)
  2217. */
  2218. var stream = require('stream');
  2219. var RenderStream = /*@__PURE__*/(function (superclass) {
  2220. function RenderStream (render) {
  2221. var this$1 = this;
  2222. superclass.call(this);
  2223. this.buffer = '';
  2224. this.render = render;
  2225. this.expectedSize = 0;
  2226. this.write = createWriteFunction(function (text, next) {
  2227. var n = this$1.expectedSize;
  2228. this$1.buffer += text;
  2229. if (this$1.buffer.length >= n) {
  2230. this$1.next = next;
  2231. this$1.pushBySize(n);
  2232. return true // we will decide when to call next
  2233. }
  2234. return false
  2235. }, function (err) {
  2236. this$1.emit('error', err);
  2237. });
  2238. this.end = function () {
  2239. this$1.emit('beforeEnd');
  2240. // the rendering is finished; we should push out the last of the buffer.
  2241. this$1.done = true;
  2242. this$1.push(this$1.buffer);
  2243. };
  2244. }
  2245. if ( superclass ) RenderStream.__proto__ = superclass;
  2246. RenderStream.prototype = Object.create( superclass && superclass.prototype );
  2247. RenderStream.prototype.constructor = RenderStream;
  2248. RenderStream.prototype.pushBySize = function pushBySize (n) {
  2249. var bufferToPush = this.buffer.substring(0, n);
  2250. this.buffer = this.buffer.substring(n);
  2251. this.push(bufferToPush);
  2252. };
  2253. RenderStream.prototype.tryRender = function tryRender () {
  2254. try {
  2255. this.render(this.write, this.end);
  2256. } catch (e) {
  2257. this.emit('error', e);
  2258. }
  2259. };
  2260. RenderStream.prototype.tryNext = function tryNext () {
  2261. try {
  2262. this.next();
  2263. } catch (e) {
  2264. this.emit('error', e);
  2265. }
  2266. };
  2267. RenderStream.prototype._read = function _read (n) {
  2268. this.expectedSize = n;
  2269. // it's possible that the last chunk added bumped the buffer up to > 2 * n,
  2270. // which means we will need to go through multiple read calls to drain it
  2271. // down to < n.
  2272. if (isTrue(this.done)) {
  2273. this.push(null);
  2274. return
  2275. }
  2276. if (this.buffer.length >= n) {
  2277. this.pushBySize(n);
  2278. return
  2279. }
  2280. if (isUndef(this.next)) {
  2281. // start the rendering chain.
  2282. this.tryRender();
  2283. } else {
  2284. // continue with the rendering.
  2285. this.tryNext();
  2286. }
  2287. };
  2288. return RenderStream;
  2289. }(stream.Readable));
  2290. /* */
  2291. var RenderContext = function RenderContext (options) {
  2292. this.userContext = options.userContext;
  2293. this.activeInstance = options.activeInstance;
  2294. this.renderStates = [];
  2295. this.write = options.write;
  2296. this.done = options.done;
  2297. this.renderNode = options.renderNode;
  2298. this.isUnaryTag = options.isUnaryTag;
  2299. this.modules = options.modules;
  2300. this.directives = options.directives;
  2301. var cache = options.cache;
  2302. if (cache && (!cache.get || !cache.set)) {
  2303. throw new Error('renderer cache must implement at least get & set.')
  2304. }
  2305. this.cache = cache;
  2306. this.get = cache && normalizeAsync(cache, 'get');
  2307. this.has = cache && normalizeAsync(cache, 'has');
  2308. this.next = this.next.bind(this);
  2309. };
  2310. RenderContext.prototype.next = function next () {
  2311. // eslint-disable-next-line
  2312. while (true) {
  2313. var lastState = this.renderStates[this.renderStates.length - 1];
  2314. if (isUndef(lastState)) {
  2315. return this.done()
  2316. }
  2317. /* eslint-disable no-case-declarations */
  2318. switch (lastState.type) {
  2319. case 'Element':
  2320. case 'Fragment':
  2321. var children = lastState.children;
  2322. var total = lastState.total;
  2323. var rendered = lastState.rendered++;
  2324. if (rendered < total) {
  2325. return this.renderNode(children[rendered], false, this)
  2326. } else {
  2327. this.renderStates.pop();
  2328. if (lastState.type === 'Element') {
  2329. return this.write(lastState.endTag, this.next)
  2330. }
  2331. }
  2332. break
  2333. case 'Component':
  2334. this.renderStates.pop();
  2335. this.activeInstance = lastState.prevActive;
  2336. break
  2337. case 'ComponentWithCache':
  2338. this.renderStates.pop();
  2339. var buffer = lastState.buffer;
  2340. var bufferIndex = lastState.bufferIndex;
  2341. var componentBuffer = lastState.componentBuffer;
  2342. var key = lastState.key;
  2343. var result = {
  2344. html: buffer[bufferIndex],
  2345. components: componentBuffer[bufferIndex]
  2346. };
  2347. this.cache.set(key, result);
  2348. if (bufferIndex === 0) {
  2349. // this is a top-level cached component,
  2350. // exit caching mode.
  2351. this.write.caching = false;
  2352. } else {
  2353. // parent component is also being cached,
  2354. // merge self into parent's result
  2355. buffer[bufferIndex - 1] += result.html;
  2356. var prev = componentBuffer[bufferIndex - 1];
  2357. result.components.forEach(function (c) { return prev.add(c); });
  2358. }
  2359. buffer.length = bufferIndex;
  2360. componentBuffer.length = bufferIndex;
  2361. break
  2362. }
  2363. }
  2364. };
  2365. function normalizeAsync (cache, method) {
  2366. var fn = cache[method];
  2367. if (isUndef(fn)) {
  2368. return
  2369. } else if (fn.length > 1) {
  2370. return function (key, cb) { return fn.call(cache, key, cb); }
  2371. } else {
  2372. return function (key, cb) { return cb(fn.call(cache, key)); }
  2373. }
  2374. }
  2375. /* */
  2376. var validDivisionCharRE = /[\w).+\-_$\]]/;
  2377. function parseFilters (exp) {
  2378. var inSingle = false;
  2379. var inDouble = false;
  2380. var inTemplateString = false;
  2381. var inRegex = false;
  2382. var curly = 0;
  2383. var square = 0;
  2384. var paren = 0;
  2385. var lastFilterIndex = 0;
  2386. var c, prev, i, expression, filters;
  2387. for (i = 0; i < exp.length; i++) {
  2388. prev = c;
  2389. c = exp.charCodeAt(i);
  2390. if (inSingle) {
  2391. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  2392. } else if (inDouble) {
  2393. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  2394. } else if (inTemplateString) {
  2395. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  2396. } else if (inRegex) {
  2397. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  2398. } else if (
  2399. c === 0x7C && // pipe
  2400. exp.charCodeAt(i + 1) !== 0x7C &&
  2401. exp.charCodeAt(i - 1) !== 0x7C &&
  2402. !curly && !square && !paren
  2403. ) {
  2404. if (expression === undefined) {
  2405. // first filter, end of expression
  2406. lastFilterIndex = i + 1;
  2407. expression = exp.slice(0, i).trim();
  2408. } else {
  2409. pushFilter();
  2410. }
  2411. } else {
  2412. switch (c) {
  2413. case 0x22: inDouble = true; break // "
  2414. case 0x27: inSingle = true; break // '
  2415. case 0x60: inTemplateString = true; break // `
  2416. case 0x28: paren++; break // (
  2417. case 0x29: paren--; break // )
  2418. case 0x5B: square++; break // [
  2419. case 0x5D: square--; break // ]
  2420. case 0x7B: curly++; break // {
  2421. case 0x7D: curly--; break // }
  2422. }
  2423. if (c === 0x2f) { // /
  2424. var j = i - 1;
  2425. var p = (void 0);
  2426. // find first non-whitespace prev char
  2427. for (; j >= 0; j--) {
  2428. p = exp.charAt(j);
  2429. if (p !== ' ') { break }
  2430. }
  2431. if (!p || !validDivisionCharRE.test(p)) {
  2432. inRegex = true;
  2433. }
  2434. }
  2435. }
  2436. }
  2437. if (expression === undefined) {
  2438. expression = exp.slice(0, i).trim();
  2439. } else if (lastFilterIndex !== 0) {
  2440. pushFilter();
  2441. }
  2442. function pushFilter () {
  2443. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  2444. lastFilterIndex = i + 1;
  2445. }
  2446. if (filters) {
  2447. for (i = 0; i < filters.length; i++) {
  2448. expression = wrapFilter(expression, filters[i]);
  2449. }
  2450. }
  2451. return expression
  2452. }
  2453. function wrapFilter (exp, filter) {
  2454. var i = filter.indexOf('(');
  2455. if (i < 0) {
  2456. // _f: resolveFilter
  2457. return ("_f(\"" + filter + "\")(" + exp + ")")
  2458. } else {
  2459. var name = filter.slice(0, i);
  2460. var args = filter.slice(i + 1);
  2461. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  2462. }
  2463. }
  2464. /* */
  2465. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  2466. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  2467. var buildRegex = cached(function (delimiters) {
  2468. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  2469. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  2470. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  2471. });
  2472. function parseText (
  2473. text,
  2474. delimiters
  2475. ) {
  2476. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  2477. if (!tagRE.test(text)) {
  2478. return
  2479. }
  2480. var tokens = [];
  2481. var rawTokens = [];
  2482. var lastIndex = tagRE.lastIndex = 0;
  2483. var match, index, tokenValue;
  2484. while ((match = tagRE.exec(text))) {
  2485. index = match.index;
  2486. // push text token
  2487. if (index > lastIndex) {
  2488. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  2489. tokens.push(JSON.stringify(tokenValue));
  2490. }
  2491. // tag token
  2492. var exp = parseFilters(match[1].trim());
  2493. tokens.push(("_s(" + exp + ")"));
  2494. rawTokens.push({ '@binding': exp });
  2495. lastIndex = index + match[0].length;
  2496. }
  2497. if (lastIndex < text.length) {
  2498. rawTokens.push(tokenValue = text.slice(lastIndex));
  2499. tokens.push(JSON.stringify(tokenValue));
  2500. }
  2501. return {
  2502. expression: tokens.join('+'),
  2503. tokens: rawTokens
  2504. }
  2505. }
  2506. /* */
  2507. /* eslint-disable no-unused-vars */
  2508. function baseWarn (msg, range) {
  2509. console.error(("[Vue compiler]: " + msg));
  2510. }
  2511. /* eslint-enable no-unused-vars */
  2512. function pluckModuleFunction (
  2513. modules,
  2514. key
  2515. ) {
  2516. return modules
  2517. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  2518. : []
  2519. }
  2520. function addProp (el, name, value, range, dynamic) {
  2521. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  2522. el.plain = false;
  2523. }
  2524. function addAttr (el, name, value, range, dynamic) {
  2525. var attrs = dynamic
  2526. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  2527. : (el.attrs || (el.attrs = []));
  2528. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  2529. el.plain = false;
  2530. }
  2531. // add a raw attr (use this in preTransforms)
  2532. function addRawAttr (el, name, value, range) {
  2533. el.attrsMap[name] = value;
  2534. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  2535. }
  2536. function addDirective (
  2537. el,
  2538. name,
  2539. rawName,
  2540. value,
  2541. arg,
  2542. isDynamicArg,
  2543. modifiers,
  2544. range
  2545. ) {
  2546. (el.directives || (el.directives = [])).push(rangeSetItem({
  2547. name: name,
  2548. rawName: rawName,
  2549. value: value,
  2550. arg: arg,
  2551. isDynamicArg: isDynamicArg,
  2552. modifiers: modifiers
  2553. }, range));
  2554. el.plain = false;
  2555. }
  2556. function prependModifierMarker (symbol, name, dynamic) {
  2557. return dynamic
  2558. ? ("_p(" + name + ",\"" + symbol + "\")")
  2559. : symbol + name // mark the event as captured
  2560. }
  2561. function addHandler (
  2562. el,
  2563. name,
  2564. value,
  2565. modifiers,
  2566. important,
  2567. warn,
  2568. range,
  2569. dynamic
  2570. ) {
  2571. modifiers = modifiers || emptyObject;
  2572. // warn prevent and passive modifier
  2573. /* istanbul ignore if */
  2574. if (
  2575. warn &&
  2576. modifiers.prevent && modifiers.passive
  2577. ) {
  2578. warn(
  2579. 'passive and prevent can\'t be used together. ' +
  2580. 'Passive handler can\'t prevent default event.',
  2581. range
  2582. );
  2583. }
  2584. // normalize click.right and click.middle since they don't actually fire
  2585. // this is technically browser-specific, but at least for now browsers are
  2586. // the only target envs that have right/middle clicks.
  2587. if (modifiers.right) {
  2588. if (dynamic) {
  2589. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  2590. } else if (name === 'click') {
  2591. name = 'contextmenu';
  2592. delete modifiers.right;
  2593. }
  2594. } else if (modifiers.middle) {
  2595. if (dynamic) {
  2596. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  2597. } else if (name === 'click') {
  2598. name = 'mouseup';
  2599. }
  2600. }
  2601. // check capture modifier
  2602. if (modifiers.capture) {
  2603. delete modifiers.capture;
  2604. name = prependModifierMarker('!', name, dynamic);
  2605. }
  2606. if (modifiers.once) {
  2607. delete modifiers.once;
  2608. name = prependModifierMarker('~', name, dynamic);
  2609. }
  2610. /* istanbul ignore if */
  2611. if (modifiers.passive) {
  2612. delete modifiers.passive;
  2613. name = prependModifierMarker('&', name, dynamic);
  2614. }
  2615. var events;
  2616. if (modifiers.native) {
  2617. delete modifiers.native;
  2618. events = el.nativeEvents || (el.nativeEvents = {});
  2619. } else {
  2620. events = el.events || (el.events = {});
  2621. }
  2622. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  2623. if (modifiers !== emptyObject) {
  2624. newHandler.modifiers = modifiers;
  2625. }
  2626. var handlers = events[name];
  2627. /* istanbul ignore if */
  2628. if (Array.isArray(handlers)) {
  2629. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  2630. } else if (handlers) {
  2631. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  2632. } else {
  2633. events[name] = newHandler;
  2634. }
  2635. el.plain = false;
  2636. }
  2637. function getRawBindingAttr (
  2638. el,
  2639. name
  2640. ) {
  2641. return el.rawAttrsMap[':' + name] ||
  2642. el.rawAttrsMap['v-bind:' + name] ||
  2643. el.rawAttrsMap[name]
  2644. }
  2645. function getBindingAttr (
  2646. el,
  2647. name,
  2648. getStatic
  2649. ) {
  2650. var dynamicValue =
  2651. getAndRemoveAttr(el, ':' + name) ||
  2652. getAndRemoveAttr(el, 'v-bind:' + name);
  2653. if (dynamicValue != null) {
  2654. return parseFilters(dynamicValue)
  2655. } else if (getStatic !== false) {
  2656. var staticValue = getAndRemoveAttr(el, name);
  2657. if (staticValue != null) {
  2658. return JSON.stringify(staticValue)
  2659. }
  2660. }
  2661. }
  2662. // note: this only removes the attr from the Array (attrsList) so that it
  2663. // doesn't get processed by processAttrs.
  2664. // By default it does NOT remove it from the map (attrsMap) because the map is
  2665. // needed during codegen.
  2666. function getAndRemoveAttr (
  2667. el,
  2668. name,
  2669. removeFromMap
  2670. ) {
  2671. var val;
  2672. if ((val = el.attrsMap[name]) != null) {
  2673. var list = el.attrsList;
  2674. for (var i = 0, l = list.length; i < l; i++) {
  2675. if (list[i].name === name) {
  2676. list.splice(i, 1);
  2677. break
  2678. }
  2679. }
  2680. }
  2681. if (removeFromMap) {
  2682. delete el.attrsMap[name];
  2683. }
  2684. return val
  2685. }
  2686. function getAndRemoveAttrByRegex (
  2687. el,
  2688. name
  2689. ) {
  2690. var list = el.attrsList;
  2691. for (var i = 0, l = list.length; i < l; i++) {
  2692. var attr = list[i];
  2693. if (name.test(attr.name)) {
  2694. list.splice(i, 1);
  2695. return attr
  2696. }
  2697. }
  2698. }
  2699. function rangeSetItem (
  2700. item,
  2701. range
  2702. ) {
  2703. if (range) {
  2704. if (range.start != null) {
  2705. item.start = range.start;
  2706. }
  2707. if (range.end != null) {
  2708. item.end = range.end;
  2709. }
  2710. }
  2711. return item
  2712. }
  2713. /* */
  2714. function transformNode (el, options) {
  2715. var warn = options.warn || baseWarn;
  2716. var staticClass = getAndRemoveAttr(el, 'class');
  2717. if (staticClass) {
  2718. var res = parseText(staticClass, options.delimiters);
  2719. if (res) {
  2720. warn(
  2721. "class=\"" + staticClass + "\": " +
  2722. 'Interpolation inside attributes has been removed. ' +
  2723. 'Use v-bind or the colon shorthand instead. For example, ' +
  2724. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  2725. el.rawAttrsMap['class']
  2726. );
  2727. }
  2728. }
  2729. if (staticClass) {
  2730. el.staticClass = JSON.stringify(staticClass);
  2731. }
  2732. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  2733. if (classBinding) {
  2734. el.classBinding = classBinding;
  2735. }
  2736. }
  2737. function genData (el) {
  2738. var data = '';
  2739. if (el.staticClass) {
  2740. data += "staticClass:" + (el.staticClass) + ",";
  2741. }
  2742. if (el.classBinding) {
  2743. data += "class:" + (el.classBinding) + ",";
  2744. }
  2745. return data
  2746. }
  2747. var klass = {
  2748. staticKeys: ['staticClass'],
  2749. transformNode: transformNode,
  2750. genData: genData
  2751. };
  2752. /* */
  2753. function transformNode$1 (el, options) {
  2754. var warn = options.warn || baseWarn;
  2755. var staticStyle = getAndRemoveAttr(el, 'style');
  2756. if (staticStyle) {
  2757. /* istanbul ignore if */
  2758. {
  2759. var res = parseText(staticStyle, options.delimiters);
  2760. if (res) {
  2761. warn(
  2762. "style=\"" + staticStyle + "\": " +
  2763. 'Interpolation inside attributes has been removed. ' +
  2764. 'Use v-bind or the colon shorthand instead. For example, ' +
  2765. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  2766. el.rawAttrsMap['style']
  2767. );
  2768. }
  2769. }
  2770. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  2771. }
  2772. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  2773. if (styleBinding) {
  2774. el.styleBinding = styleBinding;
  2775. }
  2776. }
  2777. function genData$1 (el) {
  2778. var data = '';
  2779. if (el.staticStyle) {
  2780. data += "staticStyle:" + (el.staticStyle) + ",";
  2781. }
  2782. if (el.styleBinding) {
  2783. data += "style:(" + (el.styleBinding) + "),";
  2784. }
  2785. return data
  2786. }
  2787. var style = {
  2788. staticKeys: ['staticStyle'],
  2789. transformNode: transformNode$1,
  2790. genData: genData$1
  2791. };
  2792. /**
  2793. * Not type-checking this file because it's mostly vendor code.
  2794. */
  2795. // Regular Expressions for parsing tags and attributes
  2796. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  2797. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  2798. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  2799. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  2800. var startTagOpen = new RegExp(("^<" + qnameCapture));
  2801. var startTagClose = /^\s*(\/?)>/;
  2802. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  2803. var doctype = /^<!DOCTYPE [^>]+>/i;
  2804. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  2805. var comment = /^<!\--/;
  2806. var conditionalComment = /^<!\[/;
  2807. // Special Elements (can contain anything)
  2808. var isPlainTextElement = makeMap('script,style,textarea', true);
  2809. var reCache = {};
  2810. var decodingMap = {
  2811. '&lt;': '<',
  2812. '&gt;': '>',
  2813. '&quot;': '"',
  2814. '&amp;': '&',
  2815. '&#10;': '\n',
  2816. '&#9;': '\t',
  2817. '&#39;': "'"
  2818. };
  2819. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  2820. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  2821. // #5992
  2822. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  2823. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  2824. function decodeAttr (value, shouldDecodeNewlines) {
  2825. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  2826. return value.replace(re, function (match) { return decodingMap[match]; })
  2827. }
  2828. function parseHTML (html, options) {
  2829. var stack = [];
  2830. var expectHTML = options.expectHTML;
  2831. var isUnaryTag$$1 = options.isUnaryTag || no;
  2832. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  2833. var index = 0;
  2834. var last, lastTag;
  2835. while (html) {
  2836. last = html;
  2837. // Make sure we're not in a plaintext content element like script/style
  2838. if (!lastTag || !isPlainTextElement(lastTag)) {
  2839. var textEnd = html.indexOf('<');
  2840. if (textEnd === 0) {
  2841. // Comment:
  2842. if (comment.test(html)) {
  2843. var commentEnd = html.indexOf('-->');
  2844. if (commentEnd >= 0) {
  2845. if (options.shouldKeepComment) {
  2846. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  2847. }
  2848. advance(commentEnd + 3);
  2849. continue
  2850. }
  2851. }
  2852. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  2853. if (conditionalComment.test(html)) {
  2854. var conditionalEnd = html.indexOf(']>');
  2855. if (conditionalEnd >= 0) {
  2856. advance(conditionalEnd + 2);
  2857. continue
  2858. }
  2859. }
  2860. // Doctype:
  2861. var doctypeMatch = html.match(doctype);
  2862. if (doctypeMatch) {
  2863. advance(doctypeMatch[0].length);
  2864. continue
  2865. }
  2866. // End tag:
  2867. var endTagMatch = html.match(endTag);
  2868. if (endTagMatch) {
  2869. var curIndex = index;
  2870. advance(endTagMatch[0].length);
  2871. parseEndTag(endTagMatch[1], curIndex, index);
  2872. continue
  2873. }
  2874. // Start tag:
  2875. var startTagMatch = parseStartTag();
  2876. if (startTagMatch) {
  2877. handleStartTag(startTagMatch);
  2878. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  2879. advance(1);
  2880. }
  2881. continue
  2882. }
  2883. }
  2884. var text = (void 0), rest = (void 0), next = (void 0);
  2885. if (textEnd >= 0) {
  2886. rest = html.slice(textEnd);
  2887. while (
  2888. !endTag.test(rest) &&
  2889. !startTagOpen.test(rest) &&
  2890. !comment.test(rest) &&
  2891. !conditionalComment.test(rest)
  2892. ) {
  2893. // < in plain text, be forgiving and treat it as text
  2894. next = rest.indexOf('<', 1);
  2895. if (next < 0) { break }
  2896. textEnd += next;
  2897. rest = html.slice(textEnd);
  2898. }
  2899. text = html.substring(0, textEnd);
  2900. }
  2901. if (textEnd < 0) {
  2902. text = html;
  2903. }
  2904. if (text) {
  2905. advance(text.length);
  2906. }
  2907. if (options.chars && text) {
  2908. options.chars(text, index - text.length, index);
  2909. }
  2910. } else {
  2911. var endTagLength = 0;
  2912. var stackedTag = lastTag.toLowerCase();
  2913. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  2914. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  2915. endTagLength = endTag.length;
  2916. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  2917. text = text
  2918. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  2919. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  2920. }
  2921. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  2922. text = text.slice(1);
  2923. }
  2924. if (options.chars) {
  2925. options.chars(text);
  2926. }
  2927. return ''
  2928. });
  2929. index += html.length - rest$1.length;
  2930. html = rest$1;
  2931. parseEndTag(stackedTag, index - endTagLength, index);
  2932. }
  2933. if (html === last) {
  2934. options.chars && options.chars(html);
  2935. if (!stack.length && options.warn) {
  2936. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  2937. }
  2938. break
  2939. }
  2940. }
  2941. // Clean up any remaining tags
  2942. parseEndTag();
  2943. function advance (n) {
  2944. index += n;
  2945. html = html.substring(n);
  2946. }
  2947. function parseStartTag () {
  2948. var start = html.match(startTagOpen);
  2949. if (start) {
  2950. var match = {
  2951. tagName: start[1],
  2952. attrs: [],
  2953. start: index
  2954. };
  2955. advance(start[0].length);
  2956. var end, attr;
  2957. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  2958. attr.start = index;
  2959. advance(attr[0].length);
  2960. attr.end = index;
  2961. match.attrs.push(attr);
  2962. }
  2963. if (end) {
  2964. match.unarySlash = end[1];
  2965. advance(end[0].length);
  2966. match.end = index;
  2967. return match
  2968. }
  2969. }
  2970. }
  2971. function handleStartTag (match) {
  2972. var tagName = match.tagName;
  2973. var unarySlash = match.unarySlash;
  2974. if (expectHTML) {
  2975. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  2976. parseEndTag(lastTag);
  2977. }
  2978. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  2979. parseEndTag(tagName);
  2980. }
  2981. }
  2982. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  2983. var l = match.attrs.length;
  2984. var attrs = new Array(l);
  2985. for (var i = 0; i < l; i++) {
  2986. var args = match.attrs[i];
  2987. var value = args[3] || args[4] || args[5] || '';
  2988. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  2989. ? options.shouldDecodeNewlinesForHref
  2990. : options.shouldDecodeNewlines;
  2991. attrs[i] = {
  2992. name: args[1],
  2993. value: decodeAttr(value, shouldDecodeNewlines)
  2994. };
  2995. if (options.outputSourceRange) {
  2996. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  2997. attrs[i].end = args.end;
  2998. }
  2999. }
  3000. if (!unary) {
  3001. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  3002. lastTag = tagName;
  3003. }
  3004. if (options.start) {
  3005. options.start(tagName, attrs, unary, match.start, match.end);
  3006. }
  3007. }
  3008. function parseEndTag (tagName, start, end) {
  3009. var pos, lowerCasedTagName;
  3010. if (start == null) { start = index; }
  3011. if (end == null) { end = index; }
  3012. // Find the closest opened tag of the same type
  3013. if (tagName) {
  3014. lowerCasedTagName = tagName.toLowerCase();
  3015. for (pos = stack.length - 1; pos >= 0; pos--) {
  3016. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  3017. break
  3018. }
  3019. }
  3020. } else {
  3021. // If no tag name is provided, clean shop
  3022. pos = 0;
  3023. }
  3024. if (pos >= 0) {
  3025. // Close all the open elements, up the stack
  3026. for (var i = stack.length - 1; i >= pos; i--) {
  3027. if (i > pos || !tagName &&
  3028. options.warn
  3029. ) {
  3030. options.warn(
  3031. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  3032. { start: stack[i].start, end: stack[i].end }
  3033. );
  3034. }
  3035. if (options.end) {
  3036. options.end(stack[i].tag, start, end);
  3037. }
  3038. }
  3039. // Remove the open elements from the stack
  3040. stack.length = pos;
  3041. lastTag = pos && stack[pos - 1].tag;
  3042. } else if (lowerCasedTagName === 'br') {
  3043. if (options.start) {
  3044. options.start(tagName, [], true, start, end);
  3045. }
  3046. } else if (lowerCasedTagName === 'p') {
  3047. if (options.start) {
  3048. options.start(tagName, [], false, start, end);
  3049. }
  3050. if (options.end) {
  3051. options.end(tagName, start, end);
  3052. }
  3053. }
  3054. }
  3055. }
  3056. /* */
  3057. /**
  3058. * Cross-platform code generation for component v-model
  3059. */
  3060. function genComponentModel (
  3061. el,
  3062. value,
  3063. modifiers
  3064. ) {
  3065. var ref = modifiers || {};
  3066. var number = ref.number;
  3067. var trim = ref.trim;
  3068. var baseValueExpression = '$$v';
  3069. var valueExpression = baseValueExpression;
  3070. if (trim) {
  3071. valueExpression =
  3072. "(typeof " + baseValueExpression + " === 'string'" +
  3073. "? " + baseValueExpression + ".trim()" +
  3074. ": " + baseValueExpression + ")";
  3075. }
  3076. if (number) {
  3077. valueExpression = "_n(" + valueExpression + ")";
  3078. }
  3079. var assignment = genAssignmentCode(value, valueExpression);
  3080. el.model = {
  3081. value: ("(" + value + ")"),
  3082. expression: JSON.stringify(value),
  3083. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  3084. };
  3085. }
  3086. /**
  3087. * Cross-platform codegen helper for generating v-model value assignment code.
  3088. */
  3089. function genAssignmentCode (
  3090. value,
  3091. assignment
  3092. ) {
  3093. var res = parseModel(value);
  3094. if (res.key === null) {
  3095. return (value + "=" + assignment)
  3096. } else {
  3097. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  3098. }
  3099. }
  3100. /**
  3101. * Parse a v-model expression into a base path and a final key segment.
  3102. * Handles both dot-path and possible square brackets.
  3103. *
  3104. * Possible cases:
  3105. *
  3106. * - test
  3107. * - test[key]
  3108. * - test[test1[key]]
  3109. * - test["a"][key]
  3110. * - xxx.test[a[a].test1[key]]
  3111. * - test.xxx.a["asa"][test1[key]]
  3112. *
  3113. */
  3114. var len, str, chr, index, expressionPos, expressionEndPos;
  3115. function parseModel (val) {
  3116. // Fix https://github.com/vuejs/vue/pull/7730
  3117. // allow v-model="obj.val " (trailing whitespace)
  3118. val = val.trim();
  3119. len = val.length;
  3120. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  3121. index = val.lastIndexOf('.');
  3122. if (index > -1) {
  3123. return {
  3124. exp: val.slice(0, index),
  3125. key: '"' + val.slice(index + 1) + '"'
  3126. }
  3127. } else {
  3128. return {
  3129. exp: val,
  3130. key: null
  3131. }
  3132. }
  3133. }
  3134. str = val;
  3135. index = expressionPos = expressionEndPos = 0;
  3136. while (!eof()) {
  3137. chr = next();
  3138. /* istanbul ignore if */
  3139. if (isStringStart(chr)) {
  3140. parseString(chr);
  3141. } else if (chr === 0x5B) {
  3142. parseBracket(chr);
  3143. }
  3144. }
  3145. return {
  3146. exp: val.slice(0, expressionPos),
  3147. key: val.slice(expressionPos + 1, expressionEndPos)
  3148. }
  3149. }
  3150. function next () {
  3151. return str.charCodeAt(++index)
  3152. }
  3153. function eof () {
  3154. return index >= len
  3155. }
  3156. function isStringStart (chr) {
  3157. return chr === 0x22 || chr === 0x27
  3158. }
  3159. function parseBracket (chr) {
  3160. var inBracket = 1;
  3161. expressionPos = index;
  3162. while (!eof()) {
  3163. chr = next();
  3164. if (isStringStart(chr)) {
  3165. parseString(chr);
  3166. continue
  3167. }
  3168. if (chr === 0x5B) { inBracket++; }
  3169. if (chr === 0x5D) { inBracket--; }
  3170. if (inBracket === 0) {
  3171. expressionEndPos = index;
  3172. break
  3173. }
  3174. }
  3175. }
  3176. function parseString (chr) {
  3177. var stringQuote = chr;
  3178. while (!eof()) {
  3179. chr = next();
  3180. if (chr === stringQuote) {
  3181. break
  3182. }
  3183. }
  3184. }
  3185. /* */
  3186. var onRE = /^@|^v-on:/;
  3187. var dirRE = /^v-|^@|^:|^#/;
  3188. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  3189. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  3190. var stripParensRE = /^\(|\)$/g;
  3191. var dynamicArgRE = /^\[.*\]$/;
  3192. var argRE = /:(.*)$/;
  3193. var bindRE = /^:|^\.|^v-bind:/;
  3194. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  3195. var slotRE = /^v-slot(:|$)|^#/;
  3196. var lineBreakRE = /[\r\n]/;
  3197. var whitespaceRE = /[ \f\t\r\n]+/g;
  3198. var invalidAttributeRE = /[\s"'<>\/=]/;
  3199. var decodeHTMLCached = cached(he.decode);
  3200. var emptySlotScopeToken = "_empty_";
  3201. // configurable state
  3202. var warn$1;
  3203. var delimiters;
  3204. var transforms;
  3205. var preTransforms;
  3206. var postTransforms;
  3207. var platformIsPreTag;
  3208. var platformMustUseProp;
  3209. var platformGetTagNamespace;
  3210. var maybeComponent;
  3211. function createASTElement (
  3212. tag,
  3213. attrs,
  3214. parent
  3215. ) {
  3216. return {
  3217. type: 1,
  3218. tag: tag,
  3219. attrsList: attrs,
  3220. attrsMap: makeAttrsMap(attrs),
  3221. rawAttrsMap: {},
  3222. parent: parent,
  3223. children: []
  3224. }
  3225. }
  3226. /**
  3227. * Convert HTML string to AST.
  3228. */
  3229. function parse (
  3230. template,
  3231. options
  3232. ) {
  3233. warn$1 = options.warn || baseWarn;
  3234. platformIsPreTag = options.isPreTag || no;
  3235. platformMustUseProp = options.mustUseProp || no;
  3236. platformGetTagNamespace = options.getTagNamespace || no;
  3237. var isReservedTag = options.isReservedTag || no;
  3238. maybeComponent = function (el) { return !!(
  3239. el.component ||
  3240. el.attrsMap[':is'] ||
  3241. el.attrsMap['v-bind:is'] ||
  3242. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag))
  3243. ); };
  3244. transforms = pluckModuleFunction(options.modules, 'transformNode');
  3245. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  3246. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  3247. delimiters = options.delimiters;
  3248. var stack = [];
  3249. var preserveWhitespace = options.preserveWhitespace !== false;
  3250. var whitespaceOption = options.whitespace;
  3251. var root;
  3252. var currentParent;
  3253. var inVPre = false;
  3254. var inPre = false;
  3255. var warned = false;
  3256. function warnOnce (msg, range) {
  3257. if (!warned) {
  3258. warned = true;
  3259. warn$1(msg, range);
  3260. }
  3261. }
  3262. function closeElement (element) {
  3263. trimEndingWhitespace(element);
  3264. if (!inVPre && !element.processed) {
  3265. element = processElement(element, options);
  3266. }
  3267. // tree management
  3268. if (!stack.length && element !== root) {
  3269. // allow root elements with v-if, v-else-if and v-else
  3270. if (root.if && (element.elseif || element.else)) {
  3271. {
  3272. checkRootConstraints(element);
  3273. }
  3274. addIfCondition(root, {
  3275. exp: element.elseif,
  3276. block: element
  3277. });
  3278. } else {
  3279. warnOnce(
  3280. "Component template should contain exactly one root element. " +
  3281. "If you are using v-if on multiple elements, " +
  3282. "use v-else-if to chain them instead.",
  3283. { start: element.start }
  3284. );
  3285. }
  3286. }
  3287. if (currentParent && !element.forbidden) {
  3288. if (element.elseif || element.else) {
  3289. processIfConditions(element, currentParent);
  3290. } else {
  3291. if (element.slotScope) {
  3292. // scoped slot
  3293. // keep it in the children list so that v-else(-if) conditions can
  3294. // find it as the prev node.
  3295. var name = element.slotTarget || '"default"'
  3296. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  3297. }
  3298. currentParent.children.push(element);
  3299. element.parent = currentParent;
  3300. }
  3301. }
  3302. // final children cleanup
  3303. // filter out scoped slots
  3304. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  3305. // remove trailing whitespace node again
  3306. trimEndingWhitespace(element);
  3307. // check pre state
  3308. if (element.pre) {
  3309. inVPre = false;
  3310. }
  3311. if (platformIsPreTag(element.tag)) {
  3312. inPre = false;
  3313. }
  3314. // apply post-transforms
  3315. for (var i = 0; i < postTransforms.length; i++) {
  3316. postTransforms[i](element, options);
  3317. }
  3318. }
  3319. function trimEndingWhitespace (el) {
  3320. // remove trailing whitespace node
  3321. if (!inPre) {
  3322. var lastNode;
  3323. while (
  3324. (lastNode = el.children[el.children.length - 1]) &&
  3325. lastNode.type === 3 &&
  3326. lastNode.text === ' '
  3327. ) {
  3328. el.children.pop();
  3329. }
  3330. }
  3331. }
  3332. function checkRootConstraints (el) {
  3333. if (el.tag === 'slot' || el.tag === 'template') {
  3334. warnOnce(
  3335. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  3336. 'contain multiple nodes.',
  3337. { start: el.start }
  3338. );
  3339. }
  3340. if (el.attrsMap.hasOwnProperty('v-for')) {
  3341. warnOnce(
  3342. 'Cannot use v-for on stateful component root element because ' +
  3343. 'it renders multiple elements.',
  3344. el.rawAttrsMap['v-for']
  3345. );
  3346. }
  3347. }
  3348. parseHTML(template, {
  3349. warn: warn$1,
  3350. expectHTML: options.expectHTML,
  3351. isUnaryTag: options.isUnaryTag,
  3352. canBeLeftOpenTag: options.canBeLeftOpenTag,
  3353. shouldDecodeNewlines: options.shouldDecodeNewlines,
  3354. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  3355. shouldKeepComment: options.comments,
  3356. outputSourceRange: options.outputSourceRange,
  3357. start: function start (tag, attrs, unary, start$1, end) {
  3358. // check namespace.
  3359. // inherit parent ns if there is one
  3360. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  3361. // handle IE svg bug
  3362. /* istanbul ignore if */
  3363. if (isIE && ns === 'svg') {
  3364. attrs = guardIESVGBug(attrs);
  3365. }
  3366. var element = createASTElement(tag, attrs, currentParent);
  3367. if (ns) {
  3368. element.ns = ns;
  3369. }
  3370. {
  3371. if (options.outputSourceRange) {
  3372. element.start = start$1;
  3373. element.end = end;
  3374. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  3375. cumulated[attr.name] = attr;
  3376. return cumulated
  3377. }, {});
  3378. }
  3379. attrs.forEach(function (attr) {
  3380. if (invalidAttributeRE.test(attr.name)) {
  3381. warn$1(
  3382. "Invalid dynamic argument expression: attribute names cannot contain " +
  3383. "spaces, quotes, <, >, / or =.",
  3384. {
  3385. start: attr.start + attr.name.indexOf("["),
  3386. end: attr.start + attr.name.length
  3387. }
  3388. );
  3389. }
  3390. });
  3391. }
  3392. if (isForbiddenTag(element) && !isServerRendering()) {
  3393. element.forbidden = true;
  3394. warn$1(
  3395. 'Templates should only be responsible for mapping the state to the ' +
  3396. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  3397. "<" + tag + ">" + ', as they will not be parsed.',
  3398. { start: element.start }
  3399. );
  3400. }
  3401. // apply pre-transforms
  3402. for (var i = 0; i < preTransforms.length; i++) {
  3403. element = preTransforms[i](element, options) || element;
  3404. }
  3405. if (!inVPre) {
  3406. processPre(element);
  3407. if (element.pre) {
  3408. inVPre = true;
  3409. }
  3410. }
  3411. if (platformIsPreTag(element.tag)) {
  3412. inPre = true;
  3413. }
  3414. if (inVPre) {
  3415. processRawAttrs(element);
  3416. } else if (!element.processed) {
  3417. // structural directives
  3418. processFor(element);
  3419. processIf(element);
  3420. processOnce(element);
  3421. }
  3422. if (!root) {
  3423. root = element;
  3424. {
  3425. checkRootConstraints(root);
  3426. }
  3427. }
  3428. if (!unary) {
  3429. currentParent = element;
  3430. stack.push(element);
  3431. } else {
  3432. closeElement(element);
  3433. }
  3434. },
  3435. end: function end (tag, start, end$1) {
  3436. var element = stack[stack.length - 1];
  3437. // pop stack
  3438. stack.length -= 1;
  3439. currentParent = stack[stack.length - 1];
  3440. if (options.outputSourceRange) {
  3441. element.end = end$1;
  3442. }
  3443. closeElement(element);
  3444. },
  3445. chars: function chars (text, start, end) {
  3446. if (!currentParent) {
  3447. {
  3448. if (text === template) {
  3449. warnOnce(
  3450. 'Component template requires a root element, rather than just text.',
  3451. { start: start }
  3452. );
  3453. } else if ((text = text.trim())) {
  3454. warnOnce(
  3455. ("text \"" + text + "\" outside root element will be ignored."),
  3456. { start: start }
  3457. );
  3458. }
  3459. }
  3460. return
  3461. }
  3462. // IE textarea placeholder bug
  3463. /* istanbul ignore if */
  3464. if (isIE &&
  3465. currentParent.tag === 'textarea' &&
  3466. currentParent.attrsMap.placeholder === text
  3467. ) {
  3468. return
  3469. }
  3470. var children = currentParent.children;
  3471. if (inPre || text.trim()) {
  3472. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  3473. } else if (!children.length) {
  3474. // remove the whitespace-only node right after an opening tag
  3475. text = '';
  3476. } else if (whitespaceOption) {
  3477. if (whitespaceOption === 'condense') {
  3478. // in condense mode, remove the whitespace node if it contains
  3479. // line break, otherwise condense to a single space
  3480. text = lineBreakRE.test(text) ? '' : ' ';
  3481. } else {
  3482. text = ' ';
  3483. }
  3484. } else {
  3485. text = preserveWhitespace ? ' ' : '';
  3486. }
  3487. if (text) {
  3488. if (!inPre && whitespaceOption === 'condense') {
  3489. // condense consecutive whitespaces into single space
  3490. text = text.replace(whitespaceRE, ' ');
  3491. }
  3492. var res;
  3493. var child;
  3494. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  3495. child = {
  3496. type: 2,
  3497. expression: res.expression,
  3498. tokens: res.tokens,
  3499. text: text
  3500. };
  3501. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  3502. child = {
  3503. type: 3,
  3504. text: text
  3505. };
  3506. }
  3507. if (child) {
  3508. if (options.outputSourceRange) {
  3509. child.start = start;
  3510. child.end = end;
  3511. }
  3512. children.push(child);
  3513. }
  3514. }
  3515. },
  3516. comment: function comment (text, start, end) {
  3517. // adding anything as a sibling to the root node is forbidden
  3518. // comments should still be allowed, but ignored
  3519. if (currentParent) {
  3520. var child = {
  3521. type: 3,
  3522. text: text,
  3523. isComment: true
  3524. };
  3525. if (options.outputSourceRange) {
  3526. child.start = start;
  3527. child.end = end;
  3528. }
  3529. currentParent.children.push(child);
  3530. }
  3531. }
  3532. });
  3533. return root
  3534. }
  3535. function processPre (el) {
  3536. if (getAndRemoveAttr(el, 'v-pre') != null) {
  3537. el.pre = true;
  3538. }
  3539. }
  3540. function processRawAttrs (el) {
  3541. var list = el.attrsList;
  3542. var len = list.length;
  3543. if (len) {
  3544. var attrs = el.attrs = new Array(len);
  3545. for (var i = 0; i < len; i++) {
  3546. attrs[i] = {
  3547. name: list[i].name,
  3548. value: JSON.stringify(list[i].value)
  3549. };
  3550. if (list[i].start != null) {
  3551. attrs[i].start = list[i].start;
  3552. attrs[i].end = list[i].end;
  3553. }
  3554. }
  3555. } else if (!el.pre) {
  3556. // non root node in pre blocks with no attributes
  3557. el.plain = true;
  3558. }
  3559. }
  3560. function processElement (
  3561. element,
  3562. options
  3563. ) {
  3564. processKey(element);
  3565. // determine whether this is a plain element after
  3566. // removing structural attributes
  3567. element.plain = (
  3568. !element.key &&
  3569. !element.scopedSlots &&
  3570. !element.attrsList.length
  3571. );
  3572. processRef(element);
  3573. processSlotContent(element);
  3574. processSlotOutlet(element);
  3575. processComponent(element);
  3576. for (var i = 0; i < transforms.length; i++) {
  3577. element = transforms[i](element, options) || element;
  3578. }
  3579. processAttrs(element);
  3580. return element
  3581. }
  3582. function processKey (el) {
  3583. var exp = getBindingAttr(el, 'key');
  3584. if (exp) {
  3585. {
  3586. if (el.tag === 'template') {
  3587. warn$1(
  3588. "<template> cannot be keyed. Place the key on real elements instead.",
  3589. getRawBindingAttr(el, 'key')
  3590. );
  3591. }
  3592. if (el.for) {
  3593. var iterator = el.iterator2 || el.iterator1;
  3594. var parent = el.parent;
  3595. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  3596. warn$1(
  3597. "Do not use v-for index as key on <transition-group> children, " +
  3598. "this is the same as not using keys.",
  3599. getRawBindingAttr(el, 'key'),
  3600. true /* tip */
  3601. );
  3602. }
  3603. }
  3604. }
  3605. el.key = exp;
  3606. }
  3607. }
  3608. function processRef (el) {
  3609. var ref = getBindingAttr(el, 'ref');
  3610. if (ref) {
  3611. el.ref = ref;
  3612. el.refInFor = checkInFor(el);
  3613. }
  3614. }
  3615. function processFor (el) {
  3616. var exp;
  3617. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  3618. var res = parseFor(exp);
  3619. if (res) {
  3620. extend(el, res);
  3621. } else {
  3622. warn$1(
  3623. ("Invalid v-for expression: " + exp),
  3624. el.rawAttrsMap['v-for']
  3625. );
  3626. }
  3627. }
  3628. }
  3629. function parseFor (exp) {
  3630. var inMatch = exp.match(forAliasRE);
  3631. if (!inMatch) { return }
  3632. var res = {};
  3633. res.for = inMatch[2].trim();
  3634. var alias = inMatch[1].trim().replace(stripParensRE, '');
  3635. var iteratorMatch = alias.match(forIteratorRE);
  3636. if (iteratorMatch) {
  3637. res.alias = alias.replace(forIteratorRE, '').trim();
  3638. res.iterator1 = iteratorMatch[1].trim();
  3639. if (iteratorMatch[2]) {
  3640. res.iterator2 = iteratorMatch[2].trim();
  3641. }
  3642. } else {
  3643. res.alias = alias;
  3644. }
  3645. return res
  3646. }
  3647. function processIf (el) {
  3648. var exp = getAndRemoveAttr(el, 'v-if');
  3649. if (exp) {
  3650. el.if = exp;
  3651. addIfCondition(el, {
  3652. exp: exp,
  3653. block: el
  3654. });
  3655. } else {
  3656. if (getAndRemoveAttr(el, 'v-else') != null) {
  3657. el.else = true;
  3658. }
  3659. var elseif = getAndRemoveAttr(el, 'v-else-if');
  3660. if (elseif) {
  3661. el.elseif = elseif;
  3662. }
  3663. }
  3664. }
  3665. function processIfConditions (el, parent) {
  3666. var prev = findPrevElement(parent.children);
  3667. if (prev && prev.if) {
  3668. addIfCondition(prev, {
  3669. exp: el.elseif,
  3670. block: el
  3671. });
  3672. } else {
  3673. warn$1(
  3674. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  3675. "used on element <" + (el.tag) + "> without corresponding v-if.",
  3676. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  3677. );
  3678. }
  3679. }
  3680. function findPrevElement (children) {
  3681. var i = children.length;
  3682. while (i--) {
  3683. if (children[i].type === 1) {
  3684. return children[i]
  3685. } else {
  3686. if (children[i].text !== ' ') {
  3687. warn$1(
  3688. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  3689. "will be ignored.",
  3690. children[i]
  3691. );
  3692. }
  3693. children.pop();
  3694. }
  3695. }
  3696. }
  3697. function addIfCondition (el, condition) {
  3698. if (!el.ifConditions) {
  3699. el.ifConditions = [];
  3700. }
  3701. el.ifConditions.push(condition);
  3702. }
  3703. function processOnce (el) {
  3704. var once$$1 = getAndRemoveAttr(el, 'v-once');
  3705. if (once$$1 != null) {
  3706. el.once = true;
  3707. }
  3708. }
  3709. // handle content being passed to a component as slot,
  3710. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  3711. function processSlotContent (el) {
  3712. var slotScope;
  3713. if (el.tag === 'template') {
  3714. slotScope = getAndRemoveAttr(el, 'scope');
  3715. /* istanbul ignore if */
  3716. if (slotScope) {
  3717. warn$1(
  3718. "the \"scope\" attribute for scoped slots have been deprecated and " +
  3719. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  3720. "can also be used on plain elements in addition to <template> to " +
  3721. "denote scoped slots.",
  3722. el.rawAttrsMap['scope'],
  3723. true
  3724. );
  3725. }
  3726. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  3727. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  3728. /* istanbul ignore if */
  3729. if (el.attrsMap['v-for']) {
  3730. warn$1(
  3731. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  3732. "(v-for takes higher priority). Use a wrapper <template> for the " +
  3733. "scoped slot to make it clearer.",
  3734. el.rawAttrsMap['slot-scope'],
  3735. true
  3736. );
  3737. }
  3738. el.slotScope = slotScope;
  3739. }
  3740. // slot="xxx"
  3741. var slotTarget = getBindingAttr(el, 'slot');
  3742. if (slotTarget) {
  3743. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  3744. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  3745. // preserve slot as an attribute for native shadow DOM compat
  3746. // only for non-scoped slots.
  3747. if (el.tag !== 'template' && !el.slotScope) {
  3748. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  3749. }
  3750. }
  3751. // 2.6 v-slot syntax
  3752. {
  3753. if (el.tag === 'template') {
  3754. // v-slot on <template>
  3755. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  3756. if (slotBinding) {
  3757. {
  3758. if (el.slotTarget || el.slotScope) {
  3759. warn$1(
  3760. "Unexpected mixed usage of different slot syntaxes.",
  3761. el
  3762. );
  3763. }
  3764. if (el.parent && !maybeComponent(el.parent)) {
  3765. warn$1(
  3766. "<template v-slot> can only appear at the root level inside " +
  3767. "the receiving component",
  3768. el
  3769. );
  3770. }
  3771. }
  3772. var ref = getSlotName(slotBinding);
  3773. var name = ref.name;
  3774. var dynamic = ref.dynamic;
  3775. el.slotTarget = name;
  3776. el.slotTargetDynamic = dynamic;
  3777. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  3778. }
  3779. } else {
  3780. // v-slot on component, denotes default slot
  3781. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  3782. if (slotBinding$1) {
  3783. {
  3784. if (!maybeComponent(el)) {
  3785. warn$1(
  3786. "v-slot can only be used on components or <template>.",
  3787. slotBinding$1
  3788. );
  3789. }
  3790. if (el.slotScope || el.slotTarget) {
  3791. warn$1(
  3792. "Unexpected mixed usage of different slot syntaxes.",
  3793. el
  3794. );
  3795. }
  3796. if (el.scopedSlots) {
  3797. warn$1(
  3798. "To avoid scope ambiguity, the default slot should also use " +
  3799. "<template> syntax when there are other named slots.",
  3800. slotBinding$1
  3801. );
  3802. }
  3803. }
  3804. // add the component's children to its default slot
  3805. var slots = el.scopedSlots || (el.scopedSlots = {});
  3806. var ref$1 = getSlotName(slotBinding$1);
  3807. var name$1 = ref$1.name;
  3808. var dynamic$1 = ref$1.dynamic;
  3809. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  3810. slotContainer.slotTarget = name$1;
  3811. slotContainer.slotTargetDynamic = dynamic$1;
  3812. slotContainer.children = el.children.filter(function (c) {
  3813. if (!c.slotScope) {
  3814. c.parent = slotContainer;
  3815. return true
  3816. }
  3817. });
  3818. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  3819. // remove children as they are returned from scopedSlots now
  3820. el.children = [];
  3821. // mark el non-plain so data gets generated
  3822. el.plain = false;
  3823. }
  3824. }
  3825. }
  3826. }
  3827. function getSlotName (binding) {
  3828. var name = binding.name.replace(slotRE, '');
  3829. if (!name) {
  3830. if (binding.name[0] !== '#') {
  3831. name = 'default';
  3832. } else {
  3833. warn$1(
  3834. "v-slot shorthand syntax requires a slot name.",
  3835. binding
  3836. );
  3837. }
  3838. }
  3839. return dynamicArgRE.test(name)
  3840. // dynamic [name]
  3841. ? { name: name.slice(1, -1), dynamic: true }
  3842. // static name
  3843. : { name: ("\"" + name + "\""), dynamic: false }
  3844. }
  3845. // handle <slot/> outlets
  3846. function processSlotOutlet (el) {
  3847. if (el.tag === 'slot') {
  3848. el.slotName = getBindingAttr(el, 'name');
  3849. if (el.key) {
  3850. warn$1(
  3851. "`key` does not work on <slot> because slots are abstract outlets " +
  3852. "and can possibly expand into multiple elements. " +
  3853. "Use the key on a wrapping element instead.",
  3854. getRawBindingAttr(el, 'key')
  3855. );
  3856. }
  3857. }
  3858. }
  3859. function processComponent (el) {
  3860. var binding;
  3861. if ((binding = getBindingAttr(el, 'is'))) {
  3862. el.component = binding;
  3863. }
  3864. if (getAndRemoveAttr(el, 'inline-template') != null) {
  3865. el.inlineTemplate = true;
  3866. }
  3867. }
  3868. function processAttrs (el) {
  3869. var list = el.attrsList;
  3870. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  3871. for (i = 0, l = list.length; i < l; i++) {
  3872. name = rawName = list[i].name;
  3873. value = list[i].value;
  3874. if (dirRE.test(name)) {
  3875. // mark element as dynamic
  3876. el.hasBindings = true;
  3877. // modifiers
  3878. modifiers = parseModifiers(name.replace(dirRE, ''));
  3879. // support .foo shorthand syntax for the .prop modifier
  3880. if (modifiers) {
  3881. name = name.replace(modifierRE, '');
  3882. }
  3883. if (bindRE.test(name)) { // v-bind
  3884. name = name.replace(bindRE, '');
  3885. value = parseFilters(value);
  3886. isDynamic = dynamicArgRE.test(name);
  3887. if (isDynamic) {
  3888. name = name.slice(1, -1);
  3889. }
  3890. if (
  3891. value.trim().length === 0
  3892. ) {
  3893. warn$1(
  3894. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  3895. );
  3896. }
  3897. if (modifiers) {
  3898. if (modifiers.prop && !isDynamic) {
  3899. name = camelize(name);
  3900. if (name === 'innerHtml') { name = 'innerHTML'; }
  3901. }
  3902. if (modifiers.camel && !isDynamic) {
  3903. name = camelize(name);
  3904. }
  3905. if (modifiers.sync) {
  3906. syncGen = genAssignmentCode(value, "$event");
  3907. if (!isDynamic) {
  3908. addHandler(
  3909. el,
  3910. ("update:" + (camelize(name))),
  3911. syncGen,
  3912. null,
  3913. false,
  3914. warn$1,
  3915. list[i]
  3916. );
  3917. if (hyphenate(name) !== camelize(name)) {
  3918. addHandler(
  3919. el,
  3920. ("update:" + (hyphenate(name))),
  3921. syncGen,
  3922. null,
  3923. false,
  3924. warn$1,
  3925. list[i]
  3926. );
  3927. }
  3928. } else {
  3929. // handler w/ dynamic event name
  3930. addHandler(
  3931. el,
  3932. ("\"update:\"+(" + name + ")"),
  3933. syncGen,
  3934. null,
  3935. false,
  3936. warn$1,
  3937. list[i],
  3938. true // dynamic
  3939. );
  3940. }
  3941. }
  3942. }
  3943. if ((modifiers && modifiers.prop) || (
  3944. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  3945. )) {
  3946. addProp(el, name, value, list[i], isDynamic);
  3947. } else {
  3948. addAttr(el, name, value, list[i], isDynamic);
  3949. }
  3950. } else if (onRE.test(name)) { // v-on
  3951. name = name.replace(onRE, '');
  3952. isDynamic = dynamicArgRE.test(name);
  3953. if (isDynamic) {
  3954. name = name.slice(1, -1);
  3955. }
  3956. addHandler(el, name, value, modifiers, false, warn$1, list[i], isDynamic);
  3957. } else { // normal directives
  3958. name = name.replace(dirRE, '');
  3959. // parse arg
  3960. var argMatch = name.match(argRE);
  3961. var arg = argMatch && argMatch[1];
  3962. isDynamic = false;
  3963. if (arg) {
  3964. name = name.slice(0, -(arg.length + 1));
  3965. if (dynamicArgRE.test(arg)) {
  3966. arg = arg.slice(1, -1);
  3967. isDynamic = true;
  3968. }
  3969. }
  3970. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  3971. if (name === 'model') {
  3972. checkForAliasModel(el, value);
  3973. }
  3974. }
  3975. } else {
  3976. // literal attribute
  3977. {
  3978. var res = parseText(value, delimiters);
  3979. if (res) {
  3980. warn$1(
  3981. name + "=\"" + value + "\": " +
  3982. 'Interpolation inside attributes has been removed. ' +
  3983. 'Use v-bind or the colon shorthand instead. For example, ' +
  3984. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  3985. list[i]
  3986. );
  3987. }
  3988. }
  3989. addAttr(el, name, JSON.stringify(value), list[i]);
  3990. // #6887 firefox doesn't update muted state if set via attribute
  3991. // even immediately after element creation
  3992. if (!el.component &&
  3993. name === 'muted' &&
  3994. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  3995. addProp(el, name, 'true', list[i]);
  3996. }
  3997. }
  3998. }
  3999. }
  4000. function checkInFor (el) {
  4001. var parent = el;
  4002. while (parent) {
  4003. if (parent.for !== undefined) {
  4004. return true
  4005. }
  4006. parent = parent.parent;
  4007. }
  4008. return false
  4009. }
  4010. function parseModifiers (name) {
  4011. var match = name.match(modifierRE);
  4012. if (match) {
  4013. var ret = {};
  4014. match.forEach(function (m) { ret[m.slice(1)] = true; });
  4015. return ret
  4016. }
  4017. }
  4018. function makeAttrsMap (attrs) {
  4019. var map = {};
  4020. for (var i = 0, l = attrs.length; i < l; i++) {
  4021. if (
  4022. map[attrs[i].name] && !isIE && !isEdge
  4023. ) {
  4024. warn$1('duplicate attribute: ' + attrs[i].name, attrs[i]);
  4025. }
  4026. map[attrs[i].name] = attrs[i].value;
  4027. }
  4028. return map
  4029. }
  4030. // for script (e.g. type="x/template") or style, do not decode content
  4031. function isTextTag (el) {
  4032. return el.tag === 'script' || el.tag === 'style'
  4033. }
  4034. function isForbiddenTag (el) {
  4035. return (
  4036. el.tag === 'style' ||
  4037. (el.tag === 'script' && (
  4038. !el.attrsMap.type ||
  4039. el.attrsMap.type === 'text/javascript'
  4040. ))
  4041. )
  4042. }
  4043. var ieNSBug = /^xmlns:NS\d+/;
  4044. var ieNSPrefix = /^NS\d+:/;
  4045. /* istanbul ignore next */
  4046. function guardIESVGBug (attrs) {
  4047. var res = [];
  4048. for (var i = 0; i < attrs.length; i++) {
  4049. var attr = attrs[i];
  4050. if (!ieNSBug.test(attr.name)) {
  4051. attr.name = attr.name.replace(ieNSPrefix, '');
  4052. res.push(attr);
  4053. }
  4054. }
  4055. return res
  4056. }
  4057. function checkForAliasModel (el, value) {
  4058. var _el = el;
  4059. while (_el) {
  4060. if (_el.for && _el.alias === value) {
  4061. warn$1(
  4062. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  4063. "You are binding v-model directly to a v-for iteration alias. " +
  4064. "This will not be able to modify the v-for source array because " +
  4065. "writing to the alias is like modifying a function local variable. " +
  4066. "Consider using an array of objects and use v-model on an object property instead.",
  4067. el.rawAttrsMap['v-model']
  4068. );
  4069. }
  4070. _el = _el.parent;
  4071. }
  4072. }
  4073. /* */
  4074. function preTransformNode (el, options) {
  4075. if (el.tag === 'input') {
  4076. var map = el.attrsMap;
  4077. if (!map['v-model']) {
  4078. return
  4079. }
  4080. var typeBinding;
  4081. if (map[':type'] || map['v-bind:type']) {
  4082. typeBinding = getBindingAttr(el, 'type');
  4083. }
  4084. if (!map.type && !typeBinding && map['v-bind']) {
  4085. typeBinding = "(" + (map['v-bind']) + ").type";
  4086. }
  4087. if (typeBinding) {
  4088. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  4089. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  4090. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  4091. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  4092. // 1. checkbox
  4093. var branch0 = cloneASTElement(el);
  4094. // process for on the main node
  4095. processFor(branch0);
  4096. addRawAttr(branch0, 'type', 'checkbox');
  4097. processElement(branch0, options);
  4098. branch0.processed = true; // prevent it from double-processed
  4099. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  4100. addIfCondition(branch0, {
  4101. exp: branch0.if,
  4102. block: branch0
  4103. });
  4104. // 2. add radio else-if condition
  4105. var branch1 = cloneASTElement(el);
  4106. getAndRemoveAttr(branch1, 'v-for', true);
  4107. addRawAttr(branch1, 'type', 'radio');
  4108. processElement(branch1, options);
  4109. addIfCondition(branch0, {
  4110. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  4111. block: branch1
  4112. });
  4113. // 3. other
  4114. var branch2 = cloneASTElement(el);
  4115. getAndRemoveAttr(branch2, 'v-for', true);
  4116. addRawAttr(branch2, ':type', typeBinding);
  4117. processElement(branch2, options);
  4118. addIfCondition(branch0, {
  4119. exp: ifCondition,
  4120. block: branch2
  4121. });
  4122. if (hasElse) {
  4123. branch0.else = true;
  4124. } else if (elseIfCondition) {
  4125. branch0.elseif = elseIfCondition;
  4126. }
  4127. return branch0
  4128. }
  4129. }
  4130. }
  4131. function cloneASTElement (el) {
  4132. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  4133. }
  4134. var model$1 = {
  4135. preTransformNode: preTransformNode
  4136. };
  4137. var modules$1 = [
  4138. klass,
  4139. style,
  4140. model$1
  4141. ];
  4142. /* */
  4143. var warn$2;
  4144. // in some cases, the event used has to be determined at runtime
  4145. // so we used some reserved tokens during compile.
  4146. var RANGE_TOKEN = '__r';
  4147. function model$2 (
  4148. el,
  4149. dir,
  4150. _warn
  4151. ) {
  4152. warn$2 = _warn;
  4153. var value = dir.value;
  4154. var modifiers = dir.modifiers;
  4155. var tag = el.tag;
  4156. var type = el.attrsMap.type;
  4157. {
  4158. // inputs with type="file" are read only and setting the input's
  4159. // value will throw an error.
  4160. if (tag === 'input' && type === 'file') {
  4161. warn$2(
  4162. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  4163. "File inputs are read only. Use a v-on:change listener instead.",
  4164. el.rawAttrsMap['v-model']
  4165. );
  4166. }
  4167. }
  4168. if (el.component) {
  4169. genComponentModel(el, value, modifiers);
  4170. // component v-model doesn't need extra runtime
  4171. return false
  4172. } else if (tag === 'select') {
  4173. genSelect(el, value, modifiers);
  4174. } else if (tag === 'input' && type === 'checkbox') {
  4175. genCheckboxModel(el, value, modifiers);
  4176. } else if (tag === 'input' && type === 'radio') {
  4177. genRadioModel(el, value, modifiers);
  4178. } else if (tag === 'input' || tag === 'textarea') {
  4179. genDefaultModel(el, value, modifiers);
  4180. } else {
  4181. genComponentModel(el, value, modifiers);
  4182. // component v-model doesn't need extra runtime
  4183. return false
  4184. }
  4185. // ensure runtime directive metadata
  4186. return true
  4187. }
  4188. function genCheckboxModel (
  4189. el,
  4190. value,
  4191. modifiers
  4192. ) {
  4193. var number = modifiers && modifiers.number;
  4194. var valueBinding = getBindingAttr(el, 'value') || 'null';
  4195. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  4196. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  4197. addProp(el, 'checked',
  4198. "Array.isArray(" + value + ")" +
  4199. "?_i(" + value + "," + valueBinding + ")>-1" + (
  4200. trueValueBinding === 'true'
  4201. ? (":(" + value + ")")
  4202. : (":_q(" + value + "," + trueValueBinding + ")")
  4203. )
  4204. );
  4205. addHandler(el, 'change',
  4206. "var $$a=" + value + "," +
  4207. '$$el=$event.target,' +
  4208. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  4209. 'if(Array.isArray($$a)){' +
  4210. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  4211. '$$i=_i($$a,$$v);' +
  4212. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  4213. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  4214. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  4215. null, true
  4216. );
  4217. }
  4218. function genRadioModel (
  4219. el,
  4220. value,
  4221. modifiers
  4222. ) {
  4223. var number = modifiers && modifiers.number;
  4224. var valueBinding = getBindingAttr(el, 'value') || 'null';
  4225. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  4226. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  4227. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  4228. }
  4229. function genSelect (
  4230. el,
  4231. value,
  4232. modifiers
  4233. ) {
  4234. var number = modifiers && modifiers.number;
  4235. var selectedVal = "Array.prototype.filter" +
  4236. ".call($event.target.options,function(o){return o.selected})" +
  4237. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  4238. "return " + (number ? '_n(val)' : 'val') + "})";
  4239. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  4240. var code = "var $$selectedVal = " + selectedVal + ";";
  4241. code = code + " " + (genAssignmentCode(value, assignment));
  4242. addHandler(el, 'change', code, null, true);
  4243. }
  4244. function genDefaultModel (
  4245. el,
  4246. value,
  4247. modifiers
  4248. ) {
  4249. var type = el.attrsMap.type;
  4250. // warn if v-bind:value conflicts with v-model
  4251. // except for inputs with v-bind:type
  4252. {
  4253. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  4254. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  4255. if (value$1 && !typeBinding) {
  4256. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  4257. warn$2(
  4258. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  4259. 'because the latter already expands to a value binding internally',
  4260. el.rawAttrsMap[binding]
  4261. );
  4262. }
  4263. }
  4264. var ref = modifiers || {};
  4265. var lazy = ref.lazy;
  4266. var number = ref.number;
  4267. var trim = ref.trim;
  4268. var needCompositionGuard = !lazy && type !== 'range';
  4269. var event = lazy
  4270. ? 'change'
  4271. : type === 'range'
  4272. ? RANGE_TOKEN
  4273. : 'input';
  4274. var valueExpression = '$event.target.value';
  4275. if (trim) {
  4276. valueExpression = "$event.target.value.trim()";
  4277. }
  4278. if (number) {
  4279. valueExpression = "_n(" + valueExpression + ")";
  4280. }
  4281. var code = genAssignmentCode(value, valueExpression);
  4282. if (needCompositionGuard) {
  4283. code = "if($event.target.composing)return;" + code;
  4284. }
  4285. addProp(el, 'value', ("(" + value + ")"));
  4286. addHandler(el, event, code, null, true);
  4287. if (trim || number) {
  4288. addHandler(el, 'blur', '$forceUpdate()');
  4289. }
  4290. }
  4291. /* */
  4292. function text (el, dir) {
  4293. if (dir.value) {
  4294. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  4295. }
  4296. }
  4297. /* */
  4298. function html (el, dir) {
  4299. if (dir.value) {
  4300. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  4301. }
  4302. }
  4303. var directives = {
  4304. model: model$2,
  4305. text: text,
  4306. html: html
  4307. };
  4308. /* */
  4309. var baseOptions = {
  4310. expectHTML: true,
  4311. modules: modules$1,
  4312. directives: directives,
  4313. isPreTag: isPreTag,
  4314. isUnaryTag: isUnaryTag,
  4315. mustUseProp: mustUseProp,
  4316. canBeLeftOpenTag: canBeLeftOpenTag,
  4317. isReservedTag: isReservedTag,
  4318. getTagNamespace: getTagNamespace,
  4319. staticKeys: genStaticKeys(modules$1)
  4320. };
  4321. /* */
  4322. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  4323. var fnInvokeRE = /\([^)]*?\);*$/;
  4324. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  4325. // KeyboardEvent.keyCode aliases
  4326. var keyCodes = {
  4327. esc: 27,
  4328. tab: 9,
  4329. enter: 13,
  4330. space: 32,
  4331. up: 38,
  4332. left: 37,
  4333. right: 39,
  4334. down: 40,
  4335. 'delete': [8, 46]
  4336. };
  4337. // KeyboardEvent.key aliases
  4338. var keyNames = {
  4339. // #7880: IE11 and Edge use `Esc` for Escape key name.
  4340. esc: ['Esc', 'Escape'],
  4341. tab: 'Tab',
  4342. enter: 'Enter',
  4343. // #9112: IE11 uses `Spacebar` for Space key name.
  4344. space: [' ', 'Spacebar'],
  4345. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  4346. up: ['Up', 'ArrowUp'],
  4347. left: ['Left', 'ArrowLeft'],
  4348. right: ['Right', 'ArrowRight'],
  4349. down: ['Down', 'ArrowDown'],
  4350. // #9112: IE11 uses `Del` for Delete key name.
  4351. 'delete': ['Backspace', 'Delete', 'Del']
  4352. };
  4353. // #4868: modifiers that prevent the execution of the listener
  4354. // need to explicitly return null so that we can determine whether to remove
  4355. // the listener for .once
  4356. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  4357. var modifierCode = {
  4358. stop: '$event.stopPropagation();',
  4359. prevent: '$event.preventDefault();',
  4360. self: genGuard("$event.target !== $event.currentTarget"),
  4361. ctrl: genGuard("!$event.ctrlKey"),
  4362. shift: genGuard("!$event.shiftKey"),
  4363. alt: genGuard("!$event.altKey"),
  4364. meta: genGuard("!$event.metaKey"),
  4365. left: genGuard("'button' in $event && $event.button !== 0"),
  4366. middle: genGuard("'button' in $event && $event.button !== 1"),
  4367. right: genGuard("'button' in $event && $event.button !== 2")
  4368. };
  4369. function genHandlers (
  4370. events,
  4371. isNative
  4372. ) {
  4373. var prefix = isNative ? 'nativeOn:' : 'on:';
  4374. var staticHandlers = "";
  4375. var dynamicHandlers = "";
  4376. for (var name in events) {
  4377. var handlerCode = genHandler(events[name]);
  4378. if (events[name] && events[name].dynamic) {
  4379. dynamicHandlers += name + "," + handlerCode + ",";
  4380. } else {
  4381. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  4382. }
  4383. }
  4384. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  4385. if (dynamicHandlers) {
  4386. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  4387. } else {
  4388. return prefix + staticHandlers
  4389. }
  4390. }
  4391. function genHandler (handler) {
  4392. if (!handler) {
  4393. return 'function(){}'
  4394. }
  4395. if (Array.isArray(handler)) {
  4396. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  4397. }
  4398. var isMethodPath = simplePathRE.test(handler.value);
  4399. var isFunctionExpression = fnExpRE.test(handler.value);
  4400. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  4401. if (!handler.modifiers) {
  4402. if (isMethodPath || isFunctionExpression) {
  4403. return handler.value
  4404. }
  4405. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  4406. } else {
  4407. var code = '';
  4408. var genModifierCode = '';
  4409. var keys = [];
  4410. for (var key in handler.modifiers) {
  4411. if (modifierCode[key]) {
  4412. genModifierCode += modifierCode[key];
  4413. // left/right
  4414. if (keyCodes[key]) {
  4415. keys.push(key);
  4416. }
  4417. } else if (key === 'exact') {
  4418. var modifiers = (handler.modifiers);
  4419. genModifierCode += genGuard(
  4420. ['ctrl', 'shift', 'alt', 'meta']
  4421. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  4422. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  4423. .join('||')
  4424. );
  4425. } else {
  4426. keys.push(key);
  4427. }
  4428. }
  4429. if (keys.length) {
  4430. code += genKeyFilter(keys);
  4431. }
  4432. // Make sure modifiers like prevent and stop get executed after key filtering
  4433. if (genModifierCode) {
  4434. code += genModifierCode;
  4435. }
  4436. var handlerCode = isMethodPath
  4437. ? ("return " + (handler.value) + ".apply(null, arguments)")
  4438. : isFunctionExpression
  4439. ? ("return (" + (handler.value) + ").apply(null, arguments)")
  4440. : isFunctionInvocation
  4441. ? ("return " + (handler.value))
  4442. : handler.value;
  4443. return ("function($event){" + code + handlerCode + "}")
  4444. }
  4445. }
  4446. function genKeyFilter (keys) {
  4447. return (
  4448. // make sure the key filters only apply to KeyboardEvents
  4449. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  4450. // key events that do not have keyCode property...
  4451. "if(!$event.type.indexOf('key')&&" +
  4452. (keys.map(genFilterCode).join('&&')) + ")return null;"
  4453. )
  4454. }
  4455. function genFilterCode (key) {
  4456. var keyVal = parseInt(key, 10);
  4457. if (keyVal) {
  4458. return ("$event.keyCode!==" + keyVal)
  4459. }
  4460. var keyCode = keyCodes[key];
  4461. var keyName = keyNames[key];
  4462. return (
  4463. "_k($event.keyCode," +
  4464. (JSON.stringify(key)) + "," +
  4465. (JSON.stringify(keyCode)) + "," +
  4466. "$event.key," +
  4467. "" + (JSON.stringify(keyName)) +
  4468. ")"
  4469. )
  4470. }
  4471. /* */
  4472. function on (el, dir) {
  4473. if (dir.modifiers) {
  4474. warn("v-on without argument does not support modifiers.");
  4475. }
  4476. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  4477. }
  4478. /* */
  4479. function bind$1 (el, dir) {
  4480. el.wrapData = function (code) {
  4481. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  4482. };
  4483. }
  4484. /* */
  4485. var baseDirectives$1 = {
  4486. on: on,
  4487. bind: bind$1,
  4488. cloak: noop
  4489. };
  4490. /* */
  4491. var CodegenState = function CodegenState (options) {
  4492. this.options = options;
  4493. this.warn = options.warn || baseWarn;
  4494. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  4495. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  4496. this.directives = extend(extend({}, baseDirectives$1), options.directives);
  4497. var isReservedTag = options.isReservedTag || no;
  4498. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  4499. this.onceId = 0;
  4500. this.staticRenderFns = [];
  4501. this.pre = false;
  4502. };
  4503. function generate (
  4504. ast,
  4505. options
  4506. ) {
  4507. var state = new CodegenState(options);
  4508. // fix #11483, Root level <script> tags should not be rendered.
  4509. var code = ast ? (ast.tag === 'script' ? 'null' : genElement(ast, state)) : '_c("div")';
  4510. return {
  4511. render: ("with(this){return " + code + "}"),
  4512. staticRenderFns: state.staticRenderFns
  4513. }
  4514. }
  4515. function genElement (el, state) {
  4516. if (el.parent) {
  4517. el.pre = el.pre || el.parent.pre;
  4518. }
  4519. if (el.staticRoot && !el.staticProcessed) {
  4520. return genStatic(el, state)
  4521. } else if (el.once && !el.onceProcessed) {
  4522. return genOnce(el, state)
  4523. } else if (el.for && !el.forProcessed) {
  4524. return genFor(el, state)
  4525. } else if (el.if && !el.ifProcessed) {
  4526. return genIf(el, state)
  4527. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  4528. return genChildren(el, state) || 'void 0'
  4529. } else if (el.tag === 'slot') {
  4530. return genSlot(el, state)
  4531. } else {
  4532. // component or element
  4533. var code;
  4534. if (el.component) {
  4535. code = genComponent(el.component, el, state);
  4536. } else {
  4537. var data;
  4538. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  4539. data = genData$2(el, state);
  4540. }
  4541. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  4542. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  4543. }
  4544. // module transforms
  4545. for (var i = 0; i < state.transforms.length; i++) {
  4546. code = state.transforms[i](el, code);
  4547. }
  4548. return code
  4549. }
  4550. }
  4551. // hoist static sub-trees out
  4552. function genStatic (el, state) {
  4553. el.staticProcessed = true;
  4554. // Some elements (templates) need to behave differently inside of a v-pre
  4555. // node. All pre nodes are static roots, so we can use this as a location to
  4556. // wrap a state change and reset it upon exiting the pre node.
  4557. var originalPreState = state.pre;
  4558. if (el.pre) {
  4559. state.pre = el.pre;
  4560. }
  4561. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  4562. state.pre = originalPreState;
  4563. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  4564. }
  4565. // v-once
  4566. function genOnce (el, state) {
  4567. el.onceProcessed = true;
  4568. if (el.if && !el.ifProcessed) {
  4569. return genIf(el, state)
  4570. } else if (el.staticInFor) {
  4571. var key = '';
  4572. var parent = el.parent;
  4573. while (parent) {
  4574. if (parent.for) {
  4575. key = parent.key;
  4576. break
  4577. }
  4578. parent = parent.parent;
  4579. }
  4580. if (!key) {
  4581. state.warn(
  4582. "v-once can only be used inside v-for that is keyed. ",
  4583. el.rawAttrsMap['v-once']
  4584. );
  4585. return genElement(el, state)
  4586. }
  4587. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  4588. } else {
  4589. return genStatic(el, state)
  4590. }
  4591. }
  4592. function genIf (
  4593. el,
  4594. state,
  4595. altGen,
  4596. altEmpty
  4597. ) {
  4598. el.ifProcessed = true; // avoid recursion
  4599. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  4600. }
  4601. function genIfConditions (
  4602. conditions,
  4603. state,
  4604. altGen,
  4605. altEmpty
  4606. ) {
  4607. if (!conditions.length) {
  4608. return altEmpty || '_e()'
  4609. }
  4610. var condition = conditions.shift();
  4611. if (condition.exp) {
  4612. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  4613. } else {
  4614. return ("" + (genTernaryExp(condition.block)))
  4615. }
  4616. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  4617. function genTernaryExp (el) {
  4618. return altGen
  4619. ? altGen(el, state)
  4620. : el.once
  4621. ? genOnce(el, state)
  4622. : genElement(el, state)
  4623. }
  4624. }
  4625. function genFor (
  4626. el,
  4627. state,
  4628. altGen,
  4629. altHelper
  4630. ) {
  4631. var exp = el.for;
  4632. var alias = el.alias;
  4633. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  4634. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  4635. if (state.maybeComponent(el) &&
  4636. el.tag !== 'slot' &&
  4637. el.tag !== 'template' &&
  4638. !el.key
  4639. ) {
  4640. state.warn(
  4641. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  4642. "v-for should have explicit keys. " +
  4643. "See https://vuejs.org/guide/list.html#key for more info.",
  4644. el.rawAttrsMap['v-for'],
  4645. true /* tip */
  4646. );
  4647. }
  4648. el.forProcessed = true; // avoid recursion
  4649. return (altHelper || '_l') + "((" + exp + ")," +
  4650. "function(" + alias + iterator1 + iterator2 + "){" +
  4651. "return " + ((altGen || genElement)(el, state)) +
  4652. '})'
  4653. }
  4654. function genData$2 (el, state) {
  4655. var data = '{';
  4656. // directives first.
  4657. // directives may mutate the el's other properties before they are generated.
  4658. var dirs = genDirectives(el, state);
  4659. if (dirs) { data += dirs + ','; }
  4660. // key
  4661. if (el.key) {
  4662. data += "key:" + (el.key) + ",";
  4663. }
  4664. // ref
  4665. if (el.ref) {
  4666. data += "ref:" + (el.ref) + ",";
  4667. }
  4668. if (el.refInFor) {
  4669. data += "refInFor:true,";
  4670. }
  4671. // pre
  4672. if (el.pre) {
  4673. data += "pre:true,";
  4674. }
  4675. // record original tag name for components using "is" attribute
  4676. if (el.component) {
  4677. data += "tag:\"" + (el.tag) + "\",";
  4678. }
  4679. // module data generation functions
  4680. for (var i = 0; i < state.dataGenFns.length; i++) {
  4681. data += state.dataGenFns[i](el);
  4682. }
  4683. // attributes
  4684. if (el.attrs) {
  4685. data += "attrs:" + (genProps(el.attrs)) + ",";
  4686. }
  4687. // DOM props
  4688. if (el.props) {
  4689. data += "domProps:" + (genProps(el.props)) + ",";
  4690. }
  4691. // event handlers
  4692. if (el.events) {
  4693. data += (genHandlers(el.events, false)) + ",";
  4694. }
  4695. if (el.nativeEvents) {
  4696. data += (genHandlers(el.nativeEvents, true)) + ",";
  4697. }
  4698. // slot target
  4699. // only for non-scoped slots
  4700. if (el.slotTarget && !el.slotScope) {
  4701. data += "slot:" + (el.slotTarget) + ",";
  4702. }
  4703. // scoped slots
  4704. if (el.scopedSlots) {
  4705. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  4706. }
  4707. // component v-model
  4708. if (el.model) {
  4709. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  4710. }
  4711. // inline-template
  4712. if (el.inlineTemplate) {
  4713. var inlineTemplate = genInlineTemplate(el, state);
  4714. if (inlineTemplate) {
  4715. data += inlineTemplate + ",";
  4716. }
  4717. }
  4718. data = data.replace(/,$/, '') + '}';
  4719. // v-bind dynamic argument wrap
  4720. // v-bind with dynamic arguments must be applied using the same v-bind object
  4721. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  4722. if (el.dynamicAttrs) {
  4723. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  4724. }
  4725. // v-bind data wrap
  4726. if (el.wrapData) {
  4727. data = el.wrapData(data);
  4728. }
  4729. // v-on data wrap
  4730. if (el.wrapListeners) {
  4731. data = el.wrapListeners(data);
  4732. }
  4733. return data
  4734. }
  4735. function genDirectives (el, state) {
  4736. var dirs = el.directives;
  4737. if (!dirs) { return }
  4738. var res = 'directives:[';
  4739. var hasRuntime = false;
  4740. var i, l, dir, needRuntime;
  4741. for (i = 0, l = dirs.length; i < l; i++) {
  4742. dir = dirs[i];
  4743. needRuntime = true;
  4744. var gen = state.directives[dir.name];
  4745. if (gen) {
  4746. // compile-time directive that manipulates AST.
  4747. // returns true if it also needs a runtime counterpart.
  4748. needRuntime = !!gen(el, dir, state.warn);
  4749. }
  4750. if (needRuntime) {
  4751. hasRuntime = true;
  4752. res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:" + (dir.isDynamicArg ? dir.arg : ("\"" + (dir.arg) + "\""))) : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
  4753. }
  4754. }
  4755. if (hasRuntime) {
  4756. return res.slice(0, -1) + ']'
  4757. }
  4758. }
  4759. function genInlineTemplate (el, state) {
  4760. var ast = el.children[0];
  4761. if (el.children.length !== 1 || ast.type !== 1) {
  4762. state.warn(
  4763. 'Inline-template components must have exactly one child element.',
  4764. { start: el.start }
  4765. );
  4766. }
  4767. if (ast && ast.type === 1) {
  4768. var inlineRenderFns = generate(ast, state.options);
  4769. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  4770. }
  4771. }
  4772. function genScopedSlots (
  4773. el,
  4774. slots,
  4775. state
  4776. ) {
  4777. // by default scoped slots are considered "stable", this allows child
  4778. // components with only scoped slots to skip forced updates from parent.
  4779. // but in some cases we have to bail-out of this optimization
  4780. // for example if the slot contains dynamic names, has v-if or v-for on them...
  4781. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  4782. var slot = slots[key];
  4783. return (
  4784. slot.slotTargetDynamic ||
  4785. slot.if ||
  4786. slot.for ||
  4787. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  4788. )
  4789. });
  4790. // #9534: if a component with scoped slots is inside a conditional branch,
  4791. // it's possible for the same component to be reused but with different
  4792. // compiled slot content. To avoid that, we generate a unique key based on
  4793. // the generated code of all the slot contents.
  4794. var needsKey = !!el.if;
  4795. // OR when it is inside another scoped slot or v-for (the reactivity may be
  4796. // disconnected due to the intermediate scope variable)
  4797. // #9438, #9506
  4798. // TODO: this can be further optimized by properly analyzing in-scope bindings
  4799. // and skip force updating ones that do not actually use scope variables.
  4800. if (!needsForceUpdate) {
  4801. var parent = el.parent;
  4802. while (parent) {
  4803. if (
  4804. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  4805. parent.for
  4806. ) {
  4807. needsForceUpdate = true;
  4808. break
  4809. }
  4810. if (parent.if) {
  4811. needsKey = true;
  4812. }
  4813. parent = parent.parent;
  4814. }
  4815. }
  4816. var generatedSlots = Object.keys(slots)
  4817. .map(function (key) { return genScopedSlot(slots[key], state); })
  4818. .join(',');
  4819. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  4820. }
  4821. function hash(str) {
  4822. var hash = 5381;
  4823. var i = str.length;
  4824. while(i) {
  4825. hash = (hash * 33) ^ str.charCodeAt(--i);
  4826. }
  4827. return hash >>> 0
  4828. }
  4829. function containsSlotChild (el) {
  4830. if (el.type === 1) {
  4831. if (el.tag === 'slot') {
  4832. return true
  4833. }
  4834. return el.children.some(containsSlotChild)
  4835. }
  4836. return false
  4837. }
  4838. function genScopedSlot (
  4839. el,
  4840. state
  4841. ) {
  4842. var isLegacySyntax = el.attrsMap['slot-scope'];
  4843. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  4844. return genIf(el, state, genScopedSlot, "null")
  4845. }
  4846. if (el.for && !el.forProcessed) {
  4847. return genFor(el, state, genScopedSlot)
  4848. }
  4849. var slotScope = el.slotScope === emptySlotScopeToken
  4850. ? ""
  4851. : String(el.slotScope);
  4852. var fn = "function(" + slotScope + "){" +
  4853. "return " + (el.tag === 'template'
  4854. ? el.if && isLegacySyntax
  4855. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  4856. : genChildren(el, state) || 'undefined'
  4857. : genElement(el, state)) + "}";
  4858. // reverse proxy v-slot without scope on this.$slots
  4859. var reverseProxy = slotScope ? "" : ",proxy:true";
  4860. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  4861. }
  4862. function genChildren (
  4863. el,
  4864. state,
  4865. checkSkip,
  4866. altGenElement,
  4867. altGenNode
  4868. ) {
  4869. var children = el.children;
  4870. if (children.length) {
  4871. var el$1 = children[0];
  4872. // optimize single v-for
  4873. if (children.length === 1 &&
  4874. el$1.for &&
  4875. el$1.tag !== 'template' &&
  4876. el$1.tag !== 'slot'
  4877. ) {
  4878. var normalizationType = checkSkip
  4879. ? state.maybeComponent(el$1) ? ",1" : ",0"
  4880. : "";
  4881. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  4882. }
  4883. var normalizationType$1 = checkSkip
  4884. ? getNormalizationType(children, state.maybeComponent)
  4885. : 0;
  4886. var gen = altGenNode || genNode;
  4887. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  4888. }
  4889. }
  4890. // determine the normalization needed for the children array.
  4891. // 0: no normalization needed
  4892. // 1: simple normalization needed (possible 1-level deep nested array)
  4893. // 2: full normalization needed
  4894. function getNormalizationType (
  4895. children,
  4896. maybeComponent
  4897. ) {
  4898. var res = 0;
  4899. for (var i = 0; i < children.length; i++) {
  4900. var el = children[i];
  4901. if (el.type !== 1) {
  4902. continue
  4903. }
  4904. if (needsNormalization(el) ||
  4905. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  4906. res = 2;
  4907. break
  4908. }
  4909. if (maybeComponent(el) ||
  4910. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  4911. res = 1;
  4912. }
  4913. }
  4914. return res
  4915. }
  4916. function needsNormalization (el) {
  4917. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  4918. }
  4919. function genNode (node, state) {
  4920. if (node.type === 1) {
  4921. return genElement(node, state)
  4922. } else if (node.type === 3 && node.isComment) {
  4923. return genComment(node)
  4924. } else {
  4925. return genText(node)
  4926. }
  4927. }
  4928. function genText (text) {
  4929. return ("_v(" + (text.type === 2
  4930. ? text.expression // no need for () because already wrapped in _s()
  4931. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  4932. }
  4933. function genComment (comment) {
  4934. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  4935. }
  4936. function genSlot (el, state) {
  4937. var slotName = el.slotName || '"default"';
  4938. var children = genChildren(el, state);
  4939. var res = "_t(" + slotName + (children ? (",function(){return " + children + "}") : '');
  4940. var attrs = el.attrs || el.dynamicAttrs
  4941. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  4942. // slot props are camelized
  4943. name: camelize(attr.name),
  4944. value: attr.value,
  4945. dynamic: attr.dynamic
  4946. }); }))
  4947. : null;
  4948. var bind$$1 = el.attrsMap['v-bind'];
  4949. if ((attrs || bind$$1) && !children) {
  4950. res += ",null";
  4951. }
  4952. if (attrs) {
  4953. res += "," + attrs;
  4954. }
  4955. if (bind$$1) {
  4956. res += (attrs ? '' : ',null') + "," + bind$$1;
  4957. }
  4958. return res + ')'
  4959. }
  4960. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  4961. function genComponent (
  4962. componentName,
  4963. el,
  4964. state
  4965. ) {
  4966. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  4967. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  4968. }
  4969. function genProps (props) {
  4970. var staticProps = "";
  4971. var dynamicProps = "";
  4972. for (var i = 0; i < props.length; i++) {
  4973. var prop = props[i];
  4974. var value = transformSpecialNewlines(prop.value);
  4975. if (prop.dynamic) {
  4976. dynamicProps += (prop.name) + "," + value + ",";
  4977. } else {
  4978. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  4979. }
  4980. }
  4981. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  4982. if (dynamicProps) {
  4983. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  4984. } else {
  4985. return staticProps
  4986. }
  4987. }
  4988. // #3895, #4268
  4989. function transformSpecialNewlines (text) {
  4990. return text
  4991. .replace(/\u2028/g, '\\u2028')
  4992. .replace(/\u2029/g, '\\u2029')
  4993. }
  4994. /* */
  4995. var plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/;
  4996. // let the model AST transform translate v-model into appropriate
  4997. // props bindings
  4998. function applyModelTransform (el, state) {
  4999. if (el.directives) {
  5000. for (var i = 0; i < el.directives.length; i++) {
  5001. var dir = el.directives[i];
  5002. if (dir.name === 'model') {
  5003. state.directives.model(el, dir, state.warn);
  5004. // remove value for textarea as its converted to text
  5005. if (el.tag === 'textarea' && el.props) {
  5006. el.props = el.props.filter(function (p) { return p.name !== 'value'; });
  5007. }
  5008. break
  5009. }
  5010. }
  5011. }
  5012. }
  5013. function genAttrSegments (
  5014. attrs
  5015. ) {
  5016. return attrs.map(function (ref) {
  5017. var name = ref.name;
  5018. var value = ref.value;
  5019. return genAttrSegment(name, value);
  5020. })
  5021. }
  5022. function genDOMPropSegments (
  5023. props,
  5024. attrs
  5025. ) {
  5026. var segments = [];
  5027. props.forEach(function (ref) {
  5028. var name = ref.name;
  5029. var value = ref.value;
  5030. name = propsToAttrMap[name] || name.toLowerCase();
  5031. if (isRenderableAttr(name) &&
  5032. !(attrs && attrs.some(function (a) { return a.name === name; }))
  5033. ) {
  5034. segments.push(genAttrSegment(name, value));
  5035. }
  5036. });
  5037. return segments
  5038. }
  5039. function genAttrSegment (name, value) {
  5040. if (plainStringRE.test(value)) {
  5041. // force double quote
  5042. value = value.replace(/^'|'$/g, '"');
  5043. // force enumerated attr to "true"
  5044. if (isEnumeratedAttr(name) && value !== "\"false\"") {
  5045. value = "\"true\"";
  5046. }
  5047. return {
  5048. type: RAW,
  5049. value: isBooleanAttr(name)
  5050. ? (" " + name + "=\"" + name + "\"")
  5051. : value === '""'
  5052. ? (" " + name)
  5053. : (" " + name + "=\"" + (JSON.parse(value)) + "\"")
  5054. }
  5055. } else {
  5056. return {
  5057. type: EXPRESSION,
  5058. value: ("_ssrAttr(" + (JSON.stringify(name)) + "," + value + ")")
  5059. }
  5060. }
  5061. }
  5062. function genClassSegments (
  5063. staticClass,
  5064. classBinding
  5065. ) {
  5066. if (staticClass && !classBinding) {
  5067. return [{ type: RAW, value: (" class=\"" + (JSON.parse(staticClass)) + "\"") }]
  5068. } else {
  5069. return [{
  5070. type: EXPRESSION,
  5071. value: ("_ssrClass(" + (staticClass || 'null') + "," + (classBinding || 'null') + ")")
  5072. }]
  5073. }
  5074. }
  5075. function genStyleSegments (
  5076. staticStyle,
  5077. parsedStaticStyle,
  5078. styleBinding,
  5079. vShowExpression
  5080. ) {
  5081. if (staticStyle && !styleBinding && !vShowExpression) {
  5082. return [{ type: RAW, value: (" style=" + (JSON.stringify(staticStyle))) }]
  5083. } else {
  5084. return [{
  5085. type: EXPRESSION,
  5086. value: ("_ssrStyle(" + (parsedStaticStyle || 'null') + "," + (styleBinding || 'null') + ", " + (vShowExpression
  5087. ? ("{ display: (" + vShowExpression + ") ? '' : 'none' }")
  5088. : 'null') + ")")
  5089. }]
  5090. }
  5091. }
  5092. /* */
  5093. // optimizability constants
  5094. var optimizability = {
  5095. FALSE: 0, // whole sub tree un-optimizable
  5096. FULL: 1, // whole sub tree optimizable
  5097. SELF: 2, // self optimizable but has some un-optimizable children
  5098. CHILDREN: 3, // self un-optimizable but have fully optimizable children
  5099. PARTIAL: 4 // self un-optimizable with some un-optimizable children
  5100. };
  5101. var isPlatformReservedTag;
  5102. function optimize (root, options) {
  5103. if (!root) { return }
  5104. isPlatformReservedTag = options.isReservedTag || no;
  5105. walk(root, true);
  5106. }
  5107. function walk (node, isRoot) {
  5108. if (isUnOptimizableTree(node)) {
  5109. node.ssrOptimizability = optimizability.FALSE;
  5110. return
  5111. }
  5112. // root node or nodes with custom directives should always be a VNode
  5113. var selfUnoptimizable = isRoot || hasCustomDirective(node);
  5114. var check = function (child) {
  5115. if (child.ssrOptimizability !== optimizability.FULL) {
  5116. node.ssrOptimizability = selfUnoptimizable
  5117. ? optimizability.PARTIAL
  5118. : optimizability.SELF;
  5119. }
  5120. };
  5121. if (selfUnoptimizable) {
  5122. node.ssrOptimizability = optimizability.CHILDREN;
  5123. }
  5124. if (node.type === 1) {
  5125. for (var i = 0, l = node.children.length; i < l; i++) {
  5126. var child = node.children[i];
  5127. walk(child);
  5128. check(child);
  5129. }
  5130. if (node.ifConditions) {
  5131. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  5132. var block = node.ifConditions[i$1].block;
  5133. walk(block, isRoot);
  5134. check(block);
  5135. }
  5136. }
  5137. if (node.ssrOptimizability == null ||
  5138. (!isRoot && (node.attrsMap['v-html'] || node.attrsMap['v-text']))
  5139. ) {
  5140. node.ssrOptimizability = optimizability.FULL;
  5141. } else {
  5142. node.children = optimizeSiblings(node);
  5143. }
  5144. } else {
  5145. node.ssrOptimizability = optimizability.FULL;
  5146. }
  5147. }
  5148. function optimizeSiblings (el) {
  5149. var children = el.children;
  5150. var optimizedChildren = [];
  5151. var currentOptimizableGroup = [];
  5152. var pushGroup = function () {
  5153. if (currentOptimizableGroup.length) {
  5154. optimizedChildren.push({
  5155. type: 1,
  5156. parent: el,
  5157. tag: 'template',
  5158. attrsList: [],
  5159. attrsMap: {},
  5160. rawAttrsMap: {},
  5161. children: currentOptimizableGroup,
  5162. ssrOptimizability: optimizability.FULL
  5163. });
  5164. }
  5165. currentOptimizableGroup = [];
  5166. };
  5167. for (var i = 0; i < children.length; i++) {
  5168. var c = children[i];
  5169. if (c.ssrOptimizability === optimizability.FULL) {
  5170. currentOptimizableGroup.push(c);
  5171. } else {
  5172. // wrap fully-optimizable adjacent siblings inside a template tag
  5173. // so that they can be optimized into a single ssrNode by codegen
  5174. pushGroup();
  5175. optimizedChildren.push(c);
  5176. }
  5177. }
  5178. pushGroup();
  5179. return optimizedChildren
  5180. }
  5181. function isUnOptimizableTree (node) {
  5182. if (node.type === 2 || node.type === 3) { // text or expression
  5183. return false
  5184. }
  5185. return (
  5186. isBuiltInTag(node.tag) || // built-in (slot, component)
  5187. !isPlatformReservedTag(node.tag) || // custom component
  5188. !!node.component || // "is" component
  5189. isSelectWithModel(node) // <select v-model> requires runtime inspection
  5190. )
  5191. }
  5192. var isBuiltInDir = makeMap('text,html,show,on,bind,model,pre,cloak,once');
  5193. function hasCustomDirective (node) {
  5194. return (
  5195. node.type === 1 &&
  5196. node.directives &&
  5197. node.directives.some(function (d) { return !isBuiltInDir(d.name); })
  5198. )
  5199. }
  5200. // <select v-model> cannot be optimized because it requires a runtime check
  5201. // to determine proper selected option
  5202. function isSelectWithModel (node) {
  5203. return (
  5204. node.type === 1 &&
  5205. node.tag === 'select' &&
  5206. node.directives != null &&
  5207. node.directives.some(function (d) { return d.name === 'model'; })
  5208. )
  5209. }
  5210. /* */
  5211. // segment types
  5212. var RAW = 0;
  5213. var INTERPOLATION = 1;
  5214. var EXPRESSION = 2;
  5215. function generate$1 (
  5216. ast,
  5217. options
  5218. ) {
  5219. var state = new CodegenState(options);
  5220. var code = ast ? genSSRElement(ast, state) : '_c("div")';
  5221. return {
  5222. render: ("with(this){return " + code + "}"),
  5223. staticRenderFns: state.staticRenderFns
  5224. }
  5225. }
  5226. function genSSRElement (el, state) {
  5227. if (el.for && !el.forProcessed) {
  5228. return genFor(el, state, genSSRElement)
  5229. } else if (el.if && !el.ifProcessed) {
  5230. return genIf(el, state, genSSRElement)
  5231. } else if (el.tag === 'template' && !el.slotTarget) {
  5232. return el.ssrOptimizability === optimizability.FULL
  5233. ? genChildrenAsStringNode(el, state)
  5234. : genSSRChildren(el, state) || 'void 0'
  5235. }
  5236. switch (el.ssrOptimizability) {
  5237. case optimizability.FULL:
  5238. // stringify whole tree
  5239. return genStringElement(el, state)
  5240. case optimizability.SELF:
  5241. // stringify self and check children
  5242. return genStringElementWithChildren(el, state)
  5243. case optimizability.CHILDREN:
  5244. // generate self as VNode and stringify children
  5245. return genNormalElement(el, state, true)
  5246. case optimizability.PARTIAL:
  5247. // generate self as VNode and check children
  5248. return genNormalElement(el, state, false)
  5249. default:
  5250. // bail whole tree
  5251. return genElement(el, state)
  5252. }
  5253. }
  5254. function genNormalElement (el, state, stringifyChildren) {
  5255. var data = el.plain ? undefined : genData$2(el, state);
  5256. var children = stringifyChildren
  5257. ? ("[" + (genChildrenAsStringNode(el, state)) + "]")
  5258. : genSSRChildren(el, state, true);
  5259. return ("_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")")
  5260. }
  5261. function genSSRChildren (el, state, checkSkip) {
  5262. return genChildren(el, state, checkSkip, genSSRElement, genSSRNode)
  5263. }
  5264. function genSSRNode (el, state) {
  5265. return el.type === 1
  5266. ? genSSRElement(el, state)
  5267. : genText(el)
  5268. }
  5269. function genChildrenAsStringNode (el, state) {
  5270. return el.children.length
  5271. ? ("_ssrNode(" + (flattenSegments(childrenToSegments(el, state))) + ")")
  5272. : ''
  5273. }
  5274. function genStringElement (el, state) {
  5275. return ("_ssrNode(" + (elementToString(el, state)) + ")")
  5276. }
  5277. function genStringElementWithChildren (el, state) {
  5278. var children = genSSRChildren(el, state, true);
  5279. return ("_ssrNode(" + (flattenSegments(elementToOpenTagSegments(el, state))) + ",\"</" + (el.tag) + ">\"" + (children ? ("," + children) : '') + ")")
  5280. }
  5281. function elementToString (el, state) {
  5282. return ("(" + (flattenSegments(elementToSegments(el, state))) + ")")
  5283. }
  5284. function elementToSegments (el, state) {
  5285. // v-for / v-if
  5286. if (el.for && !el.forProcessed) {
  5287. el.forProcessed = true;
  5288. return [{
  5289. type: EXPRESSION,
  5290. value: genFor(el, state, elementToString, '_ssrList')
  5291. }]
  5292. } else if (el.if && !el.ifProcessed) {
  5293. el.ifProcessed = true;
  5294. return [{
  5295. type: EXPRESSION,
  5296. value: genIf(el, state, elementToString, '"<!---->"')
  5297. }]
  5298. } else if (el.tag === 'template') {
  5299. return childrenToSegments(el, state)
  5300. }
  5301. var openSegments = elementToOpenTagSegments(el, state);
  5302. var childrenSegments = childrenToSegments(el, state);
  5303. var ref = state.options;
  5304. var isUnaryTag = ref.isUnaryTag;
  5305. var close = (isUnaryTag && isUnaryTag(el.tag))
  5306. ? []
  5307. : [{ type: RAW, value: ("</" + (el.tag) + ">") }];
  5308. return openSegments.concat(childrenSegments, close)
  5309. }
  5310. function elementToOpenTagSegments (el, state) {
  5311. applyModelTransform(el, state);
  5312. var binding;
  5313. var segments = [{ type: RAW, value: ("<" + (el.tag)) }];
  5314. // attrs
  5315. if (el.attrs) {
  5316. segments.push.apply(segments, genAttrSegments(el.attrs));
  5317. }
  5318. // domProps
  5319. if (el.props) {
  5320. segments.push.apply(segments, genDOMPropSegments(el.props, el.attrs));
  5321. }
  5322. // v-bind="object"
  5323. if ((binding = el.attrsMap['v-bind'])) {
  5324. segments.push({ type: EXPRESSION, value: ("_ssrAttrs(" + binding + ")") });
  5325. }
  5326. // v-bind.prop="object"
  5327. if ((binding = el.attrsMap['v-bind.prop'])) {
  5328. segments.push({ type: EXPRESSION, value: ("_ssrDOMProps(" + binding + ")") });
  5329. }
  5330. // class
  5331. if (el.staticClass || el.classBinding) {
  5332. segments.push.apply(
  5333. segments,
  5334. genClassSegments(el.staticClass, el.classBinding)
  5335. );
  5336. }
  5337. // style & v-show
  5338. if (el.staticStyle || el.styleBinding || el.attrsMap['v-show']) {
  5339. segments.push.apply(
  5340. segments,
  5341. genStyleSegments(
  5342. el.attrsMap.style,
  5343. el.staticStyle,
  5344. el.styleBinding,
  5345. el.attrsMap['v-show']
  5346. )
  5347. );
  5348. }
  5349. // _scopedId
  5350. if (state.options.scopeId) {
  5351. segments.push({ type: RAW, value: (" " + (state.options.scopeId)) });
  5352. }
  5353. segments.push({ type: RAW, value: ">" });
  5354. return segments
  5355. }
  5356. function childrenToSegments (el, state) {
  5357. var binding;
  5358. if ((binding = el.attrsMap['v-html'])) {
  5359. return [{ type: EXPRESSION, value: ("_s(" + binding + ")") }]
  5360. }
  5361. if ((binding = el.attrsMap['v-text'])) {
  5362. return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
  5363. }
  5364. if (el.tag === 'textarea' && (binding = el.attrsMap['v-model'])) {
  5365. return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
  5366. }
  5367. return el.children
  5368. ? nodesToSegments(el.children, state)
  5369. : []
  5370. }
  5371. function nodesToSegments (
  5372. children,
  5373. state
  5374. ) {
  5375. var segments = [];
  5376. for (var i = 0; i < children.length; i++) {
  5377. var c = children[i];
  5378. if (c.type === 1) {
  5379. segments.push.apply(segments, elementToSegments(c, state));
  5380. } else if (c.type === 2) {
  5381. segments.push({ type: INTERPOLATION, value: c.expression });
  5382. } else if (c.type === 3) {
  5383. var text = escape(c.text);
  5384. if (c.isComment) {
  5385. text = '<!--' + text + '-->';
  5386. }
  5387. segments.push({ type: RAW, value: text });
  5388. }
  5389. }
  5390. return segments
  5391. }
  5392. function flattenSegments (segments) {
  5393. var mergedSegments = [];
  5394. var textBuffer = '';
  5395. var pushBuffer = function () {
  5396. if (textBuffer) {
  5397. mergedSegments.push(JSON.stringify(textBuffer));
  5398. textBuffer = '';
  5399. }
  5400. };
  5401. for (var i = 0; i < segments.length; i++) {
  5402. var s = segments[i];
  5403. if (s.type === RAW) {
  5404. textBuffer += s.value;
  5405. } else if (s.type === INTERPOLATION) {
  5406. pushBuffer();
  5407. mergedSegments.push(("_ssrEscape(" + (s.value) + ")"));
  5408. } else if (s.type === EXPRESSION) {
  5409. pushBuffer();
  5410. mergedSegments.push(("(" + (s.value) + ")"));
  5411. }
  5412. }
  5413. pushBuffer();
  5414. return mergedSegments.join('+')
  5415. }
  5416. /* */
  5417. // these keywords should not appear inside expressions, but operators like
  5418. // typeof, instanceof and in are allowed
  5419. var prohibitedKeywordRE = new RegExp('\\b' + (
  5420. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  5421. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  5422. 'extends,finally,continue,debugger,function,arguments'
  5423. ).split(',').join('\\b|\\b') + '\\b');
  5424. // these unary operators should not be used as property/method names
  5425. var unaryOperatorsRE = new RegExp('\\b' + (
  5426. 'delete,typeof,void'
  5427. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  5428. // strip strings in expressions
  5429. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  5430. // detect problematic expressions in a template
  5431. function detectErrors (ast, warn) {
  5432. if (ast) {
  5433. checkNode(ast, warn);
  5434. }
  5435. }
  5436. function checkNode (node, warn) {
  5437. if (node.type === 1) {
  5438. for (var name in node.attrsMap) {
  5439. if (dirRE.test(name)) {
  5440. var value = node.attrsMap[name];
  5441. if (value) {
  5442. var range = node.rawAttrsMap[name];
  5443. if (name === 'v-for') {
  5444. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  5445. } else if (name === 'v-slot' || name[0] === '#') {
  5446. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  5447. } else if (onRE.test(name)) {
  5448. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  5449. } else {
  5450. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  5451. }
  5452. }
  5453. }
  5454. }
  5455. if (node.children) {
  5456. for (var i = 0; i < node.children.length; i++) {
  5457. checkNode(node.children[i], warn);
  5458. }
  5459. }
  5460. } else if (node.type === 2) {
  5461. checkExpression(node.expression, node.text, warn, node);
  5462. }
  5463. }
  5464. function checkEvent (exp, text, warn, range) {
  5465. var stripped = exp.replace(stripStringRE, '');
  5466. var keywordMatch = stripped.match(unaryOperatorsRE);
  5467. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  5468. warn(
  5469. "avoid using JavaScript unary operator as property name: " +
  5470. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  5471. range
  5472. );
  5473. }
  5474. checkExpression(exp, text, warn, range);
  5475. }
  5476. function checkFor (node, text, warn, range) {
  5477. checkExpression(node.for || '', text, warn, range);
  5478. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  5479. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  5480. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  5481. }
  5482. function checkIdentifier (
  5483. ident,
  5484. type,
  5485. text,
  5486. warn,
  5487. range
  5488. ) {
  5489. if (typeof ident === 'string') {
  5490. try {
  5491. new Function(("var " + ident + "=_"));
  5492. } catch (e) {
  5493. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  5494. }
  5495. }
  5496. }
  5497. function checkExpression (exp, text, warn, range) {
  5498. try {
  5499. new Function(("return " + exp));
  5500. } catch (e) {
  5501. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  5502. if (keywordMatch) {
  5503. warn(
  5504. "avoid using JavaScript keyword as property name: " +
  5505. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  5506. range
  5507. );
  5508. } else {
  5509. warn(
  5510. "invalid expression: " + (e.message) + " in\n\n" +
  5511. " " + exp + "\n\n" +
  5512. " Raw expression: " + (text.trim()) + "\n",
  5513. range
  5514. );
  5515. }
  5516. }
  5517. }
  5518. function checkFunctionParameterExpression (exp, text, warn, range) {
  5519. try {
  5520. new Function(exp, '');
  5521. } catch (e) {
  5522. warn(
  5523. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  5524. " " + exp + "\n\n" +
  5525. " Raw expression: " + (text.trim()) + "\n",
  5526. range
  5527. );
  5528. }
  5529. }
  5530. /* */
  5531. var range = 2;
  5532. function generateCodeFrame (
  5533. source,
  5534. start,
  5535. end
  5536. ) {
  5537. if ( start === void 0 ) start = 0;
  5538. if ( end === void 0 ) end = source.length;
  5539. var lines = source.split(/\r?\n/);
  5540. var count = 0;
  5541. var res = [];
  5542. for (var i = 0; i < lines.length; i++) {
  5543. count += lines[i].length + 1;
  5544. if (count >= start) {
  5545. for (var j = i - range; j <= i + range || end > count; j++) {
  5546. if (j < 0 || j >= lines.length) { continue }
  5547. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  5548. var lineLength = lines[j].length;
  5549. if (j === i) {
  5550. // push underline
  5551. var pad = start - (count - lineLength) + 1;
  5552. var length = end > count ? lineLength - pad : end - start;
  5553. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  5554. } else if (j > i) {
  5555. if (end > count) {
  5556. var length$1 = Math.min(end - count, lineLength);
  5557. res.push(" | " + repeat$1("^", length$1));
  5558. }
  5559. count += lineLength + 1;
  5560. }
  5561. }
  5562. break
  5563. }
  5564. }
  5565. return res.join('\n')
  5566. }
  5567. function repeat$1 (str, n) {
  5568. var result = '';
  5569. if (n > 0) {
  5570. while (true) { // eslint-disable-line
  5571. if (n & 1) { result += str; }
  5572. n >>>= 1;
  5573. if (n <= 0) { break }
  5574. str += str;
  5575. }
  5576. }
  5577. return result
  5578. }
  5579. /* */
  5580. function createFunction (code, errors) {
  5581. try {
  5582. return new Function(code)
  5583. } catch (err) {
  5584. errors.push({ err: err, code: code });
  5585. return noop
  5586. }
  5587. }
  5588. function createCompileToFunctionFn (compile) {
  5589. var cache = Object.create(null);
  5590. return function compileToFunctions (
  5591. template,
  5592. options,
  5593. vm
  5594. ) {
  5595. options = extend({}, options);
  5596. var warn$$1 = options.warn || warn;
  5597. delete options.warn;
  5598. /* istanbul ignore if */
  5599. {
  5600. // detect possible CSP restriction
  5601. try {
  5602. new Function('return 1');
  5603. } catch (e) {
  5604. if (e.toString().match(/unsafe-eval|CSP/)) {
  5605. warn$$1(
  5606. 'It seems you are using the standalone build of Vue.js in an ' +
  5607. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  5608. 'The template compiler cannot work in this environment. Consider ' +
  5609. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  5610. 'templates into render functions.'
  5611. );
  5612. }
  5613. }
  5614. }
  5615. // check cache
  5616. var key = options.delimiters
  5617. ? String(options.delimiters) + template
  5618. : template;
  5619. if (cache[key]) {
  5620. return cache[key]
  5621. }
  5622. // compile
  5623. var compiled = compile(template, options);
  5624. // check compilation errors/tips
  5625. {
  5626. if (compiled.errors && compiled.errors.length) {
  5627. if (options.outputSourceRange) {
  5628. compiled.errors.forEach(function (e) {
  5629. warn$$1(
  5630. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  5631. generateCodeFrame(template, e.start, e.end),
  5632. vm
  5633. );
  5634. });
  5635. } else {
  5636. warn$$1(
  5637. "Error compiling template:\n\n" + template + "\n\n" +
  5638. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  5639. vm
  5640. );
  5641. }
  5642. }
  5643. if (compiled.tips && compiled.tips.length) {
  5644. if (options.outputSourceRange) {
  5645. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  5646. } else {
  5647. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  5648. }
  5649. }
  5650. }
  5651. // turn code into functions
  5652. var res = {};
  5653. var fnGenErrors = [];
  5654. res.render = createFunction(compiled.render, fnGenErrors);
  5655. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  5656. return createFunction(code, fnGenErrors)
  5657. });
  5658. // check function generation errors.
  5659. // this should only happen if there is a bug in the compiler itself.
  5660. // mostly for codegen development use
  5661. /* istanbul ignore if */
  5662. {
  5663. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  5664. warn$$1(
  5665. "Failed to generate render function:\n\n" +
  5666. fnGenErrors.map(function (ref) {
  5667. var err = ref.err;
  5668. var code = ref.code;
  5669. return ((err.toString()) + " in\n\n" + code + "\n");
  5670. }).join('\n'),
  5671. vm
  5672. );
  5673. }
  5674. }
  5675. return (cache[key] = res)
  5676. }
  5677. }
  5678. /* */
  5679. function createCompilerCreator (baseCompile) {
  5680. return function createCompiler (baseOptions) {
  5681. function compile (
  5682. template,
  5683. options
  5684. ) {
  5685. var finalOptions = Object.create(baseOptions);
  5686. var errors = [];
  5687. var tips = [];
  5688. var warn = function (msg, range, tip) {
  5689. (tip ? tips : errors).push(msg);
  5690. };
  5691. if (options) {
  5692. if (options.outputSourceRange) {
  5693. // $flow-disable-line
  5694. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  5695. warn = function (msg, range, tip) {
  5696. var data = { msg: msg };
  5697. if (range) {
  5698. if (range.start != null) {
  5699. data.start = range.start + leadingSpaceLength;
  5700. }
  5701. if (range.end != null) {
  5702. data.end = range.end + leadingSpaceLength;
  5703. }
  5704. }
  5705. (tip ? tips : errors).push(data);
  5706. };
  5707. }
  5708. // merge custom modules
  5709. if (options.modules) {
  5710. finalOptions.modules =
  5711. (baseOptions.modules || []).concat(options.modules);
  5712. }
  5713. // merge custom directives
  5714. if (options.directives) {
  5715. finalOptions.directives = extend(
  5716. Object.create(baseOptions.directives || null),
  5717. options.directives
  5718. );
  5719. }
  5720. // copy other options
  5721. for (var key in options) {
  5722. if (key !== 'modules' && key !== 'directives') {
  5723. finalOptions[key] = options[key];
  5724. }
  5725. }
  5726. }
  5727. finalOptions.warn = warn;
  5728. var compiled = baseCompile(template.trim(), finalOptions);
  5729. {
  5730. detectErrors(compiled.ast, warn);
  5731. }
  5732. compiled.errors = errors;
  5733. compiled.tips = tips;
  5734. return compiled
  5735. }
  5736. return {
  5737. compile: compile,
  5738. compileToFunctions: createCompileToFunctionFn(compile)
  5739. }
  5740. }
  5741. }
  5742. /* */
  5743. var createCompiler = createCompilerCreator(function baseCompile (
  5744. template,
  5745. options
  5746. ) {
  5747. var ast = parse(template.trim(), options);
  5748. optimize(ast, options);
  5749. var code = generate$1(ast, options);
  5750. return {
  5751. ast: ast,
  5752. render: code.render,
  5753. staticRenderFns: code.staticRenderFns
  5754. }
  5755. });
  5756. /* */
  5757. var ref = createCompiler(baseOptions);
  5758. var compile = ref.compile;
  5759. var compileToFunctions = ref.compileToFunctions;
  5760. /* */
  5761. // The template compiler attempts to minimize the need for normalization by
  5762. // statically analyzing the template at compile time.
  5763. //
  5764. // For plain HTML markup, normalization can be completely skipped because the
  5765. // generated render function is guaranteed to return Array<VNode>. There are
  5766. // two cases where extra normalization is needed:
  5767. // 1. When the children contains components - because a functional component
  5768. // may return an Array instead of a single root. In this case, just a simple
  5769. // normalization is needed - if any child is an Array, we flatten the whole
  5770. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  5771. // because functional components already normalize their own children.
  5772. function simpleNormalizeChildren (children) {
  5773. for (var i = 0; i < children.length; i++) {
  5774. if (Array.isArray(children[i])) {
  5775. return Array.prototype.concat.apply([], children)
  5776. }
  5777. }
  5778. return children
  5779. }
  5780. // 2. When the children contains constructs that always generated nested Arrays,
  5781. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  5782. // with hand-written render functions / JSX. In such cases a full normalization
  5783. // is needed to cater to all possible types of children values.
  5784. function normalizeChildren (children) {
  5785. return isPrimitive(children)
  5786. ? [createTextVNode(children)]
  5787. : Array.isArray(children)
  5788. ? normalizeArrayChildren(children)
  5789. : undefined
  5790. }
  5791. function isTextNode (node) {
  5792. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  5793. }
  5794. function normalizeArrayChildren (children, nestedIndex) {
  5795. var res = [];
  5796. var i, c, lastIndex, last;
  5797. for (i = 0; i < children.length; i++) {
  5798. c = children[i];
  5799. if (isUndef(c) || typeof c === 'boolean') { continue }
  5800. lastIndex = res.length - 1;
  5801. last = res[lastIndex];
  5802. // nested
  5803. if (Array.isArray(c)) {
  5804. if (c.length > 0) {
  5805. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  5806. // merge adjacent text nodes
  5807. if (isTextNode(c[0]) && isTextNode(last)) {
  5808. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  5809. c.shift();
  5810. }
  5811. res.push.apply(res, c);
  5812. }
  5813. } else if (isPrimitive(c)) {
  5814. if (isTextNode(last)) {
  5815. // merge adjacent text nodes
  5816. // this is necessary for SSR hydration because text nodes are
  5817. // essentially merged when rendered to HTML strings
  5818. res[lastIndex] = createTextVNode(last.text + c);
  5819. } else if (c !== '') {
  5820. // convert primitive to vnode
  5821. res.push(createTextVNode(c));
  5822. }
  5823. } else {
  5824. if (isTextNode(c) && isTextNode(last)) {
  5825. // merge adjacent text nodes
  5826. res[lastIndex] = createTextVNode(last.text + c.text);
  5827. } else {
  5828. // default key for nested array children (likely generated by v-for)
  5829. if (isTrue(children._isVList) &&
  5830. isDef(c.tag) &&
  5831. isUndef(c.key) &&
  5832. isDef(nestedIndex)) {
  5833. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  5834. }
  5835. res.push(c);
  5836. }
  5837. }
  5838. }
  5839. return res
  5840. }
  5841. /* */
  5842. var ssrHelpers = {
  5843. _ssrEscape: escape,
  5844. _ssrNode: renderStringNode,
  5845. _ssrList: renderStringList,
  5846. _ssrAttr: renderAttr,
  5847. _ssrAttrs: renderAttrs$1,
  5848. _ssrDOMProps: renderDOMProps$1,
  5849. _ssrClass: renderSSRClass,
  5850. _ssrStyle: renderSSRStyle
  5851. };
  5852. function installSSRHelpers (vm) {
  5853. if (vm._ssrNode) {
  5854. return
  5855. }
  5856. var Vue = vm.constructor;
  5857. while (Vue.super) {
  5858. Vue = Vue.super;
  5859. }
  5860. extend(Vue.prototype, ssrHelpers);
  5861. if (Vue.FunctionalRenderContext) {
  5862. extend(Vue.FunctionalRenderContext.prototype, ssrHelpers);
  5863. }
  5864. }
  5865. var StringNode = function StringNode (
  5866. open,
  5867. close,
  5868. children,
  5869. normalizationType
  5870. ) {
  5871. this.isString = true;
  5872. this.open = open;
  5873. this.close = close;
  5874. if (children) {
  5875. this.children = normalizationType === 1
  5876. ? simpleNormalizeChildren(children)
  5877. : normalizationType === 2
  5878. ? normalizeChildren(children)
  5879. : children;
  5880. } else {
  5881. this.children = void 0;
  5882. }
  5883. };
  5884. function renderStringNode (
  5885. open,
  5886. close,
  5887. children,
  5888. normalizationType
  5889. ) {
  5890. return new StringNode(open, close, children, normalizationType)
  5891. }
  5892. function renderStringList (
  5893. val,
  5894. render
  5895. ) {
  5896. var ret = '';
  5897. var i, l, keys, key;
  5898. if (Array.isArray(val) || typeof val === 'string') {
  5899. for (i = 0, l = val.length; i < l; i++) {
  5900. ret += render(val[i], i);
  5901. }
  5902. } else if (typeof val === 'number') {
  5903. for (i = 0; i < val; i++) {
  5904. ret += render(i + 1, i);
  5905. }
  5906. } else if (isObject(val)) {
  5907. keys = Object.keys(val);
  5908. for (i = 0, l = keys.length; i < l; i++) {
  5909. key = keys[i];
  5910. ret += render(val[key], key, i);
  5911. }
  5912. }
  5913. return ret
  5914. }
  5915. function renderAttrs$1 (obj) {
  5916. var res = '';
  5917. for (var key in obj) {
  5918. if (isSSRUnsafeAttr(key)) {
  5919. continue
  5920. }
  5921. res += renderAttr(key, obj[key]);
  5922. }
  5923. return res
  5924. }
  5925. function renderDOMProps$1 (obj) {
  5926. var res = '';
  5927. for (var key in obj) {
  5928. var attr = propsToAttrMap[key] || key.toLowerCase();
  5929. if (isRenderableAttr(attr)) {
  5930. res += renderAttr(attr, obj[key]);
  5931. }
  5932. }
  5933. return res
  5934. }
  5935. function renderSSRClass (
  5936. staticClass,
  5937. dynamic
  5938. ) {
  5939. var res = renderClass(staticClass, dynamic);
  5940. return res === '' ? res : (" class=\"" + (escape(res)) + "\"")
  5941. }
  5942. function renderSSRStyle (
  5943. staticStyle,
  5944. dynamic,
  5945. extra
  5946. ) {
  5947. var style = {};
  5948. if (staticStyle) { extend(style, staticStyle); }
  5949. if (dynamic) { extend(style, normalizeStyleBinding(dynamic)); }
  5950. if (extra) { extend(style, extra); }
  5951. var res = genStyle(style);
  5952. return res === '' ? res : (" style=" + (JSON.stringify(escape(res))))
  5953. }
  5954. /* not type checking this file because flow doesn't play well with Proxy */
  5955. {
  5956. var allowedGlobals = makeMap(
  5957. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  5958. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  5959. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  5960. 'require' // for Webpack/Browserify
  5961. );
  5962. var hasProxy =
  5963. typeof Proxy !== 'undefined' && isNative(Proxy);
  5964. if (hasProxy) {
  5965. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  5966. config.keyCodes = new Proxy(config.keyCodes, {
  5967. set: function set (target, key, value) {
  5968. if (isBuiltInModifier(key)) {
  5969. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  5970. return false
  5971. } else {
  5972. target[key] = value;
  5973. return true
  5974. }
  5975. }
  5976. });
  5977. }
  5978. }
  5979. /* */
  5980. var seenObjects = new _Set();
  5981. /**
  5982. * Recursively traverse an object to evoke all converted
  5983. * getters, so that every nested property inside the object
  5984. * is collected as a "deep" dependency.
  5985. */
  5986. function traverse (val) {
  5987. _traverse(val, seenObjects);
  5988. seenObjects.clear();
  5989. }
  5990. function _traverse (val, seen) {
  5991. var i, keys;
  5992. var isA = Array.isArray(val);
  5993. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  5994. return
  5995. }
  5996. if (val.__ob__) {
  5997. var depId = val.__ob__.dep.id;
  5998. if (seen.has(depId)) {
  5999. return
  6000. }
  6001. seen.add(depId);
  6002. }
  6003. if (isA) {
  6004. i = val.length;
  6005. while (i--) { _traverse(val[i], seen); }
  6006. } else {
  6007. keys = Object.keys(val);
  6008. i = keys.length;
  6009. while (i--) { _traverse(val[keys[i]], seen); }
  6010. }
  6011. }
  6012. {
  6013. var perf = inBrowser && window.performance;
  6014. /* istanbul ignore if */
  6015. if (
  6016. perf &&
  6017. perf.mark &&
  6018. perf.measure &&
  6019. perf.clearMarks &&
  6020. perf.clearMeasures
  6021. ) ;
  6022. }
  6023. /* */
  6024. var normalizeEvent = cached(function (name) {
  6025. var passive = name.charAt(0) === '&';
  6026. name = passive ? name.slice(1) : name;
  6027. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  6028. name = once$$1 ? name.slice(1) : name;
  6029. var capture = name.charAt(0) === '!';
  6030. name = capture ? name.slice(1) : name;
  6031. return {
  6032. name: name,
  6033. once: once$$1,
  6034. capture: capture,
  6035. passive: passive
  6036. }
  6037. });
  6038. function createFnInvoker (fns, vm) {
  6039. function invoker () {
  6040. var arguments$1 = arguments;
  6041. var fns = invoker.fns;
  6042. if (Array.isArray(fns)) {
  6043. var cloned = fns.slice();
  6044. for (var i = 0; i < cloned.length; i++) {
  6045. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  6046. }
  6047. } else {
  6048. // return handler return value for single handlers
  6049. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  6050. }
  6051. }
  6052. invoker.fns = fns;
  6053. return invoker
  6054. }
  6055. function updateListeners (
  6056. on,
  6057. oldOn,
  6058. add,
  6059. remove$$1,
  6060. createOnceHandler,
  6061. vm
  6062. ) {
  6063. var name, def$$1, cur, old, event;
  6064. for (name in on) {
  6065. def$$1 = cur = on[name];
  6066. old = oldOn[name];
  6067. event = normalizeEvent(name);
  6068. if (isUndef(cur)) {
  6069. warn(
  6070. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  6071. vm
  6072. );
  6073. } else if (isUndef(old)) {
  6074. if (isUndef(cur.fns)) {
  6075. cur = on[name] = createFnInvoker(cur, vm);
  6076. }
  6077. if (isTrue(event.once)) {
  6078. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  6079. }
  6080. add(event.name, cur, event.capture, event.passive, event.params);
  6081. } else if (cur !== old) {
  6082. old.fns = cur;
  6083. on[name] = old;
  6084. }
  6085. }
  6086. for (name in oldOn) {
  6087. if (isUndef(on[name])) {
  6088. event = normalizeEvent(name);
  6089. remove$$1(event.name, oldOn[name], event.capture);
  6090. }
  6091. }
  6092. }
  6093. /* */
  6094. /* */
  6095. function extractPropsFromVNodeData (
  6096. data,
  6097. Ctor,
  6098. tag
  6099. ) {
  6100. // we are only extracting raw values here.
  6101. // validation and default values are handled in the child
  6102. // component itself.
  6103. var propOptions = Ctor.options.props;
  6104. if (isUndef(propOptions)) {
  6105. return
  6106. }
  6107. var res = {};
  6108. var attrs = data.attrs;
  6109. var props = data.props;
  6110. if (isDef(attrs) || isDef(props)) {
  6111. for (var key in propOptions) {
  6112. var altKey = hyphenate(key);
  6113. {
  6114. var keyInLowerCase = key.toLowerCase();
  6115. if (
  6116. key !== keyInLowerCase &&
  6117. attrs && hasOwn(attrs, keyInLowerCase)
  6118. ) {
  6119. tip(
  6120. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  6121. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  6122. " \"" + key + "\". " +
  6123. "Note that HTML attributes are case-insensitive and camelCased " +
  6124. "props need to use their kebab-case equivalents when using in-DOM " +
  6125. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  6126. );
  6127. }
  6128. }
  6129. checkProp(res, props, key, altKey, true) ||
  6130. checkProp(res, attrs, key, altKey, false);
  6131. }
  6132. }
  6133. return res
  6134. }
  6135. function checkProp (
  6136. res,
  6137. hash,
  6138. key,
  6139. altKey,
  6140. preserve
  6141. ) {
  6142. if (isDef(hash)) {
  6143. if (hasOwn(hash, key)) {
  6144. res[key] = hash[key];
  6145. if (!preserve) {
  6146. delete hash[key];
  6147. }
  6148. return true
  6149. } else if (hasOwn(hash, altKey)) {
  6150. res[key] = hash[altKey];
  6151. if (!preserve) {
  6152. delete hash[altKey];
  6153. }
  6154. return true
  6155. }
  6156. }
  6157. return false
  6158. }
  6159. /* */
  6160. var SIMPLE_NORMALIZE = 1;
  6161. var ALWAYS_NORMALIZE = 2;
  6162. // wrapper function for providing a more flexible interface
  6163. // without getting yelled at by flow
  6164. function createElement (
  6165. context,
  6166. tag,
  6167. data,
  6168. children,
  6169. normalizationType,
  6170. alwaysNormalize
  6171. ) {
  6172. if (Array.isArray(data) || isPrimitive(data)) {
  6173. normalizationType = children;
  6174. children = data;
  6175. data = undefined;
  6176. }
  6177. if (isTrue(alwaysNormalize)) {
  6178. normalizationType = ALWAYS_NORMALIZE;
  6179. }
  6180. return _createElement(context, tag, data, children, normalizationType)
  6181. }
  6182. function _createElement (
  6183. context,
  6184. tag,
  6185. data,
  6186. children,
  6187. normalizationType
  6188. ) {
  6189. if (isDef(data) && isDef((data).__ob__)) {
  6190. warn(
  6191. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  6192. 'Always create fresh vnode data objects in each render!',
  6193. context
  6194. );
  6195. return createEmptyVNode()
  6196. }
  6197. // object syntax in v-bind
  6198. if (isDef(data) && isDef(data.is)) {
  6199. tag = data.is;
  6200. }
  6201. if (!tag) {
  6202. // in case of component :is set to falsy value
  6203. return createEmptyVNode()
  6204. }
  6205. // warn against non-primitive key
  6206. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  6207. ) {
  6208. {
  6209. warn(
  6210. 'Avoid using non-primitive value as key, ' +
  6211. 'use string/number value instead.',
  6212. context
  6213. );
  6214. }
  6215. }
  6216. // support single function children as default scoped slot
  6217. if (Array.isArray(children) &&
  6218. typeof children[0] === 'function'
  6219. ) {
  6220. data = data || {};
  6221. data.scopedSlots = { default: children[0] };
  6222. children.length = 0;
  6223. }
  6224. if (normalizationType === ALWAYS_NORMALIZE) {
  6225. children = normalizeChildren(children);
  6226. } else if (normalizationType === SIMPLE_NORMALIZE) {
  6227. children = simpleNormalizeChildren(children);
  6228. }
  6229. var vnode, ns;
  6230. if (typeof tag === 'string') {
  6231. var Ctor;
  6232. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  6233. if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  6234. // component
  6235. vnode = createComponent(Ctor, data, context, children, tag);
  6236. } else {
  6237. // unknown or unlisted namespaced elements
  6238. // check at runtime because it may get assigned a namespace when its
  6239. // parent normalizes children
  6240. vnode = new VNode(
  6241. tag, data, children,
  6242. undefined, undefined, context
  6243. );
  6244. }
  6245. } else {
  6246. // direct component options / constructor
  6247. vnode = createComponent(tag, data, context, children);
  6248. }
  6249. if (Array.isArray(vnode)) {
  6250. return vnode
  6251. } else if (isDef(vnode)) {
  6252. if (isDef(ns)) { applyNS(vnode, ns); }
  6253. if (isDef(data)) { registerDeepBindings(data); }
  6254. return vnode
  6255. } else {
  6256. return createEmptyVNode()
  6257. }
  6258. }
  6259. function applyNS (vnode, ns, force) {
  6260. vnode.ns = ns;
  6261. if (vnode.tag === 'foreignObject') {
  6262. // use default namespace inside foreignObject
  6263. ns = undefined;
  6264. force = true;
  6265. }
  6266. if (isDef(vnode.children)) {
  6267. for (var i = 0, l = vnode.children.length; i < l; i++) {
  6268. var child = vnode.children[i];
  6269. if (isDef(child.tag) && (
  6270. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  6271. applyNS(child, ns, force);
  6272. }
  6273. }
  6274. }
  6275. }
  6276. // ref #5318
  6277. // necessary to ensure parent re-render when deep bindings like :style and
  6278. // :class are used on slot nodes
  6279. function registerDeepBindings (data) {
  6280. if (isObject(data.style)) {
  6281. traverse(data.style);
  6282. }
  6283. if (isObject(data.class)) {
  6284. traverse(data.class);
  6285. }
  6286. }
  6287. /* */
  6288. /**
  6289. * Runtime helper for rendering v-for lists.
  6290. */
  6291. function renderList (
  6292. val,
  6293. render
  6294. ) {
  6295. var ret, i, l, keys, key;
  6296. if (Array.isArray(val) || typeof val === 'string') {
  6297. ret = new Array(val.length);
  6298. for (i = 0, l = val.length; i < l; i++) {
  6299. ret[i] = render(val[i], i);
  6300. }
  6301. } else if (typeof val === 'number') {
  6302. ret = new Array(val);
  6303. for (i = 0; i < val; i++) {
  6304. ret[i] = render(i + 1, i);
  6305. }
  6306. } else if (isObject(val)) {
  6307. if (hasSymbol && val[Symbol.iterator]) {
  6308. ret = [];
  6309. var iterator = val[Symbol.iterator]();
  6310. var result = iterator.next();
  6311. while (!result.done) {
  6312. ret.push(render(result.value, ret.length));
  6313. result = iterator.next();
  6314. }
  6315. } else {
  6316. keys = Object.keys(val);
  6317. ret = new Array(keys.length);
  6318. for (i = 0, l = keys.length; i < l; i++) {
  6319. key = keys[i];
  6320. ret[i] = render(val[key], key, i);
  6321. }
  6322. }
  6323. }
  6324. if (!isDef(ret)) {
  6325. ret = [];
  6326. }
  6327. (ret)._isVList = true;
  6328. return ret
  6329. }
  6330. /* */
  6331. /**
  6332. * Runtime helper for rendering <slot>
  6333. */
  6334. function renderSlot (
  6335. name,
  6336. fallbackRender,
  6337. props,
  6338. bindObject
  6339. ) {
  6340. var scopedSlotFn = this.$scopedSlots[name];
  6341. var nodes;
  6342. if (scopedSlotFn) {
  6343. // scoped slot
  6344. props = props || {};
  6345. if (bindObject) {
  6346. if (!isObject(bindObject)) {
  6347. warn('slot v-bind without argument expects an Object', this);
  6348. }
  6349. props = extend(extend({}, bindObject), props);
  6350. }
  6351. nodes =
  6352. scopedSlotFn(props) ||
  6353. (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender);
  6354. } else {
  6355. nodes =
  6356. this.$slots[name] ||
  6357. (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender);
  6358. }
  6359. var target = props && props.slot;
  6360. if (target) {
  6361. return this.$createElement('template', { slot: target }, nodes)
  6362. } else {
  6363. return nodes
  6364. }
  6365. }
  6366. /* */
  6367. /**
  6368. * Runtime helper for resolving filters
  6369. */
  6370. function resolveFilter (id) {
  6371. return resolveAsset(this.$options, 'filters', id, true) || identity
  6372. }
  6373. /* */
  6374. function isKeyNotMatch (expect, actual) {
  6375. if (Array.isArray(expect)) {
  6376. return expect.indexOf(actual) === -1
  6377. } else {
  6378. return expect !== actual
  6379. }
  6380. }
  6381. /**
  6382. * Runtime helper for checking keyCodes from config.
  6383. * exposed as Vue.prototype._k
  6384. * passing in eventKeyName as last argument separately for backwards compat
  6385. */
  6386. function checkKeyCodes (
  6387. eventKeyCode,
  6388. key,
  6389. builtInKeyCode,
  6390. eventKeyName,
  6391. builtInKeyName
  6392. ) {
  6393. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  6394. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  6395. return isKeyNotMatch(builtInKeyName, eventKeyName)
  6396. } else if (mappedKeyCode) {
  6397. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  6398. } else if (eventKeyName) {
  6399. return hyphenate(eventKeyName) !== key
  6400. }
  6401. return eventKeyCode === undefined
  6402. }
  6403. /* */
  6404. /**
  6405. * Runtime helper for merging v-bind="object" into a VNode's data.
  6406. */
  6407. function bindObjectProps (
  6408. data,
  6409. tag,
  6410. value,
  6411. asProp,
  6412. isSync
  6413. ) {
  6414. if (value) {
  6415. if (!isObject(value)) {
  6416. warn(
  6417. 'v-bind without argument expects an Object or Array value',
  6418. this
  6419. );
  6420. } else {
  6421. if (Array.isArray(value)) {
  6422. value = toObject(value);
  6423. }
  6424. var hash;
  6425. var loop = function ( key ) {
  6426. if (
  6427. key === 'class' ||
  6428. key === 'style' ||
  6429. isReservedAttribute(key)
  6430. ) {
  6431. hash = data;
  6432. } else {
  6433. var type = data.attrs && data.attrs.type;
  6434. hash = asProp || config.mustUseProp(tag, type, key)
  6435. ? data.domProps || (data.domProps = {})
  6436. : data.attrs || (data.attrs = {});
  6437. }
  6438. var camelizedKey = camelize(key);
  6439. var hyphenatedKey = hyphenate(key);
  6440. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  6441. hash[key] = value[key];
  6442. if (isSync) {
  6443. var on = data.on || (data.on = {});
  6444. on[("update:" + key)] = function ($event) {
  6445. value[key] = $event;
  6446. };
  6447. }
  6448. }
  6449. };
  6450. for (var key in value) loop( key );
  6451. }
  6452. }
  6453. return data
  6454. }
  6455. /* */
  6456. /**
  6457. * Runtime helper for rendering static trees.
  6458. */
  6459. function renderStatic (
  6460. index,
  6461. isInFor
  6462. ) {
  6463. var cached = this._staticTrees || (this._staticTrees = []);
  6464. var tree = cached[index];
  6465. // if has already-rendered static tree and not inside v-for,
  6466. // we can reuse the same tree.
  6467. if (tree && !isInFor) {
  6468. return tree
  6469. }
  6470. // otherwise, render a fresh tree.
  6471. tree = cached[index] = this.$options.staticRenderFns[index].call(
  6472. this._renderProxy,
  6473. null,
  6474. this // for render fns generated for functional component templates
  6475. );
  6476. markStatic(tree, ("__static__" + index), false);
  6477. return tree
  6478. }
  6479. /**
  6480. * Runtime helper for v-once.
  6481. * Effectively it means marking the node as static with a unique key.
  6482. */
  6483. function markOnce (
  6484. tree,
  6485. index,
  6486. key
  6487. ) {
  6488. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  6489. return tree
  6490. }
  6491. function markStatic (
  6492. tree,
  6493. key,
  6494. isOnce
  6495. ) {
  6496. if (Array.isArray(tree)) {
  6497. for (var i = 0; i < tree.length; i++) {
  6498. if (tree[i] && typeof tree[i] !== 'string') {
  6499. markStaticNode(tree[i], (key + "_" + i), isOnce);
  6500. }
  6501. }
  6502. } else {
  6503. markStaticNode(tree, key, isOnce);
  6504. }
  6505. }
  6506. function markStaticNode (node, key, isOnce) {
  6507. node.isStatic = true;
  6508. node.key = key;
  6509. node.isOnce = isOnce;
  6510. }
  6511. /* */
  6512. function bindObjectListeners (data, value) {
  6513. if (value) {
  6514. if (!isPlainObject(value)) {
  6515. warn(
  6516. 'v-on without argument expects an Object value',
  6517. this
  6518. );
  6519. } else {
  6520. var on = data.on = data.on ? extend({}, data.on) : {};
  6521. for (var key in value) {
  6522. var existing = on[key];
  6523. var ours = value[key];
  6524. on[key] = existing ? [].concat(existing, ours) : ours;
  6525. }
  6526. }
  6527. }
  6528. return data
  6529. }
  6530. /* */
  6531. function resolveScopedSlots (
  6532. fns, // see flow/vnode
  6533. res,
  6534. // the following are added in 2.6
  6535. hasDynamicKeys,
  6536. contentHashKey
  6537. ) {
  6538. res = res || { $stable: !hasDynamicKeys };
  6539. for (var i = 0; i < fns.length; i++) {
  6540. var slot = fns[i];
  6541. if (Array.isArray(slot)) {
  6542. resolveScopedSlots(slot, res, hasDynamicKeys);
  6543. } else if (slot) {
  6544. // marker for reverse proxying v-slot without scope on this.$slots
  6545. if (slot.proxy) {
  6546. slot.fn.proxy = true;
  6547. }
  6548. res[slot.key] = slot.fn;
  6549. }
  6550. }
  6551. if (contentHashKey) {
  6552. (res).$key = contentHashKey;
  6553. }
  6554. return res
  6555. }
  6556. /* */
  6557. function bindDynamicKeys (baseObj, values) {
  6558. for (var i = 0; i < values.length; i += 2) {
  6559. var key = values[i];
  6560. if (typeof key === 'string' && key) {
  6561. baseObj[values[i]] = values[i + 1];
  6562. } else if (key !== '' && key !== null) {
  6563. // null is a special value for explicitly removing a binding
  6564. warn(
  6565. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  6566. this
  6567. );
  6568. }
  6569. }
  6570. return baseObj
  6571. }
  6572. // helper to dynamically append modifier runtime markers to event names.
  6573. // ensure only append when value is already string, otherwise it will be cast
  6574. // to string and cause the type check to miss.
  6575. function prependModifier (value, symbol) {
  6576. return typeof value === 'string' ? symbol + value : value
  6577. }
  6578. /* */
  6579. function installRenderHelpers (target) {
  6580. target._o = markOnce;
  6581. target._n = toNumber;
  6582. target._s = toString;
  6583. target._l = renderList;
  6584. target._t = renderSlot;
  6585. target._q = looseEqual;
  6586. target._i = looseIndexOf;
  6587. target._m = renderStatic;
  6588. target._f = resolveFilter;
  6589. target._k = checkKeyCodes;
  6590. target._b = bindObjectProps;
  6591. target._v = createTextVNode;
  6592. target._e = createEmptyVNode;
  6593. target._u = resolveScopedSlots;
  6594. target._g = bindObjectListeners;
  6595. target._d = bindDynamicKeys;
  6596. target._p = prependModifier;
  6597. }
  6598. /* */
  6599. /**
  6600. * Runtime helper for resolving raw children VNodes into a slot object.
  6601. */
  6602. function resolveSlots (
  6603. children,
  6604. context
  6605. ) {
  6606. if (!children || !children.length) {
  6607. return {}
  6608. }
  6609. var slots = {};
  6610. for (var i = 0, l = children.length; i < l; i++) {
  6611. var child = children[i];
  6612. var data = child.data;
  6613. // remove slot attribute if the node is resolved as a Vue slot node
  6614. if (data && data.attrs && data.attrs.slot) {
  6615. delete data.attrs.slot;
  6616. }
  6617. // named slots should only be respected if the vnode was rendered in the
  6618. // same context.
  6619. if ((child.context === context || child.fnContext === context) &&
  6620. data && data.slot != null
  6621. ) {
  6622. var name = data.slot;
  6623. var slot = (slots[name] || (slots[name] = []));
  6624. if (child.tag === 'template') {
  6625. slot.push.apply(slot, child.children || []);
  6626. } else {
  6627. slot.push(child);
  6628. }
  6629. } else {
  6630. (slots.default || (slots.default = [])).push(child);
  6631. }
  6632. }
  6633. // ignore slots that contains only whitespace
  6634. for (var name$1 in slots) {
  6635. if (slots[name$1].every(isWhitespace)) {
  6636. delete slots[name$1];
  6637. }
  6638. }
  6639. return slots
  6640. }
  6641. function isWhitespace (node) {
  6642. return (node.isComment && !node.asyncFactory) || node.text === ' '
  6643. }
  6644. /* */
  6645. function isAsyncPlaceholder (node) {
  6646. return node.isComment && node.asyncFactory
  6647. }
  6648. /* */
  6649. function normalizeScopedSlots (
  6650. slots,
  6651. normalSlots,
  6652. prevSlots
  6653. ) {
  6654. var res;
  6655. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  6656. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  6657. var key = slots && slots.$key;
  6658. if (!slots) {
  6659. res = {};
  6660. } else if (slots._normalized) {
  6661. // fast path 1: child component re-render only, parent did not change
  6662. return slots._normalized
  6663. } else if (
  6664. isStable &&
  6665. prevSlots &&
  6666. prevSlots !== emptyObject &&
  6667. key === prevSlots.$key &&
  6668. !hasNormalSlots &&
  6669. !prevSlots.$hasNormal
  6670. ) {
  6671. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  6672. // only need to normalize once
  6673. return prevSlots
  6674. } else {
  6675. res = {};
  6676. for (var key$1 in slots) {
  6677. if (slots[key$1] && key$1[0] !== '$') {
  6678. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  6679. }
  6680. }
  6681. }
  6682. // expose normal slots on scopedSlots
  6683. for (var key$2 in normalSlots) {
  6684. if (!(key$2 in res)) {
  6685. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  6686. }
  6687. }
  6688. // avoriaz seems to mock a non-extensible $scopedSlots object
  6689. // and when that is passed down this would cause an error
  6690. if (slots && Object.isExtensible(slots)) {
  6691. (slots)._normalized = res;
  6692. }
  6693. def(res, '$stable', isStable);
  6694. def(res, '$key', key);
  6695. def(res, '$hasNormal', hasNormalSlots);
  6696. return res
  6697. }
  6698. function normalizeScopedSlot(normalSlots, key, fn) {
  6699. var normalized = function () {
  6700. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  6701. res = res && typeof res === 'object' && !Array.isArray(res)
  6702. ? [res] // single vnode
  6703. : normalizeChildren(res);
  6704. var vnode = res && res[0];
  6705. return res && (
  6706. !vnode ||
  6707. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode)) // #9658, #10391
  6708. ) ? undefined
  6709. : res
  6710. };
  6711. // this is a slot using the new v-slot syntax without scope. although it is
  6712. // compiled as a scoped slot, render fn users would expect it to be present
  6713. // on this.$slots because the usage is semantically a normal slot.
  6714. if (fn.proxy) {
  6715. Object.defineProperty(normalSlots, key, {
  6716. get: normalized,
  6717. enumerable: true,
  6718. configurable: true
  6719. });
  6720. }
  6721. return normalized
  6722. }
  6723. function proxyNormalSlot(slots, key) {
  6724. return function () { return slots[key]; }
  6725. }
  6726. /* */
  6727. var currentRenderingInstance = null;
  6728. /* */
  6729. function ensureCtor (comp, base) {
  6730. if (
  6731. comp.__esModule ||
  6732. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  6733. ) {
  6734. comp = comp.default;
  6735. }
  6736. return isObject(comp)
  6737. ? base.extend(comp)
  6738. : comp
  6739. }
  6740. function createAsyncPlaceholder (
  6741. factory,
  6742. data,
  6743. context,
  6744. children,
  6745. tag
  6746. ) {
  6747. var node = createEmptyVNode();
  6748. node.asyncFactory = factory;
  6749. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  6750. return node
  6751. }
  6752. function resolveAsyncComponent (
  6753. factory,
  6754. baseCtor
  6755. ) {
  6756. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  6757. return factory.errorComp
  6758. }
  6759. if (isDef(factory.resolved)) {
  6760. return factory.resolved
  6761. }
  6762. var owner = currentRenderingInstance;
  6763. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  6764. // already pending
  6765. factory.owners.push(owner);
  6766. }
  6767. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  6768. return factory.loadingComp
  6769. }
  6770. if (owner && !isDef(factory.owners)) {
  6771. var owners = factory.owners = [owner];
  6772. var sync = true;
  6773. var timerLoading = null;
  6774. var timerTimeout = null
  6775. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  6776. var forceRender = function (renderCompleted) {
  6777. for (var i = 0, l = owners.length; i < l; i++) {
  6778. (owners[i]).$forceUpdate();
  6779. }
  6780. if (renderCompleted) {
  6781. owners.length = 0;
  6782. if (timerLoading !== null) {
  6783. clearTimeout(timerLoading);
  6784. timerLoading = null;
  6785. }
  6786. if (timerTimeout !== null) {
  6787. clearTimeout(timerTimeout);
  6788. timerTimeout = null;
  6789. }
  6790. }
  6791. };
  6792. var resolve = once(function (res) {
  6793. // cache resolved
  6794. factory.resolved = ensureCtor(res, baseCtor);
  6795. // invoke callbacks only if this is not a synchronous resolve
  6796. // (async resolves are shimmed as synchronous during SSR)
  6797. if (!sync) {
  6798. forceRender(true);
  6799. } else {
  6800. owners.length = 0;
  6801. }
  6802. });
  6803. var reject = once(function (reason) {
  6804. warn(
  6805. "Failed to resolve async component: " + (String(factory)) +
  6806. (reason ? ("\nReason: " + reason) : '')
  6807. );
  6808. if (isDef(factory.errorComp)) {
  6809. factory.error = true;
  6810. forceRender(true);
  6811. }
  6812. });
  6813. var res = factory(resolve, reject);
  6814. if (isObject(res)) {
  6815. if (isPromise(res)) {
  6816. // () => Promise
  6817. if (isUndef(factory.resolved)) {
  6818. res.then(resolve, reject);
  6819. }
  6820. } else if (isPromise(res.component)) {
  6821. res.component.then(resolve, reject);
  6822. if (isDef(res.error)) {
  6823. factory.errorComp = ensureCtor(res.error, baseCtor);
  6824. }
  6825. if (isDef(res.loading)) {
  6826. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  6827. if (res.delay === 0) {
  6828. factory.loading = true;
  6829. } else {
  6830. timerLoading = setTimeout(function () {
  6831. timerLoading = null;
  6832. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  6833. factory.loading = true;
  6834. forceRender(false);
  6835. }
  6836. }, res.delay || 200);
  6837. }
  6838. }
  6839. if (isDef(res.timeout)) {
  6840. timerTimeout = setTimeout(function () {
  6841. timerTimeout = null;
  6842. if (isUndef(factory.resolved)) {
  6843. reject(
  6844. "timeout (" + (res.timeout) + "ms)"
  6845. );
  6846. }
  6847. }, res.timeout);
  6848. }
  6849. }
  6850. }
  6851. sync = false;
  6852. // return in case resolved synchronously
  6853. return factory.loading
  6854. ? factory.loadingComp
  6855. : factory.resolved
  6856. }
  6857. }
  6858. /* */
  6859. /* */
  6860. /* */
  6861. var target;
  6862. function add (event, fn) {
  6863. target.$on(event, fn);
  6864. }
  6865. function remove$1 (event, fn) {
  6866. target.$off(event, fn);
  6867. }
  6868. function createOnceHandler (event, fn) {
  6869. var _target = target;
  6870. return function onceHandler () {
  6871. var res = fn.apply(null, arguments);
  6872. if (res !== null) {
  6873. _target.$off(event, onceHandler);
  6874. }
  6875. }
  6876. }
  6877. function updateComponentListeners (
  6878. vm,
  6879. listeners,
  6880. oldListeners
  6881. ) {
  6882. target = vm;
  6883. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  6884. target = undefined;
  6885. }
  6886. /* */
  6887. var activeInstance = null;
  6888. function updateChildComponent (
  6889. vm,
  6890. propsData,
  6891. listeners,
  6892. parentVnode,
  6893. renderChildren
  6894. ) {
  6895. // determine whether component has slot children
  6896. // we need to do this before overwriting $options._renderChildren.
  6897. // check if there are dynamic scopedSlots (hand-written or compiled but with
  6898. // dynamic slot names). Static scoped slots compiled from template has the
  6899. // "$stable" marker.
  6900. var newScopedSlots = parentVnode.data.scopedSlots;
  6901. var oldScopedSlots = vm.$scopedSlots;
  6902. var hasDynamicScopedSlot = !!(
  6903. (newScopedSlots && !newScopedSlots.$stable) ||
  6904. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  6905. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  6906. (!newScopedSlots && vm.$scopedSlots.$key)
  6907. );
  6908. // Any static slot children from the parent may have changed during parent's
  6909. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  6910. // update is necessary to ensure correctness.
  6911. var needsForceUpdate = !!(
  6912. renderChildren || // has new static slots
  6913. vm.$options._renderChildren || // has old static slots
  6914. hasDynamicScopedSlot
  6915. );
  6916. vm.$options._parentVnode = parentVnode;
  6917. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  6918. if (vm._vnode) { // update child tree's parent
  6919. vm._vnode.parent = parentVnode;
  6920. }
  6921. vm.$options._renderChildren = renderChildren;
  6922. // update $attrs and $listeners hash
  6923. // these are also reactive so they may trigger child update if the child
  6924. // used them during render
  6925. vm.$attrs = parentVnode.data.attrs || emptyObject;
  6926. vm.$listeners = listeners || emptyObject;
  6927. // update props
  6928. if (propsData && vm.$options.props) {
  6929. toggleObserving(false);
  6930. var props = vm._props;
  6931. var propKeys = vm.$options._propKeys || [];
  6932. for (var i = 0; i < propKeys.length; i++) {
  6933. var key = propKeys[i];
  6934. var propOptions = vm.$options.props; // wtf flow?
  6935. props[key] = validateProp(key, propOptions, propsData, vm);
  6936. }
  6937. toggleObserving(true);
  6938. // keep a copy of raw propsData
  6939. vm.$options.propsData = propsData;
  6940. }
  6941. // update listeners
  6942. listeners = listeners || emptyObject;
  6943. var oldListeners = vm.$options._parentListeners;
  6944. vm.$options._parentListeners = listeners;
  6945. updateComponentListeners(vm, listeners, oldListeners);
  6946. // resolve slots + force update if has children
  6947. if (needsForceUpdate) {
  6948. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  6949. vm.$forceUpdate();
  6950. }
  6951. }
  6952. function isInInactiveTree (vm) {
  6953. while (vm && (vm = vm.$parent)) {
  6954. if (vm._inactive) { return true }
  6955. }
  6956. return false
  6957. }
  6958. function activateChildComponent (vm, direct) {
  6959. if (direct) {
  6960. vm._directInactive = false;
  6961. if (isInInactiveTree(vm)) {
  6962. return
  6963. }
  6964. } else if (vm._directInactive) {
  6965. return
  6966. }
  6967. if (vm._inactive || vm._inactive === null) {
  6968. vm._inactive = false;
  6969. for (var i = 0; i < vm.$children.length; i++) {
  6970. activateChildComponent(vm.$children[i]);
  6971. }
  6972. callHook(vm, 'activated');
  6973. }
  6974. }
  6975. function deactivateChildComponent (vm, direct) {
  6976. if (direct) {
  6977. vm._directInactive = true;
  6978. if (isInInactiveTree(vm)) {
  6979. return
  6980. }
  6981. }
  6982. if (!vm._inactive) {
  6983. vm._inactive = true;
  6984. for (var i = 0; i < vm.$children.length; i++) {
  6985. deactivateChildComponent(vm.$children[i]);
  6986. }
  6987. callHook(vm, 'deactivated');
  6988. }
  6989. }
  6990. function callHook (vm, hook) {
  6991. // #7573 disable dep collection when invoking lifecycle hooks
  6992. pushTarget();
  6993. var handlers = vm.$options[hook];
  6994. var info = hook + " hook";
  6995. if (handlers) {
  6996. for (var i = 0, j = handlers.length; i < j; i++) {
  6997. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  6998. }
  6999. }
  7000. if (vm._hasHookEvent) {
  7001. vm.$emit('hook:' + hook);
  7002. }
  7003. popTarget();
  7004. }
  7005. /* */
  7006. // Async edge case fix requires storing an event listener's attach timestamp.
  7007. var getNow = Date.now;
  7008. // Determine what event timestamp the browser is using. Annoyingly, the
  7009. // timestamp can either be hi-res (relative to page load) or low-res
  7010. // (relative to UNIX epoch), so in order to compare time we have to use the
  7011. // same timestamp type when saving the flush timestamp.
  7012. // All IE versions use low-res event timestamps, and have problematic clock
  7013. // implementations (#9632)
  7014. if (inBrowser && !isIE) {
  7015. var performance = window.performance;
  7016. if (
  7017. performance &&
  7018. typeof performance.now === 'function' &&
  7019. getNow() > document.createEvent('Event').timeStamp
  7020. ) {
  7021. // if the event timestamp, although evaluated AFTER the Date.now(), is
  7022. // smaller than it, it means the event is using a hi-res timestamp,
  7023. // and we need to use the hi-res version for event listener timestamps as
  7024. // well.
  7025. getNow = function () { return performance.now(); };
  7026. }
  7027. }
  7028. /**
  7029. * Queue a kept-alive component that was activated during patch.
  7030. * The queue will be processed after the entire tree has been patched.
  7031. */
  7032. function queueActivatedComponent (vm) {
  7033. // setting _inactive to false here so that a render function can
  7034. // rely on checking whether it's in an inactive tree (e.g. router-view)
  7035. vm._inactive = false;
  7036. }
  7037. /* */
  7038. /* */
  7039. /* */
  7040. function resolveInject (inject, vm) {
  7041. if (inject) {
  7042. // inject is :any because flow is not smart enough to figure out cached
  7043. var result = Object.create(null);
  7044. var keys = hasSymbol
  7045. ? Reflect.ownKeys(inject)
  7046. : Object.keys(inject);
  7047. for (var i = 0; i < keys.length; i++) {
  7048. var key = keys[i];
  7049. // #6574 in case the inject object is observed...
  7050. if (key === '__ob__') { continue }
  7051. var provideKey = inject[key].from;
  7052. var source = vm;
  7053. while (source) {
  7054. if (source._provided && hasOwn(source._provided, provideKey)) {
  7055. result[key] = source._provided[provideKey];
  7056. break
  7057. }
  7058. source = source.$parent;
  7059. }
  7060. if (!source) {
  7061. if ('default' in inject[key]) {
  7062. var provideDefault = inject[key].default;
  7063. result[key] = typeof provideDefault === 'function'
  7064. ? provideDefault.call(vm)
  7065. : provideDefault;
  7066. } else {
  7067. warn(("Injection \"" + key + "\" not found"), vm);
  7068. }
  7069. }
  7070. }
  7071. return result
  7072. }
  7073. }
  7074. /* */
  7075. function resolveConstructorOptions (Ctor) {
  7076. var options = Ctor.options;
  7077. if (Ctor.super) {
  7078. var superOptions = resolveConstructorOptions(Ctor.super);
  7079. var cachedSuperOptions = Ctor.superOptions;
  7080. if (superOptions !== cachedSuperOptions) {
  7081. // super option changed,
  7082. // need to resolve new options.
  7083. Ctor.superOptions = superOptions;
  7084. // check if there are any late-modified/attached options (#4976)
  7085. var modifiedOptions = resolveModifiedOptions(Ctor);
  7086. // update base extend options
  7087. if (modifiedOptions) {
  7088. extend(Ctor.extendOptions, modifiedOptions);
  7089. }
  7090. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  7091. if (options.name) {
  7092. options.components[options.name] = Ctor;
  7093. }
  7094. }
  7095. }
  7096. return options
  7097. }
  7098. function resolveModifiedOptions (Ctor) {
  7099. var modified;
  7100. var latest = Ctor.options;
  7101. var sealed = Ctor.sealedOptions;
  7102. for (var key in latest) {
  7103. if (latest[key] !== sealed[key]) {
  7104. if (!modified) { modified = {}; }
  7105. modified[key] = latest[key];
  7106. }
  7107. }
  7108. return modified
  7109. }
  7110. /* */
  7111. function FunctionalRenderContext (
  7112. data,
  7113. props,
  7114. children,
  7115. parent,
  7116. Ctor
  7117. ) {
  7118. var this$1 = this;
  7119. var options = Ctor.options;
  7120. // ensure the createElement function in functional components
  7121. // gets a unique context - this is necessary for correct named slot check
  7122. var contextVm;
  7123. if (hasOwn(parent, '_uid')) {
  7124. contextVm = Object.create(parent);
  7125. // $flow-disable-line
  7126. contextVm._original = parent;
  7127. } else {
  7128. // the context vm passed in is a functional context as well.
  7129. // in this case we want to make sure we are able to get a hold to the
  7130. // real context instance.
  7131. contextVm = parent;
  7132. // $flow-disable-line
  7133. parent = parent._original;
  7134. }
  7135. var isCompiled = isTrue(options._compiled);
  7136. var needNormalization = !isCompiled;
  7137. this.data = data;
  7138. this.props = props;
  7139. this.children = children;
  7140. this.parent = parent;
  7141. this.listeners = data.on || emptyObject;
  7142. this.injections = resolveInject(options.inject, parent);
  7143. this.slots = function () {
  7144. if (!this$1.$slots) {
  7145. normalizeScopedSlots(
  7146. data.scopedSlots,
  7147. this$1.$slots = resolveSlots(children, parent)
  7148. );
  7149. }
  7150. return this$1.$slots
  7151. };
  7152. Object.defineProperty(this, 'scopedSlots', ({
  7153. enumerable: true,
  7154. get: function get () {
  7155. return normalizeScopedSlots(data.scopedSlots, this.slots())
  7156. }
  7157. }));
  7158. // support for compiled functional template
  7159. if (isCompiled) {
  7160. // exposing $options for renderStatic()
  7161. this.$options = options;
  7162. // pre-resolve slots for renderSlot()
  7163. this.$slots = this.slots();
  7164. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  7165. }
  7166. if (options._scopeId) {
  7167. this._c = function (a, b, c, d) {
  7168. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  7169. if (vnode && !Array.isArray(vnode)) {
  7170. vnode.fnScopeId = options._scopeId;
  7171. vnode.fnContext = parent;
  7172. }
  7173. return vnode
  7174. };
  7175. } else {
  7176. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  7177. }
  7178. }
  7179. installRenderHelpers(FunctionalRenderContext.prototype);
  7180. function createFunctionalComponent (
  7181. Ctor,
  7182. propsData,
  7183. data,
  7184. contextVm,
  7185. children
  7186. ) {
  7187. var options = Ctor.options;
  7188. var props = {};
  7189. var propOptions = options.props;
  7190. if (isDef(propOptions)) {
  7191. for (var key in propOptions) {
  7192. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  7193. }
  7194. } else {
  7195. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  7196. if (isDef(data.props)) { mergeProps(props, data.props); }
  7197. }
  7198. var renderContext = new FunctionalRenderContext(
  7199. data,
  7200. props,
  7201. children,
  7202. contextVm,
  7203. Ctor
  7204. );
  7205. var vnode = options.render.call(null, renderContext._c, renderContext);
  7206. if (vnode instanceof VNode) {
  7207. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  7208. } else if (Array.isArray(vnode)) {
  7209. var vnodes = normalizeChildren(vnode) || [];
  7210. var res = new Array(vnodes.length);
  7211. for (var i = 0; i < vnodes.length; i++) {
  7212. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  7213. }
  7214. return res
  7215. }
  7216. }
  7217. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  7218. // #7817 clone node before setting fnContext, otherwise if the node is reused
  7219. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  7220. // that should not be matched to match.
  7221. var clone = cloneVNode(vnode);
  7222. clone.fnContext = contextVm;
  7223. clone.fnOptions = options;
  7224. {
  7225. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  7226. }
  7227. if (data.slot) {
  7228. (clone.data || (clone.data = {})).slot = data.slot;
  7229. }
  7230. return clone
  7231. }
  7232. function mergeProps (to, from) {
  7233. for (var key in from) {
  7234. to[camelize(key)] = from[key];
  7235. }
  7236. }
  7237. /* */
  7238. /* */
  7239. /* */
  7240. /* */
  7241. // inline hooks to be invoked on component VNodes during patch
  7242. var componentVNodeHooks = {
  7243. init: function init (vnode, hydrating) {
  7244. if (
  7245. vnode.componentInstance &&
  7246. !vnode.componentInstance._isDestroyed &&
  7247. vnode.data.keepAlive
  7248. ) {
  7249. // kept-alive components, treat as a patch
  7250. var mountedNode = vnode; // work around flow
  7251. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  7252. } else {
  7253. var child = vnode.componentInstance = createComponentInstanceForVnode(
  7254. vnode,
  7255. activeInstance
  7256. );
  7257. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  7258. }
  7259. },
  7260. prepatch: function prepatch (oldVnode, vnode) {
  7261. var options = vnode.componentOptions;
  7262. var child = vnode.componentInstance = oldVnode.componentInstance;
  7263. updateChildComponent(
  7264. child,
  7265. options.propsData, // updated props
  7266. options.listeners, // updated listeners
  7267. vnode, // new parent vnode
  7268. options.children // new children
  7269. );
  7270. },
  7271. insert: function insert (vnode) {
  7272. var context = vnode.context;
  7273. var componentInstance = vnode.componentInstance;
  7274. if (!componentInstance._isMounted) {
  7275. componentInstance._isMounted = true;
  7276. callHook(componentInstance, 'mounted');
  7277. }
  7278. if (vnode.data.keepAlive) {
  7279. if (context._isMounted) {
  7280. // vue-router#1212
  7281. // During updates, a kept-alive component's child components may
  7282. // change, so directly walking the tree here may call activated hooks
  7283. // on incorrect children. Instead we push them into a queue which will
  7284. // be processed after the whole patch process ended.
  7285. queueActivatedComponent(componentInstance);
  7286. } else {
  7287. activateChildComponent(componentInstance, true /* direct */);
  7288. }
  7289. }
  7290. },
  7291. destroy: function destroy (vnode) {
  7292. var componentInstance = vnode.componentInstance;
  7293. if (!componentInstance._isDestroyed) {
  7294. if (!vnode.data.keepAlive) {
  7295. componentInstance.$destroy();
  7296. } else {
  7297. deactivateChildComponent(componentInstance, true /* direct */);
  7298. }
  7299. }
  7300. }
  7301. };
  7302. var hooksToMerge = Object.keys(componentVNodeHooks);
  7303. function createComponent (
  7304. Ctor,
  7305. data,
  7306. context,
  7307. children,
  7308. tag
  7309. ) {
  7310. if (isUndef(Ctor)) {
  7311. return
  7312. }
  7313. var baseCtor = context.$options._base;
  7314. // plain options object: turn it into a constructor
  7315. if (isObject(Ctor)) {
  7316. Ctor = baseCtor.extend(Ctor);
  7317. }
  7318. // if at this stage it's not a constructor or an async component factory,
  7319. // reject.
  7320. if (typeof Ctor !== 'function') {
  7321. {
  7322. warn(("Invalid Component definition: " + (String(Ctor))), context);
  7323. }
  7324. return
  7325. }
  7326. // async component
  7327. var asyncFactory;
  7328. if (isUndef(Ctor.cid)) {
  7329. asyncFactory = Ctor;
  7330. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  7331. if (Ctor === undefined) {
  7332. // return a placeholder node for async component, which is rendered
  7333. // as a comment node but preserves all the raw information for the node.
  7334. // the information will be used for async server-rendering and hydration.
  7335. return createAsyncPlaceholder(
  7336. asyncFactory,
  7337. data,
  7338. context,
  7339. children,
  7340. tag
  7341. )
  7342. }
  7343. }
  7344. data = data || {};
  7345. // resolve constructor options in case global mixins are applied after
  7346. // component constructor creation
  7347. resolveConstructorOptions(Ctor);
  7348. // transform component v-model data into props & events
  7349. if (isDef(data.model)) {
  7350. transformModel(Ctor.options, data);
  7351. }
  7352. // extract props
  7353. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  7354. // functional component
  7355. if (isTrue(Ctor.options.functional)) {
  7356. return createFunctionalComponent(Ctor, propsData, data, context, children)
  7357. }
  7358. // extract listeners, since these needs to be treated as
  7359. // child component listeners instead of DOM listeners
  7360. var listeners = data.on;
  7361. // replace with listeners with .native modifier
  7362. // so it gets processed during parent component patch.
  7363. data.on = data.nativeOn;
  7364. if (isTrue(Ctor.options.abstract)) {
  7365. // abstract components do not keep anything
  7366. // other than props & listeners & slot
  7367. // work around flow
  7368. var slot = data.slot;
  7369. data = {};
  7370. if (slot) {
  7371. data.slot = slot;
  7372. }
  7373. }
  7374. // install component management hooks onto the placeholder node
  7375. installComponentHooks(data);
  7376. // return a placeholder vnode
  7377. var name = Ctor.options.name || tag;
  7378. var vnode = new VNode(
  7379. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  7380. data, undefined, undefined, undefined, context,
  7381. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  7382. asyncFactory
  7383. );
  7384. return vnode
  7385. }
  7386. function createComponentInstanceForVnode (
  7387. // we know it's MountedComponentVNode but flow doesn't
  7388. vnode,
  7389. // activeInstance in lifecycle state
  7390. parent
  7391. ) {
  7392. var options = {
  7393. _isComponent: true,
  7394. _parentVnode: vnode,
  7395. parent: parent
  7396. };
  7397. // check inline-template render functions
  7398. var inlineTemplate = vnode.data.inlineTemplate;
  7399. if (isDef(inlineTemplate)) {
  7400. options.render = inlineTemplate.render;
  7401. options.staticRenderFns = inlineTemplate.staticRenderFns;
  7402. }
  7403. return new vnode.componentOptions.Ctor(options)
  7404. }
  7405. function installComponentHooks (data) {
  7406. var hooks = data.hook || (data.hook = {});
  7407. for (var i = 0; i < hooksToMerge.length; i++) {
  7408. var key = hooksToMerge[i];
  7409. var existing = hooks[key];
  7410. var toMerge = componentVNodeHooks[key];
  7411. if (existing !== toMerge && !(existing && existing._merged)) {
  7412. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  7413. }
  7414. }
  7415. }
  7416. function mergeHook$1 (f1, f2) {
  7417. var merged = function (a, b) {
  7418. // flow complains about extra args which is why we use any
  7419. f1(a, b);
  7420. f2(a, b);
  7421. };
  7422. merged._merged = true;
  7423. return merged
  7424. }
  7425. // transform component v-model info (value and callback) into
  7426. // prop and event handler respectively.
  7427. function transformModel (options, data) {
  7428. var prop = (options.model && options.model.prop) || 'value';
  7429. var event = (options.model && options.model.event) || 'input'
  7430. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  7431. var on = data.on || (data.on = {});
  7432. var existing = on[event];
  7433. var callback = data.model.callback;
  7434. if (isDef(existing)) {
  7435. if (
  7436. Array.isArray(existing)
  7437. ? existing.indexOf(callback) === -1
  7438. : existing !== callback
  7439. ) {
  7440. on[event] = [callback].concat(existing);
  7441. }
  7442. } else {
  7443. on[event] = callback;
  7444. }
  7445. }
  7446. /* */
  7447. var warned = Object.create(null);
  7448. var warnOnce = function (msg) {
  7449. if (!warned[msg]) {
  7450. warned[msg] = true;
  7451. // eslint-disable-next-line no-console
  7452. console.warn(("\n\u001b[31m" + msg + "\u001b[39m\n"));
  7453. }
  7454. };
  7455. var onCompilationError = function (err, vm) {
  7456. var trace = vm ? generateComponentTrace(vm) : '';
  7457. throw new Error(("\n\u001b[31m" + err + trace + "\u001b[39m\n"))
  7458. };
  7459. var normalizeRender = function (vm) {
  7460. var ref = vm.$options;
  7461. var render = ref.render;
  7462. var template = ref.template;
  7463. var _scopeId = ref._scopeId;
  7464. if (isUndef(render)) {
  7465. if (template) {
  7466. var compiled = compileToFunctions(template, {
  7467. scopeId: _scopeId,
  7468. warn: onCompilationError
  7469. }, vm);
  7470. vm.$options.render = compiled.render;
  7471. vm.$options.staticRenderFns = compiled.staticRenderFns;
  7472. } else {
  7473. throw new Error(
  7474. ("render function or template not defined in component: " + (vm.$options.name || vm.$options._componentTag || 'anonymous'))
  7475. )
  7476. }
  7477. }
  7478. };
  7479. function waitForServerPrefetch (vm, resolve, reject) {
  7480. var handlers = vm.$options.serverPrefetch;
  7481. if (isDef(handlers)) {
  7482. if (!Array.isArray(handlers)) { handlers = [handlers]; }
  7483. try {
  7484. var promises = [];
  7485. for (var i = 0, j = handlers.length; i < j; i++) {
  7486. var result = handlers[i].call(vm, vm);
  7487. if (result && typeof result.then === 'function') {
  7488. promises.push(result);
  7489. }
  7490. }
  7491. Promise.all(promises).then(resolve).catch(reject);
  7492. return
  7493. } catch (e) {
  7494. reject(e);
  7495. }
  7496. }
  7497. resolve();
  7498. }
  7499. function renderNode (node, isRoot, context) {
  7500. if (node.isString) {
  7501. renderStringNode$1(node, context);
  7502. } else if (isDef(node.componentOptions)) {
  7503. renderComponent(node, isRoot, context);
  7504. } else if (isDef(node.tag)) {
  7505. renderElement(node, isRoot, context);
  7506. } else if (isTrue(node.isComment)) {
  7507. if (isDef(node.asyncFactory)) {
  7508. // async component
  7509. renderAsyncComponent(node, isRoot, context);
  7510. } else {
  7511. context.write(("<!--" + (node.text) + "-->"), context.next);
  7512. }
  7513. } else {
  7514. context.write(
  7515. node.raw ? node.text : escape(String(node.text)),
  7516. context.next
  7517. );
  7518. }
  7519. }
  7520. function registerComponentForCache (options, write) {
  7521. // exposed by vue-loader, need to call this if cache hit because
  7522. // component lifecycle hooks will not be called.
  7523. var register = options._ssrRegister;
  7524. if (write.caching && isDef(register)) {
  7525. write.componentBuffer[write.componentBuffer.length - 1].add(register);
  7526. }
  7527. return register
  7528. }
  7529. function renderComponent (node, isRoot, context) {
  7530. var write = context.write;
  7531. var next = context.next;
  7532. var userContext = context.userContext;
  7533. // check cache hit
  7534. var Ctor = node.componentOptions.Ctor;
  7535. var getKey = Ctor.options.serverCacheKey;
  7536. var name = Ctor.options.name;
  7537. var cache = context.cache;
  7538. var registerComponent = registerComponentForCache(Ctor.options, write);
  7539. if (isDef(getKey) && isDef(cache) && isDef(name)) {
  7540. var rawKey = getKey(node.componentOptions.propsData);
  7541. if (rawKey === false) {
  7542. renderComponentInner(node, isRoot, context);
  7543. return
  7544. }
  7545. var key = name + '::' + rawKey;
  7546. var has = context.has;
  7547. var get = context.get;
  7548. if (isDef(has)) {
  7549. has(key, function (hit) {
  7550. if (hit === true && isDef(get)) {
  7551. get(key, function (res) {
  7552. if (isDef(registerComponent)) {
  7553. registerComponent(userContext);
  7554. }
  7555. res.components.forEach(function (register) { return register(userContext); });
  7556. write(res.html, next);
  7557. });
  7558. } else {
  7559. renderComponentWithCache(node, isRoot, key, context);
  7560. }
  7561. });
  7562. } else if (isDef(get)) {
  7563. get(key, function (res) {
  7564. if (isDef(res)) {
  7565. if (isDef(registerComponent)) {
  7566. registerComponent(userContext);
  7567. }
  7568. res.components.forEach(function (register) { return register(userContext); });
  7569. write(res.html, next);
  7570. } else {
  7571. renderComponentWithCache(node, isRoot, key, context);
  7572. }
  7573. });
  7574. }
  7575. } else {
  7576. if (isDef(getKey) && isUndef(cache)) {
  7577. warnOnce(
  7578. "[vue-server-renderer] Component " + (Ctor.options.name || '(anonymous)') + " implemented serverCacheKey, " +
  7579. 'but no cache was provided to the renderer.'
  7580. );
  7581. }
  7582. if (isDef(getKey) && isUndef(name)) {
  7583. warnOnce(
  7584. "[vue-server-renderer] Components that implement \"serverCacheKey\" " +
  7585. "must also define a unique \"name\" option."
  7586. );
  7587. }
  7588. renderComponentInner(node, isRoot, context);
  7589. }
  7590. }
  7591. function renderComponentWithCache (node, isRoot, key, context) {
  7592. var write = context.write;
  7593. write.caching = true;
  7594. var buffer = write.cacheBuffer;
  7595. var bufferIndex = buffer.push('') - 1;
  7596. var componentBuffer = write.componentBuffer;
  7597. componentBuffer.push(new Set());
  7598. context.renderStates.push({
  7599. type: 'ComponentWithCache',
  7600. key: key,
  7601. buffer: buffer,
  7602. bufferIndex: bufferIndex,
  7603. componentBuffer: componentBuffer
  7604. });
  7605. renderComponentInner(node, isRoot, context);
  7606. }
  7607. function renderComponentInner (node, isRoot, context) {
  7608. var prevActive = context.activeInstance;
  7609. // expose userContext on vnode
  7610. node.ssrContext = context.userContext;
  7611. var child = context.activeInstance = createComponentInstanceForVnode(
  7612. node,
  7613. context.activeInstance
  7614. );
  7615. normalizeRender(child);
  7616. var resolve = function () {
  7617. var childNode = child._render();
  7618. childNode.parent = node;
  7619. context.renderStates.push({
  7620. type: 'Component',
  7621. prevActive: prevActive
  7622. });
  7623. renderNode(childNode, isRoot, context);
  7624. };
  7625. var reject = context.done;
  7626. waitForServerPrefetch(child, resolve, reject);
  7627. }
  7628. function renderAsyncComponent (node, isRoot, context) {
  7629. var factory = node.asyncFactory;
  7630. var resolve = function (comp) {
  7631. if (comp.__esModule && comp.default) {
  7632. comp = comp.default;
  7633. }
  7634. var ref = node.asyncMeta;
  7635. var data = ref.data;
  7636. var children = ref.children;
  7637. var tag = ref.tag;
  7638. var nodeContext = node.asyncMeta.context;
  7639. var resolvedNode = createComponent(
  7640. comp,
  7641. data,
  7642. nodeContext,
  7643. children,
  7644. tag
  7645. );
  7646. if (resolvedNode) {
  7647. if (resolvedNode.componentOptions) {
  7648. // normal component
  7649. renderComponent(resolvedNode, isRoot, context);
  7650. } else if (!Array.isArray(resolvedNode)) {
  7651. // single return node from functional component
  7652. renderNode(resolvedNode, isRoot, context);
  7653. } else {
  7654. // multiple return nodes from functional component
  7655. context.renderStates.push({
  7656. type: 'Fragment',
  7657. children: resolvedNode,
  7658. rendered: 0,
  7659. total: resolvedNode.length
  7660. });
  7661. context.next();
  7662. }
  7663. } else {
  7664. // invalid component, but this does not throw on the client
  7665. // so render empty comment node
  7666. context.write("<!---->", context.next);
  7667. }
  7668. };
  7669. if (factory.resolved) {
  7670. resolve(factory.resolved);
  7671. return
  7672. }
  7673. var reject = context.done;
  7674. var res;
  7675. try {
  7676. res = factory(resolve, reject);
  7677. } catch (e) {
  7678. reject(e);
  7679. }
  7680. if (res) {
  7681. if (typeof res.then === 'function') {
  7682. res.then(resolve, reject).catch(reject);
  7683. } else {
  7684. // new syntax in 2.3
  7685. var comp = res.component;
  7686. if (comp && typeof comp.then === 'function') {
  7687. comp.then(resolve, reject).catch(reject);
  7688. }
  7689. }
  7690. }
  7691. }
  7692. function renderStringNode$1 (el, context) {
  7693. var write = context.write;
  7694. var next = context.next;
  7695. if (isUndef(el.children) || el.children.length === 0) {
  7696. write(el.open + (el.close || ''), next);
  7697. } else {
  7698. var children = el.children;
  7699. context.renderStates.push({
  7700. type: 'Element',
  7701. children: children,
  7702. rendered: 0,
  7703. total: children.length,
  7704. endTag: el.close
  7705. });
  7706. write(el.open, next);
  7707. }
  7708. }
  7709. function renderElement (el, isRoot, context) {
  7710. var write = context.write;
  7711. var next = context.next;
  7712. if (isTrue(isRoot)) {
  7713. if (!el.data) { el.data = {}; }
  7714. if (!el.data.attrs) { el.data.attrs = {}; }
  7715. el.data.attrs[SSR_ATTR] = 'true';
  7716. }
  7717. if (el.fnOptions) {
  7718. registerComponentForCache(el.fnOptions, write);
  7719. }
  7720. var startTag = renderStartingTag(el, context);
  7721. var endTag = "</" + (el.tag) + ">";
  7722. if (context.isUnaryTag(el.tag)) {
  7723. write(startTag, next);
  7724. } else if (isUndef(el.children) || el.children.length === 0) {
  7725. write(startTag + endTag, next);
  7726. } else {
  7727. var children = el.children;
  7728. context.renderStates.push({
  7729. type: 'Element',
  7730. children: children,
  7731. rendered: 0,
  7732. total: children.length,
  7733. endTag: endTag
  7734. });
  7735. write(startTag, next);
  7736. }
  7737. }
  7738. function hasAncestorData (node) {
  7739. var parentNode = node.parent;
  7740. return isDef(parentNode) && (isDef(parentNode.data) || hasAncestorData(parentNode))
  7741. }
  7742. function getVShowDirectiveInfo (node) {
  7743. var dir;
  7744. var tmp;
  7745. while (isDef(node)) {
  7746. if (node.data && node.data.directives) {
  7747. tmp = node.data.directives.find(function (dir) { return dir.name === 'show'; });
  7748. if (tmp) {
  7749. dir = tmp;
  7750. }
  7751. }
  7752. node = node.parent;
  7753. }
  7754. return dir
  7755. }
  7756. function renderStartingTag (node, context) {
  7757. var markup = "<" + (node.tag);
  7758. var directives = context.directives;
  7759. var modules = context.modules;
  7760. // construct synthetic data for module processing
  7761. // because modules like style also produce code by parent VNode data
  7762. if (isUndef(node.data) && hasAncestorData(node)) {
  7763. node.data = {};
  7764. }
  7765. if (isDef(node.data)) {
  7766. // check directives
  7767. var dirs = node.data.directives;
  7768. if (dirs) {
  7769. for (var i = 0; i < dirs.length; i++) {
  7770. var name = dirs[i].name;
  7771. if (name !== 'show') {
  7772. var dirRenderer = resolveAsset(context, 'directives', name);
  7773. if (dirRenderer) {
  7774. // directives mutate the node's data
  7775. // which then gets rendered by modules
  7776. dirRenderer(node, dirs[i]);
  7777. }
  7778. }
  7779. }
  7780. }
  7781. // v-show directive needs to be merged from parent to child
  7782. var vshowDirectiveInfo = getVShowDirectiveInfo(node);
  7783. if (vshowDirectiveInfo) {
  7784. directives.show(node, vshowDirectiveInfo);
  7785. }
  7786. // apply other modules
  7787. for (var i$1 = 0; i$1 < modules.length; i$1++) {
  7788. var res = modules[i$1](node);
  7789. if (res) {
  7790. markup += res;
  7791. }
  7792. }
  7793. }
  7794. // attach scoped CSS ID
  7795. var scopeId;
  7796. var activeInstance = context.activeInstance;
  7797. if (isDef(activeInstance) &&
  7798. activeInstance !== node.context &&
  7799. isDef(scopeId = activeInstance.$options._scopeId)
  7800. ) {
  7801. markup += " " + ((scopeId));
  7802. }
  7803. if (isDef(node.fnScopeId)) {
  7804. markup += " " + (node.fnScopeId);
  7805. } else {
  7806. while (isDef(node)) {
  7807. if (isDef(scopeId = node.context.$options._scopeId)) {
  7808. markup += " " + scopeId;
  7809. }
  7810. node = node.parent;
  7811. }
  7812. }
  7813. return markup + '>'
  7814. }
  7815. function createRenderFunction (
  7816. modules,
  7817. directives,
  7818. isUnaryTag,
  7819. cache
  7820. ) {
  7821. return function render (
  7822. component,
  7823. write,
  7824. userContext,
  7825. done
  7826. ) {
  7827. warned = Object.create(null);
  7828. var context = new RenderContext({
  7829. activeInstance: component,
  7830. userContext: userContext,
  7831. write: write, done: done, renderNode: renderNode,
  7832. isUnaryTag: isUnaryTag, modules: modules, directives: directives,
  7833. cache: cache
  7834. });
  7835. installSSRHelpers(component);
  7836. normalizeRender(component);
  7837. var resolve = function () {
  7838. renderNode(component._render(), true, context);
  7839. };
  7840. waitForServerPrefetch(component, resolve, done);
  7841. }
  7842. }
  7843. /* */
  7844. var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); };
  7845. var isCSS = function (file) { return /\.css(\?[^.]+)?$/.test(file); };
  7846. function createPromiseCallback () {
  7847. var resolve, reject;
  7848. var promise = new Promise(function (_resolve, _reject) {
  7849. resolve = _resolve;
  7850. reject = _reject;
  7851. });
  7852. var cb = function (err, res) {
  7853. if (err) { return reject(err) }
  7854. resolve(res || '');
  7855. };
  7856. return { promise: promise, cb: cb }
  7857. }
  7858. /* */
  7859. var Transform = require('stream').Transform;
  7860. var TemplateStream = /*@__PURE__*/(function (Transform) {
  7861. function TemplateStream (
  7862. renderer,
  7863. template,
  7864. context
  7865. ) {
  7866. Transform.call(this);
  7867. this.started = false;
  7868. this.renderer = renderer;
  7869. this.template = template;
  7870. this.context = context || {};
  7871. this.inject = renderer.inject;
  7872. }
  7873. if ( Transform ) TemplateStream.__proto__ = Transform;
  7874. TemplateStream.prototype = Object.create( Transform && Transform.prototype );
  7875. TemplateStream.prototype.constructor = TemplateStream;
  7876. TemplateStream.prototype._transform = function _transform (data, encoding, done) {
  7877. if (!this.started) {
  7878. this.emit('beforeStart');
  7879. this.start();
  7880. }
  7881. this.push(data);
  7882. done();
  7883. };
  7884. TemplateStream.prototype.start = function start () {
  7885. this.started = true;
  7886. this.push(this.template.head(this.context));
  7887. if (this.inject) {
  7888. // inline server-rendered head meta information
  7889. if (this.context.head) {
  7890. this.push(this.context.head);
  7891. }
  7892. // inline preload/prefetch directives for initial/async chunks
  7893. var links = this.renderer.renderResourceHints(this.context);
  7894. if (links) {
  7895. this.push(links);
  7896. }
  7897. // CSS files and inline server-rendered CSS collected by vue-style-loader
  7898. var styles = this.renderer.renderStyles(this.context);
  7899. if (styles) {
  7900. this.push(styles);
  7901. }
  7902. }
  7903. this.push(this.template.neck(this.context));
  7904. };
  7905. TemplateStream.prototype._flush = function _flush (done) {
  7906. this.emit('beforeEnd');
  7907. if (this.inject) {
  7908. // inline initial store state
  7909. var state = this.renderer.renderState(this.context);
  7910. if (state) {
  7911. this.push(state);
  7912. }
  7913. // embed scripts needed
  7914. var scripts = this.renderer.renderScripts(this.context);
  7915. if (scripts) {
  7916. this.push(scripts);
  7917. }
  7918. }
  7919. this.push(this.template.tail(this.context));
  7920. done();
  7921. };
  7922. return TemplateStream;
  7923. }(Transform));
  7924. /* */
  7925. var compile$1 = require('lodash.template');
  7926. var compileOptions = {
  7927. escape: /{{([^{][\s\S]+?[^}])}}/g,
  7928. interpolate: /{{{([\s\S]+?)}}}/g
  7929. };
  7930. function parseTemplate (
  7931. template,
  7932. contentPlaceholder
  7933. ) {
  7934. if ( contentPlaceholder === void 0 ) contentPlaceholder = '<!--vue-ssr-outlet-->';
  7935. if (typeof template === 'object') {
  7936. return template
  7937. }
  7938. var i = template.indexOf('</head>');
  7939. var j = template.indexOf(contentPlaceholder);
  7940. if (j < 0) {
  7941. throw new Error("Content placeholder not found in template.")
  7942. }
  7943. if (i < 0) {
  7944. i = template.indexOf('<body>');
  7945. if (i < 0) {
  7946. i = j;
  7947. }
  7948. }
  7949. return {
  7950. head: compile$1(template.slice(0, i), compileOptions),
  7951. neck: compile$1(template.slice(i, j), compileOptions),
  7952. tail: compile$1(template.slice(j + contentPlaceholder.length), compileOptions)
  7953. }
  7954. }
  7955. /* */
  7956. /**
  7957. * Creates a mapper that maps components used during a server-side render
  7958. * to async chunk files in the client-side build, so that we can inline them
  7959. * directly in the rendered HTML to avoid waterfall requests.
  7960. */
  7961. function createMapper (
  7962. clientManifest
  7963. ) {
  7964. var map = createMap(clientManifest);
  7965. // map server-side moduleIds to client-side files
  7966. return function mapper (moduleIds) {
  7967. var res = new Set();
  7968. for (var i = 0; i < moduleIds.length; i++) {
  7969. var mapped = map.get(moduleIds[i]);
  7970. if (mapped) {
  7971. for (var j = 0; j < mapped.length; j++) {
  7972. res.add(mapped[j]);
  7973. }
  7974. }
  7975. }
  7976. return Array.from(res)
  7977. }
  7978. }
  7979. function createMap (clientManifest) {
  7980. var map = new Map();
  7981. Object.keys(clientManifest.modules).forEach(function (id) {
  7982. map.set(id, mapIdToFile(id, clientManifest));
  7983. });
  7984. return map
  7985. }
  7986. function mapIdToFile (id, clientManifest) {
  7987. var files = [];
  7988. var fileIndices = clientManifest.modules[id];
  7989. if (fileIndices) {
  7990. fileIndices.forEach(function (index) {
  7991. var file = clientManifest.all[index];
  7992. // only include async files or non-js, non-css assets
  7993. if (
  7994. file &&
  7995. (clientManifest.async.indexOf(file) > -1 ||
  7996. !/\.(js|css)($|\?)/.test(file))
  7997. ) {
  7998. files.push(file);
  7999. }
  8000. });
  8001. }
  8002. return files
  8003. }
  8004. /* */
  8005. var path = require('path');
  8006. var serialize = require('serialize-javascript');
  8007. var TemplateRenderer = function TemplateRenderer (options) {
  8008. this.options = options;
  8009. this.inject = options.inject !== false;
  8010. // if no template option is provided, the renderer is created
  8011. // as a utility object for rendering assets like preload links and scripts.
  8012. var template = options.template;
  8013. this.parsedTemplate = template
  8014. ? typeof template === 'string'
  8015. ? parseTemplate(template)
  8016. : template
  8017. : null;
  8018. // function used to serialize initial state JSON
  8019. this.serialize = options.serializer || (function (state) {
  8020. return serialize(state, { isJSON: true })
  8021. });
  8022. // extra functionality with client manifest
  8023. if (options.clientManifest) {
  8024. var clientManifest = this.clientManifest = options.clientManifest;
  8025. // ensure publicPath ends with /
  8026. this.publicPath = clientManifest.publicPath === ''
  8027. ? ''
  8028. : clientManifest.publicPath.replace(/([^\/])$/, '$1/');
  8029. // preload/prefetch directives
  8030. this.preloadFiles = (clientManifest.initial || []).map(normalizeFile);
  8031. this.prefetchFiles = (clientManifest.async || []).map(normalizeFile);
  8032. // initial async chunk mapping
  8033. this.mapFiles = createMapper(clientManifest);
  8034. }
  8035. };
  8036. TemplateRenderer.prototype.bindRenderFns = function bindRenderFns (context) {
  8037. var renderer = this
  8038. ;['ResourceHints', 'State', 'Scripts', 'Styles'].forEach(function (type) {
  8039. context[("render" + type)] = renderer[("render" + type)].bind(renderer, context);
  8040. });
  8041. // also expose getPreloadFiles, useful for HTTP/2 push
  8042. context.getPreloadFiles = renderer.getPreloadFiles.bind(renderer, context);
  8043. };
  8044. // render synchronously given rendered app content and render context
  8045. TemplateRenderer.prototype.render = function render (content, context) {
  8046. var template = this.parsedTemplate;
  8047. if (!template) {
  8048. throw new Error('render cannot be called without a template.')
  8049. }
  8050. context = context || {};
  8051. if (typeof template === 'function') {
  8052. return template(content, context)
  8053. }
  8054. if (this.inject) {
  8055. return (
  8056. template.head(context) +
  8057. (context.head || '') +
  8058. this.renderResourceHints(context) +
  8059. this.renderStyles(context) +
  8060. template.neck(context) +
  8061. content +
  8062. this.renderState(context) +
  8063. this.renderScripts(context) +
  8064. template.tail(context)
  8065. )
  8066. } else {
  8067. return (
  8068. template.head(context) +
  8069. template.neck(context) +
  8070. content +
  8071. template.tail(context)
  8072. )
  8073. }
  8074. };
  8075. TemplateRenderer.prototype.renderStyles = function renderStyles (context) {
  8076. var this$1 = this;
  8077. var initial = this.preloadFiles || [];
  8078. var async = this.getUsedAsyncFiles(context) || [];
  8079. var cssFiles = initial.concat(async).filter(function (ref) {
  8080. var file = ref.file;
  8081. return isCSS(file);
  8082. });
  8083. return (
  8084. // render links for css files
  8085. (cssFiles.length
  8086. ? cssFiles.map(function (ref) {
  8087. var file = ref.file;
  8088. return ("<link rel=\"stylesheet\" href=\"" + (this$1.publicPath) + file + "\">");
  8089. }).join('')
  8090. : '') +
  8091. // context.styles is a getter exposed by vue-style-loader which contains
  8092. // the inline component styles collected during SSR
  8093. (context.styles || '')
  8094. )
  8095. };
  8096. TemplateRenderer.prototype.renderResourceHints = function renderResourceHints (context) {
  8097. return this.renderPreloadLinks(context) + this.renderPrefetchLinks(context)
  8098. };
  8099. TemplateRenderer.prototype.getPreloadFiles = function getPreloadFiles (context) {
  8100. var usedAsyncFiles = this.getUsedAsyncFiles(context);
  8101. if (this.preloadFiles || usedAsyncFiles) {
  8102. return (this.preloadFiles || []).concat(usedAsyncFiles || [])
  8103. } else {
  8104. return []
  8105. }
  8106. };
  8107. TemplateRenderer.prototype.renderPreloadLinks = function renderPreloadLinks (context) {
  8108. var this$1 = this;
  8109. var files = this.getPreloadFiles(context);
  8110. var shouldPreload = this.options.shouldPreload;
  8111. if (files.length) {
  8112. return files.map(function (ref) {
  8113. var file = ref.file;
  8114. var extension = ref.extension;
  8115. var fileWithoutQuery = ref.fileWithoutQuery;
  8116. var asType = ref.asType;
  8117. var extra = '';
  8118. // by default, we only preload scripts or css
  8119. if (!shouldPreload && asType !== 'script' && asType !== 'style') {
  8120. return ''
  8121. }
  8122. // user wants to explicitly control what to preload
  8123. if (shouldPreload && !shouldPreload(fileWithoutQuery, asType)) {
  8124. return ''
  8125. }
  8126. if (asType === 'font') {
  8127. extra = " type=\"font/" + extension + "\" crossorigin";
  8128. }
  8129. return ("<link rel=\"preload\" href=\"" + (this$1.publicPath) + file + "\"" + (asType !== '' ? (" as=\"" + asType + "\"") : '') + extra + ">")
  8130. }).join('')
  8131. } else {
  8132. return ''
  8133. }
  8134. };
  8135. TemplateRenderer.prototype.renderPrefetchLinks = function renderPrefetchLinks (context) {
  8136. var this$1 = this;
  8137. var shouldPrefetch = this.options.shouldPrefetch;
  8138. if (this.prefetchFiles) {
  8139. var usedAsyncFiles = this.getUsedAsyncFiles(context);
  8140. var alreadyRendered = function (file) {
  8141. return usedAsyncFiles && usedAsyncFiles.some(function (f) { return f.file === file; })
  8142. };
  8143. return this.prefetchFiles.map(function (ref) {
  8144. var file = ref.file;
  8145. var fileWithoutQuery = ref.fileWithoutQuery;
  8146. var asType = ref.asType;
  8147. if (shouldPrefetch && !shouldPrefetch(fileWithoutQuery, asType)) {
  8148. return ''
  8149. }
  8150. if (alreadyRendered(file)) {
  8151. return ''
  8152. }
  8153. return ("<link rel=\"prefetch\" href=\"" + (this$1.publicPath) + file + "\">")
  8154. }).join('')
  8155. } else {
  8156. return ''
  8157. }
  8158. };
  8159. TemplateRenderer.prototype.renderState = function renderState (context, options) {
  8160. var ref = options || {};
  8161. var contextKey = ref.contextKey; if ( contextKey === void 0 ) contextKey = 'state';
  8162. var windowKey = ref.windowKey; if ( windowKey === void 0 ) windowKey = '__INITIAL_STATE__';
  8163. var state = this.serialize(context[contextKey]);
  8164. var autoRemove = '';
  8165. var nonceAttr = context.nonce ? (" nonce=\"" + (context.nonce) + "\"") : '';
  8166. return context[contextKey]
  8167. ? ("<script" + nonceAttr + ">window." + windowKey + "=" + state + autoRemove + "</script>")
  8168. : ''
  8169. };
  8170. TemplateRenderer.prototype.renderScripts = function renderScripts (context) {
  8171. var this$1 = this;
  8172. if (this.clientManifest) {
  8173. var initial = this.preloadFiles.filter(function (ref) {
  8174. var file = ref.file;
  8175. return isJS(file);
  8176. });
  8177. var async = (this.getUsedAsyncFiles(context) || []).filter(function (ref) {
  8178. var file = ref.file;
  8179. return isJS(file);
  8180. });
  8181. var needed = [initial[0]].concat(async, initial.slice(1));
  8182. return needed.map(function (ref) {
  8183. var file = ref.file;
  8184. return ("<script src=\"" + (this$1.publicPath) + file + "\" defer></script>")
  8185. }).join('')
  8186. } else {
  8187. return ''
  8188. }
  8189. };
  8190. TemplateRenderer.prototype.getUsedAsyncFiles = function getUsedAsyncFiles (context) {
  8191. if (!context._mappedFiles && context._registeredComponents && this.mapFiles) {
  8192. var registered = Array.from(context._registeredComponents);
  8193. context._mappedFiles = this.mapFiles(registered).map(normalizeFile);
  8194. }
  8195. return context._mappedFiles
  8196. };
  8197. // create a transform stream
  8198. TemplateRenderer.prototype.createStream = function createStream (context) {
  8199. if (!this.parsedTemplate) {
  8200. throw new Error('createStream cannot be called without a template.')
  8201. }
  8202. return new TemplateStream(this, this.parsedTemplate, context || {})
  8203. };
  8204. function normalizeFile (file) {
  8205. var withoutQuery = file.replace(/\?.*/, '');
  8206. var extension = path.extname(withoutQuery).slice(1);
  8207. return {
  8208. file: file,
  8209. extension: extension,
  8210. fileWithoutQuery: withoutQuery,
  8211. asType: getPreloadType(extension)
  8212. }
  8213. }
  8214. function getPreloadType (ext) {
  8215. if (ext === 'js') {
  8216. return 'script'
  8217. } else if (ext === 'css') {
  8218. return 'style'
  8219. } else if (/jpe?g|png|svg|gif|webp|ico/.test(ext)) {
  8220. return 'image'
  8221. } else if (/woff2?|ttf|otf|eot/.test(ext)) {
  8222. return 'font'
  8223. } else {
  8224. // not exhausting all possibilities here, but above covers common cases
  8225. return ''
  8226. }
  8227. }
  8228. /* */
  8229. function createRenderer (ref) {
  8230. if ( ref === void 0 ) ref = {};
  8231. var modules = ref.modules; if ( modules === void 0 ) modules = [];
  8232. var directives = ref.directives; if ( directives === void 0 ) directives = {};
  8233. var isUnaryTag = ref.isUnaryTag; if ( isUnaryTag === void 0 ) isUnaryTag = (function () { return false; });
  8234. var template = ref.template;
  8235. var inject = ref.inject;
  8236. var cache = ref.cache;
  8237. var shouldPreload = ref.shouldPreload;
  8238. var shouldPrefetch = ref.shouldPrefetch;
  8239. var clientManifest = ref.clientManifest;
  8240. var serializer = ref.serializer;
  8241. var render = createRenderFunction(modules, directives, isUnaryTag, cache);
  8242. var templateRenderer = new TemplateRenderer({
  8243. template: template,
  8244. inject: inject,
  8245. shouldPreload: shouldPreload,
  8246. shouldPrefetch: shouldPrefetch,
  8247. clientManifest: clientManifest,
  8248. serializer: serializer
  8249. });
  8250. return {
  8251. renderToString: function renderToString (
  8252. component,
  8253. context,
  8254. cb
  8255. ) {
  8256. var assign;
  8257. if (typeof context === 'function') {
  8258. cb = context;
  8259. context = {};
  8260. }
  8261. if (context) {
  8262. templateRenderer.bindRenderFns(context);
  8263. }
  8264. // no callback, return Promise
  8265. var promise;
  8266. if (!cb) {
  8267. ((assign = createPromiseCallback(), promise = assign.promise, cb = assign.cb));
  8268. }
  8269. var result = '';
  8270. var write = createWriteFunction(function (text) {
  8271. result += text;
  8272. return false
  8273. }, cb);
  8274. try {
  8275. render(component, write, context, function (err) {
  8276. if (err) {
  8277. return cb(err)
  8278. }
  8279. if (context && context.rendered) {
  8280. context.rendered(context);
  8281. }
  8282. if (template) {
  8283. try {
  8284. var res = templateRenderer.render(result, context);
  8285. if (typeof res !== 'string') {
  8286. // function template returning promise
  8287. res
  8288. .then(function (html) { return cb(null, html); })
  8289. .catch(cb);
  8290. } else {
  8291. cb(null, res);
  8292. }
  8293. } catch (e) {
  8294. cb(e);
  8295. }
  8296. } else {
  8297. cb(null, result);
  8298. }
  8299. });
  8300. } catch (e) {
  8301. cb(e);
  8302. }
  8303. return promise
  8304. },
  8305. renderToStream: function renderToStream (
  8306. component,
  8307. context
  8308. ) {
  8309. if (context) {
  8310. templateRenderer.bindRenderFns(context);
  8311. }
  8312. var renderStream = new RenderStream(function (write, done) {
  8313. render(component, write, context, done);
  8314. });
  8315. if (!template) {
  8316. if (context && context.rendered) {
  8317. var rendered = context.rendered;
  8318. renderStream.once('beforeEnd', function () {
  8319. rendered(context);
  8320. });
  8321. }
  8322. return renderStream
  8323. } else if (typeof template === 'function') {
  8324. throw new Error("function template is only supported in renderToString.")
  8325. } else {
  8326. var templateStream = templateRenderer.createStream(context);
  8327. renderStream.on('error', function (err) {
  8328. templateStream.emit('error', err);
  8329. });
  8330. renderStream.pipe(templateStream);
  8331. if (context && context.rendered) {
  8332. var rendered$1 = context.rendered;
  8333. renderStream.once('beforeEnd', function () {
  8334. rendered$1(context);
  8335. });
  8336. }
  8337. return templateStream
  8338. }
  8339. }
  8340. }
  8341. }
  8342. var vm = require('vm');
  8343. var path$1 = require('path');
  8344. var resolve = require('resolve');
  8345. var NativeModule = require('module');
  8346. function createSandbox (context) {
  8347. var sandbox = {
  8348. Buffer: Buffer,
  8349. console: console,
  8350. process: process,
  8351. setTimeout: setTimeout,
  8352. setInterval: setInterval,
  8353. setImmediate: setImmediate,
  8354. clearTimeout: clearTimeout,
  8355. clearInterval: clearInterval,
  8356. clearImmediate: clearImmediate,
  8357. __VUE_SSR_CONTEXT__: context
  8358. };
  8359. sandbox.global = sandbox;
  8360. return sandbox
  8361. }
  8362. function compileModule (files, basedir, runInNewContext) {
  8363. var compiledScripts = {};
  8364. var resolvedModules = {};
  8365. function getCompiledScript (filename) {
  8366. if (compiledScripts[filename]) {
  8367. return compiledScripts[filename]
  8368. }
  8369. var code = files[filename];
  8370. var wrapper = NativeModule.wrap(code);
  8371. var script = new vm.Script(wrapper, {
  8372. filename: filename,
  8373. displayErrors: true
  8374. });
  8375. compiledScripts[filename] = script;
  8376. return script
  8377. }
  8378. function evaluateModule (filename, sandbox, evaluatedFiles) {
  8379. if ( evaluatedFiles === void 0 ) evaluatedFiles = {};
  8380. if (evaluatedFiles[filename]) {
  8381. return evaluatedFiles[filename]
  8382. }
  8383. var script = getCompiledScript(filename);
  8384. var compiledWrapper = runInNewContext === false
  8385. ? script.runInThisContext()
  8386. : script.runInNewContext(sandbox);
  8387. var m = { exports: {}};
  8388. var r = function (file) {
  8389. file = path$1.posix.join('.', file);
  8390. if (files[file]) {
  8391. return evaluateModule(file, sandbox, evaluatedFiles)
  8392. } else if (basedir) {
  8393. return require(
  8394. resolvedModules[file] ||
  8395. (resolvedModules[file] = resolve.sync(file, { basedir: basedir }))
  8396. )
  8397. } else {
  8398. return require(file)
  8399. }
  8400. };
  8401. compiledWrapper.call(m.exports, m.exports, r, m);
  8402. var res = Object.prototype.hasOwnProperty.call(m.exports, 'default')
  8403. ? m.exports.default
  8404. : m.exports;
  8405. evaluatedFiles[filename] = res;
  8406. return res
  8407. }
  8408. return evaluateModule
  8409. }
  8410. function deepClone (val) {
  8411. if (isPlainObject(val)) {
  8412. var res = {};
  8413. for (var key in val) {
  8414. res[key] = deepClone(val[key]);
  8415. }
  8416. return res
  8417. } else if (Array.isArray(val)) {
  8418. return val.slice()
  8419. } else {
  8420. return val
  8421. }
  8422. }
  8423. function createBundleRunner (entry, files, basedir, runInNewContext) {
  8424. var evaluate = compileModule(files, basedir, runInNewContext);
  8425. if (runInNewContext !== false && runInNewContext !== 'once') {
  8426. // new context mode: creates a fresh context and re-evaluate the bundle
  8427. // on each render. Ensures entire application state is fresh for each
  8428. // render, but incurs extra evaluation cost.
  8429. return function (userContext) {
  8430. if ( userContext === void 0 ) userContext = {};
  8431. return new Promise(function (resolve) {
  8432. userContext._registeredComponents = new Set();
  8433. var res = evaluate(entry, createSandbox(userContext));
  8434. resolve(typeof res === 'function' ? res(userContext) : res);
  8435. });
  8436. }
  8437. } else {
  8438. // direct mode: instead of re-evaluating the whole bundle on
  8439. // each render, it simply calls the exported function. This avoids the
  8440. // module evaluation costs but requires the source code to be structured
  8441. // slightly differently.
  8442. var runner; // lazy creation so that errors can be caught by user
  8443. var initialContext;
  8444. return function (userContext) {
  8445. if ( userContext === void 0 ) userContext = {};
  8446. return new Promise(function (resolve) {
  8447. if (!runner) {
  8448. var sandbox = runInNewContext === 'once'
  8449. ? createSandbox()
  8450. : global;
  8451. // the initial context is only used for collecting possible non-component
  8452. // styles injected by vue-style-loader.
  8453. initialContext = sandbox.__VUE_SSR_CONTEXT__ = {};
  8454. runner = evaluate(entry, sandbox);
  8455. // On subsequent renders, __VUE_SSR_CONTEXT__ will not be available
  8456. // to prevent cross-request pollution.
  8457. delete sandbox.__VUE_SSR_CONTEXT__;
  8458. if (typeof runner !== 'function') {
  8459. throw new Error(
  8460. 'bundle export should be a function when using ' +
  8461. '{ runInNewContext: false }.'
  8462. )
  8463. }
  8464. }
  8465. userContext._registeredComponents = new Set();
  8466. // vue-style-loader styles imported outside of component lifecycle hooks
  8467. if (initialContext._styles) {
  8468. userContext._styles = deepClone(initialContext._styles);
  8469. // #6353 ensure "styles" is exposed even if no styles are injected
  8470. // in component lifecycles.
  8471. // the renderStyles fn is exposed by vue-style-loader >= 3.0.3
  8472. var renderStyles = initialContext._renderStyles;
  8473. if (renderStyles) {
  8474. Object.defineProperty(userContext, 'styles', {
  8475. enumerable: true,
  8476. get: function get () {
  8477. return renderStyles(userContext._styles)
  8478. }
  8479. });
  8480. }
  8481. }
  8482. resolve(runner(userContext));
  8483. });
  8484. }
  8485. }
  8486. }
  8487. /* */
  8488. var SourceMapConsumer = require('source-map').SourceMapConsumer;
  8489. var filenameRE = /\(([^)]+\.js):(\d+):(\d+)\)$/;
  8490. function createSourceMapConsumers (rawMaps) {
  8491. var maps = {};
  8492. Object.keys(rawMaps).forEach(function (file) {
  8493. maps[file] = new SourceMapConsumer(rawMaps[file]);
  8494. });
  8495. return maps
  8496. }
  8497. function rewriteErrorTrace (e, mapConsumers) {
  8498. if (e && typeof e.stack === 'string') {
  8499. e.stack = e.stack.split('\n').map(function (line) {
  8500. return rewriteTraceLine(line, mapConsumers)
  8501. }).join('\n');
  8502. }
  8503. }
  8504. function rewriteTraceLine (trace, mapConsumers) {
  8505. var m = trace.match(filenameRE);
  8506. var map = m && mapConsumers[m[1]];
  8507. if (m != null && map) {
  8508. var originalPosition = map.originalPositionFor({
  8509. line: Number(m[2]),
  8510. column: Number(m[3])
  8511. });
  8512. if (originalPosition.source != null) {
  8513. var source = originalPosition.source;
  8514. var line = originalPosition.line;
  8515. var column = originalPosition.column;
  8516. var mappedPosition = "(" + (source.replace(/^webpack:\/\/\//, '')) + ":" + (String(line)) + ":" + (String(column)) + ")";
  8517. return trace.replace(filenameRE, mappedPosition)
  8518. } else {
  8519. return trace
  8520. }
  8521. } else {
  8522. return trace
  8523. }
  8524. }
  8525. /* */
  8526. var fs = require('fs');
  8527. var path$2 = require('path');
  8528. var PassThrough = require('stream').PassThrough;
  8529. var INVALID_MSG =
  8530. 'Invalid server-rendering bundle format. Should be a string ' +
  8531. 'or a bundle Object of type:\n\n' +
  8532. "{\n entry: string;\n files: { [filename: string]: string; };\n maps: { [filename: string]: string; };\n}\n";
  8533. // The render bundle can either be a string (single bundled file)
  8534. // or a bundle manifest object generated by vue-ssr-webpack-plugin.
  8535. function createBundleRendererCreator (
  8536. createRenderer
  8537. ) {
  8538. return function createBundleRenderer (
  8539. bundle,
  8540. rendererOptions
  8541. ) {
  8542. if ( rendererOptions === void 0 ) rendererOptions = {};
  8543. var files, entry, maps;
  8544. var basedir = rendererOptions.basedir;
  8545. // load bundle if given filepath
  8546. if (
  8547. typeof bundle === 'string' &&
  8548. /\.js(on)?$/.test(bundle) &&
  8549. path$2.isAbsolute(bundle)
  8550. ) {
  8551. if (fs.existsSync(bundle)) {
  8552. var isJSON = /\.json$/.test(bundle);
  8553. basedir = basedir || path$2.dirname(bundle);
  8554. bundle = fs.readFileSync(bundle, 'utf-8');
  8555. if (isJSON) {
  8556. try {
  8557. bundle = JSON.parse(bundle);
  8558. } catch (e) {
  8559. throw new Error(("Invalid JSON bundle file: " + bundle))
  8560. }
  8561. }
  8562. } else {
  8563. throw new Error(("Cannot locate bundle file: " + bundle))
  8564. }
  8565. }
  8566. if (typeof bundle === 'object') {
  8567. entry = bundle.entry;
  8568. files = bundle.files;
  8569. basedir = basedir || bundle.basedir;
  8570. maps = createSourceMapConsumers(bundle.maps);
  8571. if (typeof entry !== 'string' || typeof files !== 'object') {
  8572. throw new Error(INVALID_MSG)
  8573. }
  8574. } else if (typeof bundle === 'string') {
  8575. entry = '__vue_ssr_bundle__';
  8576. files = { '__vue_ssr_bundle__': bundle };
  8577. maps = {};
  8578. } else {
  8579. throw new Error(INVALID_MSG)
  8580. }
  8581. var renderer = createRenderer(rendererOptions);
  8582. var run = createBundleRunner(
  8583. entry,
  8584. files,
  8585. basedir,
  8586. rendererOptions.runInNewContext
  8587. );
  8588. return {
  8589. renderToString: function (context, cb) {
  8590. var assign;
  8591. if (typeof context === 'function') {
  8592. cb = context;
  8593. context = {};
  8594. }
  8595. var promise;
  8596. if (!cb) {
  8597. ((assign = createPromiseCallback(), promise = assign.promise, cb = assign.cb));
  8598. }
  8599. run(context).catch(function (err) {
  8600. rewriteErrorTrace(err, maps);
  8601. cb(err);
  8602. }).then(function (app) {
  8603. if (app) {
  8604. renderer.renderToString(app, context, function (err, res) {
  8605. rewriteErrorTrace(err, maps);
  8606. cb(err, res);
  8607. });
  8608. }
  8609. });
  8610. return promise
  8611. },
  8612. renderToStream: function (context) {
  8613. var res = new PassThrough();
  8614. run(context).catch(function (err) {
  8615. rewriteErrorTrace(err, maps);
  8616. // avoid emitting synchronously before user can
  8617. // attach error listener
  8618. process.nextTick(function () {
  8619. res.emit('error', err);
  8620. });
  8621. }).then(function (app) {
  8622. if (app) {
  8623. var renderStream = renderer.renderToStream(app, context);
  8624. renderStream.on('error', function (err) {
  8625. rewriteErrorTrace(err, maps);
  8626. res.emit('error', err);
  8627. });
  8628. // relay HTMLStream special events
  8629. if (rendererOptions && rendererOptions.template) {
  8630. renderStream.on('beforeStart', function () {
  8631. res.emit('beforeStart');
  8632. });
  8633. renderStream.on('beforeEnd', function () {
  8634. res.emit('beforeEnd');
  8635. });
  8636. }
  8637. renderStream.pipe(res);
  8638. }
  8639. });
  8640. return res
  8641. }
  8642. }
  8643. }
  8644. }
  8645. /* */
  8646. process.env.VUE_ENV = 'server';
  8647. function createRenderer$1 (options) {
  8648. if ( options === void 0 ) options = {};
  8649. return createRenderer(extend(extend({}, options), {
  8650. isUnaryTag: isUnaryTag,
  8651. canBeLeftOpenTag: canBeLeftOpenTag,
  8652. modules: modules,
  8653. // user can provide server-side implementations for custom directives
  8654. // when creating the renderer.
  8655. directives: extend(baseDirectives, options.directives)
  8656. }))
  8657. }
  8658. var createBundleRenderer = createBundleRendererCreator(createRenderer$1);
  8659. exports.createRenderer = createRenderer$1;
  8660. exports.createBundleRenderer = createBundleRenderer;