build.js 223 KB

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