1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264 |
- /**
- * @license Angular v5.2.11
- * (c) 2010-2018 Google, Inc. https://angular.io/
- * License: MIT
- */
- import { __assign, __extends } from 'tslib';
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- // Attention:
- // This file duplicates types and values from @angular/core
- // so that we are able to make @angular/compiler independent of @angular/core.
- // This is important to prevent a build cycle, as @angular/core needs to
- // be compiled with the compiler.
- /**
- * @record
- */
- function Inject() { }
- var createInject = makeMetadataFactory('Inject', function (token) { return ({ token: token }); });
- var createInjectionToken = makeMetadataFactory('InjectionToken', function (desc) { return ({ _desc: desc }); });
- /**
- * @record
- */
- function Attribute() { }
- var createAttribute = makeMetadataFactory('Attribute', function (attributeName) { return ({ attributeName: attributeName }); });
- /**
- * @record
- */
- function Query() { }
- var createContentChildren = makeMetadataFactory('ContentChildren', function (selector, data) {
- if (data === void 0) { data = {}; }
- return (__assign({ selector: selector, first: false, isViewQuery: false, descendants: false }, data));
- });
- var createContentChild = makeMetadataFactory('ContentChild', function (selector, data) {
- if (data === void 0) { data = {}; }
- return (__assign({ selector: selector, first: true, isViewQuery: false, descendants: true }, data));
- });
- var createViewChildren = makeMetadataFactory('ViewChildren', function (selector, data) {
- if (data === void 0) { data = {}; }
- return (__assign({ selector: selector, first: false, isViewQuery: true, descendants: true }, data));
- });
- var createViewChild = makeMetadataFactory('ViewChild', function (selector, data) {
- return (__assign({ selector: selector, first: true, isViewQuery: true, descendants: true }, data));
- });
- /**
- * @record
- */
- function Directive() { }
- var createDirective = makeMetadataFactory('Directive', function (dir) {
- if (dir === void 0) { dir = {}; }
- return dir;
- });
- /**
- * @record
- */
- function Component() { }
- /** @enum {number} */
- var ViewEncapsulation = {
- Emulated: 0,
- Native: 1,
- None: 2,
- };
- ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
- ViewEncapsulation[ViewEncapsulation.Native] = "Native";
- ViewEncapsulation[ViewEncapsulation.None] = "None";
- /** @enum {number} */
- var ChangeDetectionStrategy = {
- OnPush: 0,
- Default: 1,
- };
- ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
- ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
- var createComponent = makeMetadataFactory('Component', function (c) {
- if (c === void 0) { c = {}; }
- return (__assign({ changeDetection: ChangeDetectionStrategy.Default }, c));
- });
- /**
- * @record
- */
- function Pipe() { }
- var createPipe = makeMetadataFactory('Pipe', function (p) { return (__assign({ pure: true }, p)); });
- /**
- * @record
- */
- function Input() { }
- var createInput = makeMetadataFactory('Input', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
- /**
- * @record
- */
- function Output() { }
- var createOutput = makeMetadataFactory('Output', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
- /**
- * @record
- */
- function HostBinding() { }
- var createHostBinding = makeMetadataFactory('HostBinding', function (hostPropertyName) { return ({ hostPropertyName: hostPropertyName }); });
- /**
- * @record
- */
- function HostListener() { }
- var createHostListener = makeMetadataFactory('HostListener', function (eventName, args) { return ({ eventName: eventName, args: args }); });
- /**
- * @record
- */
- function NgModule() { }
- var createNgModule = makeMetadataFactory('NgModule', function (ngModule) { return ngModule; });
- /**
- * @record
- */
- function ModuleWithProviders() { }
- /**
- * @record
- */
- function SchemaMetadata() { }
- var CUSTOM_ELEMENTS_SCHEMA = {
- name: 'custom-elements'
- };
- var NO_ERRORS_SCHEMA = {
- name: 'no-errors-schema'
- };
- var createOptional = makeMetadataFactory('Optional');
- var createInjectable = makeMetadataFactory('Injectable');
- var createSelf = makeMetadataFactory('Self');
- var createSkipSelf = makeMetadataFactory('SkipSelf');
- var createHost = makeMetadataFactory('Host');
- var Type = Function;
- /** @enum {number} */
- var SecurityContext = {
- NONE: 0,
- HTML: 1,
- STYLE: 2,
- SCRIPT: 3,
- URL: 4,
- RESOURCE_URL: 5,
- };
- SecurityContext[SecurityContext.NONE] = "NONE";
- SecurityContext[SecurityContext.HTML] = "HTML";
- SecurityContext[SecurityContext.STYLE] = "STYLE";
- SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
- SecurityContext[SecurityContext.URL] = "URL";
- SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
- /** @enum {number} */
- var NodeFlags = {
- None: 0,
- TypeElement: 1,
- TypeText: 2,
- ProjectedTemplate: 4,
- CatRenderNode: 3,
- TypeNgContent: 8,
- TypePipe: 16,
- TypePureArray: 32,
- TypePureObject: 64,
- TypePurePipe: 128,
- CatPureExpression: 224,
- TypeValueProvider: 256,
- TypeClassProvider: 512,
- TypeFactoryProvider: 1024,
- TypeUseExistingProvider: 2048,
- LazyProvider: 4096,
- PrivateProvider: 8192,
- TypeDirective: 16384,
- Component: 32768,
- CatProviderNoDirective: 3840,
- CatProvider: 20224,
- OnInit: 65536,
- OnDestroy: 131072,
- DoCheck: 262144,
- OnChanges: 524288,
- AfterContentInit: 1048576,
- AfterContentChecked: 2097152,
- AfterViewInit: 4194304,
- AfterViewChecked: 8388608,
- EmbeddedViews: 16777216,
- ComponentView: 33554432,
- TypeContentQuery: 67108864,
- TypeViewQuery: 134217728,
- StaticQuery: 268435456,
- DynamicQuery: 536870912,
- CatQuery: 201326592,
- // mutually exclusive values...
- Types: 201347067,
- };
- /** @enum {number} */
- var DepFlags = {
- None: 0,
- SkipSelf: 1,
- Optional: 2,
- Value: 8,
- };
- /** @enum {number} */
- var ArgumentType = { Inline: 0, Dynamic: 1, };
- /** @enum {number} */
- var BindingFlags = {
- TypeElementAttribute: 1,
- TypeElementClass: 2,
- TypeElementStyle: 4,
- TypeProperty: 8,
- SyntheticProperty: 16,
- SyntheticHostProperty: 32,
- CatSyntheticProperty: 48,
- // mutually exclusive values...
- Types: 15,
- };
- /** @enum {number} */
- var QueryBindingType = { First: 0, All: 1, };
- /** @enum {number} */
- var QueryValueType = {
- ElementRef: 0,
- RenderElement: 1,
- TemplateRef: 2,
- ViewContainerRef: 3,
- Provider: 4,
- };
- /** @enum {number} */
- var ViewFlags = {
- None: 0,
- OnPush: 2,
- };
- /** @enum {number} */
- var MissingTranslationStrategy = {
- Error: 0,
- Warning: 1,
- Ignore: 2,
- };
- MissingTranslationStrategy[MissingTranslationStrategy.Error] = "Error";
- MissingTranslationStrategy[MissingTranslationStrategy.Warning] = "Warning";
- MissingTranslationStrategy[MissingTranslationStrategy.Ignore] = "Ignore";
- /**
- * @record
- * @template T
- */
- function MetadataFactory() { }
- /**
- * @template T
- * @param {?} name
- * @param {?=} props
- * @return {?}
- */
- function makeMetadataFactory(name, props) {
- var /** @type {?} */ factory = function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var /** @type {?} */ values = props ? props.apply(void 0, args) : {};
- return __assign({ ngMetadataName: name }, values);
- };
- factory.isTypeOf = function (obj) { return obj && obj.ngMetadataName === name; };
- factory.ngMetadataName = name;
- return factory;
- }
- /**
- * @record
- */
- function Route() { }
-
-
-
- var core = Object.freeze({
- Inject: Inject,
- createInject: createInject,
- createInjectionToken: createInjectionToken,
- Attribute: Attribute,
- createAttribute: createAttribute,
- Query: Query,
- createContentChildren: createContentChildren,
- createContentChild: createContentChild,
- createViewChildren: createViewChildren,
- createViewChild: createViewChild,
- Directive: Directive,
- createDirective: createDirective,
- Component: Component,
- ViewEncapsulation: ViewEncapsulation,
- ChangeDetectionStrategy: ChangeDetectionStrategy,
- createComponent: createComponent,
- Pipe: Pipe,
- createPipe: createPipe,
- Input: Input,
- createInput: createInput,
- Output: Output,
- createOutput: createOutput,
- HostBinding: HostBinding,
- createHostBinding: createHostBinding,
- HostListener: HostListener,
- createHostListener: createHostListener,
- NgModule: NgModule,
- createNgModule: createNgModule,
- ModuleWithProviders: ModuleWithProviders,
- SchemaMetadata: SchemaMetadata,
- CUSTOM_ELEMENTS_SCHEMA: CUSTOM_ELEMENTS_SCHEMA,
- NO_ERRORS_SCHEMA: NO_ERRORS_SCHEMA,
- createOptional: createOptional,
- createInjectable: createInjectable,
- createSelf: createSelf,
- createSkipSelf: createSkipSelf,
- createHost: createHost,
- Type: Type,
- SecurityContext: SecurityContext,
- NodeFlags: NodeFlags,
- DepFlags: DepFlags,
- ArgumentType: ArgumentType,
- BindingFlags: BindingFlags,
- QueryBindingType: QueryBindingType,
- QueryValueType: QueryValueType,
- ViewFlags: ViewFlags,
- MissingTranslationStrategy: MissingTranslationStrategy,
- MetadataFactory: MetadataFactory,
- Route: Route
- });
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var DASH_CASE_REGEXP = /-+([a-z0-9])/g;
- /**
- * @param {?} input
- * @return {?}
- */
- function dashCaseToCamelCase(input) {
- return input.replace(DASH_CASE_REGEXP, function () {
- var m = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- m[_i] = arguments[_i];
- }
- return m[1].toUpperCase();
- });
- }
- /**
- * @param {?} input
- * @param {?} defaultValues
- * @return {?}
- */
- function splitAtColon(input, defaultValues) {
- return _splitAt(input, ':', defaultValues);
- }
- /**
- * @param {?} input
- * @param {?} defaultValues
- * @return {?}
- */
- function splitAtPeriod(input, defaultValues) {
- return _splitAt(input, '.', defaultValues);
- }
- /**
- * @param {?} input
- * @param {?} character
- * @param {?} defaultValues
- * @return {?}
- */
- function _splitAt(input, character, defaultValues) {
- var /** @type {?} */ characterIndex = input.indexOf(character);
- if (characterIndex == -1)
- return defaultValues;
- return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()];
- }
- /**
- * @param {?} value
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function visitValue(value, visitor, context) {
- if (Array.isArray(value)) {
- return visitor.visitArray(/** @type {?} */ (value), context);
- }
- if (isStrictStringMap(value)) {
- return visitor.visitStringMap(/** @type {?} */ (value), context);
- }
- if (value == null || typeof value == 'string' || typeof value == 'number' ||
- typeof value == 'boolean') {
- return visitor.visitPrimitive(value, context);
- }
- return visitor.visitOther(value, context);
- }
- /**
- * @param {?} val
- * @return {?}
- */
- function isDefined(val) {
- return val !== null && val !== undefined;
- }
- /**
- * @template T
- * @param {?} val
- * @return {?}
- */
- function noUndefined(val) {
- return val === undefined ? /** @type {?} */ ((null)) : val;
- }
- /**
- * @record
- */
-
- var ValueTransformer = /** @class */ (function () {
- function ValueTransformer() {
- }
- /**
- * @param {?} arr
- * @param {?} context
- * @return {?}
- */
- ValueTransformer.prototype.visitArray = /**
- * @param {?} arr
- * @param {?} context
- * @return {?}
- */
- function (arr, context) {
- var _this = this;
- return arr.map(function (value) { return visitValue(value, _this, context); });
- };
- /**
- * @param {?} map
- * @param {?} context
- * @return {?}
- */
- ValueTransformer.prototype.visitStringMap = /**
- * @param {?} map
- * @param {?} context
- * @return {?}
- */
- function (map, context) {
- var _this = this;
- var /** @type {?} */ result = {};
- Object.keys(map).forEach(function (key) { result[key] = visitValue(map[key], _this, context); });
- return result;
- };
- /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- ValueTransformer.prototype.visitPrimitive = /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- function (value, context) { return value; };
- /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- ValueTransformer.prototype.visitOther = /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- function (value, context) { return value; };
- return ValueTransformer;
- }());
- var SyncAsync = {
- assertSync: function (value) {
- if (isPromise(value)) {
- throw new Error("Illegal state: value cannot be a promise");
- }
- return value;
- },
- then: function (value, cb) { return isPromise(value) ? value.then(cb) : cb(value); },
- all: function (syncAsyncValues) {
- return syncAsyncValues.some(isPromise) ? Promise.all(syncAsyncValues) : /** @type {?} */ (syncAsyncValues);
- }
- };
- /**
- * @param {?} msg
- * @param {?=} parseErrors
- * @return {?}
- */
- function syntaxError(msg, parseErrors) {
- var /** @type {?} */ error = Error(msg);
- (/** @type {?} */ (error))[ERROR_SYNTAX_ERROR] = true;
- if (parseErrors)
- (/** @type {?} */ (error))[ERROR_PARSE_ERRORS] = parseErrors;
- return error;
- }
- var ERROR_SYNTAX_ERROR = 'ngSyntaxError';
- var ERROR_PARSE_ERRORS = 'ngParseErrors';
- /**
- * @param {?} error
- * @return {?}
- */
- function isSyntaxError(error) {
- return (/** @type {?} */ (error))[ERROR_SYNTAX_ERROR];
- }
- /**
- * @param {?} error
- * @return {?}
- */
- function getParseErrors(error) {
- return (/** @type {?} */ (error))[ERROR_PARSE_ERRORS] || [];
- }
- /**
- * @param {?} s
- * @return {?}
- */
- function escapeRegExp(s) {
- return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
- }
- var STRING_MAP_PROTO = Object.getPrototypeOf({});
- /**
- * @param {?} obj
- * @return {?}
- */
- function isStrictStringMap(obj) {
- return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
- }
- /**
- * @param {?} str
- * @return {?}
- */
- function utf8Encode(str) {
- var /** @type {?} */ encoded = '';
- for (var /** @type {?} */ index = 0; index < str.length; index++) {
- var /** @type {?} */ codePoint = str.charCodeAt(index);
- // decode surrogate
- // see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
- if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > (index + 1)) {
- var /** @type {?} */ low = str.charCodeAt(index + 1);
- if (low >= 0xdc00 && low <= 0xdfff) {
- index++;
- codePoint = ((codePoint - 0xd800) << 10) + low - 0xdc00 + 0x10000;
- }
- }
- if (codePoint <= 0x7f) {
- encoded += String.fromCharCode(codePoint);
- }
- else if (codePoint <= 0x7ff) {
- encoded += String.fromCharCode(((codePoint >> 6) & 0x1F) | 0xc0, (codePoint & 0x3f) | 0x80);
- }
- else if (codePoint <= 0xffff) {
- encoded += String.fromCharCode((codePoint >> 12) | 0xe0, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
- }
- else if (codePoint <= 0x1fffff) {
- encoded += String.fromCharCode(((codePoint >> 18) & 0x07) | 0xf0, ((codePoint >> 12) & 0x3f) | 0x80, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
- }
- }
- return encoded;
- }
- /**
- * @record
- */
-
- /**
- * @param {?} token
- * @return {?}
- */
- function stringify(token) {
- if (typeof token === 'string') {
- return token;
- }
- if (token instanceof Array) {
- return '[' + token.map(stringify).join(', ') + ']';
- }
- if (token == null) {
- return '' + token;
- }
- if (token.overriddenName) {
- return "" + token.overriddenName;
- }
- if (token.name) {
- return "" + token.name;
- }
- var /** @type {?} */ res = token.toString();
- if (res == null) {
- return '' + res;
- }
- var /** @type {?} */ newLineIndex = res.indexOf('\n');
- return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
- }
- /**
- * Lazily retrieves the reference value from a forwardRef.
- * @param {?} type
- * @return {?}
- */
- function resolveForwardRef(type) {
- if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__')) {
- return type();
- }
- else {
- return type;
- }
- }
- /**
- * Determine if the argument is shaped like a Promise
- * @param {?} obj
- * @return {?}
- */
- function isPromise(obj) {
- // allow any Promise/A+ compliant thenable.
- // It's up to the caller to ensure that obj.then conforms to the spec
- return !!obj && typeof obj.then === 'function';
- }
- var Version = /** @class */ (function () {
- function Version(full) {
- this.full = full;
- var /** @type {?} */ splits = full.split('.');
- this.major = splits[0];
- this.minor = splits[1];
- this.patch = splits.slice(2).join('.');
- }
- return Version;
- }());
- /**
- * @record
- */
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@stable
- */
- var VERSION = new Version('5.2.11');
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * An Abstract Syntax Tree node representing part of a parsed Angular template.
- * @record
- */
-
- /**
- * A segment of text within the template.
- */
- var TextAst = /** @class */ (function () {
- function TextAst(value, ngContentIndex, sourceSpan) {
- this.value = value;
- this.ngContentIndex = ngContentIndex;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- TextAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitText(this, context); };
- return TextAst;
- }());
- /**
- * A bound expression within the text of a template.
- */
- var BoundTextAst = /** @class */ (function () {
- function BoundTextAst(value, ngContentIndex, sourceSpan) {
- this.value = value;
- this.ngContentIndex = ngContentIndex;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- BoundTextAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitBoundText(this, context);
- };
- return BoundTextAst;
- }());
- /**
- * A plain attribute on an element.
- */
- var AttrAst = /** @class */ (function () {
- function AttrAst(name, value, sourceSpan) {
- this.name = name;
- this.value = value;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- AttrAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitAttr(this, context); };
- return AttrAst;
- }());
- /**
- * A binding for an element property (e.g. `[property]="expression"`) or an animation trigger (e.g.
- * `[\@trigger]="stateExp"`)
- */
- var BoundElementPropertyAst = /** @class */ (function () {
- function BoundElementPropertyAst(name, type, securityContext, value, unit, sourceSpan) {
- this.name = name;
- this.type = type;
- this.securityContext = securityContext;
- this.value = value;
- this.unit = unit;
- this.sourceSpan = sourceSpan;
- this.isAnimation = this.type === PropertyBindingType.Animation;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- BoundElementPropertyAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitElementProperty(this, context);
- };
- return BoundElementPropertyAst;
- }());
- /**
- * A binding for an element event (e.g. `(event)="handler()"`) or an animation trigger event (e.g.
- * `(\@trigger.phase)="callback($event)"`).
- */
- var BoundEventAst = /** @class */ (function () {
- function BoundEventAst(name, target, phase, handler, sourceSpan) {
- this.name = name;
- this.target = target;
- this.phase = phase;
- this.handler = handler;
- this.sourceSpan = sourceSpan;
- this.fullName = BoundEventAst.calcFullName(this.name, this.target, this.phase);
- this.isAnimation = !!this.phase;
- }
- /**
- * @param {?} name
- * @param {?} target
- * @param {?} phase
- * @return {?}
- */
- BoundEventAst.calcFullName = /**
- * @param {?} name
- * @param {?} target
- * @param {?} phase
- * @return {?}
- */
- function (name, target, phase) {
- if (target) {
- return target + ":" + name;
- }
- else if (phase) {
- return "@" + name + "." + phase;
- }
- else {
- return name;
- }
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- BoundEventAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitEvent(this, context);
- };
- return BoundEventAst;
- }());
- /**
- * A reference declaration on an element (e.g. `let someName="expression"`).
- */
- var ReferenceAst = /** @class */ (function () {
- function ReferenceAst(name, value, sourceSpan) {
- this.name = name;
- this.value = value;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ReferenceAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitReference(this, context);
- };
- return ReferenceAst;
- }());
- /**
- * A variable declaration on a <ng-template> (e.g. `var-someName="someLocalName"`).
- */
- var VariableAst = /** @class */ (function () {
- function VariableAst(name, value, sourceSpan) {
- this.name = name;
- this.value = value;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- VariableAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitVariable(this, context);
- };
- return VariableAst;
- }());
- /**
- * An element declaration in a template.
- */
- var ElementAst = /** @class */ (function () {
- function ElementAst(name, attrs, inputs, outputs, references, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan, endSourceSpan) {
- this.name = name;
- this.attrs = attrs;
- this.inputs = inputs;
- this.outputs = outputs;
- this.references = references;
- this.directives = directives;
- this.providers = providers;
- this.hasViewContainer = hasViewContainer;
- this.queryMatches = queryMatches;
- this.children = children;
- this.ngContentIndex = ngContentIndex;
- this.sourceSpan = sourceSpan;
- this.endSourceSpan = endSourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ElementAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitElement(this, context);
- };
- return ElementAst;
- }());
- /**
- * A `<ng-template>` element included in an Angular template.
- */
- var EmbeddedTemplateAst = /** @class */ (function () {
- function EmbeddedTemplateAst(attrs, outputs, references, variables, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan) {
- this.attrs = attrs;
- this.outputs = outputs;
- this.references = references;
- this.variables = variables;
- this.directives = directives;
- this.providers = providers;
- this.hasViewContainer = hasViewContainer;
- this.queryMatches = queryMatches;
- this.children = children;
- this.ngContentIndex = ngContentIndex;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- EmbeddedTemplateAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitEmbeddedTemplate(this, context);
- };
- return EmbeddedTemplateAst;
- }());
- /**
- * A directive property with a bound value (e.g. `*ngIf="condition").
- */
- var BoundDirectivePropertyAst = /** @class */ (function () {
- function BoundDirectivePropertyAst(directiveName, templateName, value, sourceSpan) {
- this.directiveName = directiveName;
- this.templateName = templateName;
- this.value = value;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- BoundDirectivePropertyAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitDirectiveProperty(this, context);
- };
- return BoundDirectivePropertyAst;
- }());
- /**
- * A directive declared on an element.
- */
- var DirectiveAst = /** @class */ (function () {
- function DirectiveAst(directive, inputs, hostProperties, hostEvents, contentQueryStartId, sourceSpan) {
- this.directive = directive;
- this.inputs = inputs;
- this.hostProperties = hostProperties;
- this.hostEvents = hostEvents;
- this.contentQueryStartId = contentQueryStartId;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- DirectiveAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitDirective(this, context);
- };
- return DirectiveAst;
- }());
- /**
- * A provider declared on an element
- */
- var ProviderAst = /** @class */ (function () {
- function ProviderAst(token, multiProvider, eager, providers, providerType, lifecycleHooks, sourceSpan) {
- this.token = token;
- this.multiProvider = multiProvider;
- this.eager = eager;
- this.providers = providers;
- this.providerType = providerType;
- this.lifecycleHooks = lifecycleHooks;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ProviderAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- // No visit method in the visitor for now...
- return null;
- };
- return ProviderAst;
- }());
- /** @enum {number} */
- var ProviderAstType = {
- PublicService: 0,
- PrivateService: 1,
- Component: 2,
- Directive: 3,
- Builtin: 4,
- };
- ProviderAstType[ProviderAstType.PublicService] = "PublicService";
- ProviderAstType[ProviderAstType.PrivateService] = "PrivateService";
- ProviderAstType[ProviderAstType.Component] = "Component";
- ProviderAstType[ProviderAstType.Directive] = "Directive";
- ProviderAstType[ProviderAstType.Builtin] = "Builtin";
- /**
- * Position where content is to be projected (instance of `<ng-content>` in a template).
- */
- var NgContentAst = /** @class */ (function () {
- function NgContentAst(index, ngContentIndex, sourceSpan) {
- this.index = index;
- this.ngContentIndex = ngContentIndex;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- NgContentAst.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitNgContent(this, context);
- };
- return NgContentAst;
- }());
- /** @enum {number} */
- var PropertyBindingType = {
- /**
- * A normal binding to a property (e.g. `[property]="expression"`).
- */
- Property: 0,
- /**
- * A binding to an element attribute (e.g. `[attr.name]="expression"`).
- */
- Attribute: 1,
- /**
- * A binding to a CSS class (e.g. `[class.name]="condition"`).
- */
- Class: 2,
- /**
- * A binding to a style rule (e.g. `[style.rule]="expression"`).
- */
- Style: 3,
- /**
- * A binding to an animation reference (e.g. `[animate.key]="expression"`).
- */
- Animation: 4,
- };
- PropertyBindingType[PropertyBindingType.Property] = "Property";
- PropertyBindingType[PropertyBindingType.Attribute] = "Attribute";
- PropertyBindingType[PropertyBindingType.Class] = "Class";
- PropertyBindingType[PropertyBindingType.Style] = "Style";
- PropertyBindingType[PropertyBindingType.Animation] = "Animation";
- /**
- * @record
- */
-
- /**
- * A visitor for {\@link TemplateAst} trees that will process each node.
- * @record
- */
-
- /**
- * A visitor that accepts each node but doesn't do anything. It is intended to be used
- * as the base class for a visitor that is only interested in a subset of the node types.
- */
- var NullTemplateVisitor = /** @class */ (function () {
- function NullTemplateVisitor() {
- }
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitNgContent = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitEmbeddedTemplate = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitElement = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitReference = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitVariable = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitEvent = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitElementProperty = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitAttr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitBoundText = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitText = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitDirective = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullTemplateVisitor.prototype.visitDirectiveProperty = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- return NullTemplateVisitor;
- }());
- /**
- * Base class that can be used to build a visitor that visits each node
- * in an template ast recursively.
- */
- var RecursiveTemplateAstVisitor = /** @class */ (function (_super) {
- __extends(RecursiveTemplateAstVisitor, _super);
- function RecursiveTemplateAstVisitor() {
- return _super.call(this) || this;
- }
- // Nodes with children
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveTemplateAstVisitor.prototype.visitEmbeddedTemplate = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.visitChildren(context, function (visit) {
- visit(ast.attrs);
- visit(ast.references);
- visit(ast.variables);
- visit(ast.directives);
- visit(ast.providers);
- visit(ast.children);
- });
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveTemplateAstVisitor.prototype.visitElement = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.visitChildren(context, function (visit) {
- visit(ast.attrs);
- visit(ast.inputs);
- visit(ast.outputs);
- visit(ast.references);
- visit(ast.directives);
- visit(ast.providers);
- visit(ast.children);
- });
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveTemplateAstVisitor.prototype.visitDirective = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.visitChildren(context, function (visit) {
- visit(ast.inputs);
- visit(ast.hostProperties);
- visit(ast.hostEvents);
- });
- };
- /**
- * @template T
- * @param {?} context
- * @param {?} cb
- * @return {?}
- */
- RecursiveTemplateAstVisitor.prototype.visitChildren = /**
- * @template T
- * @param {?} context
- * @param {?} cb
- * @return {?}
- */
- function (context, cb) {
- var /** @type {?} */ results = [];
- var /** @type {?} */ t = this;
- /**
- * @template T
- * @param {?} children
- * @return {?}
- */
- function visit(children) {
- if (children && children.length)
- results.push(templateVisitAll(t, children, context));
- }
- cb(visit);
- return [].concat.apply([], results);
- };
- return RecursiveTemplateAstVisitor;
- }(NullTemplateVisitor));
- /**
- * Visit every node in a list of {\@link TemplateAst}s with the given {\@link TemplateAstVisitor}.
- * @param {?} visitor
- * @param {?} asts
- * @param {?=} context
- * @return {?}
- */
- function templateVisitAll(visitor, asts, context) {
- if (context === void 0) { context = null; }
- var /** @type {?} */ result = [];
- var /** @type {?} */ visit = visitor.visit ?
- function (ast) { return ((visitor.visit))(ast, context) || ast.visit(visitor, context); } :
- function (ast) { return ast.visit(visitor, context); };
- asts.forEach(function (ast) {
- var /** @type {?} */ astResult = visit(ast);
- if (astResult) {
- result.push(astResult);
- }
- });
- return result;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var CompilerConfig = /** @class */ (function () {
- function CompilerConfig(_a) {
- var _b = _a === void 0 ? {} : _a, _c = _b.defaultEncapsulation, defaultEncapsulation = _c === void 0 ? ViewEncapsulation.Emulated : _c, _d = _b.useJit, useJit = _d === void 0 ? true : _d, _e = _b.jitDevMode, jitDevMode = _e === void 0 ? false : _e, _f = _b.missingTranslation, missingTranslation = _f === void 0 ? null : _f, enableLegacyTemplate = _b.enableLegacyTemplate, preserveWhitespaces = _b.preserveWhitespaces, strictInjectionParameters = _b.strictInjectionParameters;
- this.defaultEncapsulation = defaultEncapsulation;
- this.useJit = !!useJit;
- this.jitDevMode = !!jitDevMode;
- this.missingTranslation = missingTranslation;
- this.enableLegacyTemplate = enableLegacyTemplate === true;
- this.preserveWhitespaces = preserveWhitespacesDefault(noUndefined(preserveWhitespaces));
- this.strictInjectionParameters = strictInjectionParameters === true;
- }
- return CompilerConfig;
- }());
- /**
- * @param {?} preserveWhitespacesOption
- * @param {?=} defaultSetting
- * @return {?}
- */
- function preserveWhitespacesDefault(preserveWhitespacesOption, defaultSetting) {
- if (defaultSetting === void 0) { defaultSetting = true; }
- return preserveWhitespacesOption === null ? defaultSetting : preserveWhitespacesOption;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A token representing the a reference to a static type.
- *
- * This token is unique for a filePath and name and can be used as a hash table key.
- */
- var StaticSymbol = /** @class */ (function () {
- function StaticSymbol(filePath, name, members) {
- this.filePath = filePath;
- this.name = name;
- this.members = members;
- }
- /**
- * @return {?}
- */
- StaticSymbol.prototype.assertNoMembers = /**
- * @return {?}
- */
- function () {
- if (this.members.length) {
- throw new Error("Illegal state: symbol without members expected, but got " + JSON.stringify(this) + ".");
- }
- };
- return StaticSymbol;
- }());
- /**
- * A cache of static symbol used by the StaticReflector to return the same symbol for the
- * same symbol values.
- */
- var StaticSymbolCache = /** @class */ (function () {
- function StaticSymbolCache() {
- this.cache = new Map();
- }
- /**
- * @param {?} declarationFile
- * @param {?} name
- * @param {?=} members
- * @return {?}
- */
- StaticSymbolCache.prototype.get = /**
- * @param {?} declarationFile
- * @param {?} name
- * @param {?=} members
- * @return {?}
- */
- function (declarationFile, name, members) {
- members = members || [];
- var /** @type {?} */ memberSuffix = members.length ? "." + members.join('.') : '';
- var /** @type {?} */ key = "\"" + declarationFile + "\"." + name + memberSuffix;
- var /** @type {?} */ result = this.cache.get(key);
- if (!result) {
- result = new StaticSymbol(declarationFile, name, members);
- this.cache.set(key, result);
- }
- return result;
- };
- return StaticSymbolCache;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- // group 0: "[prop] or (event) or @trigger"
- // group 1: "prop" from "[prop]"
- // group 2: "event" from "(event)"
- // group 3: "@trigger" from "@trigger"
- var HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/;
- /**
- * @param {?} name
- * @return {?}
- */
- function _sanitizeIdentifier(name) {
- return name.replace(/\W/g, '_');
- }
- var _anonymousTypeIndex = 0;
- /**
- * @param {?} compileIdentifier
- * @return {?}
- */
- function identifierName(compileIdentifier) {
- if (!compileIdentifier || !compileIdentifier.reference) {
- return null;
- }
- var /** @type {?} */ ref = compileIdentifier.reference;
- if (ref instanceof StaticSymbol) {
- return ref.name;
- }
- if (ref['__anonymousType']) {
- return ref['__anonymousType'];
- }
- var /** @type {?} */ identifier = stringify(ref);
- if (identifier.indexOf('(') >= 0) {
- // case: anonymous functions!
- identifier = "anonymous_" + _anonymousTypeIndex++;
- ref['__anonymousType'] = identifier;
- }
- else {
- identifier = _sanitizeIdentifier(identifier);
- }
- return identifier;
- }
- /**
- * @param {?} compileIdentifier
- * @return {?}
- */
- function identifierModuleUrl(compileIdentifier) {
- var /** @type {?} */ ref = compileIdentifier.reference;
- if (ref instanceof StaticSymbol) {
- return ref.filePath;
- }
- // Runtime type
- return "./" + stringify(ref);
- }
- /**
- * @param {?} compType
- * @param {?} embeddedTemplateIndex
- * @return {?}
- */
- function viewClassName(compType, embeddedTemplateIndex) {
- return "View_" + identifierName({ reference: compType }) + "_" + embeddedTemplateIndex;
- }
- /**
- * @param {?} compType
- * @return {?}
- */
- function rendererTypeName(compType) {
- return "RenderType_" + identifierName({ reference: compType });
- }
- /**
- * @param {?} compType
- * @return {?}
- */
- function hostViewClassName(compType) {
- return "HostView_" + identifierName({ reference: compType });
- }
- /**
- * @param {?} compType
- * @return {?}
- */
- function componentFactoryName(compType) {
- return identifierName({ reference: compType }) + "NgFactory";
- }
- /**
- * @record
- */
-
- /**
- * @record
- */
-
- /** @enum {number} */
- var CompileSummaryKind = {
- Pipe: 0,
- Directive: 1,
- NgModule: 2,
- Injectable: 3,
- };
- CompileSummaryKind[CompileSummaryKind.Pipe] = "Pipe";
- CompileSummaryKind[CompileSummaryKind.Directive] = "Directive";
- CompileSummaryKind[CompileSummaryKind.NgModule] = "NgModule";
- CompileSummaryKind[CompileSummaryKind.Injectable] = "Injectable";
- /**
- * A CompileSummary is the data needed to use a directive / pipe / module
- * in other modules / components. However, this data is not enough to compile
- * the directive / module itself.
- * @record
- */
-
- /**
- * @record
- */
-
- /**
- * @record
- */
-
- /**
- * @record
- */
-
- /**
- * @param {?} token
- * @return {?}
- */
- function tokenName(token) {
- return token.value != null ? _sanitizeIdentifier(token.value) : identifierName(token.identifier);
- }
- /**
- * @param {?} token
- * @return {?}
- */
- function tokenReference(token) {
- if (token.identifier != null) {
- return token.identifier.reference;
- }
- else {
- return token.value;
- }
- }
- /**
- * @record
- */
-
- /**
- * Metadata regarding compilation of a type.
- * @record
- */
-
- /**
- * @record
- */
-
- /**
- * Metadata about a stylesheet
- */
- var CompileStylesheetMetadata = /** @class */ (function () {
- function CompileStylesheetMetadata(_a) {
- var _b = _a === void 0 ? {} : _a, moduleUrl = _b.moduleUrl, styles = _b.styles, styleUrls = _b.styleUrls;
- this.moduleUrl = moduleUrl || null;
- this.styles = _normalizeArray(styles);
- this.styleUrls = _normalizeArray(styleUrls);
- }
- return CompileStylesheetMetadata;
- }());
- /**
- * Summary Metadata regarding compilation of a template.
- * @record
- */
-
- /**
- * Metadata regarding compilation of a template.
- */
- var CompileTemplateMetadata = /** @class */ (function () {
- function CompileTemplateMetadata(_a) {
- var encapsulation = _a.encapsulation, template = _a.template, templateUrl = _a.templateUrl, htmlAst = _a.htmlAst, styles = _a.styles, styleUrls = _a.styleUrls, externalStylesheets = _a.externalStylesheets, animations = _a.animations, ngContentSelectors = _a.ngContentSelectors, interpolation = _a.interpolation, isInline = _a.isInline, preserveWhitespaces = _a.preserveWhitespaces;
- this.encapsulation = encapsulation;
- this.template = template;
- this.templateUrl = templateUrl;
- this.htmlAst = htmlAst;
- this.styles = _normalizeArray(styles);
- this.styleUrls = _normalizeArray(styleUrls);
- this.externalStylesheets = _normalizeArray(externalStylesheets);
- this.animations = animations ? flatten(animations) : [];
- this.ngContentSelectors = ngContentSelectors || [];
- if (interpolation && interpolation.length != 2) {
- throw new Error("'interpolation' should have a start and an end symbol.");
- }
- this.interpolation = interpolation;
- this.isInline = isInline;
- this.preserveWhitespaces = preserveWhitespaces;
- }
- /**
- * @return {?}
- */
- CompileTemplateMetadata.prototype.toSummary = /**
- * @return {?}
- */
- function () {
- return {
- ngContentSelectors: this.ngContentSelectors,
- encapsulation: this.encapsulation,
- };
- };
- return CompileTemplateMetadata;
- }());
- /**
- * @record
- */
-
- /**
- * @record
- */
-
- /**
- * Metadata regarding compilation of a directive.
- */
- var CompileDirectiveMetadata = /** @class */ (function () {
- function CompileDirectiveMetadata(_a) {
- var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, hostListeners = _a.hostListeners, hostProperties = _a.hostProperties, hostAttributes = _a.hostAttributes, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, guards = _a.guards, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory;
- this.isHost = !!isHost;
- this.type = type;
- this.isComponent = isComponent;
- this.selector = selector;
- this.exportAs = exportAs;
- this.changeDetection = changeDetection;
- this.inputs = inputs;
- this.outputs = outputs;
- this.hostListeners = hostListeners;
- this.hostProperties = hostProperties;
- this.hostAttributes = hostAttributes;
- this.providers = _normalizeArray(providers);
- this.viewProviders = _normalizeArray(viewProviders);
- this.queries = _normalizeArray(queries);
- this.guards = guards;
- this.viewQueries = _normalizeArray(viewQueries);
- this.entryComponents = _normalizeArray(entryComponents);
- this.template = template;
- this.componentViewType = componentViewType;
- this.rendererType = rendererType;
- this.componentFactory = componentFactory;
- }
- /**
- * @param {?} __0
- * @return {?}
- */
- CompileDirectiveMetadata.create = /**
- * @param {?} __0
- * @return {?}
- */
- function (_a) {
- var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, host = _a.host, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, guards = _a.guards, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory;
- var /** @type {?} */ hostListeners = {};
- var /** @type {?} */ hostProperties = {};
- var /** @type {?} */ hostAttributes = {};
- if (host != null) {
- Object.keys(host).forEach(function (key) {
- var /** @type {?} */ value = host[key];
- var /** @type {?} */ matches = key.match(HOST_REG_EXP);
- if (matches === null) {
- hostAttributes[key] = value;
- }
- else if (matches[1] != null) {
- hostProperties[matches[1]] = value;
- }
- else if (matches[2] != null) {
- hostListeners[matches[2]] = value;
- }
- });
- }
- var /** @type {?} */ inputsMap = {};
- if (inputs != null) {
- inputs.forEach(function (bindConfig) {
- // canonical syntax: `dirProp: elProp`
- // if there is no `:`, use dirProp = elProp
- var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
- inputsMap[parts[0]] = parts[1];
- });
- }
- var /** @type {?} */ outputsMap = {};
- if (outputs != null) {
- outputs.forEach(function (bindConfig) {
- // canonical syntax: `dirProp: elProp`
- // if there is no `:`, use dirProp = elProp
- var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
- outputsMap[parts[0]] = parts[1];
- });
- }
- return new CompileDirectiveMetadata({
- isHost: isHost,
- type: type,
- isComponent: !!isComponent, selector: selector, exportAs: exportAs, changeDetection: changeDetection,
- inputs: inputsMap,
- outputs: outputsMap,
- hostListeners: hostListeners,
- hostProperties: hostProperties,
- hostAttributes: hostAttributes,
- providers: providers,
- viewProviders: viewProviders,
- queries: queries,
- guards: guards,
- viewQueries: viewQueries,
- entryComponents: entryComponents,
- template: template,
- componentViewType: componentViewType,
- rendererType: rendererType,
- componentFactory: componentFactory,
- });
- };
- /**
- * @return {?}
- */
- CompileDirectiveMetadata.prototype.toSummary = /**
- * @return {?}
- */
- function () {
- return {
- summaryKind: CompileSummaryKind.Directive,
- type: this.type,
- isComponent: this.isComponent,
- selector: this.selector,
- exportAs: this.exportAs,
- inputs: this.inputs,
- outputs: this.outputs,
- hostListeners: this.hostListeners,
- hostProperties: this.hostProperties,
- hostAttributes: this.hostAttributes,
- providers: this.providers,
- viewProviders: this.viewProviders,
- queries: this.queries,
- guards: this.guards,
- viewQueries: this.viewQueries,
- entryComponents: this.entryComponents,
- changeDetection: this.changeDetection,
- template: this.template && this.template.toSummary(),
- componentViewType: this.componentViewType,
- rendererType: this.rendererType,
- componentFactory: this.componentFactory
- };
- };
- return CompileDirectiveMetadata;
- }());
- /**
- * @record
- */
-
- var CompilePipeMetadata = /** @class */ (function () {
- function CompilePipeMetadata(_a) {
- var type = _a.type, name = _a.name, pure = _a.pure;
- this.type = type;
- this.name = name;
- this.pure = !!pure;
- }
- /**
- * @return {?}
- */
- CompilePipeMetadata.prototype.toSummary = /**
- * @return {?}
- */
- function () {
- return {
- summaryKind: CompileSummaryKind.Pipe,
- type: this.type,
- name: this.name,
- pure: this.pure
- };
- };
- return CompilePipeMetadata;
- }());
- /**
- * @record
- */
-
- /**
- * Metadata regarding compilation of a module.
- */
- var CompileNgModuleMetadata = /** @class */ (function () {
- function CompileNgModuleMetadata(_a) {
- var type = _a.type, providers = _a.providers, declaredDirectives = _a.declaredDirectives, exportedDirectives = _a.exportedDirectives, declaredPipes = _a.declaredPipes, exportedPipes = _a.exportedPipes, entryComponents = _a.entryComponents, bootstrapComponents = _a.bootstrapComponents, importedModules = _a.importedModules, exportedModules = _a.exportedModules, schemas = _a.schemas, transitiveModule = _a.transitiveModule, id = _a.id;
- this.type = type || null;
- this.declaredDirectives = _normalizeArray(declaredDirectives);
- this.exportedDirectives = _normalizeArray(exportedDirectives);
- this.declaredPipes = _normalizeArray(declaredPipes);
- this.exportedPipes = _normalizeArray(exportedPipes);
- this.providers = _normalizeArray(providers);
- this.entryComponents = _normalizeArray(entryComponents);
- this.bootstrapComponents = _normalizeArray(bootstrapComponents);
- this.importedModules = _normalizeArray(importedModules);
- this.exportedModules = _normalizeArray(exportedModules);
- this.schemas = _normalizeArray(schemas);
- this.id = id || null;
- this.transitiveModule = transitiveModule || null;
- }
- /**
- * @return {?}
- */
- CompileNgModuleMetadata.prototype.toSummary = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ module = /** @type {?} */ ((this.transitiveModule));
- return {
- summaryKind: CompileSummaryKind.NgModule,
- type: this.type,
- entryComponents: module.entryComponents,
- providers: module.providers,
- modules: module.modules,
- exportedDirectives: module.exportedDirectives,
- exportedPipes: module.exportedPipes
- };
- };
- return CompileNgModuleMetadata;
- }());
- var TransitiveCompileNgModuleMetadata = /** @class */ (function () {
- function TransitiveCompileNgModuleMetadata() {
- this.directivesSet = new Set();
- this.directives = [];
- this.exportedDirectivesSet = new Set();
- this.exportedDirectives = [];
- this.pipesSet = new Set();
- this.pipes = [];
- this.exportedPipesSet = new Set();
- this.exportedPipes = [];
- this.modulesSet = new Set();
- this.modules = [];
- this.entryComponentsSet = new Set();
- this.entryComponents = [];
- this.providers = [];
- }
- /**
- * @param {?} provider
- * @param {?} module
- * @return {?}
- */
- TransitiveCompileNgModuleMetadata.prototype.addProvider = /**
- * @param {?} provider
- * @param {?} module
- * @return {?}
- */
- function (provider, module) {
- this.providers.push({ provider: provider, module: module });
- };
- /**
- * @param {?} id
- * @return {?}
- */
- TransitiveCompileNgModuleMetadata.prototype.addDirective = /**
- * @param {?} id
- * @return {?}
- */
- function (id) {
- if (!this.directivesSet.has(id.reference)) {
- this.directivesSet.add(id.reference);
- this.directives.push(id);
- }
- };
- /**
- * @param {?} id
- * @return {?}
- */
- TransitiveCompileNgModuleMetadata.prototype.addExportedDirective = /**
- * @param {?} id
- * @return {?}
- */
- function (id) {
- if (!this.exportedDirectivesSet.has(id.reference)) {
- this.exportedDirectivesSet.add(id.reference);
- this.exportedDirectives.push(id);
- }
- };
- /**
- * @param {?} id
- * @return {?}
- */
- TransitiveCompileNgModuleMetadata.prototype.addPipe = /**
- * @param {?} id
- * @return {?}
- */
- function (id) {
- if (!this.pipesSet.has(id.reference)) {
- this.pipesSet.add(id.reference);
- this.pipes.push(id);
- }
- };
- /**
- * @param {?} id
- * @return {?}
- */
- TransitiveCompileNgModuleMetadata.prototype.addExportedPipe = /**
- * @param {?} id
- * @return {?}
- */
- function (id) {
- if (!this.exportedPipesSet.has(id.reference)) {
- this.exportedPipesSet.add(id.reference);
- this.exportedPipes.push(id);
- }
- };
- /**
- * @param {?} id
- * @return {?}
- */
- TransitiveCompileNgModuleMetadata.prototype.addModule = /**
- * @param {?} id
- * @return {?}
- */
- function (id) {
- if (!this.modulesSet.has(id.reference)) {
- this.modulesSet.add(id.reference);
- this.modules.push(id);
- }
- };
- /**
- * @param {?} ec
- * @return {?}
- */
- TransitiveCompileNgModuleMetadata.prototype.addEntryComponent = /**
- * @param {?} ec
- * @return {?}
- */
- function (ec) {
- if (!this.entryComponentsSet.has(ec.componentType)) {
- this.entryComponentsSet.add(ec.componentType);
- this.entryComponents.push(ec);
- }
- };
- return TransitiveCompileNgModuleMetadata;
- }());
- /**
- * @param {?} obj
- * @return {?}
- */
- function _normalizeArray(obj) {
- return obj || [];
- }
- var ProviderMeta = /** @class */ (function () {
- function ProviderMeta(token, _a) {
- var useClass = _a.useClass, useValue = _a.useValue, useExisting = _a.useExisting, useFactory = _a.useFactory, deps = _a.deps, multi = _a.multi;
- this.token = token;
- this.useClass = useClass || null;
- this.useValue = useValue;
- this.useExisting = useExisting;
- this.useFactory = useFactory || null;
- this.dependencies = deps || null;
- this.multi = !!multi;
- }
- return ProviderMeta;
- }());
- /**
- * @template T
- * @param {?} list
- * @return {?}
- */
- function flatten(list) {
- return list.reduce(function (flat, item) {
- var /** @type {?} */ flatItem = Array.isArray(item) ? flatten(item) : item;
- return (/** @type {?} */ (flat)).concat(flatItem);
- }, []);
- }
- /**
- * @param {?} url
- * @return {?}
- */
- function jitSourceUrl(url) {
- // Note: We need 3 "/" so that ng shows up as a separate domain
- // in the chrome dev tools.
- return url.replace(/(\w+:\/\/[\w:-]+)?(\/+)?/, 'ng:///');
- }
- /**
- * @param {?} ngModuleType
- * @param {?} compMeta
- * @param {?} templateMeta
- * @return {?}
- */
- function templateSourceUrl(ngModuleType, compMeta, templateMeta) {
- var /** @type {?} */ url;
- if (templateMeta.isInline) {
- if (compMeta.type.reference instanceof StaticSymbol) {
- // Note: a .ts file might contain multiple components with inline templates,
- // so we need to give them unique urls, as these will be used for sourcemaps.
- url = compMeta.type.reference.filePath + "." + compMeta.type.reference.name + ".html";
- }
- else {
- url = identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".html";
- }
- }
- else {
- url = /** @type {?} */ ((templateMeta.templateUrl));
- }
- return compMeta.type.reference instanceof StaticSymbol ? url : jitSourceUrl(url);
- }
- /**
- * @param {?} meta
- * @param {?} id
- * @return {?}
- */
- function sharedStylesheetJitUrl(meta, id) {
- var /** @type {?} */ pathParts = /** @type {?} */ ((meta.moduleUrl)).split(/\/\\/g);
- var /** @type {?} */ baseName = pathParts[pathParts.length - 1];
- return jitSourceUrl("css/" + id + baseName + ".ngstyle.js");
- }
- /**
- * @param {?} moduleMeta
- * @return {?}
- */
- function ngModuleJitUrl(moduleMeta) {
- return jitSourceUrl(identifierName(moduleMeta.type) + "/module.ngfactory.js");
- }
- /**
- * @param {?} ngModuleType
- * @param {?} compMeta
- * @return {?}
- */
- function templateJitUrl(ngModuleType, compMeta) {
- return jitSourceUrl(identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".ngfactory.js");
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A path is an ordered set of elements. Typically a path is to a
- * particular offset in a source file. The head of the list is the top
- * most node. The tail is the node that contains the offset directly.
- *
- * For example, the expresion `a + b + c` might have an ast that looks
- * like:
- * +
- * / \
- * a +
- * / \
- * b c
- *
- * The path to the node at offset 9 would be `['+' at 1-10, '+' at 7-10,
- * 'c' at 9-10]` and the path the node at offset 1 would be
- * `['+' at 1-10, 'a' at 1-2]`.
- * @template T
- */
- var AstPath = /** @class */ (function () {
- function AstPath(path, position) {
- if (position === void 0) { position = -1; }
- this.path = path;
- this.position = position;
- }
- Object.defineProperty(AstPath.prototype, "empty", {
- get: /**
- * @return {?}
- */
- function () { return !this.path || !this.path.length; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AstPath.prototype, "head", {
- get: /**
- * @return {?}
- */
- function () { return this.path[0]; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AstPath.prototype, "tail", {
- get: /**
- * @return {?}
- */
- function () { return this.path[this.path.length - 1]; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} node
- * @return {?}
- */
- AstPath.prototype.parentOf = /**
- * @param {?} node
- * @return {?}
- */
- function (node) {
- return node && this.path[this.path.indexOf(node) - 1];
- };
- /**
- * @param {?} node
- * @return {?}
- */
- AstPath.prototype.childOf = /**
- * @param {?} node
- * @return {?}
- */
- function (node) { return this.path[this.path.indexOf(node) + 1]; };
- /**
- * @template N
- * @param {?} ctor
- * @return {?}
- */
- AstPath.prototype.first = /**
- * @template N
- * @param {?} ctor
- * @return {?}
- */
- function (ctor) {
- for (var /** @type {?} */ i = this.path.length - 1; i >= 0; i--) {
- var /** @type {?} */ item = this.path[i];
- if (item instanceof ctor)
- return /** @type {?} */ (item);
- }
- };
- /**
- * @param {?} node
- * @return {?}
- */
- AstPath.prototype.push = /**
- * @param {?} node
- * @return {?}
- */
- function (node) { this.path.push(node); };
- /**
- * @return {?}
- */
- AstPath.prototype.pop = /**
- * @return {?}
- */
- function () { return /** @type {?} */ ((this.path.pop())); };
- return AstPath;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @record
- */
-
- var Text = /** @class */ (function () {
- function Text(value, sourceSpan) {
- this.value = value;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- Text.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitText(this, context); };
- return Text;
- }());
- var Expansion = /** @class */ (function () {
- function Expansion(switchValue, type, cases, sourceSpan, switchValueSourceSpan) {
- this.switchValue = switchValue;
- this.type = type;
- this.cases = cases;
- this.sourceSpan = sourceSpan;
- this.switchValueSourceSpan = switchValueSourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- Expansion.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitExpansion(this, context); };
- return Expansion;
- }());
- var ExpansionCase = /** @class */ (function () {
- function ExpansionCase(value, expression, sourceSpan, valueSourceSpan, expSourceSpan) {
- this.value = value;
- this.expression = expression;
- this.sourceSpan = sourceSpan;
- this.valueSourceSpan = valueSourceSpan;
- this.expSourceSpan = expSourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ExpansionCase.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitExpansionCase(this, context); };
- return ExpansionCase;
- }());
- var Attribute$1 = /** @class */ (function () {
- function Attribute(name, value, sourceSpan, valueSpan) {
- this.name = name;
- this.value = value;
- this.sourceSpan = sourceSpan;
- this.valueSpan = valueSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- Attribute.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitAttribute(this, context); };
- return Attribute;
- }());
- var Element = /** @class */ (function () {
- function Element(name, attrs, children, sourceSpan, startSourceSpan, endSourceSpan) {
- if (startSourceSpan === void 0) { startSourceSpan = null; }
- if (endSourceSpan === void 0) { endSourceSpan = null; }
- this.name = name;
- this.attrs = attrs;
- this.children = children;
- this.sourceSpan = sourceSpan;
- this.startSourceSpan = startSourceSpan;
- this.endSourceSpan = endSourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- Element.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitElement(this, context); };
- return Element;
- }());
- var Comment = /** @class */ (function () {
- function Comment(value, sourceSpan) {
- this.value = value;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- Comment.prototype.visit = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitComment(this, context); };
- return Comment;
- }());
- /**
- * @record
- */
-
- /**
- * @param {?} visitor
- * @param {?} nodes
- * @param {?=} context
- * @return {?}
- */
- function visitAll(visitor, nodes, context) {
- if (context === void 0) { context = null; }
- var /** @type {?} */ result = [];
- var /** @type {?} */ visit = visitor.visit ?
- function (ast) { return ((visitor.visit))(ast, context) || ast.visit(visitor, context); } :
- function (ast) { return ast.visit(visitor, context); };
- nodes.forEach(function (ast) {
- var /** @type {?} */ astResult = visit(ast);
- if (astResult) {
- result.push(astResult);
- }
- });
- return result;
- }
- var RecursiveVisitor = /** @class */ (function () {
- function RecursiveVisitor() {
- }
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveVisitor.prototype.visitElement = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- this.visitChildren(context, function (visit) {
- visit(ast.attrs);
- visit(ast.children);
- });
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveVisitor.prototype.visitAttribute = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveVisitor.prototype.visitText = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveVisitor.prototype.visitComment = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveVisitor.prototype.visitExpansion = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.visitChildren(context, function (visit) { visit(ast.cases); });
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveVisitor.prototype.visitExpansionCase = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @template T
- * @param {?} context
- * @param {?} cb
- * @return {?}
- */
- RecursiveVisitor.prototype.visitChildren = /**
- * @template T
- * @param {?} context
- * @param {?} cb
- * @return {?}
- */
- function (context, cb) {
- var /** @type {?} */ results = [];
- var /** @type {?} */ t = this;
- /**
- * @template T
- * @param {?} children
- * @return {?}
- */
- function visit(children) {
- if (children)
- results.push(visitAll(t, children, context));
- }
- cb(visit);
- return [].concat.apply([], results);
- };
- return RecursiveVisitor;
- }());
- /**
- * @param {?} ast
- * @return {?}
- */
- function spanOf(ast) {
- var /** @type {?} */ start = ast.sourceSpan.start.offset;
- var /** @type {?} */ end = ast.sourceSpan.end.offset;
- if (ast instanceof Element) {
- if (ast.endSourceSpan) {
- end = ast.endSourceSpan.end.offset;
- }
- else if (ast.children && ast.children.length) {
- end = spanOf(ast.children[ast.children.length - 1]).end;
- }
- }
- return { start: start, end: end };
- }
- /**
- * @param {?} nodes
- * @param {?} position
- * @return {?}
- */
- function findNode(nodes, position) {
- var /** @type {?} */ path = [];
- var /** @type {?} */ visitor = new /** @class */ (function (_super) {
- __extends(class_1, _super);
- function class_1() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- class_1.prototype.visit = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var /** @type {?} */ span = spanOf(ast);
- if (span.start <= position && position < span.end) {
- path.push(ast);
- }
- else {
- // Returning a value here will result in the children being skipped.
- return true;
- }
- };
- return class_1;
- }(RecursiveVisitor));
- visitAll(visitor, nodes);
- return new AstPath(path, position);
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} identifier
- * @param {?} value
- * @return {?}
- */
- function assertArrayOfStrings(identifier, value) {
- if (value == null) {
- return;
- }
- if (!Array.isArray(value)) {
- throw new Error("Expected '" + identifier + "' to be an array of strings.");
- }
- for (var /** @type {?} */ i = 0; i < value.length; i += 1) {
- if (typeof value[i] !== 'string') {
- throw new Error("Expected '" + identifier + "' to be an array of strings.");
- }
- }
- }
- var INTERPOLATION_BLACKLIST_REGEXPS = [
- /^\s*$/,
- /[<>]/,
- /^[{}]$/,
- /&(#|[a-z])/i,
- /^\/\//,
- ];
- /**
- * @param {?} identifier
- * @param {?} value
- * @return {?}
- */
- function assertInterpolationSymbols(identifier, value) {
- if (value != null && !(Array.isArray(value) && value.length == 2)) {
- throw new Error("Expected '" + identifier + "' to be an array, [start, end].");
- }
- else if (value != null) {
- var /** @type {?} */ start_1 = /** @type {?} */ (value[0]);
- var /** @type {?} */ end_1 = /** @type {?} */ (value[1]);
- // black list checking
- INTERPOLATION_BLACKLIST_REGEXPS.forEach(function (regexp) {
- if (regexp.test(start_1) || regexp.test(end_1)) {
- throw new Error("['" + start_1 + "', '" + end_1 + "'] contains unusable interpolation symbol.");
- }
- });
- }
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var InterpolationConfig = /** @class */ (function () {
- function InterpolationConfig(start, end) {
- this.start = start;
- this.end = end;
- }
- /**
- * @param {?} markers
- * @return {?}
- */
- InterpolationConfig.fromArray = /**
- * @param {?} markers
- * @return {?}
- */
- function (markers) {
- if (!markers) {
- return DEFAULT_INTERPOLATION_CONFIG;
- }
- assertInterpolationSymbols('interpolation', markers);
- return new InterpolationConfig(markers[0], markers[1]);
- };
- return InterpolationConfig;
- }());
- var DEFAULT_INTERPOLATION_CONFIG = new InterpolationConfig('{{', '}}');
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var StyleWithImports = /** @class */ (function () {
- function StyleWithImports(style, styleUrls) {
- this.style = style;
- this.styleUrls = styleUrls;
- }
- return StyleWithImports;
- }());
- /**
- * @param {?} url
- * @return {?}
- */
- function isStyleUrlResolvable(url) {
- if (url == null || url.length === 0 || url[0] == '/')
- return false;
- var /** @type {?} */ schemeMatch = url.match(URL_WITH_SCHEMA_REGEXP);
- return schemeMatch === null || schemeMatch[1] == 'package' || schemeMatch[1] == 'asset';
- }
- /**
- * Rewrites stylesheets by resolving and removing the \@import urls that
- * are either relative or don't have a `package:` scheme
- * @param {?} resolver
- * @param {?} baseUrl
- * @param {?} cssText
- * @return {?}
- */
- function extractStyleUrls(resolver, baseUrl, cssText) {
- var /** @type {?} */ foundUrls = [];
- var /** @type {?} */ modifiedCssText = cssText.replace(CSS_STRIPPABLE_COMMENT_REGEXP, '')
- .replace(CSS_IMPORT_REGEXP, function () {
- var m = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- m[_i] = arguments[_i];
- }
- var /** @type {?} */ url = m[1] || m[2];
- if (!isStyleUrlResolvable(url)) {
- // Do not attempt to resolve non-package absolute URLs with URI
- // scheme
- return m[0];
- }
- foundUrls.push(resolver.resolve(baseUrl, url));
- return '';
- });
- return new StyleWithImports(modifiedCssText, foundUrls);
- }
- var CSS_IMPORT_REGEXP = /@import\s+(?:url\()?\s*(?:(?:['"]([^'"]*))|([^;\)\s]*))[^;]*;?/g;
- var CSS_STRIPPABLE_COMMENT_REGEXP = /\/\*(?!#\s*(?:sourceURL|sourceMappingURL)=)[\s\S]+?\*\//g;
- var URL_WITH_SCHEMA_REGEXP = /^([^:/?#]+):/;
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /** @enum {number} */
- var TagContentType = {
- RAW_TEXT: 0,
- ESCAPABLE_RAW_TEXT: 1,
- PARSABLE_DATA: 2,
- };
- TagContentType[TagContentType.RAW_TEXT] = "RAW_TEXT";
- TagContentType[TagContentType.ESCAPABLE_RAW_TEXT] = "ESCAPABLE_RAW_TEXT";
- TagContentType[TagContentType.PARSABLE_DATA] = "PARSABLE_DATA";
- /**
- * @record
- */
-
- /**
- * @param {?} elementName
- * @return {?}
- */
- function splitNsName(elementName) {
- if (elementName[0] != ':') {
- return [null, elementName];
- }
- var /** @type {?} */ colonIndex = elementName.indexOf(':', 1);
- if (colonIndex == -1) {
- throw new Error("Unsupported format \"" + elementName + "\" expecting \":namespace:name\"");
- }
- return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
- }
- /**
- * @param {?} tagName
- * @return {?}
- */
- function isNgContainer(tagName) {
- return splitNsName(tagName)[1] === 'ng-container';
- }
- /**
- * @param {?} tagName
- * @return {?}
- */
- function isNgContent(tagName) {
- return splitNsName(tagName)[1] === 'ng-content';
- }
- /**
- * @param {?} tagName
- * @return {?}
- */
- function isNgTemplate(tagName) {
- return splitNsName(tagName)[1] === 'ng-template';
- }
- /**
- * @param {?} fullName
- * @return {?}
- */
- function getNsPrefix(fullName) {
- return fullName === null ? null : splitNsName(fullName)[0];
- }
- /**
- * @param {?} prefix
- * @param {?} localName
- * @return {?}
- */
- function mergeNsAndName(prefix, localName) {
- return prefix ? ":" + prefix + ":" + localName : localName;
- }
- // see http://www.w3.org/TR/html51/syntax.html#named-character-references
- // see https://html.spec.whatwg.org/multipage/entities.json
- // This list is not exhaustive to keep the compiler footprint low.
- // The `{` / `ƫ` syntax should be used when the named character reference does not
- // exist.
- var NAMED_ENTITIES = {
- 'Aacute': '\u00C1',
- 'aacute': '\u00E1',
- 'Acirc': '\u00C2',
- 'acirc': '\u00E2',
- 'acute': '\u00B4',
- 'AElig': '\u00C6',
- 'aelig': '\u00E6',
- 'Agrave': '\u00C0',
- 'agrave': '\u00E0',
- 'alefsym': '\u2135',
- 'Alpha': '\u0391',
- 'alpha': '\u03B1',
- 'amp': '&',
- 'and': '\u2227',
- 'ang': '\u2220',
- 'apos': '\u0027',
- 'Aring': '\u00C5',
- 'aring': '\u00E5',
- 'asymp': '\u2248',
- 'Atilde': '\u00C3',
- 'atilde': '\u00E3',
- 'Auml': '\u00C4',
- 'auml': '\u00E4',
- 'bdquo': '\u201E',
- 'Beta': '\u0392',
- 'beta': '\u03B2',
- 'brvbar': '\u00A6',
- 'bull': '\u2022',
- 'cap': '\u2229',
- 'Ccedil': '\u00C7',
- 'ccedil': '\u00E7',
- 'cedil': '\u00B8',
- 'cent': '\u00A2',
- 'Chi': '\u03A7',
- 'chi': '\u03C7',
- 'circ': '\u02C6',
- 'clubs': '\u2663',
- 'cong': '\u2245',
- 'copy': '\u00A9',
- 'crarr': '\u21B5',
- 'cup': '\u222A',
- 'curren': '\u00A4',
- 'dagger': '\u2020',
- 'Dagger': '\u2021',
- 'darr': '\u2193',
- 'dArr': '\u21D3',
- 'deg': '\u00B0',
- 'Delta': '\u0394',
- 'delta': '\u03B4',
- 'diams': '\u2666',
- 'divide': '\u00F7',
- 'Eacute': '\u00C9',
- 'eacute': '\u00E9',
- 'Ecirc': '\u00CA',
- 'ecirc': '\u00EA',
- 'Egrave': '\u00C8',
- 'egrave': '\u00E8',
- 'empty': '\u2205',
- 'emsp': '\u2003',
- 'ensp': '\u2002',
- 'Epsilon': '\u0395',
- 'epsilon': '\u03B5',
- 'equiv': '\u2261',
- 'Eta': '\u0397',
- 'eta': '\u03B7',
- 'ETH': '\u00D0',
- 'eth': '\u00F0',
- 'Euml': '\u00CB',
- 'euml': '\u00EB',
- 'euro': '\u20AC',
- 'exist': '\u2203',
- 'fnof': '\u0192',
- 'forall': '\u2200',
- 'frac12': '\u00BD',
- 'frac14': '\u00BC',
- 'frac34': '\u00BE',
- 'frasl': '\u2044',
- 'Gamma': '\u0393',
- 'gamma': '\u03B3',
- 'ge': '\u2265',
- 'gt': '>',
- 'harr': '\u2194',
- 'hArr': '\u21D4',
- 'hearts': '\u2665',
- 'hellip': '\u2026',
- 'Iacute': '\u00CD',
- 'iacute': '\u00ED',
- 'Icirc': '\u00CE',
- 'icirc': '\u00EE',
- 'iexcl': '\u00A1',
- 'Igrave': '\u00CC',
- 'igrave': '\u00EC',
- 'image': '\u2111',
- 'infin': '\u221E',
- 'int': '\u222B',
- 'Iota': '\u0399',
- 'iota': '\u03B9',
- 'iquest': '\u00BF',
- 'isin': '\u2208',
- 'Iuml': '\u00CF',
- 'iuml': '\u00EF',
- 'Kappa': '\u039A',
- 'kappa': '\u03BA',
- 'Lambda': '\u039B',
- 'lambda': '\u03BB',
- 'lang': '\u27E8',
- 'laquo': '\u00AB',
- 'larr': '\u2190',
- 'lArr': '\u21D0',
- 'lceil': '\u2308',
- 'ldquo': '\u201C',
- 'le': '\u2264',
- 'lfloor': '\u230A',
- 'lowast': '\u2217',
- 'loz': '\u25CA',
- 'lrm': '\u200E',
- 'lsaquo': '\u2039',
- 'lsquo': '\u2018',
- 'lt': '<',
- 'macr': '\u00AF',
- 'mdash': '\u2014',
- 'micro': '\u00B5',
- 'middot': '\u00B7',
- 'minus': '\u2212',
- 'Mu': '\u039C',
- 'mu': '\u03BC',
- 'nabla': '\u2207',
- 'nbsp': '\u00A0',
- 'ndash': '\u2013',
- 'ne': '\u2260',
- 'ni': '\u220B',
- 'not': '\u00AC',
- 'notin': '\u2209',
- 'nsub': '\u2284',
- 'Ntilde': '\u00D1',
- 'ntilde': '\u00F1',
- 'Nu': '\u039D',
- 'nu': '\u03BD',
- 'Oacute': '\u00D3',
- 'oacute': '\u00F3',
- 'Ocirc': '\u00D4',
- 'ocirc': '\u00F4',
- 'OElig': '\u0152',
- 'oelig': '\u0153',
- 'Ograve': '\u00D2',
- 'ograve': '\u00F2',
- 'oline': '\u203E',
- 'Omega': '\u03A9',
- 'omega': '\u03C9',
- 'Omicron': '\u039F',
- 'omicron': '\u03BF',
- 'oplus': '\u2295',
- 'or': '\u2228',
- 'ordf': '\u00AA',
- 'ordm': '\u00BA',
- 'Oslash': '\u00D8',
- 'oslash': '\u00F8',
- 'Otilde': '\u00D5',
- 'otilde': '\u00F5',
- 'otimes': '\u2297',
- 'Ouml': '\u00D6',
- 'ouml': '\u00F6',
- 'para': '\u00B6',
- 'permil': '\u2030',
- 'perp': '\u22A5',
- 'Phi': '\u03A6',
- 'phi': '\u03C6',
- 'Pi': '\u03A0',
- 'pi': '\u03C0',
- 'piv': '\u03D6',
- 'plusmn': '\u00B1',
- 'pound': '\u00A3',
- 'prime': '\u2032',
- 'Prime': '\u2033',
- 'prod': '\u220F',
- 'prop': '\u221D',
- 'Psi': '\u03A8',
- 'psi': '\u03C8',
- 'quot': '\u0022',
- 'radic': '\u221A',
- 'rang': '\u27E9',
- 'raquo': '\u00BB',
- 'rarr': '\u2192',
- 'rArr': '\u21D2',
- 'rceil': '\u2309',
- 'rdquo': '\u201D',
- 'real': '\u211C',
- 'reg': '\u00AE',
- 'rfloor': '\u230B',
- 'Rho': '\u03A1',
- 'rho': '\u03C1',
- 'rlm': '\u200F',
- 'rsaquo': '\u203A',
- 'rsquo': '\u2019',
- 'sbquo': '\u201A',
- 'Scaron': '\u0160',
- 'scaron': '\u0161',
- 'sdot': '\u22C5',
- 'sect': '\u00A7',
- 'shy': '\u00AD',
- 'Sigma': '\u03A3',
- 'sigma': '\u03C3',
- 'sigmaf': '\u03C2',
- 'sim': '\u223C',
- 'spades': '\u2660',
- 'sub': '\u2282',
- 'sube': '\u2286',
- 'sum': '\u2211',
- 'sup': '\u2283',
- 'sup1': '\u00B9',
- 'sup2': '\u00B2',
- 'sup3': '\u00B3',
- 'supe': '\u2287',
- 'szlig': '\u00DF',
- 'Tau': '\u03A4',
- 'tau': '\u03C4',
- 'there4': '\u2234',
- 'Theta': '\u0398',
- 'theta': '\u03B8',
- 'thetasym': '\u03D1',
- 'thinsp': '\u2009',
- 'THORN': '\u00DE',
- 'thorn': '\u00FE',
- 'tilde': '\u02DC',
- 'times': '\u00D7',
- 'trade': '\u2122',
- 'Uacute': '\u00DA',
- 'uacute': '\u00FA',
- 'uarr': '\u2191',
- 'uArr': '\u21D1',
- 'Ucirc': '\u00DB',
- 'ucirc': '\u00FB',
- 'Ugrave': '\u00D9',
- 'ugrave': '\u00F9',
- 'uml': '\u00A8',
- 'upsih': '\u03D2',
- 'Upsilon': '\u03A5',
- 'upsilon': '\u03C5',
- 'Uuml': '\u00DC',
- 'uuml': '\u00FC',
- 'weierp': '\u2118',
- 'Xi': '\u039E',
- 'xi': '\u03BE',
- 'Yacute': '\u00DD',
- 'yacute': '\u00FD',
- 'yen': '\u00A5',
- 'yuml': '\u00FF',
- 'Yuml': '\u0178',
- 'Zeta': '\u0396',
- 'zeta': '\u03B6',
- 'zwj': '\u200D',
- 'zwnj': '\u200C',
- };
- // The &ngsp; pseudo-entity is denoting a space. see:
- // https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart
- var NGSP_UNICODE = '\uE500';
- NAMED_ENTITIES['ngsp'] = NGSP_UNICODE;
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var NG_CONTENT_SELECT_ATTR = 'select';
- var LINK_ELEMENT = 'link';
- var LINK_STYLE_REL_ATTR = 'rel';
- var LINK_STYLE_HREF_ATTR = 'href';
- var LINK_STYLE_REL_VALUE = 'stylesheet';
- var STYLE_ELEMENT = 'style';
- var SCRIPT_ELEMENT = 'script';
- var NG_NON_BINDABLE_ATTR = 'ngNonBindable';
- var NG_PROJECT_AS = 'ngProjectAs';
- /**
- * @param {?} ast
- * @return {?}
- */
- function preparseElement(ast) {
- var /** @type {?} */ selectAttr = /** @type {?} */ ((null));
- var /** @type {?} */ hrefAttr = /** @type {?} */ ((null));
- var /** @type {?} */ relAttr = /** @type {?} */ ((null));
- var /** @type {?} */ nonBindable = false;
- var /** @type {?} */ projectAs = /** @type {?} */ ((null));
- ast.attrs.forEach(function (attr) {
- var /** @type {?} */ lcAttrName = attr.name.toLowerCase();
- if (lcAttrName == NG_CONTENT_SELECT_ATTR) {
- selectAttr = attr.value;
- }
- else if (lcAttrName == LINK_STYLE_HREF_ATTR) {
- hrefAttr = attr.value;
- }
- else if (lcAttrName == LINK_STYLE_REL_ATTR) {
- relAttr = attr.value;
- }
- else if (attr.name == NG_NON_BINDABLE_ATTR) {
- nonBindable = true;
- }
- else if (attr.name == NG_PROJECT_AS) {
- if (attr.value.length > 0) {
- projectAs = attr.value;
- }
- }
- });
- selectAttr = normalizeNgContentSelect(selectAttr);
- var /** @type {?} */ nodeName = ast.name.toLowerCase();
- var /** @type {?} */ type = PreparsedElementType.OTHER;
- if (isNgContent(nodeName)) {
- type = PreparsedElementType.NG_CONTENT;
- }
- else if (nodeName == STYLE_ELEMENT) {
- type = PreparsedElementType.STYLE;
- }
- else if (nodeName == SCRIPT_ELEMENT) {
- type = PreparsedElementType.SCRIPT;
- }
- else if (nodeName == LINK_ELEMENT && relAttr == LINK_STYLE_REL_VALUE) {
- type = PreparsedElementType.STYLESHEET;
- }
- return new PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs);
- }
- /** @enum {number} */
- var PreparsedElementType = {
- NG_CONTENT: 0,
- STYLE: 1,
- STYLESHEET: 2,
- SCRIPT: 3,
- OTHER: 4,
- };
- PreparsedElementType[PreparsedElementType.NG_CONTENT] = "NG_CONTENT";
- PreparsedElementType[PreparsedElementType.STYLE] = "STYLE";
- PreparsedElementType[PreparsedElementType.STYLESHEET] = "STYLESHEET";
- PreparsedElementType[PreparsedElementType.SCRIPT] = "SCRIPT";
- PreparsedElementType[PreparsedElementType.OTHER] = "OTHER";
- var PreparsedElement = /** @class */ (function () {
- function PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs) {
- this.type = type;
- this.selectAttr = selectAttr;
- this.hrefAttr = hrefAttr;
- this.nonBindable = nonBindable;
- this.projectAs = projectAs;
- }
- return PreparsedElement;
- }());
- /**
- * @param {?} selectAttr
- * @return {?}
- */
- function normalizeNgContentSelect(selectAttr) {
- if (selectAttr === null || selectAttr.length === 0) {
- return '*';
- }
- return selectAttr;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @record
- */
-
- var DirectiveNormalizer = /** @class */ (function () {
- function DirectiveNormalizer(_resourceLoader, _urlResolver, _htmlParser, _config) {
- this._resourceLoader = _resourceLoader;
- this._urlResolver = _urlResolver;
- this._htmlParser = _htmlParser;
- this._config = _config;
- this._resourceLoaderCache = new Map();
- }
- /**
- * @return {?}
- */
- DirectiveNormalizer.prototype.clearCache = /**
- * @return {?}
- */
- function () { this._resourceLoaderCache.clear(); };
- /**
- * @param {?} normalizedDirective
- * @return {?}
- */
- DirectiveNormalizer.prototype.clearCacheFor = /**
- * @param {?} normalizedDirective
- * @return {?}
- */
- function (normalizedDirective) {
- var _this = this;
- if (!normalizedDirective.isComponent) {
- return;
- }
- var /** @type {?} */ template = /** @type {?} */ ((normalizedDirective.template));
- this._resourceLoaderCache.delete(/** @type {?} */ ((template.templateUrl)));
- template.externalStylesheets.forEach(function (stylesheet) { _this._resourceLoaderCache.delete(/** @type {?} */ ((stylesheet.moduleUrl))); });
- };
- /**
- * @param {?} url
- * @return {?}
- */
- DirectiveNormalizer.prototype._fetch = /**
- * @param {?} url
- * @return {?}
- */
- function (url) {
- var /** @type {?} */ result = this._resourceLoaderCache.get(url);
- if (!result) {
- result = this._resourceLoader.get(url);
- this._resourceLoaderCache.set(url, result);
- }
- return result;
- };
- /**
- * @param {?} prenormData
- * @return {?}
- */
- DirectiveNormalizer.prototype.normalizeTemplate = /**
- * @param {?} prenormData
- * @return {?}
- */
- function (prenormData) {
- var _this = this;
- if (isDefined(prenormData.template)) {
- if (isDefined(prenormData.templateUrl)) {
- throw syntaxError("'" + stringify(prenormData.componentType) + "' component cannot define both template and templateUrl");
- }
- if (typeof prenormData.template !== 'string') {
- throw syntaxError("The template specified for component " + stringify(prenormData.componentType) + " is not a string");
- }
- }
- else if (isDefined(prenormData.templateUrl)) {
- if (typeof prenormData.templateUrl !== 'string') {
- throw syntaxError("The templateUrl specified for component " + stringify(prenormData.componentType) + " is not a string");
- }
- }
- else {
- throw syntaxError("No template specified for component " + stringify(prenormData.componentType));
- }
- if (isDefined(prenormData.preserveWhitespaces) &&
- typeof prenormData.preserveWhitespaces !== 'boolean') {
- throw syntaxError("The preserveWhitespaces option for component " + stringify(prenormData.componentType) + " must be a boolean");
- }
- return SyncAsync.then(this._preParseTemplate(prenormData), function (preparsedTemplate) { return _this._normalizeTemplateMetadata(prenormData, preparsedTemplate); });
- };
- /**
- * @param {?} prenomData
- * @return {?}
- */
- DirectiveNormalizer.prototype._preParseTemplate = /**
- * @param {?} prenomData
- * @return {?}
- */
- function (prenomData) {
- var _this = this;
- var /** @type {?} */ template;
- var /** @type {?} */ templateUrl;
- if (prenomData.template != null) {
- template = prenomData.template;
- templateUrl = prenomData.moduleUrl;
- }
- else {
- templateUrl = this._urlResolver.resolve(prenomData.moduleUrl, /** @type {?} */ ((prenomData.templateUrl)));
- template = this._fetch(templateUrl);
- }
- return SyncAsync.then(template, function (template) { return _this._preparseLoadedTemplate(prenomData, template, templateUrl); });
- };
- /**
- * @param {?} prenormData
- * @param {?} template
- * @param {?} templateAbsUrl
- * @return {?}
- */
- DirectiveNormalizer.prototype._preparseLoadedTemplate = /**
- * @param {?} prenormData
- * @param {?} template
- * @param {?} templateAbsUrl
- * @return {?}
- */
- function (prenormData, template, templateAbsUrl) {
- var /** @type {?} */ isInline = !!prenormData.template;
- var /** @type {?} */ interpolationConfig = InterpolationConfig.fromArray(/** @type {?} */ ((prenormData.interpolation)));
- var /** @type {?} */ rootNodesAndErrors = this._htmlParser.parse(template, templateSourceUrl({ reference: prenormData.ngModuleType }, { type: { reference: prenormData.componentType } }, { isInline: isInline, templateUrl: templateAbsUrl }), true, interpolationConfig);
- if (rootNodesAndErrors.errors.length > 0) {
- var /** @type {?} */ errorString = rootNodesAndErrors.errors.join('\n');
- throw syntaxError("Template parse errors:\n" + errorString);
- }
- var /** @type {?} */ templateMetadataStyles = this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: prenormData.styles, moduleUrl: prenormData.moduleUrl }));
- var /** @type {?} */ visitor = new TemplatePreparseVisitor();
- visitAll(visitor, rootNodesAndErrors.rootNodes);
- var /** @type {?} */ templateStyles = this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: visitor.styles, styleUrls: visitor.styleUrls, moduleUrl: templateAbsUrl }));
- var /** @type {?} */ styles = templateMetadataStyles.styles.concat(templateStyles.styles);
- var /** @type {?} */ inlineStyleUrls = templateMetadataStyles.styleUrls.concat(templateStyles.styleUrls);
- var /** @type {?} */ styleUrls = this
- ._normalizeStylesheet(new CompileStylesheetMetadata({ styleUrls: prenormData.styleUrls, moduleUrl: prenormData.moduleUrl }))
- .styleUrls;
- return {
- template: template,
- templateUrl: templateAbsUrl, isInline: isInline,
- htmlAst: rootNodesAndErrors, styles: styles, inlineStyleUrls: inlineStyleUrls, styleUrls: styleUrls,
- ngContentSelectors: visitor.ngContentSelectors,
- };
- };
- /**
- * @param {?} prenormData
- * @param {?} preparsedTemplate
- * @return {?}
- */
- DirectiveNormalizer.prototype._normalizeTemplateMetadata = /**
- * @param {?} prenormData
- * @param {?} preparsedTemplate
- * @return {?}
- */
- function (prenormData, preparsedTemplate) {
- var _this = this;
- return SyncAsync.then(this._loadMissingExternalStylesheets(preparsedTemplate.styleUrls.concat(preparsedTemplate.inlineStyleUrls)), function (externalStylesheets) {
- return _this._normalizeLoadedTemplateMetadata(prenormData, preparsedTemplate, externalStylesheets);
- });
- };
- /**
- * @param {?} prenormData
- * @param {?} preparsedTemplate
- * @param {?} stylesheets
- * @return {?}
- */
- DirectiveNormalizer.prototype._normalizeLoadedTemplateMetadata = /**
- * @param {?} prenormData
- * @param {?} preparsedTemplate
- * @param {?} stylesheets
- * @return {?}
- */
- function (prenormData, preparsedTemplate, stylesheets) {
- var _this = this;
- // Algorithm:
- // - produce exactly 1 entry per original styleUrl in
- // CompileTemplateMetadata.externalStylesheets whith all styles inlined
- // - inline all styles that are referenced by the template into CompileTemplateMetadata.styles.
- // Reason: be able to determine how many stylesheets there are even without loading
- // the template nor the stylesheets, so we can create a stub for TypeScript always synchronously
- // (as resouce loading may be async)
- var /** @type {?} */ styles = preparsedTemplate.styles.slice();
- this._inlineStyles(preparsedTemplate.inlineStyleUrls, stylesheets, styles);
- var /** @type {?} */ styleUrls = preparsedTemplate.styleUrls;
- var /** @type {?} */ externalStylesheets = styleUrls.map(function (styleUrl) {
- var /** @type {?} */ stylesheet = /** @type {?} */ ((stylesheets.get(styleUrl)));
- var /** @type {?} */ styles = stylesheet.styles.slice();
- _this._inlineStyles(stylesheet.styleUrls, stylesheets, styles);
- return new CompileStylesheetMetadata({ moduleUrl: styleUrl, styles: styles });
- });
- var /** @type {?} */ encapsulation = prenormData.encapsulation;
- if (encapsulation == null) {
- encapsulation = this._config.defaultEncapsulation;
- }
- if (encapsulation === ViewEncapsulation.Emulated && styles.length === 0 &&
- styleUrls.length === 0) {
- encapsulation = ViewEncapsulation.None;
- }
- return new CompileTemplateMetadata({
- encapsulation: encapsulation,
- template: preparsedTemplate.template,
- templateUrl: preparsedTemplate.templateUrl,
- htmlAst: preparsedTemplate.htmlAst, styles: styles, styleUrls: styleUrls,
- ngContentSelectors: preparsedTemplate.ngContentSelectors,
- animations: prenormData.animations,
- interpolation: prenormData.interpolation,
- isInline: preparsedTemplate.isInline, externalStylesheets: externalStylesheets,
- preserveWhitespaces: preserveWhitespacesDefault(prenormData.preserveWhitespaces, this._config.preserveWhitespaces),
- });
- };
- /**
- * @param {?} styleUrls
- * @param {?} stylesheets
- * @param {?} targetStyles
- * @return {?}
- */
- DirectiveNormalizer.prototype._inlineStyles = /**
- * @param {?} styleUrls
- * @param {?} stylesheets
- * @param {?} targetStyles
- * @return {?}
- */
- function (styleUrls, stylesheets, targetStyles) {
- var _this = this;
- styleUrls.forEach(function (styleUrl) {
- var /** @type {?} */ stylesheet = /** @type {?} */ ((stylesheets.get(styleUrl)));
- stylesheet.styles.forEach(function (style) { return targetStyles.push(style); });
- _this._inlineStyles(stylesheet.styleUrls, stylesheets, targetStyles);
- });
- };
- /**
- * @param {?} styleUrls
- * @param {?=} loadedStylesheets
- * @return {?}
- */
- DirectiveNormalizer.prototype._loadMissingExternalStylesheets = /**
- * @param {?} styleUrls
- * @param {?=} loadedStylesheets
- * @return {?}
- */
- function (styleUrls, loadedStylesheets) {
- var _this = this;
- if (loadedStylesheets === void 0) { loadedStylesheets = new Map(); }
- return SyncAsync.then(SyncAsync.all(styleUrls.filter(function (styleUrl) { return !loadedStylesheets.has(styleUrl); })
- .map(function (styleUrl) {
- return SyncAsync.then(_this._fetch(styleUrl), function (loadedStyle) {
- var /** @type {?} */ stylesheet = _this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: [loadedStyle], moduleUrl: styleUrl }));
- loadedStylesheets.set(styleUrl, stylesheet);
- return _this._loadMissingExternalStylesheets(stylesheet.styleUrls, loadedStylesheets);
- });
- })), function (_) { return loadedStylesheets; });
- };
- /**
- * @param {?} stylesheet
- * @return {?}
- */
- DirectiveNormalizer.prototype._normalizeStylesheet = /**
- * @param {?} stylesheet
- * @return {?}
- */
- function (stylesheet) {
- var _this = this;
- var /** @type {?} */ moduleUrl = /** @type {?} */ ((stylesheet.moduleUrl));
- var /** @type {?} */ allStyleUrls = stylesheet.styleUrls.filter(isStyleUrlResolvable)
- .map(function (url) { return _this._urlResolver.resolve(moduleUrl, url); });
- var /** @type {?} */ allStyles = stylesheet.styles.map(function (style) {
- var /** @type {?} */ styleWithImports = extractStyleUrls(_this._urlResolver, moduleUrl, style);
- allStyleUrls.push.apply(allStyleUrls, styleWithImports.styleUrls);
- return styleWithImports.style;
- });
- return new CompileStylesheetMetadata({ styles: allStyles, styleUrls: allStyleUrls, moduleUrl: moduleUrl });
- };
- return DirectiveNormalizer;
- }());
- var TemplatePreparseVisitor = /** @class */ (function () {
- function TemplatePreparseVisitor() {
- this.ngContentSelectors = [];
- this.styles = [];
- this.styleUrls = [];
- this.ngNonBindableStackCount = 0;
- }
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- TemplatePreparseVisitor.prototype.visitElement = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var /** @type {?} */ preparsedElement = preparseElement(ast);
- switch (preparsedElement.type) {
- case PreparsedElementType.NG_CONTENT:
- if (this.ngNonBindableStackCount === 0) {
- this.ngContentSelectors.push(preparsedElement.selectAttr);
- }
- break;
- case PreparsedElementType.STYLE:
- var /** @type {?} */ textContent_1 = '';
- ast.children.forEach(function (child) {
- if (child instanceof Text) {
- textContent_1 += child.value;
- }
- });
- this.styles.push(textContent_1);
- break;
- case PreparsedElementType.STYLESHEET:
- this.styleUrls.push(preparsedElement.hrefAttr);
- break;
- default:
- break;
- }
- if (preparsedElement.nonBindable) {
- this.ngNonBindableStackCount++;
- }
- visitAll(this, ast.children);
- if (preparsedElement.nonBindable) {
- this.ngNonBindableStackCount--;
- }
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- TemplatePreparseVisitor.prototype.visitExpansion = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { visitAll(this, ast.cases); };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- TemplatePreparseVisitor.prototype.visitExpansionCase = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- visitAll(this, ast.expression);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- TemplatePreparseVisitor.prototype.visitComment = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return null; };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- TemplatePreparseVisitor.prototype.visitAttribute = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return null; };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- TemplatePreparseVisitor.prototype.visitText = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return null; };
- return TemplatePreparseVisitor;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var QUERY_METADATA_IDENTIFIERS = [
- createViewChild,
- createViewChildren,
- createContentChild,
- createContentChildren,
- ];
- var DirectiveResolver = /** @class */ (function () {
- function DirectiveResolver(_reflector) {
- this._reflector = _reflector;
- }
- /**
- * @param {?} type
- * @return {?}
- */
- DirectiveResolver.prototype.isDirective = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type));
- return typeMetadata && typeMetadata.some(isDirectiveMetadata);
- };
- /**
- * @param {?} type
- * @param {?=} throwIfNotFound
- * @return {?}
- */
- DirectiveResolver.prototype.resolve = /**
- * @param {?} type
- * @param {?=} throwIfNotFound
- * @return {?}
- */
- function (type, throwIfNotFound) {
- if (throwIfNotFound === void 0) { throwIfNotFound = true; }
- var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type));
- if (typeMetadata) {
- var /** @type {?} */ metadata = findLast(typeMetadata, isDirectiveMetadata);
- if (metadata) {
- var /** @type {?} */ propertyMetadata = this._reflector.propMetadata(type);
- var /** @type {?} */ guards = this._reflector.guards(type);
- return this._mergeWithPropertyMetadata(metadata, propertyMetadata, guards, type);
- }
- }
- if (throwIfNotFound) {
- throw new Error("No Directive annotation found on " + stringify(type));
- }
- return null;
- };
- /**
- * @param {?} dm
- * @param {?} propertyMetadata
- * @param {?} guards
- * @param {?} directiveType
- * @return {?}
- */
- DirectiveResolver.prototype._mergeWithPropertyMetadata = /**
- * @param {?} dm
- * @param {?} propertyMetadata
- * @param {?} guards
- * @param {?} directiveType
- * @return {?}
- */
- function (dm, propertyMetadata, guards, directiveType) {
- var /** @type {?} */ inputs = [];
- var /** @type {?} */ outputs = [];
- var /** @type {?} */ host = {};
- var /** @type {?} */ queries = {};
- Object.keys(propertyMetadata).forEach(function (propName) {
- var /** @type {?} */ input = findLast(propertyMetadata[propName], function (a) { return createInput.isTypeOf(a); });
- if (input) {
- if (input.bindingPropertyName) {
- inputs.push(propName + ": " + input.bindingPropertyName);
- }
- else {
- inputs.push(propName);
- }
- }
- var /** @type {?} */ output = findLast(propertyMetadata[propName], function (a) { return createOutput.isTypeOf(a); });
- if (output) {
- if (output.bindingPropertyName) {
- outputs.push(propName + ": " + output.bindingPropertyName);
- }
- else {
- outputs.push(propName);
- }
- }
- var /** @type {?} */ hostBindings = propertyMetadata[propName].filter(function (a) { return createHostBinding.isTypeOf(a); });
- hostBindings.forEach(function (hostBinding) {
- if (hostBinding.hostPropertyName) {
- var /** @type {?} */ startWith = hostBinding.hostPropertyName[0];
- if (startWith === '(') {
- throw new Error("@HostBinding can not bind to events. Use @HostListener instead.");
- }
- else if (startWith === '[') {
- throw new Error("@HostBinding parameter should be a property name, 'class.<name>', or 'attr.<name>'.");
- }
- host["[" + hostBinding.hostPropertyName + "]"] = propName;
- }
- else {
- host["[" + propName + "]"] = propName;
- }
- });
- var /** @type {?} */ hostListeners = propertyMetadata[propName].filter(function (a) { return createHostListener.isTypeOf(a); });
- hostListeners.forEach(function (hostListener) {
- var /** @type {?} */ args = hostListener.args || [];
- host["(" + hostListener.eventName + ")"] = propName + "(" + args.join(',') + ")";
- });
- var /** @type {?} */ query = findLast(propertyMetadata[propName], function (a) { return QUERY_METADATA_IDENTIFIERS.some(function (i) { return i.isTypeOf(a); }); });
- if (query) {
- queries[propName] = query;
- }
- });
- return this._merge(dm, inputs, outputs, host, queries, guards, directiveType);
- };
- /**
- * @param {?} def
- * @return {?}
- */
- DirectiveResolver.prototype._extractPublicName = /**
- * @param {?} def
- * @return {?}
- */
- function (def) { return splitAtColon(def, [/** @type {?} */ ((null)), def])[1].trim(); };
- /**
- * @param {?} bindings
- * @return {?}
- */
- DirectiveResolver.prototype._dedupeBindings = /**
- * @param {?} bindings
- * @return {?}
- */
- function (bindings) {
- var /** @type {?} */ names = new Set();
- var /** @type {?} */ publicNames = new Set();
- var /** @type {?} */ reversedResult = [];
- // go last to first to allow later entries to overwrite previous entries
- for (var /** @type {?} */ i = bindings.length - 1; i >= 0; i--) {
- var /** @type {?} */ binding = bindings[i];
- var /** @type {?} */ name_1 = this._extractPublicName(binding);
- publicNames.add(name_1);
- if (!names.has(name_1)) {
- names.add(name_1);
- reversedResult.push(binding);
- }
- }
- return reversedResult.reverse();
- };
- /**
- * @param {?} directive
- * @param {?} inputs
- * @param {?} outputs
- * @param {?} host
- * @param {?} queries
- * @param {?} guards
- * @param {?} directiveType
- * @return {?}
- */
- DirectiveResolver.prototype._merge = /**
- * @param {?} directive
- * @param {?} inputs
- * @param {?} outputs
- * @param {?} host
- * @param {?} queries
- * @param {?} guards
- * @param {?} directiveType
- * @return {?}
- */
- function (directive, inputs, outputs, host, queries, guards, directiveType) {
- var /** @type {?} */ mergedInputs = this._dedupeBindings(directive.inputs ? directive.inputs.concat(inputs) : inputs);
- var /** @type {?} */ mergedOutputs = this._dedupeBindings(directive.outputs ? directive.outputs.concat(outputs) : outputs);
- var /** @type {?} */ mergedHost = directive.host ? __assign({}, directive.host, host) : host;
- var /** @type {?} */ mergedQueries = directive.queries ? __assign({}, directive.queries, queries) : queries;
- if (createComponent.isTypeOf(directive)) {
- var /** @type {?} */ comp = /** @type {?} */ (directive);
- return createComponent({
- selector: comp.selector,
- inputs: mergedInputs,
- outputs: mergedOutputs,
- host: mergedHost,
- exportAs: comp.exportAs,
- moduleId: comp.moduleId,
- queries: mergedQueries,
- changeDetection: comp.changeDetection,
- providers: comp.providers,
- viewProviders: comp.viewProviders,
- entryComponents: comp.entryComponents,
- template: comp.template,
- templateUrl: comp.templateUrl,
- styles: comp.styles,
- styleUrls: comp.styleUrls,
- encapsulation: comp.encapsulation,
- animations: comp.animations,
- interpolation: comp.interpolation,
- preserveWhitespaces: directive.preserveWhitespaces,
- });
- }
- else {
- return createDirective({
- selector: directive.selector,
- inputs: mergedInputs,
- outputs: mergedOutputs,
- host: mergedHost,
- exportAs: directive.exportAs,
- queries: mergedQueries,
- providers: directive.providers, guards: guards
- });
- }
- };
- return DirectiveResolver;
- }());
- /**
- * @param {?} type
- * @return {?}
- */
- function isDirectiveMetadata(type) {
- return createDirective.isTypeOf(type) || createComponent.isTypeOf(type);
- }
- /**
- * @template T
- * @param {?} arr
- * @param {?} condition
- * @return {?}
- */
- function findLast(arr, condition) {
- for (var /** @type {?} */ i = arr.length - 1; i >= 0; i--) {
- if (condition(arr[i])) {
- return arr[i];
- }
- }
- return null;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var $EOF = 0;
- var $TAB = 9;
- var $LF = 10;
- var $VTAB = 11;
- var $FF = 12;
- var $CR = 13;
- var $SPACE = 32;
- var $BANG = 33;
- var $DQ = 34;
- var $HASH = 35;
- var $$ = 36;
- var $PERCENT = 37;
- var $AMPERSAND = 38;
- var $SQ = 39;
- var $LPAREN = 40;
- var $RPAREN = 41;
- var $STAR = 42;
- var $PLUS = 43;
- var $COMMA = 44;
- var $MINUS = 45;
- var $PERIOD = 46;
- var $SLASH = 47;
- var $COLON = 58;
- var $SEMICOLON = 59;
- var $LT = 60;
- var $EQ = 61;
- var $GT = 62;
- var $QUESTION = 63;
- var $0 = 48;
- var $9 = 57;
- var $A = 65;
- var $E = 69;
- var $F = 70;
- var $X = 88;
- var $Z = 90;
- var $LBRACKET = 91;
- var $BACKSLASH = 92;
- var $RBRACKET = 93;
- var $CARET = 94;
- var $_ = 95;
- var $a = 97;
- var $e = 101;
- var $f = 102;
- var $n = 110;
- var $r = 114;
- var $t = 116;
- var $u = 117;
- var $v = 118;
- var $x = 120;
- var $z = 122;
- var $LBRACE = 123;
- var $BAR = 124;
- var $RBRACE = 125;
- var $NBSP = 160;
-
-
-
- var $BT = 96;
- /**
- * @param {?} code
- * @return {?}
- */
- function isWhitespace(code) {
- return (code >= $TAB && code <= $SPACE) || (code == $NBSP);
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function isDigit(code) {
- return $0 <= code && code <= $9;
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function isAsciiLetter(code) {
- return code >= $a && code <= $z || code >= $A && code <= $Z;
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function isAsciiHexDigit(code) {
- return code >= $a && code <= $f || code >= $A && code <= $F || isDigit(code);
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /** @enum {number} */
- var TokenType = {
- Character: 0,
- Identifier: 1,
- Keyword: 2,
- String: 3,
- Operator: 4,
- Number: 5,
- Error: 6,
- };
- TokenType[TokenType.Character] = "Character";
- TokenType[TokenType.Identifier] = "Identifier";
- TokenType[TokenType.Keyword] = "Keyword";
- TokenType[TokenType.String] = "String";
- TokenType[TokenType.Operator] = "Operator";
- TokenType[TokenType.Number] = "Number";
- TokenType[TokenType.Error] = "Error";
- var KEYWORDS = ['var', 'let', 'as', 'null', 'undefined', 'true', 'false', 'if', 'else', 'this'];
- var Lexer = /** @class */ (function () {
- function Lexer() {
- }
- /**
- * @param {?} text
- * @return {?}
- */
- Lexer.prototype.tokenize = /**
- * @param {?} text
- * @return {?}
- */
- function (text) {
- var /** @type {?} */ scanner = new _Scanner(text);
- var /** @type {?} */ tokens = [];
- var /** @type {?} */ token = scanner.scanToken();
- while (token != null) {
- tokens.push(token);
- token = scanner.scanToken();
- }
- return tokens;
- };
- return Lexer;
- }());
- var Token = /** @class */ (function () {
- function Token(index, type, numValue, strValue) {
- this.index = index;
- this.type = type;
- this.numValue = numValue;
- this.strValue = strValue;
- }
- /**
- * @param {?} code
- * @return {?}
- */
- Token.prototype.isCharacter = /**
- * @param {?} code
- * @return {?}
- */
- function (code) {
- return this.type == TokenType.Character && this.numValue == code;
- };
- /**
- * @return {?}
- */
- Token.prototype.isNumber = /**
- * @return {?}
- */
- function () { return this.type == TokenType.Number; };
- /**
- * @return {?}
- */
- Token.prototype.isString = /**
- * @return {?}
- */
- function () { return this.type == TokenType.String; };
- /**
- * @param {?} operater
- * @return {?}
- */
- Token.prototype.isOperator = /**
- * @param {?} operater
- * @return {?}
- */
- function (operater) {
- return this.type == TokenType.Operator && this.strValue == operater;
- };
- /**
- * @return {?}
- */
- Token.prototype.isIdentifier = /**
- * @return {?}
- */
- function () { return this.type == TokenType.Identifier; };
- /**
- * @return {?}
- */
- Token.prototype.isKeyword = /**
- * @return {?}
- */
- function () { return this.type == TokenType.Keyword; };
- /**
- * @return {?}
- */
- Token.prototype.isKeywordLet = /**
- * @return {?}
- */
- function () { return this.type == TokenType.Keyword && this.strValue == 'let'; };
- /**
- * @return {?}
- */
- Token.prototype.isKeywordAs = /**
- * @return {?}
- */
- function () { return this.type == TokenType.Keyword && this.strValue == 'as'; };
- /**
- * @return {?}
- */
- Token.prototype.isKeywordNull = /**
- * @return {?}
- */
- function () { return this.type == TokenType.Keyword && this.strValue == 'null'; };
- /**
- * @return {?}
- */
- Token.prototype.isKeywordUndefined = /**
- * @return {?}
- */
- function () {
- return this.type == TokenType.Keyword && this.strValue == 'undefined';
- };
- /**
- * @return {?}
- */
- Token.prototype.isKeywordTrue = /**
- * @return {?}
- */
- function () { return this.type == TokenType.Keyword && this.strValue == 'true'; };
- /**
- * @return {?}
- */
- Token.prototype.isKeywordFalse = /**
- * @return {?}
- */
- function () { return this.type == TokenType.Keyword && this.strValue == 'false'; };
- /**
- * @return {?}
- */
- Token.prototype.isKeywordThis = /**
- * @return {?}
- */
- function () { return this.type == TokenType.Keyword && this.strValue == 'this'; };
- /**
- * @return {?}
- */
- Token.prototype.isError = /**
- * @return {?}
- */
- function () { return this.type == TokenType.Error; };
- /**
- * @return {?}
- */
- Token.prototype.toNumber = /**
- * @return {?}
- */
- function () { return this.type == TokenType.Number ? this.numValue : -1; };
- /**
- * @return {?}
- */
- Token.prototype.toString = /**
- * @return {?}
- */
- function () {
- switch (this.type) {
- case TokenType.Character:
- case TokenType.Identifier:
- case TokenType.Keyword:
- case TokenType.Operator:
- case TokenType.String:
- case TokenType.Error:
- return this.strValue;
- case TokenType.Number:
- return this.numValue.toString();
- default:
- return null;
- }
- };
- return Token;
- }());
- /**
- * @param {?} index
- * @param {?} code
- * @return {?}
- */
- function newCharacterToken(index, code) {
- return new Token(index, TokenType.Character, code, String.fromCharCode(code));
- }
- /**
- * @param {?} index
- * @param {?} text
- * @return {?}
- */
- function newIdentifierToken(index, text) {
- return new Token(index, TokenType.Identifier, 0, text);
- }
- /**
- * @param {?} index
- * @param {?} text
- * @return {?}
- */
- function newKeywordToken(index, text) {
- return new Token(index, TokenType.Keyword, 0, text);
- }
- /**
- * @param {?} index
- * @param {?} text
- * @return {?}
- */
- function newOperatorToken(index, text) {
- return new Token(index, TokenType.Operator, 0, text);
- }
- /**
- * @param {?} index
- * @param {?} text
- * @return {?}
- */
- function newStringToken(index, text) {
- return new Token(index, TokenType.String, 0, text);
- }
- /**
- * @param {?} index
- * @param {?} n
- * @return {?}
- */
- function newNumberToken(index, n) {
- return new Token(index, TokenType.Number, n, '');
- }
- /**
- * @param {?} index
- * @param {?} message
- * @return {?}
- */
- function newErrorToken(index, message) {
- return new Token(index, TokenType.Error, 0, message);
- }
- var EOF = new Token(-1, TokenType.Character, 0, '');
- var _Scanner = /** @class */ (function () {
- function _Scanner(input) {
- this.input = input;
- this.peek = 0;
- this.index = -1;
- this.length = input.length;
- this.advance();
- }
- /**
- * @return {?}
- */
- _Scanner.prototype.advance = /**
- * @return {?}
- */
- function () {
- this.peek = ++this.index >= this.length ? $EOF : this.input.charCodeAt(this.index);
- };
- /**
- * @return {?}
- */
- _Scanner.prototype.scanToken = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ input = this.input, /** @type {?} */ length = this.length;
- var /** @type {?} */ peek = this.peek, /** @type {?} */ index = this.index;
- // Skip whitespace.
- while (peek <= $SPACE) {
- if (++index >= length) {
- peek = $EOF;
- break;
- }
- else {
- peek = input.charCodeAt(index);
- }
- }
- this.peek = peek;
- this.index = index;
- if (index >= length) {
- return null;
- }
- // Handle identifiers and numbers.
- if (isIdentifierStart(peek))
- return this.scanIdentifier();
- if (isDigit(peek))
- return this.scanNumber(index);
- var /** @type {?} */ start = index;
- switch (peek) {
- case $PERIOD:
- this.advance();
- return isDigit(this.peek) ? this.scanNumber(start) :
- newCharacterToken(start, $PERIOD);
- case $LPAREN:
- case $RPAREN:
- case $LBRACE:
- case $RBRACE:
- case $LBRACKET:
- case $RBRACKET:
- case $COMMA:
- case $COLON:
- case $SEMICOLON:
- return this.scanCharacter(start, peek);
- case $SQ:
- case $DQ:
- return this.scanString();
- case $HASH:
- case $PLUS:
- case $MINUS:
- case $STAR:
- case $SLASH:
- case $PERCENT:
- case $CARET:
- return this.scanOperator(start, String.fromCharCode(peek));
- case $QUESTION:
- return this.scanComplexOperator(start, '?', $PERIOD, '.');
- case $LT:
- case $GT:
- return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '=');
- case $BANG:
- case $EQ:
- return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '=', $EQ, '=');
- case $AMPERSAND:
- return this.scanComplexOperator(start, '&', $AMPERSAND, '&');
- case $BAR:
- return this.scanComplexOperator(start, '|', $BAR, '|');
- case $NBSP:
- while (isWhitespace(this.peek))
- this.advance();
- return this.scanToken();
- }
- this.advance();
- return this.error("Unexpected character [" + String.fromCharCode(peek) + "]", 0);
- };
- /**
- * @param {?} start
- * @param {?} code
- * @return {?}
- */
- _Scanner.prototype.scanCharacter = /**
- * @param {?} start
- * @param {?} code
- * @return {?}
- */
- function (start, code) {
- this.advance();
- return newCharacterToken(start, code);
- };
- /**
- * @param {?} start
- * @param {?} str
- * @return {?}
- */
- _Scanner.prototype.scanOperator = /**
- * @param {?} start
- * @param {?} str
- * @return {?}
- */
- function (start, str) {
- this.advance();
- return newOperatorToken(start, str);
- };
- /**
- * Tokenize a 2/3 char long operator
- *
- * @param start start index in the expression
- * @param one first symbol (always part of the operator)
- * @param twoCode code point for the second symbol
- * @param two second symbol (part of the operator when the second code point matches)
- * @param threeCode code point for the third symbol
- * @param three third symbol (part of the operator when provided and matches source expression)
- */
- /**
- * Tokenize a 2/3 char long operator
- *
- * @param {?} start start index in the expression
- * @param {?} one first symbol (always part of the operator)
- * @param {?} twoCode code point for the second symbol
- * @param {?} two second symbol (part of the operator when the second code point matches)
- * @param {?=} threeCode code point for the third symbol
- * @param {?=} three third symbol (part of the operator when provided and matches source expression)
- * @return {?}
- */
- _Scanner.prototype.scanComplexOperator = /**
- * Tokenize a 2/3 char long operator
- *
- * @param {?} start start index in the expression
- * @param {?} one first symbol (always part of the operator)
- * @param {?} twoCode code point for the second symbol
- * @param {?} two second symbol (part of the operator when the second code point matches)
- * @param {?=} threeCode code point for the third symbol
- * @param {?=} three third symbol (part of the operator when provided and matches source expression)
- * @return {?}
- */
- function (start, one, twoCode, two, threeCode, three) {
- this.advance();
- var /** @type {?} */ str = one;
- if (this.peek == twoCode) {
- this.advance();
- str += two;
- }
- if (threeCode != null && this.peek == threeCode) {
- this.advance();
- str += three;
- }
- return newOperatorToken(start, str);
- };
- /**
- * @return {?}
- */
- _Scanner.prototype.scanIdentifier = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ start = this.index;
- this.advance();
- while (isIdentifierPart(this.peek))
- this.advance();
- var /** @type {?} */ str = this.input.substring(start, this.index);
- return KEYWORDS.indexOf(str) > -1 ? newKeywordToken(start, str) :
- newIdentifierToken(start, str);
- };
- /**
- * @param {?} start
- * @return {?}
- */
- _Scanner.prototype.scanNumber = /**
- * @param {?} start
- * @return {?}
- */
- function (start) {
- var /** @type {?} */ simple = (this.index === start);
- this.advance(); // Skip initial digit.
- while (true) {
- if (isDigit(this.peek)) {
- // Do nothing.
- }
- else if (this.peek == $PERIOD) {
- simple = false;
- }
- else if (isExponentStart(this.peek)) {
- this.advance();
- if (isExponentSign(this.peek))
- this.advance();
- if (!isDigit(this.peek))
- return this.error('Invalid exponent', -1);
- simple = false;
- }
- else {
- break;
- }
- this.advance();
- }
- var /** @type {?} */ str = this.input.substring(start, this.index);
- var /** @type {?} */ value = simple ? parseIntAutoRadix(str) : parseFloat(str);
- return newNumberToken(start, value);
- };
- /**
- * @return {?}
- */
- _Scanner.prototype.scanString = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ start = this.index;
- var /** @type {?} */ quote = this.peek;
- this.advance(); // Skip initial quote.
- var /** @type {?} */ buffer = '';
- var /** @type {?} */ marker = this.index;
- var /** @type {?} */ input = this.input;
- while (this.peek != quote) {
- if (this.peek == $BACKSLASH) {
- buffer += input.substring(marker, this.index);
- this.advance();
- var /** @type {?} */ unescapedCode = void 0;
- // Workaround for TS2.1-introduced type strictness
- this.peek = this.peek;
- if (this.peek == $u) {
- // 4 character hex code for unicode character.
- var /** @type {?} */ hex = input.substring(this.index + 1, this.index + 5);
- if (/^[0-9a-f]+$/i.test(hex)) {
- unescapedCode = parseInt(hex, 16);
- }
- else {
- return this.error("Invalid unicode escape [\\u" + hex + "]", 0);
- }
- for (var /** @type {?} */ i = 0; i < 5; i++) {
- this.advance();
- }
- }
- else {
- unescapedCode = unescape(this.peek);
- this.advance();
- }
- buffer += String.fromCharCode(unescapedCode);
- marker = this.index;
- }
- else if (this.peek == $EOF) {
- return this.error('Unterminated quote', 0);
- }
- else {
- this.advance();
- }
- }
- var /** @type {?} */ last = input.substring(marker, this.index);
- this.advance(); // Skip terminating quote.
- return newStringToken(start, buffer + last);
- };
- /**
- * @param {?} message
- * @param {?} offset
- * @return {?}
- */
- _Scanner.prototype.error = /**
- * @param {?} message
- * @param {?} offset
- * @return {?}
- */
- function (message, offset) {
- var /** @type {?} */ position = this.index + offset;
- return newErrorToken(position, "Lexer Error: " + message + " at column " + position + " in expression [" + this.input + "]");
- };
- return _Scanner;
- }());
- /**
- * @param {?} code
- * @return {?}
- */
- function isIdentifierStart(code) {
- return ($a <= code && code <= $z) || ($A <= code && code <= $Z) ||
- (code == $_) || (code == $$);
- }
- /**
- * @param {?} input
- * @return {?}
- */
- function isIdentifier(input) {
- if (input.length == 0)
- return false;
- var /** @type {?} */ scanner = new _Scanner(input);
- if (!isIdentifierStart(scanner.peek))
- return false;
- scanner.advance();
- while (scanner.peek !== $EOF) {
- if (!isIdentifierPart(scanner.peek))
- return false;
- scanner.advance();
- }
- return true;
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function isIdentifierPart(code) {
- return isAsciiLetter(code) || isDigit(code) || (code == $_) ||
- (code == $$);
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function isExponentStart(code) {
- return code == $e || code == $E;
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function isExponentSign(code) {
- return code == $MINUS || code == $PLUS;
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function isQuote(code) {
- return code === $SQ || code === $DQ || code === $BT;
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function unescape(code) {
- switch (code) {
- case $n:
- return $LF;
- case $f:
- return $FF;
- case $r:
- return $CR;
- case $t:
- return $TAB;
- case $v:
- return $VTAB;
- default:
- return code;
- }
- }
- /**
- * @param {?} text
- * @return {?}
- */
- function parseIntAutoRadix(text) {
- var /** @type {?} */ result = parseInt(text);
- if (isNaN(result)) {
- throw new Error('Invalid integer literal when parsing ' + text);
- }
- return result;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var ParserError = /** @class */ (function () {
- function ParserError(message, input, errLocation, ctxLocation) {
- this.input = input;
- this.errLocation = errLocation;
- this.ctxLocation = ctxLocation;
- this.message = "Parser Error: " + message + " " + errLocation + " [" + input + "] in " + ctxLocation;
- }
- return ParserError;
- }());
- var ParseSpan = /** @class */ (function () {
- function ParseSpan(start, end) {
- this.start = start;
- this.end = end;
- }
- return ParseSpan;
- }());
- var AST = /** @class */ (function () {
- function AST(span) {
- this.span = span;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- AST.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return null;
- };
- /**
- * @return {?}
- */
- AST.prototype.toString = /**
- * @return {?}
- */
- function () { return 'AST'; };
- return AST;
- }());
- /**
- * Represents a quoted expression of the form:
- *
- * quote = prefix `:` uninterpretedExpression
- * prefix = identifier
- * uninterpretedExpression = arbitrary string
- *
- * A quoted expression is meant to be pre-processed by an AST transformer that
- * converts it into another AST that no longer contains quoted expressions.
- * It is meant to allow third-party developers to extend Angular template
- * expression language. The `uninterpretedExpression` part of the quote is
- * therefore not interpreted by the Angular's own expression parser.
- */
- var Quote = /** @class */ (function (_super) {
- __extends(Quote, _super);
- function Quote(span, prefix, uninterpretedExpression, location) {
- var _this = _super.call(this, span) || this;
- _this.prefix = prefix;
- _this.uninterpretedExpression = uninterpretedExpression;
- _this.location = location;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- Quote.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitQuote(this, context);
- };
- /**
- * @return {?}
- */
- Quote.prototype.toString = /**
- * @return {?}
- */
- function () { return 'Quote'; };
- return Quote;
- }(AST));
- var EmptyExpr = /** @class */ (function (_super) {
- __extends(EmptyExpr, _super);
- function EmptyExpr() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- EmptyExpr.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- // do nothing
- };
- return EmptyExpr;
- }(AST));
- var ImplicitReceiver = /** @class */ (function (_super) {
- __extends(ImplicitReceiver, _super);
- function ImplicitReceiver() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- ImplicitReceiver.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitImplicitReceiver(this, context);
- };
- return ImplicitReceiver;
- }(AST));
- /**
- * Multiple expressions separated by a semicolon.
- */
- var Chain = /** @class */ (function (_super) {
- __extends(Chain, _super);
- function Chain(span, expressions) {
- var _this = _super.call(this, span) || this;
- _this.expressions = expressions;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- Chain.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitChain(this, context);
- };
- return Chain;
- }(AST));
- var Conditional = /** @class */ (function (_super) {
- __extends(Conditional, _super);
- function Conditional(span, condition, trueExp, falseExp) {
- var _this = _super.call(this, span) || this;
- _this.condition = condition;
- _this.trueExp = trueExp;
- _this.falseExp = falseExp;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- Conditional.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitConditional(this, context);
- };
- return Conditional;
- }(AST));
- var PropertyRead = /** @class */ (function (_super) {
- __extends(PropertyRead, _super);
- function PropertyRead(span, receiver, name) {
- var _this = _super.call(this, span) || this;
- _this.receiver = receiver;
- _this.name = name;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- PropertyRead.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitPropertyRead(this, context);
- };
- return PropertyRead;
- }(AST));
- var PropertyWrite = /** @class */ (function (_super) {
- __extends(PropertyWrite, _super);
- function PropertyWrite(span, receiver, name, value) {
- var _this = _super.call(this, span) || this;
- _this.receiver = receiver;
- _this.name = name;
- _this.value = value;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- PropertyWrite.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitPropertyWrite(this, context);
- };
- return PropertyWrite;
- }(AST));
- var SafePropertyRead = /** @class */ (function (_super) {
- __extends(SafePropertyRead, _super);
- function SafePropertyRead(span, receiver, name) {
- var _this = _super.call(this, span) || this;
- _this.receiver = receiver;
- _this.name = name;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- SafePropertyRead.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitSafePropertyRead(this, context);
- };
- return SafePropertyRead;
- }(AST));
- var KeyedRead = /** @class */ (function (_super) {
- __extends(KeyedRead, _super);
- function KeyedRead(span, obj, key) {
- var _this = _super.call(this, span) || this;
- _this.obj = obj;
- _this.key = key;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- KeyedRead.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitKeyedRead(this, context);
- };
- return KeyedRead;
- }(AST));
- var KeyedWrite = /** @class */ (function (_super) {
- __extends(KeyedWrite, _super);
- function KeyedWrite(span, obj, key, value) {
- var _this = _super.call(this, span) || this;
- _this.obj = obj;
- _this.key = key;
- _this.value = value;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- KeyedWrite.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitKeyedWrite(this, context);
- };
- return KeyedWrite;
- }(AST));
- var BindingPipe = /** @class */ (function (_super) {
- __extends(BindingPipe, _super);
- function BindingPipe(span, exp, name, args) {
- var _this = _super.call(this, span) || this;
- _this.exp = exp;
- _this.name = name;
- _this.args = args;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- BindingPipe.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitPipe(this, context);
- };
- return BindingPipe;
- }(AST));
- var LiteralPrimitive = /** @class */ (function (_super) {
- __extends(LiteralPrimitive, _super);
- function LiteralPrimitive(span, value) {
- var _this = _super.call(this, span) || this;
- _this.value = value;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- LiteralPrimitive.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitLiteralPrimitive(this, context);
- };
- return LiteralPrimitive;
- }(AST));
- var LiteralArray = /** @class */ (function (_super) {
- __extends(LiteralArray, _super);
- function LiteralArray(span, expressions) {
- var _this = _super.call(this, span) || this;
- _this.expressions = expressions;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- LiteralArray.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitLiteralArray(this, context);
- };
- return LiteralArray;
- }(AST));
- var LiteralMap = /** @class */ (function (_super) {
- __extends(LiteralMap, _super);
- function LiteralMap(span, keys, values) {
- var _this = _super.call(this, span) || this;
- _this.keys = keys;
- _this.values = values;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- LiteralMap.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitLiteralMap(this, context);
- };
- return LiteralMap;
- }(AST));
- var Interpolation = /** @class */ (function (_super) {
- __extends(Interpolation, _super);
- function Interpolation(span, strings, expressions) {
- var _this = _super.call(this, span) || this;
- _this.strings = strings;
- _this.expressions = expressions;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- Interpolation.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitInterpolation(this, context);
- };
- return Interpolation;
- }(AST));
- var Binary = /** @class */ (function (_super) {
- __extends(Binary, _super);
- function Binary(span, operation, left, right) {
- var _this = _super.call(this, span) || this;
- _this.operation = operation;
- _this.left = left;
- _this.right = right;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- Binary.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitBinary(this, context);
- };
- return Binary;
- }(AST));
- var PrefixNot = /** @class */ (function (_super) {
- __extends(PrefixNot, _super);
- function PrefixNot(span, expression) {
- var _this = _super.call(this, span) || this;
- _this.expression = expression;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- PrefixNot.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitPrefixNot(this, context);
- };
- return PrefixNot;
- }(AST));
- var NonNullAssert = /** @class */ (function (_super) {
- __extends(NonNullAssert, _super);
- function NonNullAssert(span, expression) {
- var _this = _super.call(this, span) || this;
- _this.expression = expression;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- NonNullAssert.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitNonNullAssert(this, context);
- };
- return NonNullAssert;
- }(AST));
- var MethodCall = /** @class */ (function (_super) {
- __extends(MethodCall, _super);
- function MethodCall(span, receiver, name, args) {
- var _this = _super.call(this, span) || this;
- _this.receiver = receiver;
- _this.name = name;
- _this.args = args;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- MethodCall.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitMethodCall(this, context);
- };
- return MethodCall;
- }(AST));
- var SafeMethodCall = /** @class */ (function (_super) {
- __extends(SafeMethodCall, _super);
- function SafeMethodCall(span, receiver, name, args) {
- var _this = _super.call(this, span) || this;
- _this.receiver = receiver;
- _this.name = name;
- _this.args = args;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- SafeMethodCall.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitSafeMethodCall(this, context);
- };
- return SafeMethodCall;
- }(AST));
- var FunctionCall = /** @class */ (function (_super) {
- __extends(FunctionCall, _super);
- function FunctionCall(span, target, args) {
- var _this = _super.call(this, span) || this;
- _this.target = target;
- _this.args = args;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- FunctionCall.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return visitor.visitFunctionCall(this, context);
- };
- return FunctionCall;
- }(AST));
- var ASTWithSource = /** @class */ (function (_super) {
- __extends(ASTWithSource, _super);
- function ASTWithSource(ast, source, location, errors) {
- var _this = _super.call(this, new ParseSpan(0, source == null ? 0 : source.length)) || this;
- _this.ast = ast;
- _this.source = source;
- _this.location = location;
- _this.errors = errors;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- ASTWithSource.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) {
- if (context === void 0) { context = null; }
- return this.ast.visit(visitor, context);
- };
- /**
- * @return {?}
- */
- ASTWithSource.prototype.toString = /**
- * @return {?}
- */
- function () { return this.source + " in " + this.location; };
- return ASTWithSource;
- }(AST));
- var TemplateBinding = /** @class */ (function () {
- function TemplateBinding(span, key, keyIsVar, name, expression) {
- this.span = span;
- this.key = key;
- this.keyIsVar = keyIsVar;
- this.name = name;
- this.expression = expression;
- }
- return TemplateBinding;
- }());
- /**
- * @record
- */
-
- var NullAstVisitor = /** @class */ (function () {
- function NullAstVisitor() {
- }
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitBinary = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitChain = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitConditional = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitFunctionCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitImplicitReceiver = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitInterpolation = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitKeyedRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitKeyedWrite = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitLiteralArray = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitLiteralMap = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitLiteralPrimitive = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitMethodCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitPipe = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitPrefixNot = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitNonNullAssert = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitPropertyRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitPropertyWrite = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitQuote = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitSafeMethodCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- NullAstVisitor.prototype.visitSafePropertyRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- return NullAstVisitor;
- }());
- var RecursiveAstVisitor = /** @class */ (function () {
- function RecursiveAstVisitor() {
- }
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitBinary = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.left.visit(this);
- ast.right.visit(this);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitChain = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return this.visitAll(ast.expressions, context); };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitConditional = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.condition.visit(this);
- ast.trueExp.visit(this);
- ast.falseExp.visit(this);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitPipe = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.exp.visit(this);
- this.visitAll(ast.args, context);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitFunctionCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- /** @type {?} */ ((ast.target)).visit(this);
- this.visitAll(ast.args, context);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitImplicitReceiver = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return null; };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitInterpolation = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.visitAll(ast.expressions, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitKeyedRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.obj.visit(this);
- ast.key.visit(this);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitKeyedWrite = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.obj.visit(this);
- ast.key.visit(this);
- ast.value.visit(this);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitLiteralArray = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.visitAll(ast.expressions, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitLiteralMap = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return this.visitAll(ast.values, context); };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitLiteralPrimitive = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return null; };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitMethodCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.receiver.visit(this);
- return this.visitAll(ast.args, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitPrefixNot = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.expression.visit(this);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitNonNullAssert = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.expression.visit(this);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitPropertyRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.receiver.visit(this);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitPropertyWrite = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.receiver.visit(this);
- ast.value.visit(this);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitSafePropertyRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.receiver.visit(this);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitSafeMethodCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.receiver.visit(this);
- return this.visitAll(ast.args, context);
- };
- /**
- * @param {?} asts
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitAll = /**
- * @param {?} asts
- * @param {?} context
- * @return {?}
- */
- function (asts, context) {
- var _this = this;
- asts.forEach(function (ast) { return ast.visit(_this, context); });
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitQuote = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return null; };
- return RecursiveAstVisitor;
- }());
- var AstTransformer = /** @class */ (function () {
- function AstTransformer() {
- }
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitImplicitReceiver = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return ast; };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitInterpolation = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new Interpolation(ast.span, ast.strings, this.visitAll(ast.expressions));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitLiteralPrimitive = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new LiteralPrimitive(ast.span, ast.value);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitPropertyRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new PropertyRead(ast.span, ast.receiver.visit(this), ast.name);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitPropertyWrite = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new PropertyWrite(ast.span, ast.receiver.visit(this), ast.name, ast.value.visit(this));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitSafePropertyRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new SafePropertyRead(ast.span, ast.receiver.visit(this), ast.name);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitMethodCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new MethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitSafeMethodCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new SafeMethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitFunctionCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new FunctionCall(ast.span, /** @type {?} */ ((ast.target)).visit(this), this.visitAll(ast.args));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitLiteralArray = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new LiteralArray(ast.span, this.visitAll(ast.expressions));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitLiteralMap = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new LiteralMap(ast.span, ast.keys, this.visitAll(ast.values));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitBinary = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new Binary(ast.span, ast.operation, ast.left.visit(this), ast.right.visit(this));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitPrefixNot = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new PrefixNot(ast.span, ast.expression.visit(this));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitNonNullAssert = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new NonNullAssert(ast.span, ast.expression.visit(this));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitConditional = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new Conditional(ast.span, ast.condition.visit(this), ast.trueExp.visit(this), ast.falseExp.visit(this));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitPipe = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new BindingPipe(ast.span, ast.exp.visit(this), ast.name, this.visitAll(ast.args));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitKeyedRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new KeyedRead(ast.span, ast.obj.visit(this), ast.key.visit(this));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitKeyedWrite = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new KeyedWrite(ast.span, ast.obj.visit(this), ast.key.visit(this), ast.value.visit(this));
- };
- /**
- * @param {?} asts
- * @return {?}
- */
- AstTransformer.prototype.visitAll = /**
- * @param {?} asts
- * @return {?}
- */
- function (asts) {
- var /** @type {?} */ res = new Array(asts.length);
- for (var /** @type {?} */ i = 0; i < asts.length; ++i) {
- res[i] = asts[i].visit(this);
- }
- return res;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitChain = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new Chain(ast.span, this.visitAll(ast.expressions));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitQuote = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return new Quote(ast.span, ast.prefix, ast.uninterpretedExpression, ast.location);
- };
- return AstTransformer;
- }());
- /**
- * @param {?} ast
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function visitAstChildren(ast, visitor, context) {
- /**
- * @param {?} ast
- * @return {?}
- */
- function visit(ast) {
- visitor.visit && visitor.visit(ast, context) || ast.visit(visitor, context);
- }
- /**
- * @template T
- * @param {?} asts
- * @return {?}
- */
- function visitAll(asts) { asts.forEach(visit); }
- ast.visit({
- visitBinary: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- visit(ast.left);
- visit(ast.right);
- },
- visitChain: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { visitAll(ast.expressions); },
- visitConditional: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- visit(ast.condition);
- visit(ast.trueExp);
- visit(ast.falseExp);
- },
- visitFunctionCall: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- if (ast.target) {
- visit(ast.target);
- }
- visitAll(ast.args);
- },
- visitImplicitReceiver: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { },
- visitInterpolation: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { visitAll(ast.expressions); },
- visitKeyedRead: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- visit(ast.obj);
- visit(ast.key);
- },
- visitKeyedWrite: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- visit(ast.obj);
- visit(ast.key);
- visit(ast.obj);
- },
- visitLiteralArray: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { visitAll(ast.expressions); },
- visitLiteralMap: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { },
- visitLiteralPrimitive: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { },
- visitMethodCall: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- visit(ast.receiver);
- visitAll(ast.args);
- },
- visitPipe: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- visit(ast.exp);
- visitAll(ast.args);
- },
- visitPrefixNot: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { visit(ast.expression); },
- visitNonNullAssert: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { visit(ast.expression); },
- visitPropertyRead: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { visit(ast.receiver); },
- visitPropertyWrite: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- visit(ast.receiver);
- visit(ast.value);
- },
- visitQuote: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { },
- visitSafeMethodCall: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- visit(ast.receiver);
- visitAll(ast.args);
- },
- visitSafePropertyRead: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { visit(ast.receiver); },
- });
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var SplitInterpolation = /** @class */ (function () {
- function SplitInterpolation(strings, expressions, offsets) {
- this.strings = strings;
- this.expressions = expressions;
- this.offsets = offsets;
- }
- return SplitInterpolation;
- }());
- var TemplateBindingParseResult = /** @class */ (function () {
- function TemplateBindingParseResult(templateBindings, warnings, errors) {
- this.templateBindings = templateBindings;
- this.warnings = warnings;
- this.errors = errors;
- }
- return TemplateBindingParseResult;
- }());
- /**
- * @param {?} config
- * @return {?}
- */
- function _createInterpolateRegExp(config) {
- var /** @type {?} */ pattern = escapeRegExp(config.start) + '([\\s\\S]*?)' + escapeRegExp(config.end);
- return new RegExp(pattern, 'g');
- }
- var Parser = /** @class */ (function () {
- function Parser(_lexer) {
- this._lexer = _lexer;
- this.errors = [];
- }
- /**
- * @param {?} input
- * @param {?} location
- * @param {?=} interpolationConfig
- * @return {?}
- */
- Parser.prototype.parseAction = /**
- * @param {?} input
- * @param {?} location
- * @param {?=} interpolationConfig
- * @return {?}
- */
- function (input, location, interpolationConfig) {
- if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
- this._checkNoInterpolation(input, location, interpolationConfig);
- var /** @type {?} */ sourceToLex = this._stripComments(input);
- var /** @type {?} */ tokens = this._lexer.tokenize(this._stripComments(input));
- var /** @type {?} */ ast = new _ParseAST(input, location, tokens, sourceToLex.length, true, this.errors, input.length - sourceToLex.length)
- .parseChain();
- return new ASTWithSource(ast, input, location, this.errors);
- };
- /**
- * @param {?} input
- * @param {?} location
- * @param {?=} interpolationConfig
- * @return {?}
- */
- Parser.prototype.parseBinding = /**
- * @param {?} input
- * @param {?} location
- * @param {?=} interpolationConfig
- * @return {?}
- */
- function (input, location, interpolationConfig) {
- if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
- var /** @type {?} */ ast = this._parseBindingAst(input, location, interpolationConfig);
- return new ASTWithSource(ast, input, location, this.errors);
- };
- /**
- * @param {?} input
- * @param {?} location
- * @param {?=} interpolationConfig
- * @return {?}
- */
- Parser.prototype.parseSimpleBinding = /**
- * @param {?} input
- * @param {?} location
- * @param {?=} interpolationConfig
- * @return {?}
- */
- function (input, location, interpolationConfig) {
- if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
- var /** @type {?} */ ast = this._parseBindingAst(input, location, interpolationConfig);
- var /** @type {?} */ errors = SimpleExpressionChecker.check(ast);
- if (errors.length > 0) {
- this._reportError("Host binding expression cannot contain " + errors.join(' '), input, location);
- }
- return new ASTWithSource(ast, input, location, this.errors);
- };
- /**
- * @param {?} message
- * @param {?} input
- * @param {?} errLocation
- * @param {?=} ctxLocation
- * @return {?}
- */
- Parser.prototype._reportError = /**
- * @param {?} message
- * @param {?} input
- * @param {?} errLocation
- * @param {?=} ctxLocation
- * @return {?}
- */
- function (message, input, errLocation, ctxLocation) {
- this.errors.push(new ParserError(message, input, errLocation, ctxLocation));
- };
- /**
- * @param {?} input
- * @param {?} location
- * @param {?} interpolationConfig
- * @return {?}
- */
- Parser.prototype._parseBindingAst = /**
- * @param {?} input
- * @param {?} location
- * @param {?} interpolationConfig
- * @return {?}
- */
- function (input, location, interpolationConfig) {
- // Quotes expressions use 3rd-party expression language. We don't want to use
- // our lexer or parser for that, so we check for that ahead of time.
- var /** @type {?} */ quote = this._parseQuote(input, location);
- if (quote != null) {
- return quote;
- }
- this._checkNoInterpolation(input, location, interpolationConfig);
- var /** @type {?} */ sourceToLex = this._stripComments(input);
- var /** @type {?} */ tokens = this._lexer.tokenize(sourceToLex);
- return new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, input.length - sourceToLex.length)
- .parseChain();
- };
- /**
- * @param {?} input
- * @param {?} location
- * @return {?}
- */
- Parser.prototype._parseQuote = /**
- * @param {?} input
- * @param {?} location
- * @return {?}
- */
- function (input, location) {
- if (input == null)
- return null;
- var /** @type {?} */ prefixSeparatorIndex = input.indexOf(':');
- if (prefixSeparatorIndex == -1)
- return null;
- var /** @type {?} */ prefix = input.substring(0, prefixSeparatorIndex).trim();
- if (!isIdentifier(prefix))
- return null;
- var /** @type {?} */ uninterpretedExpression = input.substring(prefixSeparatorIndex + 1);
- return new Quote(new ParseSpan(0, input.length), prefix, uninterpretedExpression, location);
- };
- /**
- * @param {?} prefixToken
- * @param {?} input
- * @param {?} location
- * @return {?}
- */
- Parser.prototype.parseTemplateBindings = /**
- * @param {?} prefixToken
- * @param {?} input
- * @param {?} location
- * @return {?}
- */
- function (prefixToken, input, location) {
- var /** @type {?} */ tokens = this._lexer.tokenize(input);
- if (prefixToken) {
- // Prefix the tokens with the tokens from prefixToken but have them take no space (0 index).
- var /** @type {?} */ prefixTokens = this._lexer.tokenize(prefixToken).map(function (t) {
- t.index = 0;
- return t;
- });
- tokens.unshift.apply(tokens, prefixTokens);
- }
- return new _ParseAST(input, location, tokens, input.length, false, this.errors, 0)
- .parseTemplateBindings();
- };
- /**
- * @param {?} input
- * @param {?} location
- * @param {?=} interpolationConfig
- * @return {?}
- */
- Parser.prototype.parseInterpolation = /**
- * @param {?} input
- * @param {?} location
- * @param {?=} interpolationConfig
- * @return {?}
- */
- function (input, location, interpolationConfig) {
- if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
- var /** @type {?} */ split = this.splitInterpolation(input, location, interpolationConfig);
- if (split == null)
- return null;
- var /** @type {?} */ expressions = [];
- for (var /** @type {?} */ i = 0; i < split.expressions.length; ++i) {
- var /** @type {?} */ expressionText = split.expressions[i];
- var /** @type {?} */ sourceToLex = this._stripComments(expressionText);
- var /** @type {?} */ tokens = this._lexer.tokenize(sourceToLex);
- var /** @type {?} */ ast = new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, split.offsets[i] + (expressionText.length - sourceToLex.length))
- .parseChain();
- expressions.push(ast);
- }
- return new ASTWithSource(new Interpolation(new ParseSpan(0, input == null ? 0 : input.length), split.strings, expressions), input, location, this.errors);
- };
- /**
- * @param {?} input
- * @param {?} location
- * @param {?=} interpolationConfig
- * @return {?}
- */
- Parser.prototype.splitInterpolation = /**
- * @param {?} input
- * @param {?} location
- * @param {?=} interpolationConfig
- * @return {?}
- */
- function (input, location, interpolationConfig) {
- if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
- var /** @type {?} */ regexp = _createInterpolateRegExp(interpolationConfig);
- var /** @type {?} */ parts = input.split(regexp);
- if (parts.length <= 1) {
- return null;
- }
- var /** @type {?} */ strings = [];
- var /** @type {?} */ expressions = [];
- var /** @type {?} */ offsets = [];
- var /** @type {?} */ offset = 0;
- for (var /** @type {?} */ i = 0; i < parts.length; i++) {
- var /** @type {?} */ part = parts[i];
- if (i % 2 === 0) {
- // fixed string
- strings.push(part);
- offset += part.length;
- }
- else if (part.trim().length > 0) {
- offset += interpolationConfig.start.length;
- expressions.push(part);
- offsets.push(offset);
- offset += part.length + interpolationConfig.end.length;
- }
- else {
- this._reportError('Blank expressions are not allowed in interpolated strings', input, "at column " + this._findInterpolationErrorColumn(parts, i, interpolationConfig) + " in", location);
- expressions.push('$implict');
- offsets.push(offset);
- }
- }
- return new SplitInterpolation(strings, expressions, offsets);
- };
- /**
- * @param {?} input
- * @param {?} location
- * @return {?}
- */
- Parser.prototype.wrapLiteralPrimitive = /**
- * @param {?} input
- * @param {?} location
- * @return {?}
- */
- function (input, location) {
- return new ASTWithSource(new LiteralPrimitive(new ParseSpan(0, input == null ? 0 : input.length), input), input, location, this.errors);
- };
- /**
- * @param {?} input
- * @return {?}
- */
- Parser.prototype._stripComments = /**
- * @param {?} input
- * @return {?}
- */
- function (input) {
- var /** @type {?} */ i = this._commentStart(input);
- return i != null ? input.substring(0, i).trim() : input;
- };
- /**
- * @param {?} input
- * @return {?}
- */
- Parser.prototype._commentStart = /**
- * @param {?} input
- * @return {?}
- */
- function (input) {
- var /** @type {?} */ outerQuote = null;
- for (var /** @type {?} */ i = 0; i < input.length - 1; i++) {
- var /** @type {?} */ char = input.charCodeAt(i);
- var /** @type {?} */ nextChar = input.charCodeAt(i + 1);
- if (char === $SLASH && nextChar == $SLASH && outerQuote == null)
- return i;
- if (outerQuote === char) {
- outerQuote = null;
- }
- else if (outerQuote == null && isQuote(char)) {
- outerQuote = char;
- }
- }
- return null;
- };
- /**
- * @param {?} input
- * @param {?} location
- * @param {?} interpolationConfig
- * @return {?}
- */
- Parser.prototype._checkNoInterpolation = /**
- * @param {?} input
- * @param {?} location
- * @param {?} interpolationConfig
- * @return {?}
- */
- function (input, location, interpolationConfig) {
- var /** @type {?} */ regexp = _createInterpolateRegExp(interpolationConfig);
- var /** @type {?} */ parts = input.split(regexp);
- if (parts.length > 1) {
- this._reportError("Got interpolation (" + interpolationConfig.start + interpolationConfig.end + ") where expression was expected", input, "at column " + this._findInterpolationErrorColumn(parts, 1, interpolationConfig) + " in", location);
- }
- };
- /**
- * @param {?} parts
- * @param {?} partInErrIdx
- * @param {?} interpolationConfig
- * @return {?}
- */
- Parser.prototype._findInterpolationErrorColumn = /**
- * @param {?} parts
- * @param {?} partInErrIdx
- * @param {?} interpolationConfig
- * @return {?}
- */
- function (parts, partInErrIdx, interpolationConfig) {
- var /** @type {?} */ errLocation = '';
- for (var /** @type {?} */ j = 0; j < partInErrIdx; j++) {
- errLocation += j % 2 === 0 ?
- parts[j] :
- "" + interpolationConfig.start + parts[j] + interpolationConfig.end;
- }
- return errLocation.length;
- };
- return Parser;
- }());
- var _ParseAST = /** @class */ (function () {
- function _ParseAST(input, location, tokens, inputLength, parseAction, errors, offset) {
- this.input = input;
- this.location = location;
- this.tokens = tokens;
- this.inputLength = inputLength;
- this.parseAction = parseAction;
- this.errors = errors;
- this.offset = offset;
- this.rparensExpected = 0;
- this.rbracketsExpected = 0;
- this.rbracesExpected = 0;
- this.index = 0;
- }
- /**
- * @param {?} offset
- * @return {?}
- */
- _ParseAST.prototype.peek = /**
- * @param {?} offset
- * @return {?}
- */
- function (offset) {
- var /** @type {?} */ i = this.index + offset;
- return i < this.tokens.length ? this.tokens[i] : EOF;
- };
- Object.defineProperty(_ParseAST.prototype, "next", {
- get: /**
- * @return {?}
- */
- function () { return this.peek(0); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(_ParseAST.prototype, "inputIndex", {
- get: /**
- * @return {?}
- */
- function () {
- return (this.index < this.tokens.length) ? this.next.index + this.offset :
- this.inputLength + this.offset;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} start
- * @return {?}
- */
- _ParseAST.prototype.span = /**
- * @param {?} start
- * @return {?}
- */
- function (start) { return new ParseSpan(start, this.inputIndex); };
- /**
- * @return {?}
- */
- _ParseAST.prototype.advance = /**
- * @return {?}
- */
- function () { this.index++; };
- /**
- * @param {?} code
- * @return {?}
- */
- _ParseAST.prototype.optionalCharacter = /**
- * @param {?} code
- * @return {?}
- */
- function (code) {
- if (this.next.isCharacter(code)) {
- this.advance();
- return true;
- }
- else {
- return false;
- }
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.peekKeywordLet = /**
- * @return {?}
- */
- function () { return this.next.isKeywordLet(); };
- /**
- * @return {?}
- */
- _ParseAST.prototype.peekKeywordAs = /**
- * @return {?}
- */
- function () { return this.next.isKeywordAs(); };
- /**
- * @param {?} code
- * @return {?}
- */
- _ParseAST.prototype.expectCharacter = /**
- * @param {?} code
- * @return {?}
- */
- function (code) {
- if (this.optionalCharacter(code))
- return;
- this.error("Missing expected " + String.fromCharCode(code));
- };
- /**
- * @param {?} op
- * @return {?}
- */
- _ParseAST.prototype.optionalOperator = /**
- * @param {?} op
- * @return {?}
- */
- function (op) {
- if (this.next.isOperator(op)) {
- this.advance();
- return true;
- }
- else {
- return false;
- }
- };
- /**
- * @param {?} operator
- * @return {?}
- */
- _ParseAST.prototype.expectOperator = /**
- * @param {?} operator
- * @return {?}
- */
- function (operator) {
- if (this.optionalOperator(operator))
- return;
- this.error("Missing expected operator " + operator);
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.expectIdentifierOrKeyword = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ n = this.next;
- if (!n.isIdentifier() && !n.isKeyword()) {
- this.error("Unexpected token " + n + ", expected identifier or keyword");
- return '';
- }
- this.advance();
- return /** @type {?} */ (n.toString());
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.expectIdentifierOrKeywordOrString = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ n = this.next;
- if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) {
- this.error("Unexpected token " + n + ", expected identifier, keyword, or string");
- return '';
- }
- this.advance();
- return /** @type {?} */ (n.toString());
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseChain = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ exprs = [];
- var /** @type {?} */ start = this.inputIndex;
- while (this.index < this.tokens.length) {
- var /** @type {?} */ expr = this.parsePipe();
- exprs.push(expr);
- if (this.optionalCharacter($SEMICOLON)) {
- if (!this.parseAction) {
- this.error('Binding expression cannot contain chained expression');
- }
- while (this.optionalCharacter($SEMICOLON)) {
- } // read all semicolons
- }
- else if (this.index < this.tokens.length) {
- this.error("Unexpected token '" + this.next + "'");
- }
- }
- if (exprs.length == 0)
- return new EmptyExpr(this.span(start));
- if (exprs.length == 1)
- return exprs[0];
- return new Chain(this.span(start), exprs);
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parsePipe = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ result = this.parseExpression();
- if (this.optionalOperator('|')) {
- if (this.parseAction) {
- this.error('Cannot have a pipe in an action expression');
- }
- do {
- var /** @type {?} */ name_1 = this.expectIdentifierOrKeyword();
- var /** @type {?} */ args = [];
- while (this.optionalCharacter($COLON)) {
- args.push(this.parseExpression());
- }
- result = new BindingPipe(this.span(result.span.start), result, name_1, args);
- } while (this.optionalOperator('|'));
- }
- return result;
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseExpression = /**
- * @return {?}
- */
- function () { return this.parseConditional(); };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseConditional = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ start = this.inputIndex;
- var /** @type {?} */ result = this.parseLogicalOr();
- if (this.optionalOperator('?')) {
- var /** @type {?} */ yes = this.parsePipe();
- var /** @type {?} */ no = void 0;
- if (!this.optionalCharacter($COLON)) {
- var /** @type {?} */ end = this.inputIndex;
- var /** @type {?} */ expression = this.input.substring(start, end);
- this.error("Conditional expression " + expression + " requires all 3 expressions");
- no = new EmptyExpr(this.span(start));
- }
- else {
- no = this.parsePipe();
- }
- return new Conditional(this.span(start), result, yes, no);
- }
- else {
- return result;
- }
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseLogicalOr = /**
- * @return {?}
- */
- function () {
- // '||'
- var /** @type {?} */ result = this.parseLogicalAnd();
- while (this.optionalOperator('||')) {
- var /** @type {?} */ right = this.parseLogicalAnd();
- result = new Binary(this.span(result.span.start), '||', result, right);
- }
- return result;
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseLogicalAnd = /**
- * @return {?}
- */
- function () {
- // '&&'
- var /** @type {?} */ result = this.parseEquality();
- while (this.optionalOperator('&&')) {
- var /** @type {?} */ right = this.parseEquality();
- result = new Binary(this.span(result.span.start), '&&', result, right);
- }
- return result;
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseEquality = /**
- * @return {?}
- */
- function () {
- // '==','!=','===','!=='
- var /** @type {?} */ result = this.parseRelational();
- while (this.next.type == TokenType.Operator) {
- var /** @type {?} */ operator = this.next.strValue;
- switch (operator) {
- case '==':
- case '===':
- case '!=':
- case '!==':
- this.advance();
- var /** @type {?} */ right = this.parseRelational();
- result = new Binary(this.span(result.span.start), operator, result, right);
- continue;
- }
- break;
- }
- return result;
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseRelational = /**
- * @return {?}
- */
- function () {
- // '<', '>', '<=', '>='
- var /** @type {?} */ result = this.parseAdditive();
- while (this.next.type == TokenType.Operator) {
- var /** @type {?} */ operator = this.next.strValue;
- switch (operator) {
- case '<':
- case '>':
- case '<=':
- case '>=':
- this.advance();
- var /** @type {?} */ right = this.parseAdditive();
- result = new Binary(this.span(result.span.start), operator, result, right);
- continue;
- }
- break;
- }
- return result;
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseAdditive = /**
- * @return {?}
- */
- function () {
- // '+', '-'
- var /** @type {?} */ result = this.parseMultiplicative();
- while (this.next.type == TokenType.Operator) {
- var /** @type {?} */ operator = this.next.strValue;
- switch (operator) {
- case '+':
- case '-':
- this.advance();
- var /** @type {?} */ right = this.parseMultiplicative();
- result = new Binary(this.span(result.span.start), operator, result, right);
- continue;
- }
- break;
- }
- return result;
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseMultiplicative = /**
- * @return {?}
- */
- function () {
- // '*', '%', '/'
- var /** @type {?} */ result = this.parsePrefix();
- while (this.next.type == TokenType.Operator) {
- var /** @type {?} */ operator = this.next.strValue;
- switch (operator) {
- case '*':
- case '%':
- case '/':
- this.advance();
- var /** @type {?} */ right = this.parsePrefix();
- result = new Binary(this.span(result.span.start), operator, result, right);
- continue;
- }
- break;
- }
- return result;
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parsePrefix = /**
- * @return {?}
- */
- function () {
- if (this.next.type == TokenType.Operator) {
- var /** @type {?} */ start = this.inputIndex;
- var /** @type {?} */ operator = this.next.strValue;
- var /** @type {?} */ result = void 0;
- switch (operator) {
- case '+':
- this.advance();
- result = this.parsePrefix();
- return new Binary(this.span(start), '-', result, new LiteralPrimitive(new ParseSpan(start, start), 0));
- case '-':
- this.advance();
- result = this.parsePrefix();
- return new Binary(this.span(start), operator, new LiteralPrimitive(new ParseSpan(start, start), 0), result);
- case '!':
- this.advance();
- result = this.parsePrefix();
- return new PrefixNot(this.span(start), result);
- }
- }
- return this.parseCallChain();
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseCallChain = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ result = this.parsePrimary();
- while (true) {
- if (this.optionalCharacter($PERIOD)) {
- result = this.parseAccessMemberOrMethodCall(result, false);
- }
- else if (this.optionalOperator('?.')) {
- result = this.parseAccessMemberOrMethodCall(result, true);
- }
- else if (this.optionalCharacter($LBRACKET)) {
- this.rbracketsExpected++;
- var /** @type {?} */ key = this.parsePipe();
- this.rbracketsExpected--;
- this.expectCharacter($RBRACKET);
- if (this.optionalOperator('=')) {
- var /** @type {?} */ value = this.parseConditional();
- result = new KeyedWrite(this.span(result.span.start), result, key, value);
- }
- else {
- result = new KeyedRead(this.span(result.span.start), result, key);
- }
- }
- else if (this.optionalCharacter($LPAREN)) {
- this.rparensExpected++;
- var /** @type {?} */ args = this.parseCallArguments();
- this.rparensExpected--;
- this.expectCharacter($RPAREN);
- result = new FunctionCall(this.span(result.span.start), result, args);
- }
- else if (this.optionalOperator('!')) {
- result = new NonNullAssert(this.span(result.span.start), result);
- }
- else {
- return result;
- }
- }
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parsePrimary = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ start = this.inputIndex;
- if (this.optionalCharacter($LPAREN)) {
- this.rparensExpected++;
- var /** @type {?} */ result = this.parsePipe();
- this.rparensExpected--;
- this.expectCharacter($RPAREN);
- return result;
- }
- else if (this.next.isKeywordNull()) {
- this.advance();
- return new LiteralPrimitive(this.span(start), null);
- }
- else if (this.next.isKeywordUndefined()) {
- this.advance();
- return new LiteralPrimitive(this.span(start), void 0);
- }
- else if (this.next.isKeywordTrue()) {
- this.advance();
- return new LiteralPrimitive(this.span(start), true);
- }
- else if (this.next.isKeywordFalse()) {
- this.advance();
- return new LiteralPrimitive(this.span(start), false);
- }
- else if (this.next.isKeywordThis()) {
- this.advance();
- return new ImplicitReceiver(this.span(start));
- }
- else if (this.optionalCharacter($LBRACKET)) {
- this.rbracketsExpected++;
- var /** @type {?} */ elements = this.parseExpressionList($RBRACKET);
- this.rbracketsExpected--;
- this.expectCharacter($RBRACKET);
- return new LiteralArray(this.span(start), elements);
- }
- else if (this.next.isCharacter($LBRACE)) {
- return this.parseLiteralMap();
- }
- else if (this.next.isIdentifier()) {
- return this.parseAccessMemberOrMethodCall(new ImplicitReceiver(this.span(start)), false);
- }
- else if (this.next.isNumber()) {
- var /** @type {?} */ value = this.next.toNumber();
- this.advance();
- return new LiteralPrimitive(this.span(start), value);
- }
- else if (this.next.isString()) {
- var /** @type {?} */ literalValue = this.next.toString();
- this.advance();
- return new LiteralPrimitive(this.span(start), literalValue);
- }
- else if (this.index >= this.tokens.length) {
- this.error("Unexpected end of expression: " + this.input);
- return new EmptyExpr(this.span(start));
- }
- else {
- this.error("Unexpected token " + this.next);
- return new EmptyExpr(this.span(start));
- }
- };
- /**
- * @param {?} terminator
- * @return {?}
- */
- _ParseAST.prototype.parseExpressionList = /**
- * @param {?} terminator
- * @return {?}
- */
- function (terminator) {
- var /** @type {?} */ result = [];
- if (!this.next.isCharacter(terminator)) {
- do {
- result.push(this.parsePipe());
- } while (this.optionalCharacter($COMMA));
- }
- return result;
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseLiteralMap = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ keys = [];
- var /** @type {?} */ values = [];
- var /** @type {?} */ start = this.inputIndex;
- this.expectCharacter($LBRACE);
- if (!this.optionalCharacter($RBRACE)) {
- this.rbracesExpected++;
- do {
- var /** @type {?} */ quoted = this.next.isString();
- var /** @type {?} */ key = this.expectIdentifierOrKeywordOrString();
- keys.push({ key: key, quoted: quoted });
- this.expectCharacter($COLON);
- values.push(this.parsePipe());
- } while (this.optionalCharacter($COMMA));
- this.rbracesExpected--;
- this.expectCharacter($RBRACE);
- }
- return new LiteralMap(this.span(start), keys, values);
- };
- /**
- * @param {?} receiver
- * @param {?=} isSafe
- * @return {?}
- */
- _ParseAST.prototype.parseAccessMemberOrMethodCall = /**
- * @param {?} receiver
- * @param {?=} isSafe
- * @return {?}
- */
- function (receiver, isSafe) {
- if (isSafe === void 0) { isSafe = false; }
- var /** @type {?} */ start = receiver.span.start;
- var /** @type {?} */ id = this.expectIdentifierOrKeyword();
- if (this.optionalCharacter($LPAREN)) {
- this.rparensExpected++;
- var /** @type {?} */ args = this.parseCallArguments();
- this.expectCharacter($RPAREN);
- this.rparensExpected--;
- var /** @type {?} */ span = this.span(start);
- return isSafe ? new SafeMethodCall(span, receiver, id, args) :
- new MethodCall(span, receiver, id, args);
- }
- else {
- if (isSafe) {
- if (this.optionalOperator('=')) {
- this.error('The \'?.\' operator cannot be used in the assignment');
- return new EmptyExpr(this.span(start));
- }
- else {
- return new SafePropertyRead(this.span(start), receiver, id);
- }
- }
- else {
- if (this.optionalOperator('=')) {
- if (!this.parseAction) {
- this.error('Bindings cannot contain assignments');
- return new EmptyExpr(this.span(start));
- }
- var /** @type {?} */ value = this.parseConditional();
- return new PropertyWrite(this.span(start), receiver, id, value);
- }
- else {
- return new PropertyRead(this.span(start), receiver, id);
- }
- }
- }
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseCallArguments = /**
- * @return {?}
- */
- function () {
- if (this.next.isCharacter($RPAREN))
- return [];
- var /** @type {?} */ positionals = [];
- do {
- positionals.push(this.parsePipe());
- } while (this.optionalCharacter($COMMA));
- return /** @type {?} */ (positionals);
- };
- /**
- * An identifier, a keyword, a string with an optional `-` inbetween.
- */
- /**
- * An identifier, a keyword, a string with an optional `-` inbetween.
- * @return {?}
- */
- _ParseAST.prototype.expectTemplateBindingKey = /**
- * An identifier, a keyword, a string with an optional `-` inbetween.
- * @return {?}
- */
- function () {
- var /** @type {?} */ result = '';
- var /** @type {?} */ operatorFound = false;
- do {
- result += this.expectIdentifierOrKeywordOrString();
- operatorFound = this.optionalOperator('-');
- if (operatorFound) {
- result += '-';
- }
- } while (operatorFound);
- return result.toString();
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.parseTemplateBindings = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ bindings = [];
- var /** @type {?} */ prefix = /** @type {?} */ ((null));
- var /** @type {?} */ warnings = [];
- while (this.index < this.tokens.length) {
- var /** @type {?} */ start = this.inputIndex;
- var /** @type {?} */ keyIsVar = this.peekKeywordLet();
- if (keyIsVar) {
- this.advance();
- }
- var /** @type {?} */ rawKey = this.expectTemplateBindingKey();
- var /** @type {?} */ key = rawKey;
- if (!keyIsVar) {
- if (prefix == null) {
- prefix = key;
- }
- else {
- key = prefix + key[0].toUpperCase() + key.substring(1);
- }
- }
- this.optionalCharacter($COLON);
- var /** @type {?} */ name_2 = /** @type {?} */ ((null));
- var /** @type {?} */ expression = /** @type {?} */ ((null));
- if (keyIsVar) {
- if (this.optionalOperator('=')) {
- name_2 = this.expectTemplateBindingKey();
- }
- else {
- name_2 = '\$implicit';
- }
- }
- else if (this.peekKeywordAs()) {
- var /** @type {?} */ letStart = this.inputIndex;
- this.advance(); // consume `as`
- name_2 = rawKey;
- key = this.expectTemplateBindingKey(); // read local var name
- keyIsVar = true;
- }
- else if (this.next !== EOF && !this.peekKeywordLet()) {
- var /** @type {?} */ start_1 = this.inputIndex;
- var /** @type {?} */ ast = this.parsePipe();
- var /** @type {?} */ source = this.input.substring(start_1 - this.offset, this.inputIndex - this.offset);
- expression = new ASTWithSource(ast, source, this.location, this.errors);
- }
- bindings.push(new TemplateBinding(this.span(start), key, keyIsVar, name_2, expression));
- if (this.peekKeywordAs() && !keyIsVar) {
- var /** @type {?} */ letStart = this.inputIndex;
- this.advance(); // consume `as`
- var /** @type {?} */ letName = this.expectTemplateBindingKey(); // read local var name
- bindings.push(new TemplateBinding(this.span(letStart), letName, true, key, /** @type {?} */ ((null))));
- }
- if (!this.optionalCharacter($SEMICOLON)) {
- this.optionalCharacter($COMMA);
- }
- }
- return new TemplateBindingParseResult(bindings, warnings, this.errors);
- };
- /**
- * @param {?} message
- * @param {?=} index
- * @return {?}
- */
- _ParseAST.prototype.error = /**
- * @param {?} message
- * @param {?=} index
- * @return {?}
- */
- function (message, index) {
- if (index === void 0) { index = null; }
- this.errors.push(new ParserError(message, this.input, this.locationText(index), this.location));
- this.skip();
- };
- /**
- * @param {?=} index
- * @return {?}
- */
- _ParseAST.prototype.locationText = /**
- * @param {?=} index
- * @return {?}
- */
- function (index) {
- if (index === void 0) { index = null; }
- if (index == null)
- index = this.index;
- return (index < this.tokens.length) ? "at column " + (this.tokens[index].index + 1) + " in" :
- "at the end of the expression";
- };
- /**
- * @return {?}
- */
- _ParseAST.prototype.skip = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ n = this.next;
- while (this.index < this.tokens.length && !n.isCharacter($SEMICOLON) &&
- (this.rparensExpected <= 0 || !n.isCharacter($RPAREN)) &&
- (this.rbracesExpected <= 0 || !n.isCharacter($RBRACE)) &&
- (this.rbracketsExpected <= 0 || !n.isCharacter($RBRACKET))) {
- if (this.next.isError()) {
- this.errors.push(new ParserError(/** @type {?} */ ((this.next.toString())), this.input, this.locationText(), this.location));
- }
- this.advance();
- n = this.next;
- }
- };
- return _ParseAST;
- }());
- var SimpleExpressionChecker = /** @class */ (function () {
- function SimpleExpressionChecker() {
- this.errors = [];
- }
- /**
- * @param {?} ast
- * @return {?}
- */
- SimpleExpressionChecker.check = /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- var /** @type {?} */ s = new SimpleExpressionChecker();
- ast.visit(s);
- return s.errors;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitImplicitReceiver = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitInterpolation = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitLiteralPrimitive = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitPropertyRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitPropertyWrite = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitSafePropertyRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitMethodCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitSafeMethodCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitFunctionCall = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitLiteralArray = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { this.visitAll(ast.expressions); };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitLiteralMap = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { this.visitAll(ast.values); };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitBinary = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitPrefixNot = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitNonNullAssert = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitConditional = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitPipe = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { this.errors.push('pipes'); };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitKeyedRead = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitKeyedWrite = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} asts
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitAll = /**
- * @param {?} asts
- * @return {?}
- */
- function (asts) {
- var _this = this;
- return asts.map(function (node) { return node.visit(_this); });
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitChain = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- SimpleExpressionChecker.prototype.visitQuote = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- return SimpleExpressionChecker;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- var ParseLocation = /** @class */ (function () {
- function ParseLocation(file, offset, line, col) {
- this.file = file;
- this.offset = offset;
- this.line = line;
- this.col = col;
- }
- /**
- * @return {?}
- */
- ParseLocation.prototype.toString = /**
- * @return {?}
- */
- function () {
- return this.offset != null ? this.file.url + "@" + this.line + ":" + this.col : this.file.url;
- };
- /**
- * @param {?} delta
- * @return {?}
- */
- ParseLocation.prototype.moveBy = /**
- * @param {?} delta
- * @return {?}
- */
- function (delta) {
- var /** @type {?} */ source = this.file.content;
- var /** @type {?} */ len = source.length;
- var /** @type {?} */ offset = this.offset;
- var /** @type {?} */ line = this.line;
- var /** @type {?} */ col = this.col;
- while (offset > 0 && delta < 0) {
- offset--;
- delta++;
- var /** @type {?} */ ch = source.charCodeAt(offset);
- if (ch == $LF) {
- line--;
- var /** @type {?} */ priorLine = source.substr(0, offset - 1).lastIndexOf(String.fromCharCode($LF));
- col = priorLine > 0 ? offset - priorLine : offset;
- }
- else {
- col--;
- }
- }
- while (offset < len && delta > 0) {
- var /** @type {?} */ ch = source.charCodeAt(offset);
- offset++;
- delta--;
- if (ch == $LF) {
- line++;
- col = 0;
- }
- else {
- col++;
- }
- }
- return new ParseLocation(this.file, offset, line, col);
- };
- // Return the source around the location
- // Up to `maxChars` or `maxLines` on each side of the location
- /**
- * @param {?} maxChars
- * @param {?} maxLines
- * @return {?}
- */
- ParseLocation.prototype.getContext = /**
- * @param {?} maxChars
- * @param {?} maxLines
- * @return {?}
- */
- function (maxChars, maxLines) {
- var /** @type {?} */ content = this.file.content;
- var /** @type {?} */ startOffset = this.offset;
- if (startOffset != null) {
- if (startOffset > content.length - 1) {
- startOffset = content.length - 1;
- }
- var /** @type {?} */ endOffset = startOffset;
- var /** @type {?} */ ctxChars = 0;
- var /** @type {?} */ ctxLines = 0;
- while (ctxChars < maxChars && startOffset > 0) {
- startOffset--;
- ctxChars++;
- if (content[startOffset] == '\n') {
- if (++ctxLines == maxLines) {
- break;
- }
- }
- }
- ctxChars = 0;
- ctxLines = 0;
- while (ctxChars < maxChars && endOffset < content.length - 1) {
- endOffset++;
- ctxChars++;
- if (content[endOffset] == '\n') {
- if (++ctxLines == maxLines) {
- break;
- }
- }
- }
- return {
- before: content.substring(startOffset, this.offset),
- after: content.substring(this.offset, endOffset + 1),
- };
- }
- return null;
- };
- return ParseLocation;
- }());
- var ParseSourceFile = /** @class */ (function () {
- function ParseSourceFile(content, url) {
- this.content = content;
- this.url = url;
- }
- return ParseSourceFile;
- }());
- var ParseSourceSpan = /** @class */ (function () {
- function ParseSourceSpan(start, end, details) {
- if (details === void 0) { details = null; }
- this.start = start;
- this.end = end;
- this.details = details;
- }
- /**
- * @return {?}
- */
- ParseSourceSpan.prototype.toString = /**
- * @return {?}
- */
- function () {
- return this.start.file.content.substring(this.start.offset, this.end.offset);
- };
- return ParseSourceSpan;
- }());
- /** @enum {number} */
- var ParseErrorLevel = {
- WARNING: 0,
- ERROR: 1,
- };
- ParseErrorLevel[ParseErrorLevel.WARNING] = "WARNING";
- ParseErrorLevel[ParseErrorLevel.ERROR] = "ERROR";
- var ParseError = /** @class */ (function () {
- function ParseError(span, msg, level) {
- if (level === void 0) { level = ParseErrorLevel.ERROR; }
- this.span = span;
- this.msg = msg;
- this.level = level;
- }
- /**
- * @return {?}
- */
- ParseError.prototype.contextualMessage = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ ctx = this.span.start.getContext(100, 3);
- return ctx ? this.msg + " (\"" + ctx.before + "[" + ParseErrorLevel[this.level] + " ->]" + ctx.after + "\")" :
- this.msg;
- };
- /**
- * @return {?}
- */
- ParseError.prototype.toString = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ details = this.span.details ? ", " + this.span.details : '';
- return this.contextualMessage() + ": " + this.span.start + details;
- };
- return ParseError;
- }());
- /**
- * @param {?} kind
- * @param {?} type
- * @return {?}
- */
- function typeSourceSpan(kind, type) {
- var /** @type {?} */ moduleUrl = identifierModuleUrl(type);
- var /** @type {?} */ sourceFileName = moduleUrl != null ? "in " + kind + " " + identifierName(type) + " in " + moduleUrl :
- "in " + kind + " " + identifierName(type);
- var /** @type {?} */ sourceFile = new ParseSourceFile('', sourceFileName);
- return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /** @enum {number} */
- var TokenType$1 = {
- TAG_OPEN_START: 0,
- TAG_OPEN_END: 1,
- TAG_OPEN_END_VOID: 2,
- TAG_CLOSE: 3,
- TEXT: 4,
- ESCAPABLE_RAW_TEXT: 5,
- RAW_TEXT: 6,
- COMMENT_START: 7,
- COMMENT_END: 8,
- CDATA_START: 9,
- CDATA_END: 10,
- ATTR_NAME: 11,
- ATTR_VALUE: 12,
- DOC_TYPE: 13,
- EXPANSION_FORM_START: 14,
- EXPANSION_CASE_VALUE: 15,
- EXPANSION_CASE_EXP_START: 16,
- EXPANSION_CASE_EXP_END: 17,
- EXPANSION_FORM_END: 18,
- EOF: 19,
- };
- TokenType$1[TokenType$1.TAG_OPEN_START] = "TAG_OPEN_START";
- TokenType$1[TokenType$1.TAG_OPEN_END] = "TAG_OPEN_END";
- TokenType$1[TokenType$1.TAG_OPEN_END_VOID] = "TAG_OPEN_END_VOID";
- TokenType$1[TokenType$1.TAG_CLOSE] = "TAG_CLOSE";
- TokenType$1[TokenType$1.TEXT] = "TEXT";
- TokenType$1[TokenType$1.ESCAPABLE_RAW_TEXT] = "ESCAPABLE_RAW_TEXT";
- TokenType$1[TokenType$1.RAW_TEXT] = "RAW_TEXT";
- TokenType$1[TokenType$1.COMMENT_START] = "COMMENT_START";
- TokenType$1[TokenType$1.COMMENT_END] = "COMMENT_END";
- TokenType$1[TokenType$1.CDATA_START] = "CDATA_START";
- TokenType$1[TokenType$1.CDATA_END] = "CDATA_END";
- TokenType$1[TokenType$1.ATTR_NAME] = "ATTR_NAME";
- TokenType$1[TokenType$1.ATTR_VALUE] = "ATTR_VALUE";
- TokenType$1[TokenType$1.DOC_TYPE] = "DOC_TYPE";
- TokenType$1[TokenType$1.EXPANSION_FORM_START] = "EXPANSION_FORM_START";
- TokenType$1[TokenType$1.EXPANSION_CASE_VALUE] = "EXPANSION_CASE_VALUE";
- TokenType$1[TokenType$1.EXPANSION_CASE_EXP_START] = "EXPANSION_CASE_EXP_START";
- TokenType$1[TokenType$1.EXPANSION_CASE_EXP_END] = "EXPANSION_CASE_EXP_END";
- TokenType$1[TokenType$1.EXPANSION_FORM_END] = "EXPANSION_FORM_END";
- TokenType$1[TokenType$1.EOF] = "EOF";
- var Token$1 = /** @class */ (function () {
- function Token(type, parts, sourceSpan) {
- this.type = type;
- this.parts = parts;
- this.sourceSpan = sourceSpan;
- }
- return Token;
- }());
- var TokenError = /** @class */ (function (_super) {
- __extends(TokenError, _super);
- function TokenError(errorMsg, tokenType, span) {
- var _this = _super.call(this, span, errorMsg) || this;
- _this.tokenType = tokenType;
- return _this;
- }
- return TokenError;
- }(ParseError));
- var TokenizeResult = /** @class */ (function () {
- function TokenizeResult(tokens, errors) {
- this.tokens = tokens;
- this.errors = errors;
- }
- return TokenizeResult;
- }());
- /**
- * @param {?} source
- * @param {?} url
- * @param {?} getTagDefinition
- * @param {?=} tokenizeExpansionForms
- * @param {?=} interpolationConfig
- * @return {?}
- */
- function tokenize(source, url, getTagDefinition, tokenizeExpansionForms, interpolationConfig) {
- if (tokenizeExpansionForms === void 0) { tokenizeExpansionForms = false; }
- if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
- return new _Tokenizer(new ParseSourceFile(source, url), getTagDefinition, tokenizeExpansionForms, interpolationConfig)
- .tokenize();
- }
- var _CR_OR_CRLF_REGEXP = /\r\n?/g;
- /**
- * @param {?} charCode
- * @return {?}
- */
- function _unexpectedCharacterErrorMsg(charCode) {
- var /** @type {?} */ char = charCode === $EOF ? 'EOF' : String.fromCharCode(charCode);
- return "Unexpected character \"" + char + "\"";
- }
- /**
- * @param {?} entitySrc
- * @return {?}
- */
- function _unknownEntityErrorMsg(entitySrc) {
- return "Unknown entity \"" + entitySrc + "\" - use the \"&#<decimal>;\" or \"&#x<hex>;\" syntax";
- }
- var _ControlFlowError = /** @class */ (function () {
- function _ControlFlowError(error) {
- this.error = error;
- }
- return _ControlFlowError;
- }());
- var _Tokenizer = /** @class */ (function () {
- /**
- * @param _file The html source
- * @param _getTagDefinition
- * @param _tokenizeIcu Whether to tokenize ICU messages (considered as text nodes when false)
- * @param _interpolationConfig
- */
- function _Tokenizer(_file, _getTagDefinition, _tokenizeIcu, _interpolationConfig) {
- if (_interpolationConfig === void 0) { _interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
- this._file = _file;
- this._getTagDefinition = _getTagDefinition;
- this._tokenizeIcu = _tokenizeIcu;
- this._interpolationConfig = _interpolationConfig;
- this._peek = -1;
- this._nextPeek = -1;
- this._index = -1;
- this._line = 0;
- this._column = -1;
- this._expansionCaseStack = [];
- this._inInterpolation = false;
- this.tokens = [];
- this.errors = [];
- this._input = _file.content;
- this._length = _file.content.length;
- this._advance();
- }
- /**
- * @param {?} content
- * @return {?}
- */
- _Tokenizer.prototype._processCarriageReturns = /**
- * @param {?} content
- * @return {?}
- */
- function (content) {
- // http://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream
- // In order to keep the original position in the source, we can not
- // pre-process it.
- // Instead CRs are processed right before instantiating the tokens.
- return content.replace(_CR_OR_CRLF_REGEXP, '\n');
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype.tokenize = /**
- * @return {?}
- */
- function () {
- while (this._peek !== $EOF) {
- var /** @type {?} */ start = this._getLocation();
- try {
- if (this._attemptCharCode($LT)) {
- if (this._attemptCharCode($BANG)) {
- if (this._attemptCharCode($LBRACKET)) {
- this._consumeCdata(start);
- }
- else if (this._attemptCharCode($MINUS)) {
- this._consumeComment(start);
- }
- else {
- this._consumeDocType(start);
- }
- }
- else if (this._attemptCharCode($SLASH)) {
- this._consumeTagClose(start);
- }
- else {
- this._consumeTagOpen(start);
- }
- }
- else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) {
- this._consumeText();
- }
- }
- catch (/** @type {?} */ e) {
- if (e instanceof _ControlFlowError) {
- this.errors.push(e.error);
- }
- else {
- throw e;
- }
- }
- }
- this._beginToken(TokenType$1.EOF);
- this._endToken([]);
- return new TokenizeResult(mergeTextTokens(this.tokens), this.errors);
- };
- /**
- * \@internal
- * @return {?} whether an ICU token has been created
- */
- _Tokenizer.prototype._tokenizeExpansionForm = /**
- * \@internal
- * @return {?} whether an ICU token has been created
- */
- function () {
- if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) {
- this._consumeExpansionFormStart();
- return true;
- }
- if (isExpansionCaseStart(this._peek) && this._isInExpansionForm()) {
- this._consumeExpansionCaseStart();
- return true;
- }
- if (this._peek === $RBRACE) {
- if (this._isInExpansionCase()) {
- this._consumeExpansionCaseEnd();
- return true;
- }
- if (this._isInExpansionForm()) {
- this._consumeExpansionFormEnd();
- return true;
- }
- }
- return false;
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._getLocation = /**
- * @return {?}
- */
- function () {
- return new ParseLocation(this._file, this._index, this._line, this._column);
- };
- /**
- * @param {?=} start
- * @param {?=} end
- * @return {?}
- */
- _Tokenizer.prototype._getSpan = /**
- * @param {?=} start
- * @param {?=} end
- * @return {?}
- */
- function (start, end) {
- if (start === void 0) { start = this._getLocation(); }
- if (end === void 0) { end = this._getLocation(); }
- return new ParseSourceSpan(start, end);
- };
- /**
- * @param {?} type
- * @param {?=} start
- * @return {?}
- */
- _Tokenizer.prototype._beginToken = /**
- * @param {?} type
- * @param {?=} start
- * @return {?}
- */
- function (type, start) {
- if (start === void 0) { start = this._getLocation(); }
- this._currentTokenStart = start;
- this._currentTokenType = type;
- };
- /**
- * @param {?} parts
- * @param {?=} end
- * @return {?}
- */
- _Tokenizer.prototype._endToken = /**
- * @param {?} parts
- * @param {?=} end
- * @return {?}
- */
- function (parts, end) {
- if (end === void 0) { end = this._getLocation(); }
- var /** @type {?} */ token = new Token$1(this._currentTokenType, parts, new ParseSourceSpan(this._currentTokenStart, end));
- this.tokens.push(token);
- this._currentTokenStart = /** @type {?} */ ((null));
- this._currentTokenType = /** @type {?} */ ((null));
- return token;
- };
- /**
- * @param {?} msg
- * @param {?} span
- * @return {?}
- */
- _Tokenizer.prototype._createError = /**
- * @param {?} msg
- * @param {?} span
- * @return {?}
- */
- function (msg, span) {
- if (this._isInExpansionForm()) {
- msg += " (Do you have an unescaped \"{\" in your template? Use \"{{ '{' }}\") to escape it.)";
- }
- var /** @type {?} */ error = new TokenError(msg, this._currentTokenType, span);
- this._currentTokenStart = /** @type {?} */ ((null));
- this._currentTokenType = /** @type {?} */ ((null));
- return new _ControlFlowError(error);
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._advance = /**
- * @return {?}
- */
- function () {
- if (this._index >= this._length) {
- throw this._createError(_unexpectedCharacterErrorMsg($EOF), this._getSpan());
- }
- if (this._peek === $LF) {
- this._line++;
- this._column = 0;
- }
- else if (this._peek !== $LF && this._peek !== $CR) {
- this._column++;
- }
- this._index++;
- this._peek = this._index >= this._length ? $EOF : this._input.charCodeAt(this._index);
- this._nextPeek =
- this._index + 1 >= this._length ? $EOF : this._input.charCodeAt(this._index + 1);
- };
- /**
- * @param {?} charCode
- * @return {?}
- */
- _Tokenizer.prototype._attemptCharCode = /**
- * @param {?} charCode
- * @return {?}
- */
- function (charCode) {
- if (this._peek === charCode) {
- this._advance();
- return true;
- }
- return false;
- };
- /**
- * @param {?} charCode
- * @return {?}
- */
- _Tokenizer.prototype._attemptCharCodeCaseInsensitive = /**
- * @param {?} charCode
- * @return {?}
- */
- function (charCode) {
- if (compareCharCodeCaseInsensitive(this._peek, charCode)) {
- this._advance();
- return true;
- }
- return false;
- };
- /**
- * @param {?} charCode
- * @return {?}
- */
- _Tokenizer.prototype._requireCharCode = /**
- * @param {?} charCode
- * @return {?}
- */
- function (charCode) {
- var /** @type {?} */ location = this._getLocation();
- if (!this._attemptCharCode(charCode)) {
- throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location, location));
- }
- };
- /**
- * @param {?} chars
- * @return {?}
- */
- _Tokenizer.prototype._attemptStr = /**
- * @param {?} chars
- * @return {?}
- */
- function (chars) {
- var /** @type {?} */ len = chars.length;
- if (this._index + len > this._length) {
- return false;
- }
- var /** @type {?} */ initialPosition = this._savePosition();
- for (var /** @type {?} */ i = 0; i < len; i++) {
- if (!this._attemptCharCode(chars.charCodeAt(i))) {
- // If attempting to parse the string fails, we want to reset the parser
- // to where it was before the attempt
- this._restorePosition(initialPosition);
- return false;
- }
- }
- return true;
- };
- /**
- * @param {?} chars
- * @return {?}
- */
- _Tokenizer.prototype._attemptStrCaseInsensitive = /**
- * @param {?} chars
- * @return {?}
- */
- function (chars) {
- for (var /** @type {?} */ i = 0; i < chars.length; i++) {
- if (!this._attemptCharCodeCaseInsensitive(chars.charCodeAt(i))) {
- return false;
- }
- }
- return true;
- };
- /**
- * @param {?} chars
- * @return {?}
- */
- _Tokenizer.prototype._requireStr = /**
- * @param {?} chars
- * @return {?}
- */
- function (chars) {
- var /** @type {?} */ location = this._getLocation();
- if (!this._attemptStr(chars)) {
- throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location));
- }
- };
- /**
- * @param {?} predicate
- * @return {?}
- */
- _Tokenizer.prototype._attemptCharCodeUntilFn = /**
- * @param {?} predicate
- * @return {?}
- */
- function (predicate) {
- while (!predicate(this._peek)) {
- this._advance();
- }
- };
- /**
- * @param {?} predicate
- * @param {?} len
- * @return {?}
- */
- _Tokenizer.prototype._requireCharCodeUntilFn = /**
- * @param {?} predicate
- * @param {?} len
- * @return {?}
- */
- function (predicate, len) {
- var /** @type {?} */ start = this._getLocation();
- this._attemptCharCodeUntilFn(predicate);
- if (this._index - start.offset < len) {
- throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(start, start));
- }
- };
- /**
- * @param {?} char
- * @return {?}
- */
- _Tokenizer.prototype._attemptUntilChar = /**
- * @param {?} char
- * @return {?}
- */
- function (char) {
- while (this._peek !== char) {
- this._advance();
- }
- };
- /**
- * @param {?} decodeEntities
- * @return {?}
- */
- _Tokenizer.prototype._readChar = /**
- * @param {?} decodeEntities
- * @return {?}
- */
- function (decodeEntities) {
- if (decodeEntities && this._peek === $AMPERSAND) {
- return this._decodeEntity();
- }
- else {
- var /** @type {?} */ index = this._index;
- this._advance();
- return this._input[index];
- }
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._decodeEntity = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ start = this._getLocation();
- this._advance();
- if (this._attemptCharCode($HASH)) {
- var /** @type {?} */ isHex = this._attemptCharCode($x) || this._attemptCharCode($X);
- var /** @type {?} */ numberStart = this._getLocation().offset;
- this._attemptCharCodeUntilFn(isDigitEntityEnd);
- if (this._peek != $SEMICOLON) {
- throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan());
- }
- this._advance();
- var /** @type {?} */ strNum = this._input.substring(numberStart, this._index - 1);
- try {
- var /** @type {?} */ charCode = parseInt(strNum, isHex ? 16 : 10);
- return String.fromCharCode(charCode);
- }
- catch (/** @type {?} */ e) {
- var /** @type {?} */ entity = this._input.substring(start.offset + 1, this._index - 1);
- throw this._createError(_unknownEntityErrorMsg(entity), this._getSpan(start));
- }
- }
- else {
- var /** @type {?} */ startPosition = this._savePosition();
- this._attemptCharCodeUntilFn(isNamedEntityEnd);
- if (this._peek != $SEMICOLON) {
- this._restorePosition(startPosition);
- return '&';
- }
- this._advance();
- var /** @type {?} */ name_1 = this._input.substring(start.offset + 1, this._index - 1);
- var /** @type {?} */ char = NAMED_ENTITIES[name_1];
- if (!char) {
- throw this._createError(_unknownEntityErrorMsg(name_1), this._getSpan(start));
- }
- return char;
- }
- };
- /**
- * @param {?} decodeEntities
- * @param {?} firstCharOfEnd
- * @param {?} attemptEndRest
- * @return {?}
- */
- _Tokenizer.prototype._consumeRawText = /**
- * @param {?} decodeEntities
- * @param {?} firstCharOfEnd
- * @param {?} attemptEndRest
- * @return {?}
- */
- function (decodeEntities, firstCharOfEnd, attemptEndRest) {
- var /** @type {?} */ tagCloseStart;
- var /** @type {?} */ textStart = this._getLocation();
- this._beginToken(decodeEntities ? TokenType$1.ESCAPABLE_RAW_TEXT : TokenType$1.RAW_TEXT, textStart);
- var /** @type {?} */ parts = [];
- while (true) {
- tagCloseStart = this._getLocation();
- if (this._attemptCharCode(firstCharOfEnd) && attemptEndRest()) {
- break;
- }
- if (this._index > tagCloseStart.offset) {
- // add the characters consumed by the previous if statement to the output
- parts.push(this._input.substring(tagCloseStart.offset, this._index));
- }
- while (this._peek !== firstCharOfEnd) {
- parts.push(this._readChar(decodeEntities));
- }
- }
- return this._endToken([this._processCarriageReturns(parts.join(''))], tagCloseStart);
- };
- /**
- * @param {?} start
- * @return {?}
- */
- _Tokenizer.prototype._consumeComment = /**
- * @param {?} start
- * @return {?}
- */
- function (start) {
- var _this = this;
- this._beginToken(TokenType$1.COMMENT_START, start);
- this._requireCharCode($MINUS);
- this._endToken([]);
- var /** @type {?} */ textToken = this._consumeRawText(false, $MINUS, function () { return _this._attemptStr('->'); });
- this._beginToken(TokenType$1.COMMENT_END, textToken.sourceSpan.end);
- this._endToken([]);
- };
- /**
- * @param {?} start
- * @return {?}
- */
- _Tokenizer.prototype._consumeCdata = /**
- * @param {?} start
- * @return {?}
- */
- function (start) {
- var _this = this;
- this._beginToken(TokenType$1.CDATA_START, start);
- this._requireStr('CDATA[');
- this._endToken([]);
- var /** @type {?} */ textToken = this._consumeRawText(false, $RBRACKET, function () { return _this._attemptStr(']>'); });
- this._beginToken(TokenType$1.CDATA_END, textToken.sourceSpan.end);
- this._endToken([]);
- };
- /**
- * @param {?} start
- * @return {?}
- */
- _Tokenizer.prototype._consumeDocType = /**
- * @param {?} start
- * @return {?}
- */
- function (start) {
- this._beginToken(TokenType$1.DOC_TYPE, start);
- this._attemptUntilChar($GT);
- this._advance();
- this._endToken([this._input.substring(start.offset + 2, this._index - 1)]);
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._consumePrefixAndName = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ nameOrPrefixStart = this._index;
- var /** @type {?} */ prefix = /** @type {?} */ ((null));
- while (this._peek !== $COLON && !isPrefixEnd(this._peek)) {
- this._advance();
- }
- var /** @type {?} */ nameStart;
- if (this._peek === $COLON) {
- this._advance();
- prefix = this._input.substring(nameOrPrefixStart, this._index - 1);
- nameStart = this._index;
- }
- else {
- nameStart = nameOrPrefixStart;
- }
- this._requireCharCodeUntilFn(isNameEnd, this._index === nameStart ? 1 : 0);
- var /** @type {?} */ name = this._input.substring(nameStart, this._index);
- return [prefix, name];
- };
- /**
- * @param {?} start
- * @return {?}
- */
- _Tokenizer.prototype._consumeTagOpen = /**
- * @param {?} start
- * @return {?}
- */
- function (start) {
- var /** @type {?} */ savedPos = this._savePosition();
- var /** @type {?} */ tagName;
- var /** @type {?} */ lowercaseTagName;
- try {
- if (!isAsciiLetter(this._peek)) {
- throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan());
- }
- var /** @type {?} */ nameStart = this._index;
- this._consumeTagOpenStart(start);
- tagName = this._input.substring(nameStart, this._index);
- lowercaseTagName = tagName.toLowerCase();
- this._attemptCharCodeUntilFn(isNotWhitespace);
- while (this._peek !== $SLASH && this._peek !== $GT) {
- this._consumeAttributeName();
- this._attemptCharCodeUntilFn(isNotWhitespace);
- if (this._attemptCharCode($EQ)) {
- this._attemptCharCodeUntilFn(isNotWhitespace);
- this._consumeAttributeValue();
- }
- this._attemptCharCodeUntilFn(isNotWhitespace);
- }
- this._consumeTagOpenEnd();
- }
- catch (/** @type {?} */ e) {
- if (e instanceof _ControlFlowError) {
- // When the start tag is invalid, assume we want a "<"
- this._restorePosition(savedPos);
- // Back to back text tokens are merged at the end
- this._beginToken(TokenType$1.TEXT, start);
- this._endToken(['<']);
- return;
- }
- throw e;
- }
- var /** @type {?} */ contentTokenType = this._getTagDefinition(tagName).contentType;
- if (contentTokenType === TagContentType.RAW_TEXT) {
- this._consumeRawTextWithTagClose(lowercaseTagName, false);
- }
- else if (contentTokenType === TagContentType.ESCAPABLE_RAW_TEXT) {
- this._consumeRawTextWithTagClose(lowercaseTagName, true);
- }
- };
- /**
- * @param {?} lowercaseTagName
- * @param {?} decodeEntities
- * @return {?}
- */
- _Tokenizer.prototype._consumeRawTextWithTagClose = /**
- * @param {?} lowercaseTagName
- * @param {?} decodeEntities
- * @return {?}
- */
- function (lowercaseTagName, decodeEntities) {
- var _this = this;
- var /** @type {?} */ textToken = this._consumeRawText(decodeEntities, $LT, function () {
- if (!_this._attemptCharCode($SLASH))
- return false;
- _this._attemptCharCodeUntilFn(isNotWhitespace);
- if (!_this._attemptStrCaseInsensitive(lowercaseTagName))
- return false;
- _this._attemptCharCodeUntilFn(isNotWhitespace);
- return _this._attemptCharCode($GT);
- });
- this._beginToken(TokenType$1.TAG_CLOSE, textToken.sourceSpan.end);
- this._endToken([/** @type {?} */ ((null)), lowercaseTagName]);
- };
- /**
- * @param {?} start
- * @return {?}
- */
- _Tokenizer.prototype._consumeTagOpenStart = /**
- * @param {?} start
- * @return {?}
- */
- function (start) {
- this._beginToken(TokenType$1.TAG_OPEN_START, start);
- var /** @type {?} */ parts = this._consumePrefixAndName();
- this._endToken(parts);
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._consumeAttributeName = /**
- * @return {?}
- */
- function () {
- this._beginToken(TokenType$1.ATTR_NAME);
- var /** @type {?} */ prefixAndName = this._consumePrefixAndName();
- this._endToken(prefixAndName);
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._consumeAttributeValue = /**
- * @return {?}
- */
- function () {
- this._beginToken(TokenType$1.ATTR_VALUE);
- var /** @type {?} */ value;
- if (this._peek === $SQ || this._peek === $DQ) {
- var /** @type {?} */ quoteChar = this._peek;
- this._advance();
- var /** @type {?} */ parts = [];
- while (this._peek !== quoteChar) {
- parts.push(this._readChar(true));
- }
- value = parts.join('');
- this._advance();
- }
- else {
- var /** @type {?} */ valueStart = this._index;
- this._requireCharCodeUntilFn(isNameEnd, 1);
- value = this._input.substring(valueStart, this._index);
- }
- this._endToken([this._processCarriageReturns(value)]);
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._consumeTagOpenEnd = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ tokenType = this._attemptCharCode($SLASH) ? TokenType$1.TAG_OPEN_END_VOID : TokenType$1.TAG_OPEN_END;
- this._beginToken(tokenType);
- this._requireCharCode($GT);
- this._endToken([]);
- };
- /**
- * @param {?} start
- * @return {?}
- */
- _Tokenizer.prototype._consumeTagClose = /**
- * @param {?} start
- * @return {?}
- */
- function (start) {
- this._beginToken(TokenType$1.TAG_CLOSE, start);
- this._attemptCharCodeUntilFn(isNotWhitespace);
- var /** @type {?} */ prefixAndName = this._consumePrefixAndName();
- this._attemptCharCodeUntilFn(isNotWhitespace);
- this._requireCharCode($GT);
- this._endToken(prefixAndName);
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._consumeExpansionFormStart = /**
- * @return {?}
- */
- function () {
- this._beginToken(TokenType$1.EXPANSION_FORM_START, this._getLocation());
- this._requireCharCode($LBRACE);
- this._endToken([]);
- this._expansionCaseStack.push(TokenType$1.EXPANSION_FORM_START);
- this._beginToken(TokenType$1.RAW_TEXT, this._getLocation());
- var /** @type {?} */ condition = this._readUntil($COMMA);
- this._endToken([condition], this._getLocation());
- this._requireCharCode($COMMA);
- this._attemptCharCodeUntilFn(isNotWhitespace);
- this._beginToken(TokenType$1.RAW_TEXT, this._getLocation());
- var /** @type {?} */ type = this._readUntil($COMMA);
- this._endToken([type], this._getLocation());
- this._requireCharCode($COMMA);
- this._attemptCharCodeUntilFn(isNotWhitespace);
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._consumeExpansionCaseStart = /**
- * @return {?}
- */
- function () {
- this._beginToken(TokenType$1.EXPANSION_CASE_VALUE, this._getLocation());
- var /** @type {?} */ value = this._readUntil($LBRACE).trim();
- this._endToken([value], this._getLocation());
- this._attemptCharCodeUntilFn(isNotWhitespace);
- this._beginToken(TokenType$1.EXPANSION_CASE_EXP_START, this._getLocation());
- this._requireCharCode($LBRACE);
- this._endToken([], this._getLocation());
- this._attemptCharCodeUntilFn(isNotWhitespace);
- this._expansionCaseStack.push(TokenType$1.EXPANSION_CASE_EXP_START);
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._consumeExpansionCaseEnd = /**
- * @return {?}
- */
- function () {
- this._beginToken(TokenType$1.EXPANSION_CASE_EXP_END, this._getLocation());
- this._requireCharCode($RBRACE);
- this._endToken([], this._getLocation());
- this._attemptCharCodeUntilFn(isNotWhitespace);
- this._expansionCaseStack.pop();
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._consumeExpansionFormEnd = /**
- * @return {?}
- */
- function () {
- this._beginToken(TokenType$1.EXPANSION_FORM_END, this._getLocation());
- this._requireCharCode($RBRACE);
- this._endToken([]);
- this._expansionCaseStack.pop();
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._consumeText = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ start = this._getLocation();
- this._beginToken(TokenType$1.TEXT, start);
- var /** @type {?} */ parts = [];
- do {
- if (this._interpolationConfig && this._attemptStr(this._interpolationConfig.start)) {
- parts.push(this._interpolationConfig.start);
- this._inInterpolation = true;
- }
- else if (this._interpolationConfig && this._inInterpolation &&
- this._attemptStr(this._interpolationConfig.end)) {
- parts.push(this._interpolationConfig.end);
- this._inInterpolation = false;
- }
- else {
- parts.push(this._readChar(true));
- }
- } while (!this._isTextEnd());
- this._endToken([this._processCarriageReturns(parts.join(''))]);
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._isTextEnd = /**
- * @return {?}
- */
- function () {
- if (this._peek === $LT || this._peek === $EOF) {
- return true;
- }
- if (this._tokenizeIcu && !this._inInterpolation) {
- if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) {
- // start of an expansion form
- return true;
- }
- if (this._peek === $RBRACE && this._isInExpansionCase()) {
- // end of and expansion case
- return true;
- }
- }
- return false;
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._savePosition = /**
- * @return {?}
- */
- function () {
- return [this._peek, this._index, this._column, this._line, this.tokens.length];
- };
- /**
- * @param {?} char
- * @return {?}
- */
- _Tokenizer.prototype._readUntil = /**
- * @param {?} char
- * @return {?}
- */
- function (char) {
- var /** @type {?} */ start = this._index;
- this._attemptUntilChar(char);
- return this._input.substring(start, this._index);
- };
- /**
- * @param {?} position
- * @return {?}
- */
- _Tokenizer.prototype._restorePosition = /**
- * @param {?} position
- * @return {?}
- */
- function (position) {
- this._peek = position[0];
- this._index = position[1];
- this._column = position[2];
- this._line = position[3];
- var /** @type {?} */ nbTokens = position[4];
- if (nbTokens < this.tokens.length) {
- // remove any extra tokens
- this.tokens = this.tokens.slice(0, nbTokens);
- }
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._isInExpansionCase = /**
- * @return {?}
- */
- function () {
- return this._expansionCaseStack.length > 0 &&
- this._expansionCaseStack[this._expansionCaseStack.length - 1] ===
- TokenType$1.EXPANSION_CASE_EXP_START;
- };
- /**
- * @return {?}
- */
- _Tokenizer.prototype._isInExpansionForm = /**
- * @return {?}
- */
- function () {
- return this._expansionCaseStack.length > 0 &&
- this._expansionCaseStack[this._expansionCaseStack.length - 1] ===
- TokenType$1.EXPANSION_FORM_START;
- };
- return _Tokenizer;
- }());
- /**
- * @param {?} code
- * @return {?}
- */
- function isNotWhitespace(code) {
- return !isWhitespace(code) || code === $EOF;
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function isNameEnd(code) {
- return isWhitespace(code) || code === $GT || code === $SLASH ||
- code === $SQ || code === $DQ || code === $EQ;
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function isPrefixEnd(code) {
- return (code < $a || $z < code) && (code < $A || $Z < code) &&
- (code < $0 || code > $9);
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function isDigitEntityEnd(code) {
- return code == $SEMICOLON || code == $EOF || !isAsciiHexDigit(code);
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function isNamedEntityEnd(code) {
- return code == $SEMICOLON || code == $EOF || !isAsciiLetter(code);
- }
- /**
- * @param {?} input
- * @param {?} offset
- * @param {?} interpolationConfig
- * @return {?}
- */
- function isExpansionFormStart(input, offset, interpolationConfig) {
- var /** @type {?} */ isInterpolationStart = interpolationConfig ? input.indexOf(interpolationConfig.start, offset) == offset : false;
- return input.charCodeAt(offset) == $LBRACE && !isInterpolationStart;
- }
- /**
- * @param {?} peek
- * @return {?}
- */
- function isExpansionCaseStart(peek) {
- return peek === $EQ || isAsciiLetter(peek) || isDigit(peek);
- }
- /**
- * @param {?} code1
- * @param {?} code2
- * @return {?}
- */
- function compareCharCodeCaseInsensitive(code1, code2) {
- return toUpperCaseCharCode(code1) == toUpperCaseCharCode(code2);
- }
- /**
- * @param {?} code
- * @return {?}
- */
- function toUpperCaseCharCode(code) {
- return code >= $a && code <= $z ? code - $a + $A : code;
- }
- /**
- * @param {?} srcTokens
- * @return {?}
- */
- function mergeTextTokens(srcTokens) {
- var /** @type {?} */ dstTokens = [];
- var /** @type {?} */ lastDstToken = undefined;
- for (var /** @type {?} */ i = 0; i < srcTokens.length; i++) {
- var /** @type {?} */ token = srcTokens[i];
- if (lastDstToken && lastDstToken.type == TokenType$1.TEXT && token.type == TokenType$1.TEXT) {
- lastDstToken.parts[0] += token.parts[0];
- lastDstToken.sourceSpan.end = token.sourceSpan.end;
- }
- else {
- lastDstToken = token;
- dstTokens.push(lastDstToken);
- }
- }
- return dstTokens;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var TreeError = /** @class */ (function (_super) {
- __extends(TreeError, _super);
- function TreeError(elementName, span, msg) {
- var _this = _super.call(this, span, msg) || this;
- _this.elementName = elementName;
- return _this;
- }
- /**
- * @param {?} elementName
- * @param {?} span
- * @param {?} msg
- * @return {?}
- */
- TreeError.create = /**
- * @param {?} elementName
- * @param {?} span
- * @param {?} msg
- * @return {?}
- */
- function (elementName, span, msg) {
- return new TreeError(elementName, span, msg);
- };
- return TreeError;
- }(ParseError));
- var ParseTreeResult = /** @class */ (function () {
- function ParseTreeResult(rootNodes, errors) {
- this.rootNodes = rootNodes;
- this.errors = errors;
- }
- return ParseTreeResult;
- }());
- var Parser$1 = /** @class */ (function () {
- function Parser(getTagDefinition) {
- this.getTagDefinition = getTagDefinition;
- }
- /**
- * @param {?} source
- * @param {?} url
- * @param {?=} parseExpansionForms
- * @param {?=} interpolationConfig
- * @return {?}
- */
- Parser.prototype.parse = /**
- * @param {?} source
- * @param {?} url
- * @param {?=} parseExpansionForms
- * @param {?=} interpolationConfig
- * @return {?}
- */
- function (source, url, parseExpansionForms, interpolationConfig) {
- if (parseExpansionForms === void 0) { parseExpansionForms = false; }
- if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
- var /** @type {?} */ tokensAndErrors = tokenize(source, url, this.getTagDefinition, parseExpansionForms, interpolationConfig);
- var /** @type {?} */ treeAndErrors = new _TreeBuilder(tokensAndErrors.tokens, this.getTagDefinition).build();
- return new ParseTreeResult(treeAndErrors.rootNodes, (/** @type {?} */ (tokensAndErrors.errors)).concat(treeAndErrors.errors));
- };
- return Parser;
- }());
- var _TreeBuilder = /** @class */ (function () {
- function _TreeBuilder(tokens, getTagDefinition) {
- this.tokens = tokens;
- this.getTagDefinition = getTagDefinition;
- this._index = -1;
- this._rootNodes = [];
- this._errors = [];
- this._elementStack = [];
- this._advance();
- }
- /**
- * @return {?}
- */
- _TreeBuilder.prototype.build = /**
- * @return {?}
- */
- function () {
- while (this._peek.type !== TokenType$1.EOF) {
- if (this._peek.type === TokenType$1.TAG_OPEN_START) {
- this._consumeStartTag(this._advance());
- }
- else if (this._peek.type === TokenType$1.TAG_CLOSE) {
- this._consumeEndTag(this._advance());
- }
- else if (this._peek.type === TokenType$1.CDATA_START) {
- this._closeVoidElement();
- this._consumeCdata(this._advance());
- }
- else if (this._peek.type === TokenType$1.COMMENT_START) {
- this._closeVoidElement();
- this._consumeComment(this._advance());
- }
- else if (this._peek.type === TokenType$1.TEXT || this._peek.type === TokenType$1.RAW_TEXT ||
- this._peek.type === TokenType$1.ESCAPABLE_RAW_TEXT) {
- this._closeVoidElement();
- this._consumeText(this._advance());
- }
- else if (this._peek.type === TokenType$1.EXPANSION_FORM_START) {
- this._consumeExpansion(this._advance());
- }
- else {
- // Skip all other tokens...
- this._advance();
- }
- }
- return new ParseTreeResult(this._rootNodes, this._errors);
- };
- /**
- * @return {?}
- */
- _TreeBuilder.prototype._advance = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ prev = this._peek;
- if (this._index < this.tokens.length - 1) {
- // Note: there is always an EOF token at the end
- this._index++;
- }
- this._peek = this.tokens[this._index];
- return prev;
- };
- /**
- * @param {?} type
- * @return {?}
- */
- _TreeBuilder.prototype._advanceIf = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- if (this._peek.type === type) {
- return this._advance();
- }
- return null;
- };
- /**
- * @param {?} startToken
- * @return {?}
- */
- _TreeBuilder.prototype._consumeCdata = /**
- * @param {?} startToken
- * @return {?}
- */
- function (startToken) {
- this._consumeText(this._advance());
- this._advanceIf(TokenType$1.CDATA_END);
- };
- /**
- * @param {?} token
- * @return {?}
- */
- _TreeBuilder.prototype._consumeComment = /**
- * @param {?} token
- * @return {?}
- */
- function (token) {
- var /** @type {?} */ text = this._advanceIf(TokenType$1.RAW_TEXT);
- this._advanceIf(TokenType$1.COMMENT_END);
- var /** @type {?} */ value = text != null ? text.parts[0].trim() : null;
- this._addToParent(new Comment(value, token.sourceSpan));
- };
- /**
- * @param {?} token
- * @return {?}
- */
- _TreeBuilder.prototype._consumeExpansion = /**
- * @param {?} token
- * @return {?}
- */
- function (token) {
- var /** @type {?} */ switchValue = this._advance();
- var /** @type {?} */ type = this._advance();
- var /** @type {?} */ cases = [];
- // read =
- while (this._peek.type === TokenType$1.EXPANSION_CASE_VALUE) {
- var /** @type {?} */ expCase = this._parseExpansionCase();
- if (!expCase)
- return; // error
- cases.push(expCase);
- }
- // read the final }
- if (this._peek.type !== TokenType$1.EXPANSION_FORM_END) {
- this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '}'."));
- return;
- }
- var /** @type {?} */ sourceSpan = new ParseSourceSpan(token.sourceSpan.start, this._peek.sourceSpan.end);
- this._addToParent(new Expansion(switchValue.parts[0], type.parts[0], cases, sourceSpan, switchValue.sourceSpan));
- this._advance();
- };
- /**
- * @return {?}
- */
- _TreeBuilder.prototype._parseExpansionCase = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ value = this._advance();
- // read {
- if (this._peek.type !== TokenType$1.EXPANSION_CASE_EXP_START) {
- this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '{'."));
- return null;
- }
- // read until }
- var /** @type {?} */ start = this._advance();
- var /** @type {?} */ exp = this._collectExpansionExpTokens(start);
- if (!exp)
- return null;
- var /** @type {?} */ end = this._advance();
- exp.push(new Token$1(TokenType$1.EOF, [], end.sourceSpan));
- // parse everything in between { and }
- var /** @type {?} */ parsedExp = new _TreeBuilder(exp, this.getTagDefinition).build();
- if (parsedExp.errors.length > 0) {
- this._errors = this._errors.concat(/** @type {?} */ (parsedExp.errors));
- return null;
- }
- var /** @type {?} */ sourceSpan = new ParseSourceSpan(value.sourceSpan.start, end.sourceSpan.end);
- var /** @type {?} */ expSourceSpan = new ParseSourceSpan(start.sourceSpan.start, end.sourceSpan.end);
- return new ExpansionCase(value.parts[0], parsedExp.rootNodes, sourceSpan, value.sourceSpan, expSourceSpan);
- };
- /**
- * @param {?} start
- * @return {?}
- */
- _TreeBuilder.prototype._collectExpansionExpTokens = /**
- * @param {?} start
- * @return {?}
- */
- function (start) {
- var /** @type {?} */ exp = [];
- var /** @type {?} */ expansionFormStack = [TokenType$1.EXPANSION_CASE_EXP_START];
- while (true) {
- if (this._peek.type === TokenType$1.EXPANSION_FORM_START ||
- this._peek.type === TokenType$1.EXPANSION_CASE_EXP_START) {
- expansionFormStack.push(this._peek.type);
- }
- if (this._peek.type === TokenType$1.EXPANSION_CASE_EXP_END) {
- if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_CASE_EXP_START)) {
- expansionFormStack.pop();
- if (expansionFormStack.length == 0)
- return exp;
- }
- else {
- this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
- return null;
- }
- }
- if (this._peek.type === TokenType$1.EXPANSION_FORM_END) {
- if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_FORM_START)) {
- expansionFormStack.pop();
- }
- else {
- this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
- return null;
- }
- }
- if (this._peek.type === TokenType$1.EOF) {
- this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
- return null;
- }
- exp.push(this._advance());
- }
- };
- /**
- * @param {?} token
- * @return {?}
- */
- _TreeBuilder.prototype._consumeText = /**
- * @param {?} token
- * @return {?}
- */
- function (token) {
- var /** @type {?} */ text = token.parts[0];
- if (text.length > 0 && text[0] == '\n') {
- var /** @type {?} */ parent_1 = this._getParentElement();
- if (parent_1 != null && parent_1.children.length == 0 &&
- this.getTagDefinition(parent_1.name).ignoreFirstLf) {
- text = text.substring(1);
- }
- }
- if (text.length > 0) {
- this._addToParent(new Text(text, token.sourceSpan));
- }
- };
- /**
- * @return {?}
- */
- _TreeBuilder.prototype._closeVoidElement = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ el = this._getParentElement();
- if (el && this.getTagDefinition(el.name).isVoid) {
- this._elementStack.pop();
- }
- };
- /**
- * @param {?} startTagToken
- * @return {?}
- */
- _TreeBuilder.prototype._consumeStartTag = /**
- * @param {?} startTagToken
- * @return {?}
- */
- function (startTagToken) {
- var /** @type {?} */ prefix = startTagToken.parts[0];
- var /** @type {?} */ name = startTagToken.parts[1];
- var /** @type {?} */ attrs = [];
- while (this._peek.type === TokenType$1.ATTR_NAME) {
- attrs.push(this._consumeAttr(this._advance()));
- }
- var /** @type {?} */ fullName = this._getElementFullName(prefix, name, this._getParentElement());
- var /** @type {?} */ selfClosing = false;
- // Note: There could have been a tokenizer error
- // so that we don't get a token for the end tag...
- if (this._peek.type === TokenType$1.TAG_OPEN_END_VOID) {
- this._advance();
- selfClosing = true;
- var /** @type {?} */ tagDef = this.getTagDefinition(fullName);
- if (!(tagDef.canSelfClose || getNsPrefix(fullName) !== null || tagDef.isVoid)) {
- this._errors.push(TreeError.create(fullName, startTagToken.sourceSpan, "Only void and foreign elements can be self closed \"" + startTagToken.parts[1] + "\""));
- }
- }
- else if (this._peek.type === TokenType$1.TAG_OPEN_END) {
- this._advance();
- selfClosing = false;
- }
- var /** @type {?} */ end = this._peek.sourceSpan.start;
- var /** @type {?} */ span = new ParseSourceSpan(startTagToken.sourceSpan.start, end);
- var /** @type {?} */ el = new Element(fullName, attrs, [], span, span, undefined);
- this._pushElement(el);
- if (selfClosing) {
- this._popElement(fullName);
- el.endSourceSpan = span;
- }
- };
- /**
- * @param {?} el
- * @return {?}
- */
- _TreeBuilder.prototype._pushElement = /**
- * @param {?} el
- * @return {?}
- */
- function (el) {
- var /** @type {?} */ parentEl = this._getParentElement();
- if (parentEl && this.getTagDefinition(parentEl.name).isClosedByChild(el.name)) {
- this._elementStack.pop();
- }
- var /** @type {?} */ tagDef = this.getTagDefinition(el.name);
- var _a = this._getParentElementSkippingContainers(), parent = _a.parent, container = _a.container;
- if (parent && tagDef.requireExtraParent(parent.name)) {
- var /** @type {?} */ newParent = new Element(tagDef.parentToAdd, [], [], el.sourceSpan, el.startSourceSpan, el.endSourceSpan);
- this._insertBeforeContainer(parent, container, newParent);
- }
- this._addToParent(el);
- this._elementStack.push(el);
- };
- /**
- * @param {?} endTagToken
- * @return {?}
- */
- _TreeBuilder.prototype._consumeEndTag = /**
- * @param {?} endTagToken
- * @return {?}
- */
- function (endTagToken) {
- var /** @type {?} */ fullName = this._getElementFullName(endTagToken.parts[0], endTagToken.parts[1], this._getParentElement());
- if (this._getParentElement()) {
- /** @type {?} */ ((this._getParentElement())).endSourceSpan = endTagToken.sourceSpan;
- }
- if (this.getTagDefinition(fullName).isVoid) {
- this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, "Void elements do not have end tags \"" + endTagToken.parts[1] + "\""));
- }
- else if (!this._popElement(fullName)) {
- var /** @type {?} */ errMsg = "Unexpected closing tag \"" + fullName + "\". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags";
- this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, errMsg));
- }
- };
- /**
- * @param {?} fullName
- * @return {?}
- */
- _TreeBuilder.prototype._popElement = /**
- * @param {?} fullName
- * @return {?}
- */
- function (fullName) {
- for (var /** @type {?} */ stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) {
- var /** @type {?} */ el = this._elementStack[stackIndex];
- if (el.name == fullName) {
- this._elementStack.splice(stackIndex, this._elementStack.length - stackIndex);
- return true;
- }
- if (!this.getTagDefinition(el.name).closedByParent) {
- return false;
- }
- }
- return false;
- };
- /**
- * @param {?} attrName
- * @return {?}
- */
- _TreeBuilder.prototype._consumeAttr = /**
- * @param {?} attrName
- * @return {?}
- */
- function (attrName) {
- var /** @type {?} */ fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]);
- var /** @type {?} */ end = attrName.sourceSpan.end;
- var /** @type {?} */ value = '';
- var /** @type {?} */ valueSpan = /** @type {?} */ ((undefined));
- if (this._peek.type === TokenType$1.ATTR_VALUE) {
- var /** @type {?} */ valueToken = this._advance();
- value = valueToken.parts[0];
- end = valueToken.sourceSpan.end;
- valueSpan = valueToken.sourceSpan;
- }
- return new Attribute$1(fullName, value, new ParseSourceSpan(attrName.sourceSpan.start, end), valueSpan);
- };
- /**
- * @return {?}
- */
- _TreeBuilder.prototype._getParentElement = /**
- * @return {?}
- */
- function () {
- return this._elementStack.length > 0 ? this._elementStack[this._elementStack.length - 1] : null;
- };
- /**
- * Returns the parent in the DOM and the container.
- *
- * `<ng-container>` elements are skipped as they are not rendered as DOM element.
- * @return {?}
- */
- _TreeBuilder.prototype._getParentElementSkippingContainers = /**
- * Returns the parent in the DOM and the container.
- *
- * `<ng-container>` elements are skipped as they are not rendered as DOM element.
- * @return {?}
- */
- function () {
- var /** @type {?} */ container = null;
- for (var /** @type {?} */ i = this._elementStack.length - 1; i >= 0; i--) {
- if (!isNgContainer(this._elementStack[i].name)) {
- return { parent: this._elementStack[i], container: container };
- }
- container = this._elementStack[i];
- }
- return { parent: null, container: container };
- };
- /**
- * @param {?} node
- * @return {?}
- */
- _TreeBuilder.prototype._addToParent = /**
- * @param {?} node
- * @return {?}
- */
- function (node) {
- var /** @type {?} */ parent = this._getParentElement();
- if (parent != null) {
- parent.children.push(node);
- }
- else {
- this._rootNodes.push(node);
- }
- };
- /**
- * Insert a node between the parent and the container.
- * When no container is given, the node is appended as a child of the parent.
- * Also updates the element stack accordingly.
- *
- * \@internal
- * @param {?} parent
- * @param {?} container
- * @param {?} node
- * @return {?}
- */
- _TreeBuilder.prototype._insertBeforeContainer = /**
- * Insert a node between the parent and the container.
- * When no container is given, the node is appended as a child of the parent.
- * Also updates the element stack accordingly.
- *
- * \@internal
- * @param {?} parent
- * @param {?} container
- * @param {?} node
- * @return {?}
- */
- function (parent, container, node) {
- if (!container) {
- this._addToParent(node);
- this._elementStack.push(node);
- }
- else {
- if (parent) {
- // replace the container with the new node in the children
- var /** @type {?} */ index = parent.children.indexOf(container);
- parent.children[index] = node;
- }
- else {
- this._rootNodes.push(node);
- }
- node.children.push(container);
- this._elementStack.splice(this._elementStack.indexOf(container), 0, node);
- }
- };
- /**
- * @param {?} prefix
- * @param {?} localName
- * @param {?} parentElement
- * @return {?}
- */
- _TreeBuilder.prototype._getElementFullName = /**
- * @param {?} prefix
- * @param {?} localName
- * @param {?} parentElement
- * @return {?}
- */
- function (prefix, localName, parentElement) {
- if (prefix == null) {
- prefix = /** @type {?} */ ((this.getTagDefinition(localName).implicitNamespacePrefix));
- if (prefix == null && parentElement != null) {
- prefix = getNsPrefix(parentElement.name);
- }
- }
- return mergeNsAndName(prefix, localName);
- };
- return _TreeBuilder;
- }());
- /**
- * @param {?} stack
- * @param {?} element
- * @return {?}
- */
- function lastOnStack(stack, element) {
- return stack.length > 0 && stack[stack.length - 1] === element;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} message
- * @return {?}
- */
- function digest(message) {
- return message.id || sha1(serializeNodes(message.nodes).join('') + ("[" + message.meaning + "]"));
- }
- /**
- * @param {?} message
- * @return {?}
- */
- function decimalDigest(message) {
- if (message.id) {
- return message.id;
- }
- var /** @type {?} */ visitor = new _SerializerIgnoreIcuExpVisitor();
- var /** @type {?} */ parts = message.nodes.map(function (a) { return a.visit(visitor, null); });
- return computeMsgId(parts.join(''), message.meaning);
- }
- /**
- * Serialize the i18n ast to something xml-like in order to generate an UID.
- *
- * The visitor is also used in the i18n parser tests
- *
- * \@internal
- */
- var _SerializerVisitor = /** @class */ (function () {
- function _SerializerVisitor() {
- }
- /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- _SerializerVisitor.prototype.visitText = /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- function (text, context) { return text.value; };
- /**
- * @param {?} container
- * @param {?} context
- * @return {?}
- */
- _SerializerVisitor.prototype.visitContainer = /**
- * @param {?} container
- * @param {?} context
- * @return {?}
- */
- function (container, context) {
- var _this = this;
- return "[" + container.children.map(function (child) { return child.visit(_this); }).join(', ') + "]";
- };
- /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- _SerializerVisitor.prototype.visitIcu = /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- function (icu, context) {
- var _this = this;
- var /** @type {?} */ strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
- return "{" + icu.expression + ", " + icu.type + ", " + strCases.join(', ') + "}";
- };
- /**
- * @param {?} ph
- * @param {?} context
- * @return {?}
- */
- _SerializerVisitor.prototype.visitTagPlaceholder = /**
- * @param {?} ph
- * @param {?} context
- * @return {?}
- */
- function (ph, context) {
- var _this = this;
- return ph.isVoid ?
- "<ph tag name=\"" + ph.startName + "\"/>" :
- "<ph tag name=\"" + ph.startName + "\">" + ph.children.map(function (child) { return child.visit(_this); }).join(', ') + "</ph name=\"" + ph.closeName + "\">";
- };
- /**
- * @param {?} ph
- * @param {?} context
- * @return {?}
- */
- _SerializerVisitor.prototype.visitPlaceholder = /**
- * @param {?} ph
- * @param {?} context
- * @return {?}
- */
- function (ph, context) {
- return ph.value ? "<ph name=\"" + ph.name + "\">" + ph.value + "</ph>" : "<ph name=\"" + ph.name + "\"/>";
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- _SerializerVisitor.prototype.visitIcuPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- return "<ph icu name=\"" + ph.name + "\">" + ph.value.visit(this) + "</ph>";
- };
- return _SerializerVisitor;
- }());
- var serializerVisitor = new _SerializerVisitor();
- /**
- * @param {?} nodes
- * @return {?}
- */
- function serializeNodes(nodes) {
- return nodes.map(function (a) { return a.visit(serializerVisitor, null); });
- }
- /**
- * Serialize the i18n ast to something xml-like in order to generate an UID.
- *
- * Ignore the ICU expressions so that message IDs stays identical if only the expression changes.
- *
- * \@internal
- */
- var _SerializerIgnoreIcuExpVisitor = /** @class */ (function (_super) {
- __extends(_SerializerIgnoreIcuExpVisitor, _super);
- function _SerializerIgnoreIcuExpVisitor() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- _SerializerIgnoreIcuExpVisitor.prototype.visitIcu = /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- function (icu, context) {
- var _this = this;
- var /** @type {?} */ strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
- // Do not take the expression into account
- return "{" + icu.type + ", " + strCases.join(', ') + "}";
- };
- return _SerializerIgnoreIcuExpVisitor;
- }(_SerializerVisitor));
- /**
- * Compute the SHA1 of the given string
- *
- * see http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
- *
- * WARNING: this function has not been designed not tested with security in mind.
- * DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT.
- * @param {?} str
- * @return {?}
- */
- function sha1(str) {
- var /** @type {?} */ utf8 = utf8Encode(str);
- var /** @type {?} */ words32 = stringToWords32(utf8, Endian.Big);
- var /** @type {?} */ len = utf8.length * 8;
- var /** @type {?} */ w = new Array(80);
- var _a = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0], a = _a[0], b = _a[1], c = _a[2], d = _a[3], e = _a[4];
- words32[len >> 5] |= 0x80 << (24 - len % 32);
- words32[((len + 64 >> 9) << 4) + 15] = len;
- for (var /** @type {?} */ i = 0; i < words32.length; i += 16) {
- var _b = [a, b, c, d, e], h0 = _b[0], h1 = _b[1], h2 = _b[2], h3 = _b[3], h4 = _b[4];
- for (var /** @type {?} */ j = 0; j < 80; j++) {
- if (j < 16) {
- w[j] = words32[i + j];
- }
- else {
- w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
- }
- var _c = fk(j, b, c, d), f = _c[0], k = _c[1];
- var /** @type {?} */ temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
- _d = [d, c, rol32(b, 30), a, temp], e = _d[0], d = _d[1], c = _d[2], b = _d[3], a = _d[4];
- }
- _e = [add32(a, h0), add32(b, h1), add32(c, h2), add32(d, h3), add32(e, h4)], a = _e[0], b = _e[1], c = _e[2], d = _e[3], e = _e[4];
- }
- return byteStringToHexString(words32ToByteString([a, b, c, d, e]));
- var _d, _e;
- }
- /**
- * @param {?} index
- * @param {?} b
- * @param {?} c
- * @param {?} d
- * @return {?}
- */
- function fk(index, b, c, d) {
- if (index < 20) {
- return [(b & c) | (~b & d), 0x5a827999];
- }
- if (index < 40) {
- return [b ^ c ^ d, 0x6ed9eba1];
- }
- if (index < 60) {
- return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc];
- }
- return [b ^ c ^ d, 0xca62c1d6];
- }
- /**
- * Compute the fingerprint of the given string
- *
- * The output is 64 bit number encoded as a decimal string
- *
- * based on:
- * https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
- * @param {?} str
- * @return {?}
- */
- function fingerprint(str) {
- var /** @type {?} */ utf8 = utf8Encode(str);
- var _a = [hash32(utf8, 0), hash32(utf8, 102072)], hi = _a[0], lo = _a[1];
- if (hi == 0 && (lo == 0 || lo == 1)) {
- hi = hi ^ 0x130f9bef;
- lo = lo ^ -0x6b5f56d8;
- }
- return [hi, lo];
- }
- /**
- * @param {?} msg
- * @param {?} meaning
- * @return {?}
- */
- function computeMsgId(msg, meaning) {
- var _a = fingerprint(msg), hi = _a[0], lo = _a[1];
- if (meaning) {
- var _b = fingerprint(meaning), him = _b[0], lom = _b[1];
- _c = add64(rol64([hi, lo], 1), [him, lom]), hi = _c[0], lo = _c[1];
- }
- return byteStringToDecString(words32ToByteString([hi & 0x7fffffff, lo]));
- var _c;
- }
- /**
- * @param {?} str
- * @param {?} c
- * @return {?}
- */
- function hash32(str, c) {
- var _a = [0x9e3779b9, 0x9e3779b9], a = _a[0], b = _a[1];
- var /** @type {?} */ i;
- var /** @type {?} */ len = str.length;
- for (i = 0; i + 12 <= len; i += 12) {
- a = add32(a, wordAt(str, i, Endian.Little));
- b = add32(b, wordAt(str, i + 4, Endian.Little));
- c = add32(c, wordAt(str, i + 8, Endian.Little));
- _b = mix([a, b, c]), a = _b[0], b = _b[1], c = _b[2];
- }
- a = add32(a, wordAt(str, i, Endian.Little));
- b = add32(b, wordAt(str, i + 4, Endian.Little));
- // the first byte of c is reserved for the length
- c = add32(c, len);
- c = add32(c, wordAt(str, i + 8, Endian.Little) << 8);
- return mix([a, b, c])[2];
- var _b;
- }
- /**
- * @param {?} __0
- * @return {?}
- */
- function mix(_a) {
- var a = _a[0], b = _a[1], c = _a[2];
- a = sub32(a, b);
- a = sub32(a, c);
- a ^= c >>> 13;
- b = sub32(b, c);
- b = sub32(b, a);
- b ^= a << 8;
- c = sub32(c, a);
- c = sub32(c, b);
- c ^= b >>> 13;
- a = sub32(a, b);
- a = sub32(a, c);
- a ^= c >>> 12;
- b = sub32(b, c);
- b = sub32(b, a);
- b ^= a << 16;
- c = sub32(c, a);
- c = sub32(c, b);
- c ^= b >>> 5;
- a = sub32(a, b);
- a = sub32(a, c);
- a ^= c >>> 3;
- b = sub32(b, c);
- b = sub32(b, a);
- b ^= a << 10;
- c = sub32(c, a);
- c = sub32(c, b);
- c ^= b >>> 15;
- return [a, b, c];
- }
- /** @enum {number} */
- var Endian = {
- Little: 0,
- Big: 1,
- };
- Endian[Endian.Little] = "Little";
- Endian[Endian.Big] = "Big";
- /**
- * @param {?} a
- * @param {?} b
- * @return {?}
- */
- function add32(a, b) {
- return add32to64(a, b)[1];
- }
- /**
- * @param {?} a
- * @param {?} b
- * @return {?}
- */
- function add32to64(a, b) {
- var /** @type {?} */ low = (a & 0xffff) + (b & 0xffff);
- var /** @type {?} */ high = (a >>> 16) + (b >>> 16) + (low >>> 16);
- return [high >>> 16, (high << 16) | (low & 0xffff)];
- }
- /**
- * @param {?} __0
- * @param {?} __1
- * @return {?}
- */
- function add64(_a, _b) {
- var ah = _a[0], al = _a[1];
- var bh = _b[0], bl = _b[1];
- var _c = add32to64(al, bl), carry = _c[0], l = _c[1];
- var /** @type {?} */ h = add32(add32(ah, bh), carry);
- return [h, l];
- }
- /**
- * @param {?} a
- * @param {?} b
- * @return {?}
- */
- function sub32(a, b) {
- var /** @type {?} */ low = (a & 0xffff) - (b & 0xffff);
- var /** @type {?} */ high = (a >> 16) - (b >> 16) + (low >> 16);
- return (high << 16) | (low & 0xffff);
- }
- /**
- * @param {?} a
- * @param {?} count
- * @return {?}
- */
- function rol32(a, count) {
- return (a << count) | (a >>> (32 - count));
- }
- /**
- * @param {?} __0
- * @param {?} count
- * @return {?}
- */
- function rol64(_a, count) {
- var hi = _a[0], lo = _a[1];
- var /** @type {?} */ h = (hi << count) | (lo >>> (32 - count));
- var /** @type {?} */ l = (lo << count) | (hi >>> (32 - count));
- return [h, l];
- }
- /**
- * @param {?} str
- * @param {?} endian
- * @return {?}
- */
- function stringToWords32(str, endian) {
- var /** @type {?} */ words32 = Array((str.length + 3) >>> 2);
- for (var /** @type {?} */ i = 0; i < words32.length; i++) {
- words32[i] = wordAt(str, i * 4, endian);
- }
- return words32;
- }
- /**
- * @param {?} str
- * @param {?} index
- * @return {?}
- */
- function byteAt(str, index) {
- return index >= str.length ? 0 : str.charCodeAt(index) & 0xff;
- }
- /**
- * @param {?} str
- * @param {?} index
- * @param {?} endian
- * @return {?}
- */
- function wordAt(str, index, endian) {
- var /** @type {?} */ word = 0;
- if (endian === Endian.Big) {
- for (var /** @type {?} */ i = 0; i < 4; i++) {
- word += byteAt(str, index + i) << (24 - 8 * i);
- }
- }
- else {
- for (var /** @type {?} */ i = 0; i < 4; i++) {
- word += byteAt(str, index + i) << 8 * i;
- }
- }
- return word;
- }
- /**
- * @param {?} words32
- * @return {?}
- */
- function words32ToByteString(words32) {
- return words32.reduce(function (str, word) { return str + word32ToByteString(word); }, '');
- }
- /**
- * @param {?} word
- * @return {?}
- */
- function word32ToByteString(word) {
- var /** @type {?} */ str = '';
- for (var /** @type {?} */ i = 0; i < 4; i++) {
- str += String.fromCharCode((word >>> 8 * (3 - i)) & 0xff);
- }
- return str;
- }
- /**
- * @param {?} str
- * @return {?}
- */
- function byteStringToHexString(str) {
- var /** @type {?} */ hex = '';
- for (var /** @type {?} */ i = 0; i < str.length; i++) {
- var /** @type {?} */ b = byteAt(str, i);
- hex += (b >>> 4).toString(16) + (b & 0x0f).toString(16);
- }
- return hex.toLowerCase();
- }
- /**
- * @param {?} str
- * @return {?}
- */
- function byteStringToDecString(str) {
- var /** @type {?} */ decimal = '';
- var /** @type {?} */ toThePower = '1';
- for (var /** @type {?} */ i = str.length - 1; i >= 0; i--) {
- decimal = addBigInt(decimal, numberTimesBigInt(byteAt(str, i), toThePower));
- toThePower = numberTimesBigInt(256, toThePower);
- }
- return decimal.split('').reverse().join('');
- }
- /**
- * @param {?} x
- * @param {?} y
- * @return {?}
- */
- function addBigInt(x, y) {
- var /** @type {?} */ sum = '';
- var /** @type {?} */ len = Math.max(x.length, y.length);
- for (var /** @type {?} */ i = 0, /** @type {?} */ carry = 0; i < len || carry; i++) {
- var /** @type {?} */ tmpSum = carry + +(x[i] || 0) + +(y[i] || 0);
- if (tmpSum >= 10) {
- carry = 1;
- sum += tmpSum - 10;
- }
- else {
- carry = 0;
- sum += tmpSum;
- }
- }
- return sum;
- }
- /**
- * @param {?} num
- * @param {?} b
- * @return {?}
- */
- function numberTimesBigInt(num, b) {
- var /** @type {?} */ product = '';
- var /** @type {?} */ bToThePower = b;
- for (; num !== 0; num = num >>> 1) {
- if (num & 1)
- product = addBigInt(product, bToThePower);
- bToThePower = addBigInt(bToThePower, bToThePower);
- }
- return product;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var Message = /** @class */ (function () {
- /**
- * @param nodes message AST
- * @param placeholders maps placeholder names to static content
- * @param placeholderToMessage maps placeholder names to messages (used for nested ICU messages)
- * @param meaning
- * @param description
- * @param id
- */
- function Message(nodes, placeholders, placeholderToMessage, meaning, description, id) {
- this.nodes = nodes;
- this.placeholders = placeholders;
- this.placeholderToMessage = placeholderToMessage;
- this.meaning = meaning;
- this.description = description;
- this.id = id;
- if (nodes.length) {
- this.sources = [{
- filePath: nodes[0].sourceSpan.start.file.url,
- startLine: nodes[0].sourceSpan.start.line + 1,
- startCol: nodes[0].sourceSpan.start.col + 1,
- endLine: nodes[nodes.length - 1].sourceSpan.end.line + 1,
- endCol: nodes[0].sourceSpan.start.col + 1
- }];
- }
- else {
- this.sources = [];
- }
- }
- return Message;
- }());
- /**
- * @record
- */
-
- /**
- * @record
- */
-
- var Text$1 = /** @class */ (function () {
- function Text(value, sourceSpan) {
- this.value = value;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- Text.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitText(this, context); };
- return Text;
- }());
- var Container = /** @class */ (function () {
- function Container(children, sourceSpan) {
- this.children = children;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- Container.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitContainer(this, context); };
- return Container;
- }());
- var Icu = /** @class */ (function () {
- function Icu(expression, type, cases, sourceSpan) {
- this.expression = expression;
- this.type = type;
- this.cases = cases;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- Icu.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitIcu(this, context); };
- return Icu;
- }());
- var TagPlaceholder = /** @class */ (function () {
- function TagPlaceholder(tag, attrs, startName, closeName, children, isVoid, sourceSpan) {
- this.tag = tag;
- this.attrs = attrs;
- this.startName = startName;
- this.closeName = closeName;
- this.children = children;
- this.isVoid = isVoid;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- TagPlaceholder.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitTagPlaceholder(this, context); };
- return TagPlaceholder;
- }());
- var Placeholder = /** @class */ (function () {
- function Placeholder(value, name, sourceSpan) {
- this.value = value;
- this.name = name;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- Placeholder.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitPlaceholder(this, context); };
- return Placeholder;
- }());
- var IcuPlaceholder = /** @class */ (function () {
- function IcuPlaceholder(value, name, sourceSpan) {
- this.value = value;
- this.name = name;
- this.sourceSpan = sourceSpan;
- }
- /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- IcuPlaceholder.prototype.visit = /**
- * @param {?} visitor
- * @param {?=} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitIcuPlaceholder(this, context); };
- return IcuPlaceholder;
- }());
- /**
- * @record
- */
-
- var CloneVisitor = /** @class */ (function () {
- function CloneVisitor() {
- }
- /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- CloneVisitor.prototype.visitText = /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- function (text, context) { return new Text$1(text.value, text.sourceSpan); };
- /**
- * @param {?} container
- * @param {?=} context
- * @return {?}
- */
- CloneVisitor.prototype.visitContainer = /**
- * @param {?} container
- * @param {?=} context
- * @return {?}
- */
- function (container, context) {
- var _this = this;
- var /** @type {?} */ children = container.children.map(function (n) { return n.visit(_this, context); });
- return new Container(children, container.sourceSpan);
- };
- /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- CloneVisitor.prototype.visitIcu = /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- function (icu, context) {
- var _this = this;
- var /** @type {?} */ cases = {};
- Object.keys(icu.cases).forEach(function (key) { return cases[key] = icu.cases[key].visit(_this, context); });
- var /** @type {?} */ msg = new Icu(icu.expression, icu.type, cases, icu.sourceSpan);
- msg.expressionPlaceholder = icu.expressionPlaceholder;
- return msg;
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- CloneVisitor.prototype.visitTagPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var _this = this;
- var /** @type {?} */ children = ph.children.map(function (n) { return n.visit(_this, context); });
- return new TagPlaceholder(ph.tag, ph.attrs, ph.startName, ph.closeName, children, ph.isVoid, ph.sourceSpan);
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- CloneVisitor.prototype.visitPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- return new Placeholder(ph.value, ph.name, ph.sourceSpan);
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- CloneVisitor.prototype.visitIcuPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- return new IcuPlaceholder(ph.value, ph.name, ph.sourceSpan);
- };
- return CloneVisitor;
- }());
- var RecurseVisitor = /** @class */ (function () {
- function RecurseVisitor() {
- }
- /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- RecurseVisitor.prototype.visitText = /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- function (text, context) { };
- /**
- * @param {?} container
- * @param {?=} context
- * @return {?}
- */
- RecurseVisitor.prototype.visitContainer = /**
- * @param {?} container
- * @param {?=} context
- * @return {?}
- */
- function (container, context) {
- var _this = this;
- container.children.forEach(function (child) { return child.visit(_this); });
- };
- /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- RecurseVisitor.prototype.visitIcu = /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- function (icu, context) {
- var _this = this;
- Object.keys(icu.cases).forEach(function (k) { icu.cases[k].visit(_this); });
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- RecurseVisitor.prototype.visitTagPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var _this = this;
- ph.children.forEach(function (child) { return child.visit(_this); });
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- RecurseVisitor.prototype.visitPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) { };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- RecurseVisitor.prototype.visitIcuPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) { };
- return RecurseVisitor;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var HtmlTagDefinition = /** @class */ (function () {
- function HtmlTagDefinition(_a) {
- var _b = _a === void 0 ? {} : _a, closedByChildren = _b.closedByChildren, requiredParents = _b.requiredParents, implicitNamespacePrefix = _b.implicitNamespacePrefix, _c = _b.contentType, contentType = _c === void 0 ? TagContentType.PARSABLE_DATA : _c, _d = _b.closedByParent, closedByParent = _d === void 0 ? false : _d, _e = _b.isVoid, isVoid = _e === void 0 ? false : _e, _f = _b.ignoreFirstLf, ignoreFirstLf = _f === void 0 ? false : _f;
- var _this = this;
- this.closedByChildren = {};
- this.closedByParent = false;
- this.canSelfClose = false;
- if (closedByChildren && closedByChildren.length > 0) {
- closedByChildren.forEach(function (tagName) { return _this.closedByChildren[tagName] = true; });
- }
- this.isVoid = isVoid;
- this.closedByParent = closedByParent || isVoid;
- if (requiredParents && requiredParents.length > 0) {
- this.requiredParents = {};
- // The first parent is the list is automatically when none of the listed parents are present
- this.parentToAdd = requiredParents[0];
- requiredParents.forEach(function (tagName) { return _this.requiredParents[tagName] = true; });
- }
- this.implicitNamespacePrefix = implicitNamespacePrefix || null;
- this.contentType = contentType;
- this.ignoreFirstLf = ignoreFirstLf;
- }
- /**
- * @param {?} currentParent
- * @return {?}
- */
- HtmlTagDefinition.prototype.requireExtraParent = /**
- * @param {?} currentParent
- * @return {?}
- */
- function (currentParent) {
- if (!this.requiredParents) {
- return false;
- }
- if (!currentParent) {
- return true;
- }
- var /** @type {?} */ lcParent = currentParent.toLowerCase();
- var /** @type {?} */ isParentTemplate = lcParent === 'template' || currentParent === 'ng-template';
- return !isParentTemplate && this.requiredParents[lcParent] != true;
- };
- /**
- * @param {?} name
- * @return {?}
- */
- HtmlTagDefinition.prototype.isClosedByChild = /**
- * @param {?} name
- * @return {?}
- */
- function (name) {
- return this.isVoid || name.toLowerCase() in this.closedByChildren;
- };
- return HtmlTagDefinition;
- }());
- // see http://www.w3.org/TR/html51/syntax.html#optional-tags
- // This implementation does not fully conform to the HTML5 spec.
- var TAG_DEFINITIONS = {
- 'base': new HtmlTagDefinition({ isVoid: true }),
- 'meta': new HtmlTagDefinition({ isVoid: true }),
- 'area': new HtmlTagDefinition({ isVoid: true }),
- 'embed': new HtmlTagDefinition({ isVoid: true }),
- 'link': new HtmlTagDefinition({ isVoid: true }),
- 'img': new HtmlTagDefinition({ isVoid: true }),
- 'input': new HtmlTagDefinition({ isVoid: true }),
- 'param': new HtmlTagDefinition({ isVoid: true }),
- 'hr': new HtmlTagDefinition({ isVoid: true }),
- 'br': new HtmlTagDefinition({ isVoid: true }),
- 'source': new HtmlTagDefinition({ isVoid: true }),
- 'track': new HtmlTagDefinition({ isVoid: true }),
- 'wbr': new HtmlTagDefinition({ isVoid: true }),
- 'p': new HtmlTagDefinition({
- closedByChildren: [
- 'address', 'article', 'aside', 'blockquote', 'div', 'dl', 'fieldset', 'footer', 'form',
- 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr',
- 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'
- ],
- closedByParent: true
- }),
- 'thead': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'] }),
- 'tbody': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'], closedByParent: true }),
- 'tfoot': new HtmlTagDefinition({ closedByChildren: ['tbody'], closedByParent: true }),
- 'tr': new HtmlTagDefinition({
- closedByChildren: ['tr'],
- requiredParents: ['tbody', 'tfoot', 'thead'],
- closedByParent: true
- }),
- 'td': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }),
- 'th': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }),
- 'col': new HtmlTagDefinition({ requiredParents: ['colgroup'], isVoid: true }),
- 'svg': new HtmlTagDefinition({ implicitNamespacePrefix: 'svg' }),
- 'math': new HtmlTagDefinition({ implicitNamespacePrefix: 'math' }),
- 'li': new HtmlTagDefinition({ closedByChildren: ['li'], closedByParent: true }),
- 'dt': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'] }),
- 'dd': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'], closedByParent: true }),
- 'rb': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
- 'rt': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
- 'rtc': new HtmlTagDefinition({ closedByChildren: ['rb', 'rtc', 'rp'], closedByParent: true }),
- 'rp': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
- 'optgroup': new HtmlTagDefinition({ closedByChildren: ['optgroup'], closedByParent: true }),
- 'option': new HtmlTagDefinition({ closedByChildren: ['option', 'optgroup'], closedByParent: true }),
- 'pre': new HtmlTagDefinition({ ignoreFirstLf: true }),
- 'listing': new HtmlTagDefinition({ ignoreFirstLf: true }),
- 'style': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }),
- 'script': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }),
- 'title': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT }),
- 'textarea': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT, ignoreFirstLf: true }),
- };
- var _DEFAULT_TAG_DEFINITION = new HtmlTagDefinition();
- /**
- * @param {?} tagName
- * @return {?}
- */
- function getHtmlTagDefinition(tagName) {
- return TAG_DEFINITIONS[tagName.toLowerCase()] || _DEFAULT_TAG_DEFINITION;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var TAG_TO_PLACEHOLDER_NAMES = {
- 'A': 'LINK',
- 'B': 'BOLD_TEXT',
- 'BR': 'LINE_BREAK',
- 'EM': 'EMPHASISED_TEXT',
- 'H1': 'HEADING_LEVEL1',
- 'H2': 'HEADING_LEVEL2',
- 'H3': 'HEADING_LEVEL3',
- 'H4': 'HEADING_LEVEL4',
- 'H5': 'HEADING_LEVEL5',
- 'H6': 'HEADING_LEVEL6',
- 'HR': 'HORIZONTAL_RULE',
- 'I': 'ITALIC_TEXT',
- 'LI': 'LIST_ITEM',
- 'LINK': 'MEDIA_LINK',
- 'OL': 'ORDERED_LIST',
- 'P': 'PARAGRAPH',
- 'Q': 'QUOTATION',
- 'S': 'STRIKETHROUGH_TEXT',
- 'SMALL': 'SMALL_TEXT',
- 'SUB': 'SUBSTRIPT',
- 'SUP': 'SUPERSCRIPT',
- 'TBODY': 'TABLE_BODY',
- 'TD': 'TABLE_CELL',
- 'TFOOT': 'TABLE_FOOTER',
- 'TH': 'TABLE_HEADER_CELL',
- 'THEAD': 'TABLE_HEADER',
- 'TR': 'TABLE_ROW',
- 'TT': 'MONOSPACED_TEXT',
- 'U': 'UNDERLINED_TEXT',
- 'UL': 'UNORDERED_LIST',
- };
- /**
- * Creates unique names for placeholder with different content.
- *
- * Returns the same placeholder name when the content is identical.
- */
- var PlaceholderRegistry = /** @class */ (function () {
- function PlaceholderRegistry() {
- this._placeHolderNameCounts = {};
- this._signatureToName = {};
- }
- /**
- * @param {?} tag
- * @param {?} attrs
- * @param {?} isVoid
- * @return {?}
- */
- PlaceholderRegistry.prototype.getStartTagPlaceholderName = /**
- * @param {?} tag
- * @param {?} attrs
- * @param {?} isVoid
- * @return {?}
- */
- function (tag, attrs, isVoid) {
- var /** @type {?} */ signature = this._hashTag(tag, attrs, isVoid);
- if (this._signatureToName[signature]) {
- return this._signatureToName[signature];
- }
- var /** @type {?} */ upperTag = tag.toUpperCase();
- var /** @type {?} */ baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag;
- var /** @type {?} */ name = this._generateUniqueName(isVoid ? baseName : "START_" + baseName);
- this._signatureToName[signature] = name;
- return name;
- };
- /**
- * @param {?} tag
- * @return {?}
- */
- PlaceholderRegistry.prototype.getCloseTagPlaceholderName = /**
- * @param {?} tag
- * @return {?}
- */
- function (tag) {
- var /** @type {?} */ signature = this._hashClosingTag(tag);
- if (this._signatureToName[signature]) {
- return this._signatureToName[signature];
- }
- var /** @type {?} */ upperTag = tag.toUpperCase();
- var /** @type {?} */ baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag;
- var /** @type {?} */ name = this._generateUniqueName("CLOSE_" + baseName);
- this._signatureToName[signature] = name;
- return name;
- };
- /**
- * @param {?} name
- * @param {?} content
- * @return {?}
- */
- PlaceholderRegistry.prototype.getPlaceholderName = /**
- * @param {?} name
- * @param {?} content
- * @return {?}
- */
- function (name, content) {
- var /** @type {?} */ upperName = name.toUpperCase();
- var /** @type {?} */ signature = "PH: " + upperName + "=" + content;
- if (this._signatureToName[signature]) {
- return this._signatureToName[signature];
- }
- var /** @type {?} */ uniqueName = this._generateUniqueName(upperName);
- this._signatureToName[signature] = uniqueName;
- return uniqueName;
- };
- /**
- * @param {?} name
- * @return {?}
- */
- PlaceholderRegistry.prototype.getUniquePlaceholder = /**
- * @param {?} name
- * @return {?}
- */
- function (name) {
- return this._generateUniqueName(name.toUpperCase());
- };
- /**
- * @param {?} tag
- * @param {?} attrs
- * @param {?} isVoid
- * @return {?}
- */
- PlaceholderRegistry.prototype._hashTag = /**
- * @param {?} tag
- * @param {?} attrs
- * @param {?} isVoid
- * @return {?}
- */
- function (tag, attrs, isVoid) {
- var /** @type {?} */ start = "<" + tag;
- var /** @type {?} */ strAttrs = Object.keys(attrs).sort().map(function (name) { return " " + name + "=" + attrs[name]; }).join('');
- var /** @type {?} */ end = isVoid ? '/>' : "></" + tag + ">";
- return start + strAttrs + end;
- };
- /**
- * @param {?} tag
- * @return {?}
- */
- PlaceholderRegistry.prototype._hashClosingTag = /**
- * @param {?} tag
- * @return {?}
- */
- function (tag) { return this._hashTag("/" + tag, {}, false); };
- /**
- * @param {?} base
- * @return {?}
- */
- PlaceholderRegistry.prototype._generateUniqueName = /**
- * @param {?} base
- * @return {?}
- */
- function (base) {
- var /** @type {?} */ seen = this._placeHolderNameCounts.hasOwnProperty(base);
- if (!seen) {
- this._placeHolderNameCounts[base] = 1;
- return base;
- }
- var /** @type {?} */ id = this._placeHolderNameCounts[base];
- this._placeHolderNameCounts[base] = id + 1;
- return base + "_" + id;
- };
- return PlaceholderRegistry;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _expParser = new Parser(new Lexer());
- /**
- * Returns a function converting html nodes to an i18n Message given an interpolationConfig
- * @param {?} interpolationConfig
- * @return {?}
- */
- function createI18nMessageFactory(interpolationConfig) {
- var /** @type {?} */ visitor = new _I18nVisitor(_expParser, interpolationConfig);
- return function (nodes, meaning, description, id) {
- return visitor.toI18nMessage(nodes, meaning, description, id);
- };
- }
- var _I18nVisitor = /** @class */ (function () {
- function _I18nVisitor(_expressionParser, _interpolationConfig) {
- this._expressionParser = _expressionParser;
- this._interpolationConfig = _interpolationConfig;
- }
- /**
- * @param {?} nodes
- * @param {?} meaning
- * @param {?} description
- * @param {?} id
- * @return {?}
- */
- _I18nVisitor.prototype.toI18nMessage = /**
- * @param {?} nodes
- * @param {?} meaning
- * @param {?} description
- * @param {?} id
- * @return {?}
- */
- function (nodes, meaning, description, id) {
- this._isIcu = nodes.length == 1 && nodes[0] instanceof Expansion;
- this._icuDepth = 0;
- this._placeholderRegistry = new PlaceholderRegistry();
- this._placeholderToContent = {};
- this._placeholderToMessage = {};
- var /** @type {?} */ i18nodes = visitAll(this, nodes, {});
- return new Message(i18nodes, this._placeholderToContent, this._placeholderToMessage, meaning, description, id);
- };
- /**
- * @param {?} el
- * @param {?} context
- * @return {?}
- */
- _I18nVisitor.prototype.visitElement = /**
- * @param {?} el
- * @param {?} context
- * @return {?}
- */
- function (el, context) {
- var /** @type {?} */ children = visitAll(this, el.children);
- var /** @type {?} */ attrs = {};
- el.attrs.forEach(function (attr) {
- // Do not visit the attributes, translatable ones are top-level ASTs
- attrs[attr.name] = attr.value;
- });
- var /** @type {?} */ isVoid = getHtmlTagDefinition(el.name).isVoid;
- var /** @type {?} */ startPhName = this._placeholderRegistry.getStartTagPlaceholderName(el.name, attrs, isVoid);
- this._placeholderToContent[startPhName] = /** @type {?} */ ((el.sourceSpan)).toString();
- var /** @type {?} */ closePhName = '';
- if (!isVoid) {
- closePhName = this._placeholderRegistry.getCloseTagPlaceholderName(el.name);
- this._placeholderToContent[closePhName] = "</" + el.name + ">";
- }
- return new TagPlaceholder(el.name, attrs, startPhName, closePhName, children, isVoid, /** @type {?} */ ((el.sourceSpan)));
- };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- _I18nVisitor.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) {
- return this._visitTextWithInterpolation(attribute.value, attribute.sourceSpan);
- };
- /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- _I18nVisitor.prototype.visitText = /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- function (text, context) {
- return this._visitTextWithInterpolation(text.value, /** @type {?} */ ((text.sourceSpan)));
- };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- _I18nVisitor.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) { return null; };
- /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- _I18nVisitor.prototype.visitExpansion = /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- function (icu, context) {
- var _this = this;
- this._icuDepth++;
- var /** @type {?} */ i18nIcuCases = {};
- var /** @type {?} */ i18nIcu = new Icu(icu.switchValue, icu.type, i18nIcuCases, icu.sourceSpan);
- icu.cases.forEach(function (caze) {
- i18nIcuCases[caze.value] = new Container(caze.expression.map(function (node) { return node.visit(_this, {}); }), caze.expSourceSpan);
- });
- this._icuDepth--;
- if (this._isIcu || this._icuDepth > 0) {
- // Returns an ICU node when:
- // - the message (vs a part of the message) is an ICU message, or
- // - the ICU message is nested.
- var /** @type {?} */ expPh = this._placeholderRegistry.getUniquePlaceholder("VAR_" + icu.type);
- i18nIcu.expressionPlaceholder = expPh;
- this._placeholderToContent[expPh] = icu.switchValue;
- return i18nIcu;
- }
- // Else returns a placeholder
- // ICU placeholders should not be replaced with their original content but with the their
- // translations. We need to create a new visitor (they are not re-entrant) to compute the
- // message id.
- // TODO(vicb): add a html.Node -> i18n.Message cache to avoid having to re-create the msg
- var /** @type {?} */ phName = this._placeholderRegistry.getPlaceholderName('ICU', icu.sourceSpan.toString());
- var /** @type {?} */ visitor = new _I18nVisitor(this._expressionParser, this._interpolationConfig);
- this._placeholderToMessage[phName] = visitor.toI18nMessage([icu], '', '', '');
- return new IcuPlaceholder(i18nIcu, phName, icu.sourceSpan);
- };
- /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- _I18nVisitor.prototype.visitExpansionCase = /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- function (icuCase, context) {
- throw new Error('Unreachable code');
- };
- /**
- * @param {?} text
- * @param {?} sourceSpan
- * @return {?}
- */
- _I18nVisitor.prototype._visitTextWithInterpolation = /**
- * @param {?} text
- * @param {?} sourceSpan
- * @return {?}
- */
- function (text, sourceSpan) {
- var /** @type {?} */ splitInterpolation = this._expressionParser.splitInterpolation(text, sourceSpan.start.toString(), this._interpolationConfig);
- if (!splitInterpolation) {
- // No expression, return a single text
- return new Text$1(text, sourceSpan);
- }
- // Return a group of text + expressions
- var /** @type {?} */ nodes = [];
- var /** @type {?} */ container = new Container(nodes, sourceSpan);
- var _a = this._interpolationConfig, sDelimiter = _a.start, eDelimiter = _a.end;
- for (var /** @type {?} */ i = 0; i < splitInterpolation.strings.length - 1; i++) {
- var /** @type {?} */ expression = splitInterpolation.expressions[i];
- var /** @type {?} */ baseName = _extractPlaceholderName(expression) || 'INTERPOLATION';
- var /** @type {?} */ phName = this._placeholderRegistry.getPlaceholderName(baseName, expression);
- if (splitInterpolation.strings[i].length) {
- // No need to add empty strings
- nodes.push(new Text$1(splitInterpolation.strings[i], sourceSpan));
- }
- nodes.push(new Placeholder(expression, phName, sourceSpan));
- this._placeholderToContent[phName] = sDelimiter + expression + eDelimiter;
- }
- // The last index contains no expression
- var /** @type {?} */ lastStringIdx = splitInterpolation.strings.length - 1;
- if (splitInterpolation.strings[lastStringIdx].length) {
- nodes.push(new Text$1(splitInterpolation.strings[lastStringIdx], sourceSpan));
- }
- return container;
- };
- return _I18nVisitor;
- }());
- var _CUSTOM_PH_EXP = /\/\/[\s\S]*i18n[\s\S]*\([\s\S]*ph[\s\S]*=[\s\S]*("|')([\s\S]*?)\1[\s\S]*\)/g;
- /**
- * @param {?} input
- * @return {?}
- */
- function _extractPlaceholderName(input) {
- return input.split(_CUSTOM_PH_EXP)[2];
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * An i18n error.
- */
- var I18nError = /** @class */ (function (_super) {
- __extends(I18nError, _super);
- function I18nError(span, msg) {
- return _super.call(this, span, msg) || this;
- }
- return I18nError;
- }(ParseError));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _I18N_ATTR = 'i18n';
- var _I18N_ATTR_PREFIX = 'i18n-';
- var _I18N_COMMENT_PREFIX_REGEXP = /^i18n:?/;
- var MEANING_SEPARATOR = '|';
- var ID_SEPARATOR = '@@';
- var i18nCommentsWarned = false;
- /**
- * Extract translatable messages from an html AST
- * @param {?} nodes
- * @param {?} interpolationConfig
- * @param {?} implicitTags
- * @param {?} implicitAttrs
- * @return {?}
- */
- function extractMessages(nodes, interpolationConfig, implicitTags, implicitAttrs) {
- var /** @type {?} */ visitor = new _Visitor(implicitTags, implicitAttrs);
- return visitor.extract(nodes, interpolationConfig);
- }
- /**
- * @param {?} nodes
- * @param {?} translations
- * @param {?} interpolationConfig
- * @param {?} implicitTags
- * @param {?} implicitAttrs
- * @return {?}
- */
- function mergeTranslations(nodes, translations, interpolationConfig, implicitTags, implicitAttrs) {
- var /** @type {?} */ visitor = new _Visitor(implicitTags, implicitAttrs);
- return visitor.merge(nodes, translations, interpolationConfig);
- }
- var ExtractionResult = /** @class */ (function () {
- function ExtractionResult(messages, errors) {
- this.messages = messages;
- this.errors = errors;
- }
- return ExtractionResult;
- }());
- /** @enum {number} */
- var _VisitorMode = {
- Extract: 0,
- Merge: 1,
- };
- _VisitorMode[_VisitorMode.Extract] = "Extract";
- _VisitorMode[_VisitorMode.Merge] = "Merge";
- /**
- * This Visitor is used:
- * 1. to extract all the translatable strings from an html AST (see `extract()`),
- * 2. to replace the translatable strings with the actual translations (see `merge()`)
- *
- * \@internal
- */
- var _Visitor = /** @class */ (function () {
- function _Visitor(_implicitTags, _implicitAttrs) {
- this._implicitTags = _implicitTags;
- this._implicitAttrs = _implicitAttrs;
- }
- /**
- * Extracts the messages from the tree
- */
- /**
- * Extracts the messages from the tree
- * @param {?} nodes
- * @param {?} interpolationConfig
- * @return {?}
- */
- _Visitor.prototype.extract = /**
- * Extracts the messages from the tree
- * @param {?} nodes
- * @param {?} interpolationConfig
- * @return {?}
- */
- function (nodes, interpolationConfig) {
- var _this = this;
- this._init(_VisitorMode.Extract, interpolationConfig);
- nodes.forEach(function (node) { return node.visit(_this, null); });
- if (this._inI18nBlock) {
- this._reportError(nodes[nodes.length - 1], 'Unclosed block');
- }
- return new ExtractionResult(this._messages, this._errors);
- };
- /**
- * Returns a tree where all translatable nodes are translated
- */
- /**
- * Returns a tree where all translatable nodes are translated
- * @param {?} nodes
- * @param {?} translations
- * @param {?} interpolationConfig
- * @return {?}
- */
- _Visitor.prototype.merge = /**
- * Returns a tree where all translatable nodes are translated
- * @param {?} nodes
- * @param {?} translations
- * @param {?} interpolationConfig
- * @return {?}
- */
- function (nodes, translations, interpolationConfig) {
- this._init(_VisitorMode.Merge, interpolationConfig);
- this._translations = translations;
- // Construct a single fake root element
- var /** @type {?} */ wrapper = new Element('wrapper', [], nodes, /** @type {?} */ ((undefined)), undefined, undefined);
- var /** @type {?} */ translatedNode = wrapper.visit(this, null);
- if (this._inI18nBlock) {
- this._reportError(nodes[nodes.length - 1], 'Unclosed block');
- }
- return new ParseTreeResult(translatedNode.children, this._errors);
- };
- /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- _Visitor.prototype.visitExpansionCase = /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- function (icuCase, context) {
- // Parse cases for translatable html attributes
- var /** @type {?} */ expression = visitAll(this, icuCase.expression, context);
- if (this._mode === _VisitorMode.Merge) {
- return new ExpansionCase(icuCase.value, expression, icuCase.sourceSpan, icuCase.valueSourceSpan, icuCase.expSourceSpan);
- }
- };
- /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- _Visitor.prototype.visitExpansion = /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- function (icu, context) {
- this._mayBeAddBlockChildren(icu);
- var /** @type {?} */ wasInIcu = this._inIcu;
- if (!this._inIcu) {
- // nested ICU messages should not be extracted but top-level translated as a whole
- if (this._isInTranslatableSection) {
- this._addMessage([icu]);
- }
- this._inIcu = true;
- }
- var /** @type {?} */ cases = visitAll(this, icu.cases, context);
- if (this._mode === _VisitorMode.Merge) {
- icu = new Expansion(icu.switchValue, icu.type, cases, icu.sourceSpan, icu.switchValueSourceSpan);
- }
- this._inIcu = wasInIcu;
- return icu;
- };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- _Visitor.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) {
- var /** @type {?} */ isOpening = _isOpeningComment(comment);
- if (isOpening && this._isInTranslatableSection) {
- this._reportError(comment, 'Could not start a block inside a translatable section');
- return;
- }
- var /** @type {?} */ isClosing = _isClosingComment(comment);
- if (isClosing && !this._inI18nBlock) {
- this._reportError(comment, 'Trying to close an unopened block');
- return;
- }
- if (!this._inI18nNode && !this._inIcu) {
- if (!this._inI18nBlock) {
- if (isOpening) {
- // deprecated from v5 you should use <ng-container i18n> instead of i18n comments
- if (!i18nCommentsWarned && /** @type {?} */ (console) && /** @type {?} */ (console.warn)) {
- i18nCommentsWarned = true;
- var /** @type {?} */ details = comment.sourceSpan.details ? ", " + comment.sourceSpan.details : '';
- // TODO(ocombe): use a log service once there is a public one available
- console.warn("I18n comments are deprecated, use an <ng-container> element instead (" + comment.sourceSpan.start + details + ")");
- }
- this._inI18nBlock = true;
- this._blockStartDepth = this._depth;
- this._blockChildren = [];
- this._blockMeaningAndDesc = /** @type {?} */ ((comment.value)).replace(_I18N_COMMENT_PREFIX_REGEXP, '').trim();
- this._openTranslatableSection(comment);
- }
- }
- else {
- if (isClosing) {
- if (this._depth == this._blockStartDepth) {
- this._closeTranslatableSection(comment, this._blockChildren);
- this._inI18nBlock = false;
- var /** @type {?} */ message = /** @type {?} */ ((this._addMessage(this._blockChildren, this._blockMeaningAndDesc)));
- // merge attributes in sections
- var /** @type {?} */ nodes = this._translateMessage(comment, message);
- return visitAll(this, nodes);
- }
- else {
- this._reportError(comment, 'I18N blocks should not cross element boundaries');
- return;
- }
- }
- }
- }
- };
- /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- _Visitor.prototype.visitText = /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- function (text, context) {
- if (this._isInTranslatableSection) {
- this._mayBeAddBlockChildren(text);
- }
- return text;
- };
- /**
- * @param {?} el
- * @param {?} context
- * @return {?}
- */
- _Visitor.prototype.visitElement = /**
- * @param {?} el
- * @param {?} context
- * @return {?}
- */
- function (el, context) {
- var _this = this;
- this._mayBeAddBlockChildren(el);
- this._depth++;
- var /** @type {?} */ wasInI18nNode = this._inI18nNode;
- var /** @type {?} */ wasInImplicitNode = this._inImplicitNode;
- var /** @type {?} */ childNodes = [];
- var /** @type {?} */ translatedChildNodes = /** @type {?} */ ((undefined));
- // Extract:
- // - top level nodes with the (implicit) "i18n" attribute if not already in a section
- // - ICU messages
- var /** @type {?} */ i18nAttr = _getI18nAttr(el);
- var /** @type {?} */ i18nMeta = i18nAttr ? i18nAttr.value : '';
- var /** @type {?} */ isImplicit = this._implicitTags.some(function (tag) { return el.name === tag; }) && !this._inIcu &&
- !this._isInTranslatableSection;
- var /** @type {?} */ isTopLevelImplicit = !wasInImplicitNode && isImplicit;
- this._inImplicitNode = wasInImplicitNode || isImplicit;
- if (!this._isInTranslatableSection && !this._inIcu) {
- if (i18nAttr || isTopLevelImplicit) {
- this._inI18nNode = true;
- var /** @type {?} */ message = /** @type {?} */ ((this._addMessage(el.children, i18nMeta)));
- translatedChildNodes = this._translateMessage(el, message);
- }
- if (this._mode == _VisitorMode.Extract) {
- var /** @type {?} */ isTranslatable = i18nAttr || isTopLevelImplicit;
- if (isTranslatable)
- this._openTranslatableSection(el);
- visitAll(this, el.children);
- if (isTranslatable)
- this._closeTranslatableSection(el, el.children);
- }
- }
- else {
- if (i18nAttr || isTopLevelImplicit) {
- this._reportError(el, 'Could not mark an element as translatable inside a translatable section');
- }
- if (this._mode == _VisitorMode.Extract) {
- // Descend into child nodes for extraction
- visitAll(this, el.children);
- }
- }
- if (this._mode === _VisitorMode.Merge) {
- var /** @type {?} */ visitNodes = translatedChildNodes || el.children;
- visitNodes.forEach(function (child) {
- var /** @type {?} */ visited = child.visit(_this, context);
- if (visited && !_this._isInTranslatableSection) {
- // Do not add the children from translatable sections (= i18n blocks here)
- // They will be added later in this loop when the block closes (i.e. on `<!-- /i18n -->`)
- childNodes = childNodes.concat(visited);
- }
- });
- }
- this._visitAttributesOf(el);
- this._depth--;
- this._inI18nNode = wasInI18nNode;
- this._inImplicitNode = wasInImplicitNode;
- if (this._mode === _VisitorMode.Merge) {
- var /** @type {?} */ translatedAttrs = this._translateAttributes(el);
- return new Element(el.name, translatedAttrs, childNodes, el.sourceSpan, el.startSourceSpan, el.endSourceSpan);
- }
- return null;
- };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- _Visitor.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) {
- throw new Error('unreachable code');
- };
- /**
- * @param {?} mode
- * @param {?} interpolationConfig
- * @return {?}
- */
- _Visitor.prototype._init = /**
- * @param {?} mode
- * @param {?} interpolationConfig
- * @return {?}
- */
- function (mode, interpolationConfig) {
- this._mode = mode;
- this._inI18nBlock = false;
- this._inI18nNode = false;
- this._depth = 0;
- this._inIcu = false;
- this._msgCountAtSectionStart = undefined;
- this._errors = [];
- this._messages = [];
- this._inImplicitNode = false;
- this._createI18nMessage = createI18nMessageFactory(interpolationConfig);
- };
- /**
- * @param {?} el
- * @return {?}
- */
- _Visitor.prototype._visitAttributesOf = /**
- * @param {?} el
- * @return {?}
- */
- function (el) {
- var _this = this;
- var /** @type {?} */ explicitAttrNameToValue = {};
- var /** @type {?} */ implicitAttrNames = this._implicitAttrs[el.name] || [];
- el.attrs.filter(function (attr) { return attr.name.startsWith(_I18N_ATTR_PREFIX); })
- .forEach(function (attr) {
- return explicitAttrNameToValue[attr.name.slice(_I18N_ATTR_PREFIX.length)] =
- attr.value;
- });
- el.attrs.forEach(function (attr) {
- if (attr.name in explicitAttrNameToValue) {
- _this._addMessage([attr], explicitAttrNameToValue[attr.name]);
- }
- else if (implicitAttrNames.some(function (name) { return attr.name === name; })) {
- _this._addMessage([attr]);
- }
- });
- };
- /**
- * @param {?} ast
- * @param {?=} msgMeta
- * @return {?}
- */
- _Visitor.prototype._addMessage = /**
- * @param {?} ast
- * @param {?=} msgMeta
- * @return {?}
- */
- function (ast, msgMeta) {
- if (ast.length == 0 ||
- ast.length == 1 && ast[0] instanceof Attribute$1 && !(/** @type {?} */ (ast[0])).value) {
- // Do not create empty messages
- return null;
- }
- var _a = _parseMessageMeta(msgMeta), meaning = _a.meaning, description = _a.description, id = _a.id;
- var /** @type {?} */ message = this._createI18nMessage(ast, meaning, description, id);
- this._messages.push(message);
- return message;
- };
- /**
- * @param {?} el
- * @param {?} message
- * @return {?}
- */
- _Visitor.prototype._translateMessage = /**
- * @param {?} el
- * @param {?} message
- * @return {?}
- */
- function (el, message) {
- if (message && this._mode === _VisitorMode.Merge) {
- var /** @type {?} */ nodes = this._translations.get(message);
- if (nodes) {
- return nodes;
- }
- this._reportError(el, "Translation unavailable for message id=\"" + this._translations.digest(message) + "\"");
- }
- return [];
- };
- /**
- * @param {?} el
- * @return {?}
- */
- _Visitor.prototype._translateAttributes = /**
- * @param {?} el
- * @return {?}
- */
- function (el) {
- var _this = this;
- var /** @type {?} */ attributes = el.attrs;
- var /** @type {?} */ i18nParsedMessageMeta = {};
- attributes.forEach(function (attr) {
- if (attr.name.startsWith(_I18N_ATTR_PREFIX)) {
- i18nParsedMessageMeta[attr.name.slice(_I18N_ATTR_PREFIX.length)] =
- _parseMessageMeta(attr.value);
- }
- });
- var /** @type {?} */ translatedAttributes = [];
- attributes.forEach(function (attr) {
- if (attr.name === _I18N_ATTR || attr.name.startsWith(_I18N_ATTR_PREFIX)) {
- // strip i18n specific attributes
- return;
- }
- if (attr.value && attr.value != '' && i18nParsedMessageMeta.hasOwnProperty(attr.name)) {
- var _a = i18nParsedMessageMeta[attr.name], meaning = _a.meaning, description = _a.description, id = _a.id;
- var /** @type {?} */ message = _this._createI18nMessage([attr], meaning, description, id);
- var /** @type {?} */ nodes = _this._translations.get(message);
- if (nodes) {
- if (nodes.length == 0) {
- translatedAttributes.push(new Attribute$1(attr.name, '', attr.sourceSpan));
- }
- else if (nodes[0] instanceof Text) {
- var /** @type {?} */ value = (/** @type {?} */ (nodes[0])).value;
- translatedAttributes.push(new Attribute$1(attr.name, value, attr.sourceSpan));
- }
- else {
- _this._reportError(el, "Unexpected translation for attribute \"" + attr.name + "\" (id=\"" + (id || _this._translations.digest(message)) + "\")");
- }
- }
- else {
- _this._reportError(el, "Translation unavailable for attribute \"" + attr.name + "\" (id=\"" + (id || _this._translations.digest(message)) + "\")");
- }
- }
- else {
- translatedAttributes.push(attr);
- }
- });
- return translatedAttributes;
- };
- /**
- * Add the node as a child of the block when:
- * - we are in a block,
- * - we are not inside a ICU message (those are handled separately),
- * - the node is a "direct child" of the block
- * @param {?} node
- * @return {?}
- */
- _Visitor.prototype._mayBeAddBlockChildren = /**
- * Add the node as a child of the block when:
- * - we are in a block,
- * - we are not inside a ICU message (those are handled separately),
- * - the node is a "direct child" of the block
- * @param {?} node
- * @return {?}
- */
- function (node) {
- if (this._inI18nBlock && !this._inIcu && this._depth == this._blockStartDepth) {
- this._blockChildren.push(node);
- }
- };
- /**
- * Marks the start of a section, see `_closeTranslatableSection`
- * @param {?} node
- * @return {?}
- */
- _Visitor.prototype._openTranslatableSection = /**
- * Marks the start of a section, see `_closeTranslatableSection`
- * @param {?} node
- * @return {?}
- */
- function (node) {
- if (this._isInTranslatableSection) {
- this._reportError(node, 'Unexpected section start');
- }
- else {
- this._msgCountAtSectionStart = this._messages.length;
- }
- };
- Object.defineProperty(_Visitor.prototype, "_isInTranslatableSection", {
- get: /**
- * A translatable section could be:
- * - the content of translatable element,
- * - nodes between `<!-- i18n -->` and `<!-- /i18n -->` comments
- * @return {?}
- */
- function () {
- return this._msgCountAtSectionStart !== void 0;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Terminates a section.
- *
- * If a section has only one significant children (comments not significant) then we should not
- * keep the message from this children:
- *
- * `<p i18n="meaning|description">{ICU message}</p>` would produce two messages:
- * - one for the <p> content with meaning and description,
- * - another one for the ICU message.
- *
- * In this case the last message is discarded as it contains less information (the AST is
- * otherwise identical).
- *
- * Note that we should still keep messages extracted from attributes inside the section (ie in the
- * ICU message here)
- * @param {?} node
- * @param {?} directChildren
- * @return {?}
- */
- _Visitor.prototype._closeTranslatableSection = /**
- * Terminates a section.
- *
- * If a section has only one significant children (comments not significant) then we should not
- * keep the message from this children:
- *
- * `<p i18n="meaning|description">{ICU message}</p>` would produce two messages:
- * - one for the <p> content with meaning and description,
- * - another one for the ICU message.
- *
- * In this case the last message is discarded as it contains less information (the AST is
- * otherwise identical).
- *
- * Note that we should still keep messages extracted from attributes inside the section (ie in the
- * ICU message here)
- * @param {?} node
- * @param {?} directChildren
- * @return {?}
- */
- function (node, directChildren) {
- if (!this._isInTranslatableSection) {
- this._reportError(node, 'Unexpected section end');
- return;
- }
- var /** @type {?} */ startIndex = this._msgCountAtSectionStart;
- var /** @type {?} */ significantChildren = directChildren.reduce(function (count, node) { return count + (node instanceof Comment ? 0 : 1); }, 0);
- if (significantChildren == 1) {
- for (var /** @type {?} */ i = this._messages.length - 1; i >= /** @type {?} */ ((startIndex)); i--) {
- var /** @type {?} */ ast = this._messages[i].nodes;
- if (!(ast.length == 1 && ast[0] instanceof Text$1)) {
- this._messages.splice(i, 1);
- break;
- }
- }
- }
- this._msgCountAtSectionStart = undefined;
- };
- /**
- * @param {?} node
- * @param {?} msg
- * @return {?}
- */
- _Visitor.prototype._reportError = /**
- * @param {?} node
- * @param {?} msg
- * @return {?}
- */
- function (node, msg) {
- this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), msg));
- };
- return _Visitor;
- }());
- /**
- * @param {?} n
- * @return {?}
- */
- function _isOpeningComment(n) {
- return !!(n instanceof Comment && n.value && n.value.startsWith('i18n'));
- }
- /**
- * @param {?} n
- * @return {?}
- */
- function _isClosingComment(n) {
- return !!(n instanceof Comment && n.value && n.value === '/i18n');
- }
- /**
- * @param {?} p
- * @return {?}
- */
- function _getI18nAttr(p) {
- return p.attrs.find(function (attr) { return attr.name === _I18N_ATTR; }) || null;
- }
- /**
- * @param {?=} i18n
- * @return {?}
- */
- function _parseMessageMeta(i18n) {
- if (!i18n)
- return { meaning: '', description: '', id: '' };
- var /** @type {?} */ idIndex = i18n.indexOf(ID_SEPARATOR);
- var /** @type {?} */ descIndex = i18n.indexOf(MEANING_SEPARATOR);
- var _a = (idIndex > -1) ? [i18n.slice(0, idIndex), i18n.slice(idIndex + 2)] : [i18n, ''], meaningAndDesc = _a[0], id = _a[1];
- var _b = (descIndex > -1) ?
- [meaningAndDesc.slice(0, descIndex), meaningAndDesc.slice(descIndex + 1)] :
- ['', meaningAndDesc], meaning = _b[0], description = _b[1];
- return { meaning: meaning, description: description, id: id };
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var XmlTagDefinition = /** @class */ (function () {
- function XmlTagDefinition() {
- this.closedByParent = false;
- this.contentType = TagContentType.PARSABLE_DATA;
- this.isVoid = false;
- this.ignoreFirstLf = false;
- this.canSelfClose = true;
- }
- /**
- * @param {?} currentParent
- * @return {?}
- */
- XmlTagDefinition.prototype.requireExtraParent = /**
- * @param {?} currentParent
- * @return {?}
- */
- function (currentParent) { return false; };
- /**
- * @param {?} name
- * @return {?}
- */
- XmlTagDefinition.prototype.isClosedByChild = /**
- * @param {?} name
- * @return {?}
- */
- function (name) { return false; };
- return XmlTagDefinition;
- }());
- var _TAG_DEFINITION = new XmlTagDefinition();
- /**
- * @param {?} tagName
- * @return {?}
- */
- function getXmlTagDefinition(tagName) {
- return _TAG_DEFINITION;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var XmlParser = /** @class */ (function (_super) {
- __extends(XmlParser, _super);
- function XmlParser() {
- return _super.call(this, getXmlTagDefinition) || this;
- }
- /**
- * @param {?} source
- * @param {?} url
- * @param {?=} parseExpansionForms
- * @return {?}
- */
- XmlParser.prototype.parse = /**
- * @param {?} source
- * @param {?} url
- * @param {?=} parseExpansionForms
- * @return {?}
- */
- function (source, url, parseExpansionForms) {
- if (parseExpansionForms === void 0) { parseExpansionForms = false; }
- return _super.prototype.parse.call(this, source, url, parseExpansionForms);
- };
- return XmlParser;
- }(Parser$1));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @abstract
- */
- var Serializer = /** @class */ (function () {
- function Serializer() {
- }
- // Creates a name mapper, see `PlaceholderMapper`
- // Returning `null` means that no name mapping is used.
- /**
- * @param {?} message
- * @return {?}
- */
- Serializer.prototype.createNameMapper = /**
- * @param {?} message
- * @return {?}
- */
- function (message) { return null; };
- return Serializer;
- }());
- /**
- * A `PlaceholderMapper` converts placeholder names from internal to serialized representation and
- * back.
- *
- * It should be used for serialization format that put constraints on the placeholder names.
- * @record
- */
-
- /**
- * A simple mapper that take a function to transform an internal name to a public name
- */
- var SimplePlaceholderMapper = /** @class */ (function (_super) {
- __extends(SimplePlaceholderMapper, _super);
- // create a mapping from the message
- function SimplePlaceholderMapper(message, mapName) {
- var _this = _super.call(this) || this;
- _this.mapName = mapName;
- _this.internalToPublic = {};
- _this.publicToNextId = {};
- _this.publicToInternal = {};
- message.nodes.forEach(function (node) { return node.visit(_this); });
- return _this;
- }
- /**
- * @param {?} internalName
- * @return {?}
- */
- SimplePlaceholderMapper.prototype.toPublicName = /**
- * @param {?} internalName
- * @return {?}
- */
- function (internalName) {
- return this.internalToPublic.hasOwnProperty(internalName) ?
- this.internalToPublic[internalName] :
- null;
- };
- /**
- * @param {?} publicName
- * @return {?}
- */
- SimplePlaceholderMapper.prototype.toInternalName = /**
- * @param {?} publicName
- * @return {?}
- */
- function (publicName) {
- return this.publicToInternal.hasOwnProperty(publicName) ? this.publicToInternal[publicName] :
- null;
- };
- /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- SimplePlaceholderMapper.prototype.visitText = /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- function (text, context) { return null; };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- SimplePlaceholderMapper.prototype.visitTagPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- this.visitPlaceholderName(ph.startName);
- _super.prototype.visitTagPlaceholder.call(this, ph, context);
- this.visitPlaceholderName(ph.closeName);
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- SimplePlaceholderMapper.prototype.visitPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) { this.visitPlaceholderName(ph.name); };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- SimplePlaceholderMapper.prototype.visitIcuPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- this.visitPlaceholderName(ph.name);
- };
- /**
- * @param {?} internalName
- * @return {?}
- */
- SimplePlaceholderMapper.prototype.visitPlaceholderName = /**
- * @param {?} internalName
- * @return {?}
- */
- function (internalName) {
- if (!internalName || this.internalToPublic.hasOwnProperty(internalName)) {
- return;
- }
- var /** @type {?} */ publicName = this.mapName(internalName);
- if (this.publicToInternal.hasOwnProperty(publicName)) {
- // Create a new XMB when it has already been used
- var /** @type {?} */ nextId = this.publicToNextId[publicName];
- this.publicToNextId[publicName] = nextId + 1;
- publicName = publicName + "_" + nextId;
- }
- else {
- this.publicToNextId[publicName] = 1;
- }
- this.internalToPublic[internalName] = publicName;
- this.publicToInternal[publicName] = internalName;
- };
- return SimplePlaceholderMapper;
- }(RecurseVisitor));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @record
- */
-
- var _Visitor$1 = /** @class */ (function () {
- function _Visitor() {
- }
- /**
- * @param {?} tag
- * @return {?}
- */
- _Visitor.prototype.visitTag = /**
- * @param {?} tag
- * @return {?}
- */
- function (tag) {
- var _this = this;
- var /** @type {?} */ strAttrs = this._serializeAttributes(tag.attrs);
- if (tag.children.length == 0) {
- return "<" + tag.name + strAttrs + "/>";
- }
- var /** @type {?} */ strChildren = tag.children.map(function (node) { return node.visit(_this); });
- return "<" + tag.name + strAttrs + ">" + strChildren.join('') + "</" + tag.name + ">";
- };
- /**
- * @param {?} text
- * @return {?}
- */
- _Visitor.prototype.visitText = /**
- * @param {?} text
- * @return {?}
- */
- function (text) { return text.value; };
- /**
- * @param {?} decl
- * @return {?}
- */
- _Visitor.prototype.visitDeclaration = /**
- * @param {?} decl
- * @return {?}
- */
- function (decl) {
- return "<?xml" + this._serializeAttributes(decl.attrs) + " ?>";
- };
- /**
- * @param {?} attrs
- * @return {?}
- */
- _Visitor.prototype._serializeAttributes = /**
- * @param {?} attrs
- * @return {?}
- */
- function (attrs) {
- var /** @type {?} */ strAttrs = Object.keys(attrs).map(function (name) { return name + "=\"" + attrs[name] + "\""; }).join(' ');
- return strAttrs.length > 0 ? ' ' + strAttrs : '';
- };
- /**
- * @param {?} doctype
- * @return {?}
- */
- _Visitor.prototype.visitDoctype = /**
- * @param {?} doctype
- * @return {?}
- */
- function (doctype) {
- return "<!DOCTYPE " + doctype.rootTag + " [\n" + doctype.dtd + "\n]>";
- };
- return _Visitor;
- }());
- var _visitor = new _Visitor$1();
- /**
- * @param {?} nodes
- * @return {?}
- */
- function serialize(nodes) {
- return nodes.map(function (node) { return node.visit(_visitor); }).join('');
- }
- /**
- * @record
- */
-
- var Declaration = /** @class */ (function () {
- function Declaration(unescapedAttrs) {
- var _this = this;
- this.attrs = {};
- Object.keys(unescapedAttrs).forEach(function (k) {
- _this.attrs[k] = escapeXml(unescapedAttrs[k]);
- });
- }
- /**
- * @param {?} visitor
- * @return {?}
- */
- Declaration.prototype.visit = /**
- * @param {?} visitor
- * @return {?}
- */
- function (visitor) { return visitor.visitDeclaration(this); };
- return Declaration;
- }());
- var Doctype = /** @class */ (function () {
- function Doctype(rootTag, dtd) {
- this.rootTag = rootTag;
- this.dtd = dtd;
- }
- /**
- * @param {?} visitor
- * @return {?}
- */
- Doctype.prototype.visit = /**
- * @param {?} visitor
- * @return {?}
- */
- function (visitor) { return visitor.visitDoctype(this); };
- return Doctype;
- }());
- var Tag = /** @class */ (function () {
- function Tag(name, unescapedAttrs, children) {
- if (unescapedAttrs === void 0) { unescapedAttrs = {}; }
- if (children === void 0) { children = []; }
- var _this = this;
- this.name = name;
- this.children = children;
- this.attrs = {};
- Object.keys(unescapedAttrs).forEach(function (k) {
- _this.attrs[k] = escapeXml(unescapedAttrs[k]);
- });
- }
- /**
- * @param {?} visitor
- * @return {?}
- */
- Tag.prototype.visit = /**
- * @param {?} visitor
- * @return {?}
- */
- function (visitor) { return visitor.visitTag(this); };
- return Tag;
- }());
- var Text$2 = /** @class */ (function () {
- function Text(unescapedValue) {
- this.value = escapeXml(unescapedValue);
- }
- /**
- * @param {?} visitor
- * @return {?}
- */
- Text.prototype.visit = /**
- * @param {?} visitor
- * @return {?}
- */
- function (visitor) { return visitor.visitText(this); };
- return Text;
- }());
- var CR = /** @class */ (function (_super) {
- __extends(CR, _super);
- function CR(ws) {
- if (ws === void 0) { ws = 0; }
- return _super.call(this, "\n" + new Array(ws + 1).join(' ')) || this;
- }
- return CR;
- }(Text$2));
- var _ESCAPED_CHARS = [
- [/&/g, '&'],
- [/"/g, '"'],
- [/'/g, '''],
- [/</g, '<'],
- [/>/g, '>'],
- ];
- /**
- * @param {?} text
- * @return {?}
- */
- function escapeXml(text) {
- return _ESCAPED_CHARS.reduce(function (text, entry) { return text.replace(entry[0], entry[1]); }, text);
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _VERSION = '1.2';
- var _XMLNS = 'urn:oasis:names:tc:xliff:document:1.2';
- // TODO(vicb): make this a param (s/_/-/)
- var _DEFAULT_SOURCE_LANG = 'en';
- var _PLACEHOLDER_TAG = 'x';
- var _MARKER_TAG = 'mrk';
- var _FILE_TAG = 'file';
- var _SOURCE_TAG = 'source';
- var _SEGMENT_SOURCE_TAG = 'seg-source';
- var _TARGET_TAG = 'target';
- var _UNIT_TAG = 'trans-unit';
- var _CONTEXT_GROUP_TAG = 'context-group';
- var _CONTEXT_TAG = 'context';
- var Xliff = /** @class */ (function (_super) {
- __extends(Xliff, _super);
- function Xliff() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} messages
- * @param {?} locale
- * @return {?}
- */
- Xliff.prototype.write = /**
- * @param {?} messages
- * @param {?} locale
- * @return {?}
- */
- function (messages, locale) {
- var /** @type {?} */ visitor = new _WriteVisitor();
- var /** @type {?} */ transUnits = [];
- messages.forEach(function (message) {
- var /** @type {?} */ contextTags = [];
- message.sources.forEach(function (source) {
- var /** @type {?} */ contextGroupTag = new Tag(_CONTEXT_GROUP_TAG, { purpose: 'location' });
- contextGroupTag.children.push(new CR(10), new Tag(_CONTEXT_TAG, { 'context-type': 'sourcefile' }, [new Text$2(source.filePath)]), new CR(10), new Tag(_CONTEXT_TAG, { 'context-type': 'linenumber' }, [new Text$2("" + source.startLine)]), new CR(8));
- contextTags.push(new CR(8), contextGroupTag);
- });
- var /** @type {?} */ transUnit = new Tag(_UNIT_TAG, { id: message.id, datatype: 'html' });
- (_a = transUnit.children).push.apply(_a, [new CR(8), new Tag(_SOURCE_TAG, {}, visitor.serialize(message.nodes))].concat(contextTags));
- if (message.description) {
- transUnit.children.push(new CR(8), new Tag('note', { priority: '1', from: 'description' }, [new Text$2(message.description)]));
- }
- if (message.meaning) {
- transUnit.children.push(new CR(8), new Tag('note', { priority: '1', from: 'meaning' }, [new Text$2(message.meaning)]));
- }
- transUnit.children.push(new CR(6));
- transUnits.push(new CR(6), transUnit);
- var _a;
- });
- var /** @type {?} */ body = new Tag('body', {}, transUnits.concat([new CR(4)]));
- var /** @type {?} */ file = new Tag('file', {
- 'source-language': locale || _DEFAULT_SOURCE_LANG,
- datatype: 'plaintext',
- original: 'ng2.template',
- }, [new CR(4), body, new CR(2)]);
- var /** @type {?} */ xliff = new Tag('xliff', { version: _VERSION, xmlns: _XMLNS }, [new CR(2), file, new CR()]);
- return serialize([
- new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), xliff, new CR()
- ]);
- };
- /**
- * @param {?} content
- * @param {?} url
- * @return {?}
- */
- Xliff.prototype.load = /**
- * @param {?} content
- * @param {?} url
- * @return {?}
- */
- function (content, url) {
- // xliff to xml nodes
- var /** @type {?} */ xliffParser = new XliffParser();
- var _a = xliffParser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
- // xml nodes to i18n nodes
- var /** @type {?} */ i18nNodesByMsgId = {};
- var /** @type {?} */ converter = new XmlToI18n();
- Object.keys(msgIdToHtml).forEach(function (msgId) {
- var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, e = _a.errors;
- errors.push.apply(errors, e);
- i18nNodesByMsgId[msgId] = i18nNodes;
- });
- if (errors.length) {
- throw new Error("xliff parse errors:\n" + errors.join('\n'));
- }
- return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
- };
- /**
- * @param {?} message
- * @return {?}
- */
- Xliff.prototype.digest = /**
- * @param {?} message
- * @return {?}
- */
- function (message) { return digest(message); };
- return Xliff;
- }(Serializer));
- var _WriteVisitor = /** @class */ (function () {
- function _WriteVisitor() {
- }
- /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitText = /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- function (text, context) { return [new Text$2(text.value)]; };
- /**
- * @param {?} container
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitContainer = /**
- * @param {?} container
- * @param {?=} context
- * @return {?}
- */
- function (container, context) {
- var _this = this;
- var /** @type {?} */ nodes = [];
- container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
- return nodes;
- };
- /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitIcu = /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- function (icu, context) {
- var _this = this;
- var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
- Object.keys(icu.cases).forEach(function (c) {
- nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
- });
- nodes.push(new Text$2("}"));
- return nodes;
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitTagPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var /** @type {?} */ ctype = getCtypeForTag(ph.tag);
- if (ph.isVoid) {
- // void tags have no children nor closing tags
- return [new Tag(_PLACEHOLDER_TAG, { id: ph.startName, ctype: ctype, 'equiv-text': "<" + ph.tag + "/>" })];
- }
- var /** @type {?} */ startTagPh = new Tag(_PLACEHOLDER_TAG, { id: ph.startName, ctype: ctype, 'equiv-text': "<" + ph.tag + ">" });
- var /** @type {?} */ closeTagPh = new Tag(_PLACEHOLDER_TAG, { id: ph.closeName, ctype: ctype, 'equiv-text': "</" + ph.tag + ">" });
- return [startTagPh].concat(this.serialize(ph.children), [closeTagPh]);
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- return [new Tag(_PLACEHOLDER_TAG, { id: ph.name, 'equiv-text': "{{" + ph.value + "}}" })];
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitIcuPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var /** @type {?} */ equivText = "{" + ph.value.expression + ", " + ph.value.type + ", " + Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' ') + "}";
- return [new Tag(_PLACEHOLDER_TAG, { id: ph.name, 'equiv-text': equivText })];
- };
- /**
- * @param {?} nodes
- * @return {?}
- */
- _WriteVisitor.prototype.serialize = /**
- * @param {?} nodes
- * @return {?}
- */
- function (nodes) {
- var _this = this;
- return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
- };
- return _WriteVisitor;
- }());
- var XliffParser = /** @class */ (function () {
- function XliffParser() {
- this._locale = null;
- }
- /**
- * @param {?} xliff
- * @param {?} url
- * @return {?}
- */
- XliffParser.prototype.parse = /**
- * @param {?} xliff
- * @param {?} url
- * @return {?}
- */
- function (xliff, url) {
- this._unitMlString = null;
- this._msgIdToHtml = {};
- var /** @type {?} */ xml = new XmlParser().parse(xliff, url, false);
- this._errors = xml.errors;
- visitAll(this, xml.rootNodes, null);
- return {
- msgIdToHtml: this._msgIdToHtml,
- errors: this._errors,
- locale: this._locale,
- };
- };
- /**
- * @param {?} element
- * @param {?} context
- * @return {?}
- */
- XliffParser.prototype.visitElement = /**
- * @param {?} element
- * @param {?} context
- * @return {?}
- */
- function (element, context) {
- switch (element.name) {
- case _UNIT_TAG:
- this._unitMlString = /** @type {?} */ ((null));
- var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
- if (!idAttr) {
- this._addError(element, "<" + _UNIT_TAG + "> misses the \"id\" attribute");
- }
- else {
- var /** @type {?} */ id = idAttr.value;
- if (this._msgIdToHtml.hasOwnProperty(id)) {
- this._addError(element, "Duplicated translations for msg " + id);
- }
- else {
- visitAll(this, element.children, null);
- if (typeof this._unitMlString === 'string') {
- this._msgIdToHtml[id] = this._unitMlString;
- }
- else {
- this._addError(element, "Message " + id + " misses a translation");
- }
- }
- }
- break;
- // ignore those tags
- case _SOURCE_TAG:
- case _SEGMENT_SOURCE_TAG:
- break;
- case _TARGET_TAG:
- var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset;
- var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset;
- var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content;
- var /** @type {?} */ innerText = content.slice(innerTextStart, innerTextEnd);
- this._unitMlString = innerText;
- break;
- case _FILE_TAG:
- var /** @type {?} */ localeAttr = element.attrs.find(function (attr) { return attr.name === 'target-language'; });
- if (localeAttr) {
- this._locale = localeAttr.value;
- }
- visitAll(this, element.children, null);
- break;
- default:
- // TODO(vicb): assert file structure, xliff version
- // For now only recurse on unhandled nodes
- visitAll(this, element.children, null);
- }
- };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- XliffParser.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) { };
- /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- XliffParser.prototype.visitText = /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- function (text, context) { };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- XliffParser.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) { };
- /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- XliffParser.prototype.visitExpansion = /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- function (expansion, context) { };
- /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- XliffParser.prototype.visitExpansionCase = /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- function (expansionCase, context) { };
- /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- XliffParser.prototype._addError = /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- function (node, message) {
- this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
- };
- return XliffParser;
- }());
- var XmlToI18n = /** @class */ (function () {
- function XmlToI18n() {
- }
- /**
- * @param {?} message
- * @param {?} url
- * @return {?}
- */
- XmlToI18n.prototype.convert = /**
- * @param {?} message
- * @param {?} url
- * @return {?}
- */
- function (message, url) {
- var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
- this._errors = xmlIcu.errors;
- var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
- [] : [].concat.apply([], visitAll(this, xmlIcu.rootNodes));
- return {
- i18nNodes: i18nNodes,
- errors: this._errors,
- };
- };
- /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitText = /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- function (text, context) { return new Text$1(text.value, /** @type {?} */ ((text.sourceSpan))); };
- /**
- * @param {?} el
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitElement = /**
- * @param {?} el
- * @param {?} context
- * @return {?}
- */
- function (el, context) {
- if (el.name === _PLACEHOLDER_TAG) {
- var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'id'; });
- if (nameAttr) {
- return new Placeholder('', nameAttr.value, /** @type {?} */ ((el.sourceSpan)));
- }
- this._addError(el, "<" + _PLACEHOLDER_TAG + "> misses the \"id\" attribute");
- return null;
- }
- if (el.name === _MARKER_TAG) {
- return [].concat.apply([], visitAll(this, el.children));
- }
- this._addError(el, "Unexpected tag");
- return null;
- };
- /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitExpansion = /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- function (icu, context) {
- var /** @type {?} */ caseMap = {};
- visitAll(this, icu.cases).forEach(function (c) {
- caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
- });
- return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
- };
- /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitExpansionCase = /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- function (icuCase, context) {
- return {
- value: icuCase.value,
- nodes: visitAll(this, icuCase.expression),
- };
- };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) { };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) { };
- /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- XmlToI18n.prototype._addError = /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- function (node, message) {
- this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
- };
- return XmlToI18n;
- }());
- /**
- * @param {?} tag
- * @return {?}
- */
- function getCtypeForTag(tag) {
- switch (tag.toLowerCase()) {
- case 'br':
- return 'lb';
- case 'img':
- return 'image';
- default:
- return "x-" + tag;
- }
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _VERSION$1 = '2.0';
- var _XMLNS$1 = 'urn:oasis:names:tc:xliff:document:2.0';
- // TODO(vicb): make this a param (s/_/-/)
- var _DEFAULT_SOURCE_LANG$1 = 'en';
- var _PLACEHOLDER_TAG$1 = 'ph';
- var _PLACEHOLDER_SPANNING_TAG = 'pc';
- var _MARKER_TAG$1 = 'mrk';
- var _XLIFF_TAG = 'xliff';
- var _SOURCE_TAG$1 = 'source';
- var _TARGET_TAG$1 = 'target';
- var _UNIT_TAG$1 = 'unit';
- var Xliff2 = /** @class */ (function (_super) {
- __extends(Xliff2, _super);
- function Xliff2() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} messages
- * @param {?} locale
- * @return {?}
- */
- Xliff2.prototype.write = /**
- * @param {?} messages
- * @param {?} locale
- * @return {?}
- */
- function (messages, locale) {
- var /** @type {?} */ visitor = new _WriteVisitor$1();
- var /** @type {?} */ units = [];
- messages.forEach(function (message) {
- var /** @type {?} */ unit = new Tag(_UNIT_TAG$1, { id: message.id });
- var /** @type {?} */ notes = new Tag('notes');
- if (message.description || message.meaning) {
- if (message.description) {
- notes.children.push(new CR(8), new Tag('note', { category: 'description' }, [new Text$2(message.description)]));
- }
- if (message.meaning) {
- notes.children.push(new CR(8), new Tag('note', { category: 'meaning' }, [new Text$2(message.meaning)]));
- }
- }
- message.sources.forEach(function (source) {
- notes.children.push(new CR(8), new Tag('note', { category: 'location' }, [
- new Text$2(source.filePath + ":" + source.startLine + (source.endLine !== source.startLine ? ',' + source.endLine : ''))
- ]));
- });
- notes.children.push(new CR(6));
- unit.children.push(new CR(6), notes);
- var /** @type {?} */ segment = new Tag('segment');
- segment.children.push(new CR(8), new Tag(_SOURCE_TAG$1, {}, visitor.serialize(message.nodes)), new CR(6));
- unit.children.push(new CR(6), segment, new CR(4));
- units.push(new CR(4), unit);
- });
- var /** @type {?} */ file = new Tag('file', { 'original': 'ng.template', id: 'ngi18n' }, units.concat([new CR(2)]));
- var /** @type {?} */ xliff = new Tag(_XLIFF_TAG, { version: _VERSION$1, xmlns: _XMLNS$1, srcLang: locale || _DEFAULT_SOURCE_LANG$1 }, [new CR(2), file, new CR()]);
- return serialize([
- new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), xliff, new CR()
- ]);
- };
- /**
- * @param {?} content
- * @param {?} url
- * @return {?}
- */
- Xliff2.prototype.load = /**
- * @param {?} content
- * @param {?} url
- * @return {?}
- */
- function (content, url) {
- // xliff to xml nodes
- var /** @type {?} */ xliff2Parser = new Xliff2Parser();
- var _a = xliff2Parser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
- // xml nodes to i18n nodes
- var /** @type {?} */ i18nNodesByMsgId = {};
- var /** @type {?} */ converter = new XmlToI18n$1();
- Object.keys(msgIdToHtml).forEach(function (msgId) {
- var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, e = _a.errors;
- errors.push.apply(errors, e);
- i18nNodesByMsgId[msgId] = i18nNodes;
- });
- if (errors.length) {
- throw new Error("xliff2 parse errors:\n" + errors.join('\n'));
- }
- return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
- };
- /**
- * @param {?} message
- * @return {?}
- */
- Xliff2.prototype.digest = /**
- * @param {?} message
- * @return {?}
- */
- function (message) { return decimalDigest(message); };
- return Xliff2;
- }(Serializer));
- var _WriteVisitor$1 = /** @class */ (function () {
- function _WriteVisitor() {
- }
- /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitText = /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- function (text, context) { return [new Text$2(text.value)]; };
- /**
- * @param {?} container
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitContainer = /**
- * @param {?} container
- * @param {?=} context
- * @return {?}
- */
- function (container, context) {
- var _this = this;
- var /** @type {?} */ nodes = [];
- container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
- return nodes;
- };
- /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitIcu = /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- function (icu, context) {
- var _this = this;
- var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
- Object.keys(icu.cases).forEach(function (c) {
- nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
- });
- nodes.push(new Text$2("}"));
- return nodes;
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitTagPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var _this = this;
- var /** @type {?} */ type = getTypeForTag(ph.tag);
- if (ph.isVoid) {
- var /** @type {?} */ tagPh = new Tag(_PLACEHOLDER_TAG$1, {
- id: (this._nextPlaceholderId++).toString(),
- equiv: ph.startName,
- type: type,
- disp: "<" + ph.tag + "/>",
- });
- return [tagPh];
- }
- var /** @type {?} */ tagPc = new Tag(_PLACEHOLDER_SPANNING_TAG, {
- id: (this._nextPlaceholderId++).toString(),
- equivStart: ph.startName,
- equivEnd: ph.closeName,
- type: type,
- dispStart: "<" + ph.tag + ">",
- dispEnd: "</" + ph.tag + ">",
- });
- var /** @type {?} */ nodes = [].concat.apply([], ph.children.map(function (node) { return node.visit(_this); }));
- if (nodes.length) {
- nodes.forEach(function (node) { return tagPc.children.push(node); });
- }
- else {
- tagPc.children.push(new Text$2(''));
- }
- return [tagPc];
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var /** @type {?} */ idStr = (this._nextPlaceholderId++).toString();
- return [new Tag(_PLACEHOLDER_TAG$1, {
- id: idStr,
- equiv: ph.name,
- disp: "{{" + ph.value + "}}",
- })];
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- _WriteVisitor.prototype.visitIcuPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var /** @type {?} */ cases = Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' ');
- var /** @type {?} */ idStr = (this._nextPlaceholderId++).toString();
- return [new Tag(_PLACEHOLDER_TAG$1, { id: idStr, equiv: ph.name, disp: "{" + ph.value.expression + ", " + ph.value.type + ", " + cases + "}" })];
- };
- /**
- * @param {?} nodes
- * @return {?}
- */
- _WriteVisitor.prototype.serialize = /**
- * @param {?} nodes
- * @return {?}
- */
- function (nodes) {
- var _this = this;
- this._nextPlaceholderId = 0;
- return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
- };
- return _WriteVisitor;
- }());
- var Xliff2Parser = /** @class */ (function () {
- function Xliff2Parser() {
- this._locale = null;
- }
- /**
- * @param {?} xliff
- * @param {?} url
- * @return {?}
- */
- Xliff2Parser.prototype.parse = /**
- * @param {?} xliff
- * @param {?} url
- * @return {?}
- */
- function (xliff, url) {
- this._unitMlString = null;
- this._msgIdToHtml = {};
- var /** @type {?} */ xml = new XmlParser().parse(xliff, url, false);
- this._errors = xml.errors;
- visitAll(this, xml.rootNodes, null);
- return {
- msgIdToHtml: this._msgIdToHtml,
- errors: this._errors,
- locale: this._locale,
- };
- };
- /**
- * @param {?} element
- * @param {?} context
- * @return {?}
- */
- Xliff2Parser.prototype.visitElement = /**
- * @param {?} element
- * @param {?} context
- * @return {?}
- */
- function (element, context) {
- switch (element.name) {
- case _UNIT_TAG$1:
- this._unitMlString = null;
- var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
- if (!idAttr) {
- this._addError(element, "<" + _UNIT_TAG$1 + "> misses the \"id\" attribute");
- }
- else {
- var /** @type {?} */ id = idAttr.value;
- if (this._msgIdToHtml.hasOwnProperty(id)) {
- this._addError(element, "Duplicated translations for msg " + id);
- }
- else {
- visitAll(this, element.children, null);
- if (typeof this._unitMlString === 'string') {
- this._msgIdToHtml[id] = this._unitMlString;
- }
- else {
- this._addError(element, "Message " + id + " misses a translation");
- }
- }
- }
- break;
- case _SOURCE_TAG$1:
- // ignore source message
- break;
- case _TARGET_TAG$1:
- var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset;
- var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset;
- var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content;
- var /** @type {?} */ innerText = content.slice(innerTextStart, innerTextEnd);
- this._unitMlString = innerText;
- break;
- case _XLIFF_TAG:
- var /** @type {?} */ localeAttr = element.attrs.find(function (attr) { return attr.name === 'trgLang'; });
- if (localeAttr) {
- this._locale = localeAttr.value;
- }
- var /** @type {?} */ versionAttr = element.attrs.find(function (attr) { return attr.name === 'version'; });
- if (versionAttr) {
- var /** @type {?} */ version = versionAttr.value;
- if (version !== '2.0') {
- this._addError(element, "The XLIFF file version " + version + " is not compatible with XLIFF 2.0 serializer");
- }
- else {
- visitAll(this, element.children, null);
- }
- }
- break;
- default:
- visitAll(this, element.children, null);
- }
- };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- Xliff2Parser.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) { };
- /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- Xliff2Parser.prototype.visitText = /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- function (text, context) { };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- Xliff2Parser.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) { };
- /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- Xliff2Parser.prototype.visitExpansion = /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- function (expansion, context) { };
- /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- Xliff2Parser.prototype.visitExpansionCase = /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- function (expansionCase, context) { };
- /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- Xliff2Parser.prototype._addError = /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- function (node, message) {
- this._errors.push(new I18nError(node.sourceSpan, message));
- };
- return Xliff2Parser;
- }());
- var XmlToI18n$1 = /** @class */ (function () {
- function XmlToI18n() {
- }
- /**
- * @param {?} message
- * @param {?} url
- * @return {?}
- */
- XmlToI18n.prototype.convert = /**
- * @param {?} message
- * @param {?} url
- * @return {?}
- */
- function (message, url) {
- var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
- this._errors = xmlIcu.errors;
- var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
- [] : [].concat.apply([], visitAll(this, xmlIcu.rootNodes));
- return {
- i18nNodes: i18nNodes,
- errors: this._errors,
- };
- };
- /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitText = /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- function (text, context) { return new Text$1(text.value, text.sourceSpan); };
- /**
- * @param {?} el
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitElement = /**
- * @param {?} el
- * @param {?} context
- * @return {?}
- */
- function (el, context) {
- var _this = this;
- switch (el.name) {
- case _PLACEHOLDER_TAG$1:
- var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'equiv'; });
- if (nameAttr) {
- return [new Placeholder('', nameAttr.value, el.sourceSpan)];
- }
- this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equiv\" attribute");
- break;
- case _PLACEHOLDER_SPANNING_TAG:
- var /** @type {?} */ startAttr = el.attrs.find(function (attr) { return attr.name === 'equivStart'; });
- var /** @type {?} */ endAttr = el.attrs.find(function (attr) { return attr.name === 'equivEnd'; });
- if (!startAttr) {
- this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equivStart\" attribute");
- }
- else if (!endAttr) {
- this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equivEnd\" attribute");
- }
- else {
- var /** @type {?} */ startId = startAttr.value;
- var /** @type {?} */ endId = endAttr.value;
- var /** @type {?} */ nodes = [];
- return nodes.concat.apply(nodes, [new Placeholder('', startId, el.sourceSpan)].concat(el.children.map(function (node) { return node.visit(_this, null); }), [new Placeholder('', endId, el.sourceSpan)]));
- }
- break;
- case _MARKER_TAG$1:
- return [].concat.apply([], visitAll(this, el.children));
- default:
- this._addError(el, "Unexpected tag");
- }
- return null;
- };
- /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitExpansion = /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- function (icu, context) {
- var /** @type {?} */ caseMap = {};
- visitAll(this, icu.cases).forEach(function (c) {
- caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
- });
- return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
- };
- /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitExpansionCase = /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- function (icuCase, context) {
- return {
- value: icuCase.value,
- nodes: [].concat.apply([], visitAll(this, icuCase.expression)),
- };
- };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) { };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) { };
- /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- XmlToI18n.prototype._addError = /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- function (node, message) {
- this._errors.push(new I18nError(node.sourceSpan, message));
- };
- return XmlToI18n;
- }());
- /**
- * @param {?} tag
- * @return {?}
- */
- function getTypeForTag(tag) {
- switch (tag.toLowerCase()) {
- case 'br':
- case 'b':
- case 'i':
- case 'u':
- return 'fmt';
- case 'img':
- return 'image';
- case 'a':
- return 'link';
- default:
- return 'other';
- }
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _MESSAGES_TAG = 'messagebundle';
- var _MESSAGE_TAG = 'msg';
- var _PLACEHOLDER_TAG$2 = 'ph';
- var _EXEMPLE_TAG = 'ex';
- var _SOURCE_TAG$2 = 'source';
- var _DOCTYPE = "<!ELEMENT messagebundle (msg)*>\n<!ATTLIST messagebundle class CDATA #IMPLIED>\n\n<!ELEMENT msg (#PCDATA|ph|source)*>\n<!ATTLIST msg id CDATA #IMPLIED>\n<!ATTLIST msg seq CDATA #IMPLIED>\n<!ATTLIST msg name CDATA #IMPLIED>\n<!ATTLIST msg desc CDATA #IMPLIED>\n<!ATTLIST msg meaning CDATA #IMPLIED>\n<!ATTLIST msg obsolete (obsolete) #IMPLIED>\n<!ATTLIST msg xml:space (default|preserve) \"default\">\n<!ATTLIST msg is_hidden CDATA #IMPLIED>\n\n<!ELEMENT source (#PCDATA)>\n\n<!ELEMENT ph (#PCDATA|ex)*>\n<!ATTLIST ph name CDATA #REQUIRED>\n\n<!ELEMENT ex (#PCDATA)>";
- var Xmb = /** @class */ (function (_super) {
- __extends(Xmb, _super);
- function Xmb() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} messages
- * @param {?} locale
- * @return {?}
- */
- Xmb.prototype.write = /**
- * @param {?} messages
- * @param {?} locale
- * @return {?}
- */
- function (messages, locale) {
- var /** @type {?} */ exampleVisitor = new ExampleVisitor();
- var /** @type {?} */ visitor = new _Visitor$2();
- var /** @type {?} */ rootNode = new Tag(_MESSAGES_TAG);
- messages.forEach(function (message) {
- var /** @type {?} */ attrs = { id: message.id };
- if (message.description) {
- attrs['desc'] = message.description;
- }
- if (message.meaning) {
- attrs['meaning'] = message.meaning;
- }
- var /** @type {?} */ sourceTags = [];
- message.sources.forEach(function (source) {
- sourceTags.push(new Tag(_SOURCE_TAG$2, {}, [
- new Text$2(source.filePath + ":" + source.startLine + (source.endLine !== source.startLine ? ',' + source.endLine : ''))
- ]));
- });
- rootNode.children.push(new CR(2), new Tag(_MESSAGE_TAG, attrs, sourceTags.concat(visitor.serialize(message.nodes))));
- });
- rootNode.children.push(new CR());
- return serialize([
- new Declaration({ version: '1.0', encoding: 'UTF-8' }),
- new CR(),
- new Doctype(_MESSAGES_TAG, _DOCTYPE),
- new CR(),
- exampleVisitor.addDefaultExamples(rootNode),
- new CR(),
- ]);
- };
- /**
- * @param {?} content
- * @param {?} url
- * @return {?}
- */
- Xmb.prototype.load = /**
- * @param {?} content
- * @param {?} url
- * @return {?}
- */
- function (content, url) {
- throw new Error('Unsupported');
- };
- /**
- * @param {?} message
- * @return {?}
- */
- Xmb.prototype.digest = /**
- * @param {?} message
- * @return {?}
- */
- function (message) { return digest$1(message); };
- /**
- * @param {?} message
- * @return {?}
- */
- Xmb.prototype.createNameMapper = /**
- * @param {?} message
- * @return {?}
- */
- function (message) {
- return new SimplePlaceholderMapper(message, toPublicName);
- };
- return Xmb;
- }(Serializer));
- var _Visitor$2 = /** @class */ (function () {
- function _Visitor() {
- }
- /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- _Visitor.prototype.visitText = /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- function (text, context) { return [new Text$2(text.value)]; };
- /**
- * @param {?} container
- * @param {?} context
- * @return {?}
- */
- _Visitor.prototype.visitContainer = /**
- * @param {?} container
- * @param {?} context
- * @return {?}
- */
- function (container, context) {
- var _this = this;
- var /** @type {?} */ nodes = [];
- container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
- return nodes;
- };
- /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- _Visitor.prototype.visitIcu = /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- function (icu, context) {
- var _this = this;
- var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
- Object.keys(icu.cases).forEach(function (c) {
- nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
- });
- nodes.push(new Text$2("}"));
- return nodes;
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- _Visitor.prototype.visitTagPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var /** @type {?} */ startEx = new Tag(_EXEMPLE_TAG, {}, [new Text$2("<" + ph.tag + ">")]);
- var /** @type {?} */ startTagPh = new Tag(_PLACEHOLDER_TAG$2, { name: ph.startName }, [startEx]);
- if (ph.isVoid) {
- // void tags have no children nor closing tags
- return [startTagPh];
- }
- var /** @type {?} */ closeEx = new Tag(_EXEMPLE_TAG, {}, [new Text$2("</" + ph.tag + ">")]);
- var /** @type {?} */ closeTagPh = new Tag(_PLACEHOLDER_TAG$2, { name: ph.closeName }, [closeEx]);
- return [startTagPh].concat(this.serialize(ph.children), [closeTagPh]);
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- _Visitor.prototype.visitPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var /** @type {?} */ exTag = new Tag(_EXEMPLE_TAG, {}, [new Text$2("{{" + ph.value + "}}")]);
- return [new Tag(_PLACEHOLDER_TAG$2, { name: ph.name }, [exTag])];
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- _Visitor.prototype.visitIcuPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var /** @type {?} */ exTag = new Tag(_EXEMPLE_TAG, {}, [
- new Text$2("{" + ph.value.expression + ", " + ph.value.type + ", " + Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' ') + "}")
- ]);
- return [new Tag(_PLACEHOLDER_TAG$2, { name: ph.name }, [exTag])];
- };
- /**
- * @param {?} nodes
- * @return {?}
- */
- _Visitor.prototype.serialize = /**
- * @param {?} nodes
- * @return {?}
- */
- function (nodes) {
- var _this = this;
- return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
- };
- return _Visitor;
- }());
- /**
- * @param {?} message
- * @return {?}
- */
- function digest$1(message) {
- return decimalDigest(message);
- }
- var ExampleVisitor = /** @class */ (function () {
- function ExampleVisitor() {
- }
- /**
- * @param {?} node
- * @return {?}
- */
- ExampleVisitor.prototype.addDefaultExamples = /**
- * @param {?} node
- * @return {?}
- */
- function (node) {
- node.visit(this);
- return node;
- };
- /**
- * @param {?} tag
- * @return {?}
- */
- ExampleVisitor.prototype.visitTag = /**
- * @param {?} tag
- * @return {?}
- */
- function (tag) {
- var _this = this;
- if (tag.name === _PLACEHOLDER_TAG$2) {
- if (!tag.children || tag.children.length == 0) {
- var /** @type {?} */ exText = new Text$2(tag.attrs['name'] || '...');
- tag.children = [new Tag(_EXEMPLE_TAG, {}, [exText])];
- }
- }
- else if (tag.children) {
- tag.children.forEach(function (node) { return node.visit(_this); });
- }
- };
- /**
- * @param {?} text
- * @return {?}
- */
- ExampleVisitor.prototype.visitText = /**
- * @param {?} text
- * @return {?}
- */
- function (text) { };
- /**
- * @param {?} decl
- * @return {?}
- */
- ExampleVisitor.prototype.visitDeclaration = /**
- * @param {?} decl
- * @return {?}
- */
- function (decl) { };
- /**
- * @param {?} doctype
- * @return {?}
- */
- ExampleVisitor.prototype.visitDoctype = /**
- * @param {?} doctype
- * @return {?}
- */
- function (doctype) { };
- return ExampleVisitor;
- }());
- /**
- * @param {?} internalName
- * @return {?}
- */
- function toPublicName(internalName) {
- return internalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_');
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _TRANSLATIONS_TAG = 'translationbundle';
- var _TRANSLATION_TAG = 'translation';
- var _PLACEHOLDER_TAG$3 = 'ph';
- var Xtb = /** @class */ (function (_super) {
- __extends(Xtb, _super);
- function Xtb() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} messages
- * @param {?} locale
- * @return {?}
- */
- Xtb.prototype.write = /**
- * @param {?} messages
- * @param {?} locale
- * @return {?}
- */
- function (messages, locale) { throw new Error('Unsupported'); };
- /**
- * @param {?} content
- * @param {?} url
- * @return {?}
- */
- Xtb.prototype.load = /**
- * @param {?} content
- * @param {?} url
- * @return {?}
- */
- function (content, url) {
- // xtb to xml nodes
- var /** @type {?} */ xtbParser = new XtbParser();
- var _a = xtbParser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
- // xml nodes to i18n nodes
- var /** @type {?} */ i18nNodesByMsgId = {};
- var /** @type {?} */ converter = new XmlToI18n$2();
- // Because we should be able to load xtb files that rely on features not supported by angular,
- // we need to delay the conversion of html to i18n nodes so that non angular messages are not
- // converted
- Object.keys(msgIdToHtml).forEach(function (msgId) {
- var /** @type {?} */ valueFn = function () {
- var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, errors = _a.errors;
- if (errors.length) {
- throw new Error("xtb parse errors:\n" + errors.join('\n'));
- }
- return i18nNodes;
- };
- createLazyProperty(i18nNodesByMsgId, msgId, valueFn);
- });
- if (errors.length) {
- throw new Error("xtb parse errors:\n" + errors.join('\n'));
- }
- return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
- };
- /**
- * @param {?} message
- * @return {?}
- */
- Xtb.prototype.digest = /**
- * @param {?} message
- * @return {?}
- */
- function (message) { return digest$1(message); };
- /**
- * @param {?} message
- * @return {?}
- */
- Xtb.prototype.createNameMapper = /**
- * @param {?} message
- * @return {?}
- */
- function (message) {
- return new SimplePlaceholderMapper(message, toPublicName);
- };
- return Xtb;
- }(Serializer));
- /**
- * @param {?} messages
- * @param {?} id
- * @param {?} valueFn
- * @return {?}
- */
- function createLazyProperty(messages, id, valueFn) {
- Object.defineProperty(messages, id, {
- configurable: true,
- enumerable: true,
- get: function () {
- var /** @type {?} */ value = valueFn();
- Object.defineProperty(messages, id, { enumerable: true, value: value });
- return value;
- },
- set: function (_) { throw new Error('Could not overwrite an XTB translation'); },
- });
- }
- var XtbParser = /** @class */ (function () {
- function XtbParser() {
- this._locale = null;
- }
- /**
- * @param {?} xtb
- * @param {?} url
- * @return {?}
- */
- XtbParser.prototype.parse = /**
- * @param {?} xtb
- * @param {?} url
- * @return {?}
- */
- function (xtb, url) {
- this._bundleDepth = 0;
- this._msgIdToHtml = {};
- // We can not parse the ICU messages at this point as some messages might not originate
- // from Angular that could not be lex'd.
- var /** @type {?} */ xml = new XmlParser().parse(xtb, url, false);
- this._errors = xml.errors;
- visitAll(this, xml.rootNodes);
- return {
- msgIdToHtml: this._msgIdToHtml,
- errors: this._errors,
- locale: this._locale,
- };
- };
- /**
- * @param {?} element
- * @param {?} context
- * @return {?}
- */
- XtbParser.prototype.visitElement = /**
- * @param {?} element
- * @param {?} context
- * @return {?}
- */
- function (element, context) {
- switch (element.name) {
- case _TRANSLATIONS_TAG:
- this._bundleDepth++;
- if (this._bundleDepth > 1) {
- this._addError(element, "<" + _TRANSLATIONS_TAG + "> elements can not be nested");
- }
- var /** @type {?} */ langAttr = element.attrs.find(function (attr) { return attr.name === 'lang'; });
- if (langAttr) {
- this._locale = langAttr.value;
- }
- visitAll(this, element.children, null);
- this._bundleDepth--;
- break;
- case _TRANSLATION_TAG:
- var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
- if (!idAttr) {
- this._addError(element, "<" + _TRANSLATION_TAG + "> misses the \"id\" attribute");
- }
- else {
- var /** @type {?} */ id = idAttr.value;
- if (this._msgIdToHtml.hasOwnProperty(id)) {
- this._addError(element, "Duplicated translations for msg " + id);
- }
- else {
- var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset;
- var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset;
- var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content;
- var /** @type {?} */ innerText = content.slice(/** @type {?} */ ((innerTextStart)), /** @type {?} */ ((innerTextEnd)));
- this._msgIdToHtml[id] = innerText;
- }
- }
- break;
- default:
- this._addError(element, 'Unexpected tag');
- }
- };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- XtbParser.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) { };
- /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- XtbParser.prototype.visitText = /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- function (text, context) { };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- XtbParser.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) { };
- /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- XtbParser.prototype.visitExpansion = /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- function (expansion, context) { };
- /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- XtbParser.prototype.visitExpansionCase = /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- function (expansionCase, context) { };
- /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- XtbParser.prototype._addError = /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- function (node, message) {
- this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
- };
- return XtbParser;
- }());
- var XmlToI18n$2 = /** @class */ (function () {
- function XmlToI18n() {
- }
- /**
- * @param {?} message
- * @param {?} url
- * @return {?}
- */
- XmlToI18n.prototype.convert = /**
- * @param {?} message
- * @param {?} url
- * @return {?}
- */
- function (message, url) {
- var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
- this._errors = xmlIcu.errors;
- var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
- [] :
- visitAll(this, xmlIcu.rootNodes);
- return {
- i18nNodes: i18nNodes,
- errors: this._errors,
- };
- };
- /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitText = /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- function (text, context) { return new Text$1(text.value, /** @type {?} */ ((text.sourceSpan))); };
- /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitExpansion = /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- function (icu, context) {
- var /** @type {?} */ caseMap = {};
- visitAll(this, icu.cases).forEach(function (c) {
- caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
- });
- return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
- };
- /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitExpansionCase = /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- function (icuCase, context) {
- return {
- value: icuCase.value,
- nodes: visitAll(this, icuCase.expression),
- };
- };
- /**
- * @param {?} el
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitElement = /**
- * @param {?} el
- * @param {?} context
- * @return {?}
- */
- function (el, context) {
- if (el.name === _PLACEHOLDER_TAG$3) {
- var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'name'; });
- if (nameAttr) {
- return new Placeholder('', nameAttr.value, /** @type {?} */ ((el.sourceSpan)));
- }
- this._addError(el, "<" + _PLACEHOLDER_TAG$3 + "> misses the \"name\" attribute");
- }
- else {
- this._addError(el, "Unexpected tag");
- }
- return null;
- };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) { };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- XmlToI18n.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) { };
- /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- XmlToI18n.prototype._addError = /**
- * @param {?} node
- * @param {?} message
- * @return {?}
- */
- function (node, message) {
- this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
- };
- return XmlToI18n;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var HtmlParser = /** @class */ (function (_super) {
- __extends(HtmlParser, _super);
- function HtmlParser() {
- return _super.call(this, getHtmlTagDefinition) || this;
- }
- /**
- * @param {?} source
- * @param {?} url
- * @param {?=} parseExpansionForms
- * @param {?=} interpolationConfig
- * @return {?}
- */
- HtmlParser.prototype.parse = /**
- * @param {?} source
- * @param {?} url
- * @param {?=} parseExpansionForms
- * @param {?=} interpolationConfig
- * @return {?}
- */
- function (source, url, parseExpansionForms, interpolationConfig) {
- if (parseExpansionForms === void 0) { parseExpansionForms = false; }
- if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
- return _super.prototype.parse.call(this, source, url, parseExpansionForms, interpolationConfig);
- };
- return HtmlParser;
- }(Parser$1));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A container for translated messages
- */
- var TranslationBundle = /** @class */ (function () {
- function TranslationBundle(_i18nNodesByMsgId, locale, digest, mapperFactory, missingTranslationStrategy, console) {
- if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; }
- if (missingTranslationStrategy === void 0) { missingTranslationStrategy = MissingTranslationStrategy.Warning; }
- this._i18nNodesByMsgId = _i18nNodesByMsgId;
- this.digest = digest;
- this.mapperFactory = mapperFactory;
- this._i18nToHtml = new I18nToHtmlVisitor(_i18nNodesByMsgId, locale, digest, /** @type {?} */ ((mapperFactory)), missingTranslationStrategy, console);
- }
- // Creates a `TranslationBundle` by parsing the given `content` with the `serializer`.
- /**
- * @param {?} content
- * @param {?} url
- * @param {?} serializer
- * @param {?} missingTranslationStrategy
- * @param {?=} console
- * @return {?}
- */
- TranslationBundle.load = /**
- * @param {?} content
- * @param {?} url
- * @param {?} serializer
- * @param {?} missingTranslationStrategy
- * @param {?=} console
- * @return {?}
- */
- function (content, url, serializer, missingTranslationStrategy, console) {
- var _a = serializer.load(content, url), locale = _a.locale, i18nNodesByMsgId = _a.i18nNodesByMsgId;
- var /** @type {?} */ digestFn = function (m) { return serializer.digest(m); };
- var /** @type {?} */ mapperFactory = function (m) { return ((serializer.createNameMapper(m))); };
- return new TranslationBundle(i18nNodesByMsgId, locale, digestFn, mapperFactory, missingTranslationStrategy, console);
- };
- // Returns the translation as HTML nodes from the given source message.
- /**
- * @param {?} srcMsg
- * @return {?}
- */
- TranslationBundle.prototype.get = /**
- * @param {?} srcMsg
- * @return {?}
- */
- function (srcMsg) {
- var /** @type {?} */ html = this._i18nToHtml.convert(srcMsg);
- if (html.errors.length) {
- throw new Error(html.errors.join('\n'));
- }
- return html.nodes;
- };
- /**
- * @param {?} srcMsg
- * @return {?}
- */
- TranslationBundle.prototype.has = /**
- * @param {?} srcMsg
- * @return {?}
- */
- function (srcMsg) { return this.digest(srcMsg) in this._i18nNodesByMsgId; };
- return TranslationBundle;
- }());
- var I18nToHtmlVisitor = /** @class */ (function () {
- function I18nToHtmlVisitor(_i18nNodesByMsgId, _locale, _digest, _mapperFactory, _missingTranslationStrategy, _console) {
- if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; }
- this._i18nNodesByMsgId = _i18nNodesByMsgId;
- this._locale = _locale;
- this._digest = _digest;
- this._mapperFactory = _mapperFactory;
- this._missingTranslationStrategy = _missingTranslationStrategy;
- this._console = _console;
- this._contextStack = [];
- this._errors = [];
- }
- /**
- * @param {?} srcMsg
- * @return {?}
- */
- I18nToHtmlVisitor.prototype.convert = /**
- * @param {?} srcMsg
- * @return {?}
- */
- function (srcMsg) {
- this._contextStack.length = 0;
- this._errors.length = 0;
- // i18n to text
- var /** @type {?} */ text = this._convertToText(srcMsg);
- // text to html
- var /** @type {?} */ url = srcMsg.nodes[0].sourceSpan.start.file.url;
- var /** @type {?} */ html = new HtmlParser().parse(text, url, true);
- return {
- nodes: html.rootNodes,
- errors: this._errors.concat(html.errors),
- };
- };
- /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- I18nToHtmlVisitor.prototype.visitText = /**
- * @param {?} text
- * @param {?=} context
- * @return {?}
- */
- function (text, context) {
- // `convert()` uses an `HtmlParser` to return `html.Node`s
- // we should then make sure that any special characters are escaped
- return escapeXml(text.value);
- };
- /**
- * @param {?} container
- * @param {?=} context
- * @return {?}
- */
- I18nToHtmlVisitor.prototype.visitContainer = /**
- * @param {?} container
- * @param {?=} context
- * @return {?}
- */
- function (container, context) {
- var _this = this;
- return container.children.map(function (n) { return n.visit(_this); }).join('');
- };
- /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- I18nToHtmlVisitor.prototype.visitIcu = /**
- * @param {?} icu
- * @param {?=} context
- * @return {?}
- */
- function (icu, context) {
- var _this = this;
- var /** @type {?} */ cases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
- // TODO(vicb): Once all format switch to using expression placeholders
- // we should throw when the placeholder is not in the source message
- var /** @type {?} */ exp = this._srcMsg.placeholders.hasOwnProperty(icu.expression) ?
- this._srcMsg.placeholders[icu.expression] :
- icu.expression;
- return "{" + exp + ", " + icu.type + ", " + cases.join(' ') + "}";
- };
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- I18nToHtmlVisitor.prototype.visitPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var /** @type {?} */ phName = this._mapper(ph.name);
- if (this._srcMsg.placeholders.hasOwnProperty(phName)) {
- return this._srcMsg.placeholders[phName];
- }
- if (this._srcMsg.placeholderToMessage.hasOwnProperty(phName)) {
- return this._convertToText(this._srcMsg.placeholderToMessage[phName]);
- }
- this._addError(ph, "Unknown placeholder \"" + ph.name + "\"");
- return '';
- };
- // Loaded message contains only placeholders (vs tag and icu placeholders).
- // However when a translation can not be found, we need to serialize the source message
- // which can contain tag placeholders
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- I18nToHtmlVisitor.prototype.visitTagPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- var _this = this;
- var /** @type {?} */ tag = "" + ph.tag;
- var /** @type {?} */ attrs = Object.keys(ph.attrs).map(function (name) { return name + "=\"" + ph.attrs[name] + "\""; }).join(' ');
- if (ph.isVoid) {
- return "<" + tag + " " + attrs + "/>";
- }
- var /** @type {?} */ children = ph.children.map(function (c) { return c.visit(_this); }).join('');
- return "<" + tag + " " + attrs + ">" + children + "</" + tag + ">";
- };
- // Loaded message contains only placeholders (vs tag and icu placeholders).
- // However when a translation can not be found, we need to serialize the source message
- // which can contain tag placeholders
- /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- I18nToHtmlVisitor.prototype.visitIcuPlaceholder = /**
- * @param {?} ph
- * @param {?=} context
- * @return {?}
- */
- function (ph, context) {
- // An ICU placeholder references the source message to be serialized
- return this._convertToText(this._srcMsg.placeholderToMessage[ph.name]);
- };
- /**
- * Convert a source message to a translated text string:
- * - text nodes are replaced with their translation,
- * - placeholders are replaced with their content,
- * - ICU nodes are converted to ICU expressions.
- * @param {?} srcMsg
- * @return {?}
- */
- I18nToHtmlVisitor.prototype._convertToText = /**
- * Convert a source message to a translated text string:
- * - text nodes are replaced with their translation,
- * - placeholders are replaced with their content,
- * - ICU nodes are converted to ICU expressions.
- * @param {?} srcMsg
- * @return {?}
- */
- function (srcMsg) {
- var _this = this;
- var /** @type {?} */ id = this._digest(srcMsg);
- var /** @type {?} */ mapper = this._mapperFactory ? this._mapperFactory(srcMsg) : null;
- var /** @type {?} */ nodes;
- this._contextStack.push({ msg: this._srcMsg, mapper: this._mapper });
- this._srcMsg = srcMsg;
- if (this._i18nNodesByMsgId.hasOwnProperty(id)) {
- // When there is a translation use its nodes as the source
- // And create a mapper to convert serialized placeholder names to internal names
- nodes = this._i18nNodesByMsgId[id];
- this._mapper = function (name) { return mapper ? /** @type {?} */ ((mapper.toInternalName(name))) : name; };
- }
- else {
- // When no translation has been found
- // - report an error / a warning / nothing,
- // - use the nodes from the original message
- // - placeholders are already internal and need no mapper
- if (this._missingTranslationStrategy === MissingTranslationStrategy.Error) {
- var /** @type {?} */ ctx = this._locale ? " for locale \"" + this._locale + "\"" : '';
- this._addError(srcMsg.nodes[0], "Missing translation for message \"" + id + "\"" + ctx);
- }
- else if (this._console &&
- this._missingTranslationStrategy === MissingTranslationStrategy.Warning) {
- var /** @type {?} */ ctx = this._locale ? " for locale \"" + this._locale + "\"" : '';
- this._console.warn("Missing translation for message \"" + id + "\"" + ctx);
- }
- nodes = srcMsg.nodes;
- this._mapper = function (name) { return name; };
- }
- var /** @type {?} */ text = nodes.map(function (node) { return node.visit(_this); }).join('');
- var /** @type {?} */ context = /** @type {?} */ ((this._contextStack.pop()));
- this._srcMsg = context.msg;
- this._mapper = context.mapper;
- return text;
- };
- /**
- * @param {?} el
- * @param {?} msg
- * @return {?}
- */
- I18nToHtmlVisitor.prototype._addError = /**
- * @param {?} el
- * @param {?} msg
- * @return {?}
- */
- function (el, msg) {
- this._errors.push(new I18nError(el.sourceSpan, msg));
- };
- return I18nToHtmlVisitor;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var I18NHtmlParser = /** @class */ (function () {
- function I18NHtmlParser(_htmlParser, translations, translationsFormat, missingTranslation, console) {
- if (missingTranslation === void 0) { missingTranslation = MissingTranslationStrategy.Warning; }
- this._htmlParser = _htmlParser;
- if (translations) {
- var /** @type {?} */ serializer = createSerializer(translationsFormat);
- this._translationBundle =
- TranslationBundle.load(translations, 'i18n', serializer, missingTranslation, console);
- }
- else {
- this._translationBundle =
- new TranslationBundle({}, null, digest, undefined, missingTranslation, console);
- }
- }
- /**
- * @param {?} source
- * @param {?} url
- * @param {?=} parseExpansionForms
- * @param {?=} interpolationConfig
- * @return {?}
- */
- I18NHtmlParser.prototype.parse = /**
- * @param {?} source
- * @param {?} url
- * @param {?=} parseExpansionForms
- * @param {?=} interpolationConfig
- * @return {?}
- */
- function (source, url, parseExpansionForms, interpolationConfig) {
- if (parseExpansionForms === void 0) { parseExpansionForms = false; }
- if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
- var /** @type {?} */ parseResult = this._htmlParser.parse(source, url, parseExpansionForms, interpolationConfig);
- if (parseResult.errors.length) {
- return new ParseTreeResult(parseResult.rootNodes, parseResult.errors);
- }
- return mergeTranslations(parseResult.rootNodes, this._translationBundle, interpolationConfig, [], {});
- };
- return I18NHtmlParser;
- }());
- /**
- * @param {?=} format
- * @return {?}
- */
- function createSerializer(format) {
- format = (format || 'xlf').toLowerCase();
- switch (format) {
- case 'xmb':
- return new Xmb();
- case 'xtb':
- return new Xtb();
- case 'xliff2':
- case 'xlf2':
- return new Xliff2();
- case 'xliff':
- case 'xlf':
- default:
- return new Xliff();
- }
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var STRIP_SRC_FILE_SUFFIXES = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
- var GENERATED_FILE = /\.ngfactory\.|\.ngsummary\./;
- var JIT_SUMMARY_FILE = /\.ngsummary\./;
- var JIT_SUMMARY_NAME = /NgSummary$/;
- /**
- * @param {?} filePath
- * @param {?=} forceSourceFile
- * @return {?}
- */
- function ngfactoryFilePath(filePath, forceSourceFile) {
- if (forceSourceFile === void 0) { forceSourceFile = false; }
- var /** @type {?} */ urlWithSuffix = splitTypescriptSuffix(filePath, forceSourceFile);
- return urlWithSuffix[0] + ".ngfactory" + normalizeGenFileSuffix(urlWithSuffix[1]);
- }
- /**
- * @param {?} filePath
- * @return {?}
- */
- function stripGeneratedFileSuffix(filePath) {
- return filePath.replace(GENERATED_FILE, '.');
- }
- /**
- * @param {?} filePath
- * @return {?}
- */
- function isGeneratedFile(filePath) {
- return GENERATED_FILE.test(filePath);
- }
- /**
- * @param {?} path
- * @param {?=} forceSourceFile
- * @return {?}
- */
- function splitTypescriptSuffix(path, forceSourceFile) {
- if (forceSourceFile === void 0) { forceSourceFile = false; }
- if (path.endsWith('.d.ts')) {
- return [path.slice(0, -5), forceSourceFile ? '.ts' : '.d.ts'];
- }
- var /** @type {?} */ lastDot = path.lastIndexOf('.');
- if (lastDot !== -1) {
- return [path.substring(0, lastDot), path.substring(lastDot)];
- }
- return [path, ''];
- }
- /**
- * @param {?} srcFileSuffix
- * @return {?}
- */
- function normalizeGenFileSuffix(srcFileSuffix) {
- return srcFileSuffix === '.tsx' ? '.ts' : srcFileSuffix;
- }
- /**
- * @param {?} fileName
- * @return {?}
- */
- function summaryFileName(fileName) {
- var /** @type {?} */ fileNameWithoutSuffix = fileName.replace(STRIP_SRC_FILE_SUFFIXES, '');
- return fileNameWithoutSuffix + ".ngsummary.json";
- }
- /**
- * @param {?} fileName
- * @param {?=} forceSourceFile
- * @return {?}
- */
- function summaryForJitFileName(fileName, forceSourceFile) {
- if (forceSourceFile === void 0) { forceSourceFile = false; }
- var /** @type {?} */ urlWithSuffix = splitTypescriptSuffix(stripGeneratedFileSuffix(fileName), forceSourceFile);
- return urlWithSuffix[0] + ".ngsummary" + urlWithSuffix[1];
- }
- /**
- * @param {?} filePath
- * @return {?}
- */
- function stripSummaryForJitFileSuffix(filePath) {
- return filePath.replace(JIT_SUMMARY_FILE, '.');
- }
- /**
- * @param {?} symbolName
- * @return {?}
- */
- function summaryForJitName(symbolName) {
- return symbolName + "NgSummary";
- }
- /**
- * @param {?} symbolName
- * @return {?}
- */
- function stripSummaryForJitNameSuffix(symbolName) {
- return symbolName.replace(JIT_SUMMARY_NAME, '');
- }
- var LOWERED_SYMBOL = /\u0275\d+/;
- /**
- * @param {?} name
- * @return {?}
- */
- function isLoweredSymbol(name) {
- return LOWERED_SYMBOL.test(name);
- }
- /**
- * @param {?} id
- * @return {?}
- */
- function createLoweredSymbol(id) {
- return "\u0275" + id;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var CORE = '@angular/core';
- var Identifiers = /** @class */ (function () {
- function Identifiers() {
- }
- Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS = {
- name: 'ANALYZE_FOR_ENTRY_COMPONENTS',
- moduleName: CORE,
- };
- Identifiers.ElementRef = { name: 'ElementRef', moduleName: CORE };
- Identifiers.NgModuleRef = { name: 'NgModuleRef', moduleName: CORE };
- Identifiers.ViewContainerRef = { name: 'ViewContainerRef', moduleName: CORE };
- Identifiers.ChangeDetectorRef = {
- name: 'ChangeDetectorRef',
- moduleName: CORE,
- };
- Identifiers.QueryList = { name: 'QueryList', moduleName: CORE };
- Identifiers.TemplateRef = { name: 'TemplateRef', moduleName: CORE };
- Identifiers.CodegenComponentFactoryResolver = {
- name: 'ɵCodegenComponentFactoryResolver',
- moduleName: CORE,
- };
- Identifiers.ComponentFactoryResolver = {
- name: 'ComponentFactoryResolver',
- moduleName: CORE,
- };
- Identifiers.ComponentFactory = { name: 'ComponentFactory', moduleName: CORE };
- Identifiers.ComponentRef = { name: 'ComponentRef', moduleName: CORE };
- Identifiers.NgModuleFactory = { name: 'NgModuleFactory', moduleName: CORE };
- Identifiers.createModuleFactory = {
- name: 'ɵcmf',
- moduleName: CORE,
- };
- Identifiers.moduleDef = {
- name: 'ɵmod',
- moduleName: CORE,
- };
- Identifiers.moduleProviderDef = {
- name: 'ɵmpd',
- moduleName: CORE,
- };
- Identifiers.RegisterModuleFactoryFn = {
- name: 'ɵregisterModuleFactory',
- moduleName: CORE,
- };
- Identifiers.Injector = { name: 'Injector', moduleName: CORE };
- Identifiers.ViewEncapsulation = {
- name: 'ViewEncapsulation',
- moduleName: CORE,
- };
- Identifiers.ChangeDetectionStrategy = {
- name: 'ChangeDetectionStrategy',
- moduleName: CORE,
- };
- Identifiers.SecurityContext = {
- name: 'SecurityContext',
- moduleName: CORE,
- };
- Identifiers.LOCALE_ID = { name: 'LOCALE_ID', moduleName: CORE };
- Identifiers.TRANSLATIONS_FORMAT = {
- name: 'TRANSLATIONS_FORMAT',
- moduleName: CORE,
- };
- Identifiers.inlineInterpolate = {
- name: 'ɵinlineInterpolate',
- moduleName: CORE,
- };
- Identifiers.interpolate = { name: 'ɵinterpolate', moduleName: CORE };
- Identifiers.EMPTY_ARRAY = { name: 'ɵEMPTY_ARRAY', moduleName: CORE };
- Identifiers.EMPTY_MAP = { name: 'ɵEMPTY_MAP', moduleName: CORE };
- Identifiers.Renderer = { name: 'Renderer', moduleName: CORE };
- Identifiers.viewDef = { name: 'ɵvid', moduleName: CORE };
- Identifiers.elementDef = { name: 'ɵeld', moduleName: CORE };
- Identifiers.anchorDef = { name: 'ɵand', moduleName: CORE };
- Identifiers.textDef = { name: 'ɵted', moduleName: CORE };
- Identifiers.directiveDef = { name: 'ɵdid', moduleName: CORE };
- Identifiers.providerDef = { name: 'ɵprd', moduleName: CORE };
- Identifiers.queryDef = { name: 'ɵqud', moduleName: CORE };
- Identifiers.pureArrayDef = { name: 'ɵpad', moduleName: CORE };
- Identifiers.pureObjectDef = { name: 'ɵpod', moduleName: CORE };
- Identifiers.purePipeDef = { name: 'ɵppd', moduleName: CORE };
- Identifiers.pipeDef = { name: 'ɵpid', moduleName: CORE };
- Identifiers.nodeValue = { name: 'ɵnov', moduleName: CORE };
- Identifiers.ngContentDef = { name: 'ɵncd', moduleName: CORE };
- Identifiers.unwrapValue = { name: 'ɵunv', moduleName: CORE };
- Identifiers.createRendererType2 = { name: 'ɵcrt', moduleName: CORE };
- // type only
- Identifiers.RendererType2 = {
- name: 'RendererType2',
- moduleName: CORE,
- };
- // type only
- Identifiers.ViewDefinition = {
- name: 'ɵViewDefinition',
- moduleName: CORE,
- };
- Identifiers.createComponentFactory = { name: 'ɵccf', moduleName: CORE };
- return Identifiers;
- }());
- /**
- * @param {?} reference
- * @return {?}
- */
- function createTokenForReference(reference) {
- return { identifier: { reference: reference } };
- }
- /**
- * @param {?} reflector
- * @param {?} reference
- * @return {?}
- */
- function createTokenForExternalReference(reflector, reference) {
- return createTokenForReference(reflector.resolveExternalReference(reference));
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /** @enum {number} */
- var LifecycleHooks = {
- OnInit: 0,
- OnDestroy: 1,
- DoCheck: 2,
- OnChanges: 3,
- AfterContentInit: 4,
- AfterContentChecked: 5,
- AfterViewInit: 6,
- AfterViewChecked: 7,
- };
- LifecycleHooks[LifecycleHooks.OnInit] = "OnInit";
- LifecycleHooks[LifecycleHooks.OnDestroy] = "OnDestroy";
- LifecycleHooks[LifecycleHooks.DoCheck] = "DoCheck";
- LifecycleHooks[LifecycleHooks.OnChanges] = "OnChanges";
- LifecycleHooks[LifecycleHooks.AfterContentInit] = "AfterContentInit";
- LifecycleHooks[LifecycleHooks.AfterContentChecked] = "AfterContentChecked";
- LifecycleHooks[LifecycleHooks.AfterViewInit] = "AfterViewInit";
- LifecycleHooks[LifecycleHooks.AfterViewChecked] = "AfterViewChecked";
- var LIFECYCLE_HOOKS_VALUES = [
- LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges,
- LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit,
- LifecycleHooks.AfterViewChecked
- ];
- /**
- * @param {?} reflector
- * @param {?} hook
- * @param {?} token
- * @return {?}
- */
- function hasLifecycleHook(reflector, hook, token) {
- return reflector.hasLifecycleHook(token, getHookName(hook));
- }
- /**
- * @param {?} reflector
- * @param {?} token
- * @return {?}
- */
- function getAllLifecycleHooks(reflector, token) {
- return LIFECYCLE_HOOKS_VALUES.filter(function (hook) { return hasLifecycleHook(reflector, hook, token); });
- }
- /**
- * @param {?} hook
- * @return {?}
- */
- function getHookName(hook) {
- switch (hook) {
- case LifecycleHooks.OnInit:
- return 'ngOnInit';
- case LifecycleHooks.OnDestroy:
- return 'ngOnDestroy';
- case LifecycleHooks.DoCheck:
- return 'ngDoCheck';
- case LifecycleHooks.OnChanges:
- return 'ngOnChanges';
- case LifecycleHooks.AfterContentInit:
- return 'ngAfterContentInit';
- case LifecycleHooks.AfterContentChecked:
- return 'ngAfterContentChecked';
- case LifecycleHooks.AfterViewInit:
- return 'ngAfterViewInit';
- case LifecycleHooks.AfterViewChecked:
- return 'ngAfterViewChecked';
- }
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _SELECTOR_REGEXP = new RegExp('(\\:not\\()|' + //":not("
- '([-\\w]+)|' + // "tag"
- '(?:\\.([-\\w]+))|' + // ".class"
- '(?:\\[([-.\\w*]+)(?:=([\"\']?)([^\\]\"\']*)\\5)?\\])|' + // "[name]", "[name=value]",
- '(\\))|' + // ")"
- '(\\s*,\\s*)', // ","
- 'g');
- /**
- * A css selector contains an element name,
- * css classes and attribute/value pairs with the purpose
- * of selecting subsets out of them.
- */
- var CssSelector = /** @class */ (function () {
- function CssSelector() {
- this.element = null;
- this.classNames = [];
- this.attrs = [];
- this.notSelectors = [];
- }
- /**
- * @param {?} selector
- * @return {?}
- */
- CssSelector.parse = /**
- * @param {?} selector
- * @return {?}
- */
- function (selector) {
- var /** @type {?} */ results = [];
- var /** @type {?} */ _addResult = function (res, cssSel) {
- if (cssSel.notSelectors.length > 0 && !cssSel.element && cssSel.classNames.length == 0 &&
- cssSel.attrs.length == 0) {
- cssSel.element = '*';
- }
- res.push(cssSel);
- };
- var /** @type {?} */ cssSelector = new CssSelector();
- var /** @type {?} */ match;
- var /** @type {?} */ current = cssSelector;
- var /** @type {?} */ inNot = false;
- _SELECTOR_REGEXP.lastIndex = 0;
- while (match = _SELECTOR_REGEXP.exec(selector)) {
- if (match[1]) {
- if (inNot) {
- throw new Error('Nesting :not is not allowed in a selector');
- }
- inNot = true;
- current = new CssSelector();
- cssSelector.notSelectors.push(current);
- }
- if (match[2]) {
- current.setElement(match[2]);
- }
- if (match[3]) {
- current.addClassName(match[3]);
- }
- if (match[4]) {
- current.addAttribute(match[4], match[6]);
- }
- if (match[7]) {
- inNot = false;
- current = cssSelector;
- }
- if (match[8]) {
- if (inNot) {
- throw new Error('Multiple selectors in :not are not supported');
- }
- _addResult(results, cssSelector);
- cssSelector = current = new CssSelector();
- }
- }
- _addResult(results, cssSelector);
- return results;
- };
- /**
- * @return {?}
- */
- CssSelector.prototype.isElementSelector = /**
- * @return {?}
- */
- function () {
- return this.hasElementSelector() && this.classNames.length == 0 && this.attrs.length == 0 &&
- this.notSelectors.length === 0;
- };
- /**
- * @return {?}
- */
- CssSelector.prototype.hasElementSelector = /**
- * @return {?}
- */
- function () { return !!this.element; };
- /**
- * @param {?=} element
- * @return {?}
- */
- CssSelector.prototype.setElement = /**
- * @param {?=} element
- * @return {?}
- */
- function (element) {
- if (element === void 0) { element = null; }
- this.element = element;
- };
- /** Gets a template string for an element that matches the selector. */
- /**
- * Gets a template string for an element that matches the selector.
- * @return {?}
- */
- CssSelector.prototype.getMatchingElementTemplate = /**
- * Gets a template string for an element that matches the selector.
- * @return {?}
- */
- function () {
- var /** @type {?} */ tagName = this.element || 'div';
- var /** @type {?} */ classAttr = this.classNames.length > 0 ? " class=\"" + this.classNames.join(' ') + "\"" : '';
- var /** @type {?} */ attrs = '';
- for (var /** @type {?} */ i = 0; i < this.attrs.length; i += 2) {
- var /** @type {?} */ attrName = this.attrs[i];
- var /** @type {?} */ attrValue = this.attrs[i + 1] !== '' ? "=\"" + this.attrs[i + 1] + "\"" : '';
- attrs += " " + attrName + attrValue;
- }
- return getHtmlTagDefinition(tagName).isVoid ? "<" + tagName + classAttr + attrs + "/>" :
- "<" + tagName + classAttr + attrs + "></" + tagName + ">";
- };
- /**
- * @param {?} name
- * @param {?=} value
- * @return {?}
- */
- CssSelector.prototype.addAttribute = /**
- * @param {?} name
- * @param {?=} value
- * @return {?}
- */
- function (name, value) {
- if (value === void 0) { value = ''; }
- this.attrs.push(name, value && value.toLowerCase() || '');
- };
- /**
- * @param {?} name
- * @return {?}
- */
- CssSelector.prototype.addClassName = /**
- * @param {?} name
- * @return {?}
- */
- function (name) { this.classNames.push(name.toLowerCase()); };
- /**
- * @return {?}
- */
- CssSelector.prototype.toString = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ res = this.element || '';
- if (this.classNames) {
- this.classNames.forEach(function (klass) { return res += "." + klass; });
- }
- if (this.attrs) {
- for (var /** @type {?} */ i = 0; i < this.attrs.length; i += 2) {
- var /** @type {?} */ name_1 = this.attrs[i];
- var /** @type {?} */ value = this.attrs[i + 1];
- res += "[" + name_1 + (value ? '=' + value : '') + "]";
- }
- }
- this.notSelectors.forEach(function (notSelector) { return res += ":not(" + notSelector + ")"; });
- return res;
- };
- return CssSelector;
- }());
- /**
- * Reads a list of CssSelectors and allows to calculate which ones
- * are contained in a given CssSelector.
- */
- var SelectorMatcher = /** @class */ (function () {
- function SelectorMatcher() {
- this._elementMap = new Map();
- this._elementPartialMap = new Map();
- this._classMap = new Map();
- this._classPartialMap = new Map();
- this._attrValueMap = new Map();
- this._attrValuePartialMap = new Map();
- this._listContexts = [];
- }
- /**
- * @param {?} notSelectors
- * @return {?}
- */
- SelectorMatcher.createNotMatcher = /**
- * @param {?} notSelectors
- * @return {?}
- */
- function (notSelectors) {
- var /** @type {?} */ notMatcher = new SelectorMatcher();
- notMatcher.addSelectables(notSelectors, null);
- return notMatcher;
- };
- /**
- * @param {?} cssSelectors
- * @param {?=} callbackCtxt
- * @return {?}
- */
- SelectorMatcher.prototype.addSelectables = /**
- * @param {?} cssSelectors
- * @param {?=} callbackCtxt
- * @return {?}
- */
- function (cssSelectors, callbackCtxt) {
- var /** @type {?} */ listContext = /** @type {?} */ ((null));
- if (cssSelectors.length > 1) {
- listContext = new SelectorListContext(cssSelectors);
- this._listContexts.push(listContext);
- }
- for (var /** @type {?} */ i = 0; i < cssSelectors.length; i++) {
- this._addSelectable(cssSelectors[i], callbackCtxt, listContext);
- }
- };
- /**
- * Add an object that can be found later on by calling `match`.
- * @param {?} cssSelector A css selector
- * @param {?} callbackCtxt An opaque object that will be given to the callback of the `match` function
- * @param {?} listContext
- * @return {?}
- */
- SelectorMatcher.prototype._addSelectable = /**
- * Add an object that can be found later on by calling `match`.
- * @param {?} cssSelector A css selector
- * @param {?} callbackCtxt An opaque object that will be given to the callback of the `match` function
- * @param {?} listContext
- * @return {?}
- */
- function (cssSelector, callbackCtxt, listContext) {
- var /** @type {?} */ matcher = this;
- var /** @type {?} */ element = cssSelector.element;
- var /** @type {?} */ classNames = cssSelector.classNames;
- var /** @type {?} */ attrs = cssSelector.attrs;
- var /** @type {?} */ selectable = new SelectorContext(cssSelector, callbackCtxt, listContext);
- if (element) {
- var /** @type {?} */ isTerminal = attrs.length === 0 && classNames.length === 0;
- if (isTerminal) {
- this._addTerminal(matcher._elementMap, element, selectable);
- }
- else {
- matcher = this._addPartial(matcher._elementPartialMap, element);
- }
- }
- if (classNames) {
- for (var /** @type {?} */ i = 0; i < classNames.length; i++) {
- var /** @type {?} */ isTerminal = attrs.length === 0 && i === classNames.length - 1;
- var /** @type {?} */ className = classNames[i];
- if (isTerminal) {
- this._addTerminal(matcher._classMap, className, selectable);
- }
- else {
- matcher = this._addPartial(matcher._classPartialMap, className);
- }
- }
- }
- if (attrs) {
- for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) {
- var /** @type {?} */ isTerminal = i === attrs.length - 2;
- var /** @type {?} */ name_2 = attrs[i];
- var /** @type {?} */ value = attrs[i + 1];
- if (isTerminal) {
- var /** @type {?} */ terminalMap = matcher._attrValueMap;
- var /** @type {?} */ terminalValuesMap = terminalMap.get(name_2);
- if (!terminalValuesMap) {
- terminalValuesMap = new Map();
- terminalMap.set(name_2, terminalValuesMap);
- }
- this._addTerminal(terminalValuesMap, value, selectable);
- }
- else {
- var /** @type {?} */ partialMap = matcher._attrValuePartialMap;
- var /** @type {?} */ partialValuesMap = partialMap.get(name_2);
- if (!partialValuesMap) {
- partialValuesMap = new Map();
- partialMap.set(name_2, partialValuesMap);
- }
- matcher = this._addPartial(partialValuesMap, value);
- }
- }
- }
- };
- /**
- * @param {?} map
- * @param {?} name
- * @param {?} selectable
- * @return {?}
- */
- SelectorMatcher.prototype._addTerminal = /**
- * @param {?} map
- * @param {?} name
- * @param {?} selectable
- * @return {?}
- */
- function (map, name, selectable) {
- var /** @type {?} */ terminalList = map.get(name);
- if (!terminalList) {
- terminalList = [];
- map.set(name, terminalList);
- }
- terminalList.push(selectable);
- };
- /**
- * @param {?} map
- * @param {?} name
- * @return {?}
- */
- SelectorMatcher.prototype._addPartial = /**
- * @param {?} map
- * @param {?} name
- * @return {?}
- */
- function (map, name) {
- var /** @type {?} */ matcher = map.get(name);
- if (!matcher) {
- matcher = new SelectorMatcher();
- map.set(name, matcher);
- }
- return matcher;
- };
- /**
- * Find the objects that have been added via `addSelectable`
- * whose css selector is contained in the given css selector.
- * @param cssSelector A css selector
- * @param matchedCallback This callback will be called with the object handed into `addSelectable`
- * @return boolean true if a match was found
- */
- /**
- * Find the objects that have been added via `addSelectable`
- * whose css selector is contained in the given css selector.
- * @param {?} cssSelector A css selector
- * @param {?} matchedCallback This callback will be called with the object handed into `addSelectable`
- * @return {?} boolean true if a match was found
- */
- SelectorMatcher.prototype.match = /**
- * Find the objects that have been added via `addSelectable`
- * whose css selector is contained in the given css selector.
- * @param {?} cssSelector A css selector
- * @param {?} matchedCallback This callback will be called with the object handed into `addSelectable`
- * @return {?} boolean true if a match was found
- */
- function (cssSelector, matchedCallback) {
- var /** @type {?} */ result = false;
- var /** @type {?} */ element = /** @type {?} */ ((cssSelector.element));
- var /** @type {?} */ classNames = cssSelector.classNames;
- var /** @type {?} */ attrs = cssSelector.attrs;
- for (var /** @type {?} */ i = 0; i < this._listContexts.length; i++) {
- this._listContexts[i].alreadyMatched = false;
- }
- result = this._matchTerminal(this._elementMap, element, cssSelector, matchedCallback) || result;
- result = this._matchPartial(this._elementPartialMap, element, cssSelector, matchedCallback) ||
- result;
- if (classNames) {
- for (var /** @type {?} */ i = 0; i < classNames.length; i++) {
- var /** @type {?} */ className = classNames[i];
- result =
- this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result;
- result =
- this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) ||
- result;
- }
- }
- if (attrs) {
- for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) {
- var /** @type {?} */ name_3 = attrs[i];
- var /** @type {?} */ value = attrs[i + 1];
- var /** @type {?} */ terminalValuesMap = /** @type {?} */ ((this._attrValueMap.get(name_3)));
- if (value) {
- result =
- this._matchTerminal(terminalValuesMap, '', cssSelector, matchedCallback) || result;
- }
- result =
- this._matchTerminal(terminalValuesMap, value, cssSelector, matchedCallback) || result;
- var /** @type {?} */ partialValuesMap = /** @type {?} */ ((this._attrValuePartialMap.get(name_3)));
- if (value) {
- result = this._matchPartial(partialValuesMap, '', cssSelector, matchedCallback) || result;
- }
- result =
- this._matchPartial(partialValuesMap, value, cssSelector, matchedCallback) || result;
- }
- }
- return result;
- };
- /** @internal */
- /**
- * \@internal
- * @param {?} map
- * @param {?} name
- * @param {?} cssSelector
- * @param {?} matchedCallback
- * @return {?}
- */
- SelectorMatcher.prototype._matchTerminal = /**
- * \@internal
- * @param {?} map
- * @param {?} name
- * @param {?} cssSelector
- * @param {?} matchedCallback
- * @return {?}
- */
- function (map, name, cssSelector, matchedCallback) {
- if (!map || typeof name !== 'string') {
- return false;
- }
- var /** @type {?} */ selectables = map.get(name) || [];
- var /** @type {?} */ starSelectables = /** @type {?} */ ((map.get('*')));
- if (starSelectables) {
- selectables = selectables.concat(starSelectables);
- }
- if (selectables.length === 0) {
- return false;
- }
- var /** @type {?} */ selectable;
- var /** @type {?} */ result = false;
- for (var /** @type {?} */ i = 0; i < selectables.length; i++) {
- selectable = selectables[i];
- result = selectable.finalize(cssSelector, matchedCallback) || result;
- }
- return result;
- };
- /** @internal */
- /**
- * \@internal
- * @param {?} map
- * @param {?} name
- * @param {?} cssSelector
- * @param {?} matchedCallback
- * @return {?}
- */
- SelectorMatcher.prototype._matchPartial = /**
- * \@internal
- * @param {?} map
- * @param {?} name
- * @param {?} cssSelector
- * @param {?} matchedCallback
- * @return {?}
- */
- function (map, name, cssSelector, matchedCallback) {
- if (!map || typeof name !== 'string') {
- return false;
- }
- var /** @type {?} */ nestedSelector = map.get(name);
- if (!nestedSelector) {
- return false;
- }
- // TODO(perf): get rid of recursion and measure again
- // TODO(perf): don't pass the whole selector into the recursion,
- // but only the not processed parts
- return nestedSelector.match(cssSelector, matchedCallback);
- };
- return SelectorMatcher;
- }());
- var SelectorListContext = /** @class */ (function () {
- function SelectorListContext(selectors) {
- this.selectors = selectors;
- this.alreadyMatched = false;
- }
- return SelectorListContext;
- }());
- var SelectorContext = /** @class */ (function () {
- function SelectorContext(selector, cbContext, listContext) {
- this.selector = selector;
- this.cbContext = cbContext;
- this.listContext = listContext;
- this.notSelectors = selector.notSelectors;
- }
- /**
- * @param {?} cssSelector
- * @param {?} callback
- * @return {?}
- */
- SelectorContext.prototype.finalize = /**
- * @param {?} cssSelector
- * @param {?} callback
- * @return {?}
- */
- function (cssSelector, callback) {
- var /** @type {?} */ result = true;
- if (this.notSelectors.length > 0 && (!this.listContext || !this.listContext.alreadyMatched)) {
- var /** @type {?} */ notMatcher = SelectorMatcher.createNotMatcher(this.notSelectors);
- result = !notMatcher.match(cssSelector, null);
- }
- if (result && callback && (!this.listContext || !this.listContext.alreadyMatched)) {
- if (this.listContext) {
- this.listContext.alreadyMatched = true;
- }
- callback(this.selector, this.cbContext);
- }
- return result;
- };
- return SelectorContext;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var ERROR_COMPONENT_TYPE = 'ngComponentType';
- var CompileMetadataResolver = /** @class */ (function () {
- function CompileMetadataResolver(_config, _htmlParser, _ngModuleResolver, _directiveResolver, _pipeResolver, _summaryResolver, _schemaRegistry, _directiveNormalizer, _console, _staticSymbolCache, _reflector, _errorCollector) {
- this._config = _config;
- this._htmlParser = _htmlParser;
- this._ngModuleResolver = _ngModuleResolver;
- this._directiveResolver = _directiveResolver;
- this._pipeResolver = _pipeResolver;
- this._summaryResolver = _summaryResolver;
- this._schemaRegistry = _schemaRegistry;
- this._directiveNormalizer = _directiveNormalizer;
- this._console = _console;
- this._staticSymbolCache = _staticSymbolCache;
- this._reflector = _reflector;
- this._errorCollector = _errorCollector;
- this._nonNormalizedDirectiveCache = new Map();
- this._directiveCache = new Map();
- this._summaryCache = new Map();
- this._pipeCache = new Map();
- this._ngModuleCache = new Map();
- this._ngModuleOfTypes = new Map();
- }
- /**
- * @return {?}
- */
- CompileMetadataResolver.prototype.getReflector = /**
- * @return {?}
- */
- function () { return this._reflector; };
- /**
- * @param {?} type
- * @return {?}
- */
- CompileMetadataResolver.prototype.clearCacheFor = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- var /** @type {?} */ dirMeta = this._directiveCache.get(type);
- this._directiveCache.delete(type);
- this._nonNormalizedDirectiveCache.delete(type);
- this._summaryCache.delete(type);
- this._pipeCache.delete(type);
- this._ngModuleOfTypes.delete(type);
- // Clear all of the NgModule as they contain transitive information!
- this._ngModuleCache.clear();
- if (dirMeta) {
- this._directiveNormalizer.clearCacheFor(dirMeta);
- }
- };
- /**
- * @return {?}
- */
- CompileMetadataResolver.prototype.clearCache = /**
- * @return {?}
- */
- function () {
- this._directiveCache.clear();
- this._nonNormalizedDirectiveCache.clear();
- this._summaryCache.clear();
- this._pipeCache.clear();
- this._ngModuleCache.clear();
- this._ngModuleOfTypes.clear();
- this._directiveNormalizer.clearCache();
- };
- /**
- * @param {?} baseType
- * @param {?} name
- * @return {?}
- */
- CompileMetadataResolver.prototype._createProxyClass = /**
- * @param {?} baseType
- * @param {?} name
- * @return {?}
- */
- function (baseType, name) {
- var /** @type {?} */ delegate = null;
- var /** @type {?} */ proxyClass = /** @type {?} */ (function () {
- if (!delegate) {
- throw new Error("Illegal state: Class " + name + " for type " + stringify(baseType) + " is not compiled yet!");
- }
- return delegate.apply(this, arguments);
- });
- proxyClass.setDelegate = function (d) {
- delegate = d;
- (/** @type {?} */ (proxyClass)).prototype = d.prototype;
- };
- // Make stringify work correctly
- (/** @type {?} */ (proxyClass)).overriddenName = name;
- return proxyClass;
- };
- /**
- * @param {?} dirType
- * @param {?} name
- * @return {?}
- */
- CompileMetadataResolver.prototype.getGeneratedClass = /**
- * @param {?} dirType
- * @param {?} name
- * @return {?}
- */
- function (dirType, name) {
- if (dirType instanceof StaticSymbol) {
- return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), name);
- }
- else {
- return this._createProxyClass(dirType, name);
- }
- };
- /**
- * @param {?} dirType
- * @return {?}
- */
- CompileMetadataResolver.prototype.getComponentViewClass = /**
- * @param {?} dirType
- * @return {?}
- */
- function (dirType) {
- return this.getGeneratedClass(dirType, viewClassName(dirType, 0));
- };
- /**
- * @param {?} dirType
- * @return {?}
- */
- CompileMetadataResolver.prototype.getHostComponentViewClass = /**
- * @param {?} dirType
- * @return {?}
- */
- function (dirType) {
- return this.getGeneratedClass(dirType, hostViewClassName(dirType));
- };
- /**
- * @param {?} dirType
- * @return {?}
- */
- CompileMetadataResolver.prototype.getHostComponentType = /**
- * @param {?} dirType
- * @return {?}
- */
- function (dirType) {
- var /** @type {?} */ name = identifierName({ reference: dirType }) + "_Host";
- if (dirType instanceof StaticSymbol) {
- return this._staticSymbolCache.get(dirType.filePath, name);
- }
- else {
- var /** @type {?} */ HostClass = /** @type {?} */ (function HostClass() { });
- HostClass.overriddenName = name;
- return HostClass;
- }
- };
- /**
- * @param {?} dirType
- * @return {?}
- */
- CompileMetadataResolver.prototype.getRendererType = /**
- * @param {?} dirType
- * @return {?}
- */
- function (dirType) {
- if (dirType instanceof StaticSymbol) {
- return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), rendererTypeName(dirType));
- }
- else {
- // returning an object as proxy,
- // that we fill later during runtime compilation.
- return /** @type {?} */ ({});
- }
- };
- /**
- * @param {?} selector
- * @param {?} dirType
- * @param {?} inputs
- * @param {?} outputs
- * @return {?}
- */
- CompileMetadataResolver.prototype.getComponentFactory = /**
- * @param {?} selector
- * @param {?} dirType
- * @param {?} inputs
- * @param {?} outputs
- * @return {?}
- */
- function (selector, dirType, inputs, outputs) {
- if (dirType instanceof StaticSymbol) {
- return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), componentFactoryName(dirType));
- }
- else {
- var /** @type {?} */ hostView = this.getHostComponentViewClass(dirType);
- // Note: ngContentSelectors will be filled later once the template is
- // loaded.
- var /** @type {?} */ createComponentFactory = this._reflector.resolveExternalReference(Identifiers.createComponentFactory);
- return createComponentFactory(selector, dirType, /** @type {?} */ (hostView), inputs, outputs, []);
- }
- };
- /**
- * @param {?} factory
- * @param {?} ngContentSelectors
- * @return {?}
- */
- CompileMetadataResolver.prototype.initComponentFactory = /**
- * @param {?} factory
- * @param {?} ngContentSelectors
- * @return {?}
- */
- function (factory, ngContentSelectors) {
- if (!(factory instanceof StaticSymbol)) {
- (_a = (/** @type {?} */ (factory)).ngContentSelectors).push.apply(_a, ngContentSelectors);
- }
- var _a;
- };
- /**
- * @param {?} type
- * @param {?} kind
- * @return {?}
- */
- CompileMetadataResolver.prototype._loadSummary = /**
- * @param {?} type
- * @param {?} kind
- * @return {?}
- */
- function (type, kind) {
- var /** @type {?} */ typeSummary = this._summaryCache.get(type);
- if (!typeSummary) {
- var /** @type {?} */ summary = this._summaryResolver.resolveSummary(type);
- typeSummary = summary ? summary.type : null;
- this._summaryCache.set(type, typeSummary || null);
- }
- return typeSummary && typeSummary.summaryKind === kind ? typeSummary : null;
- };
- /**
- * @param {?} compMeta
- * @param {?=} hostViewType
- * @return {?}
- */
- CompileMetadataResolver.prototype.getHostComponentMetadata = /**
- * @param {?} compMeta
- * @param {?=} hostViewType
- * @return {?}
- */
- function (compMeta, hostViewType) {
- var /** @type {?} */ hostType = this.getHostComponentType(compMeta.type.reference);
- if (!hostViewType) {
- hostViewType = this.getHostComponentViewClass(hostType);
- }
- // Note: ! is ok here as this method should only be called with normalized directive
- // metadata, which always fills in the selector.
- var /** @type {?} */ template = CssSelector.parse(/** @type {?} */ ((compMeta.selector)))[0].getMatchingElementTemplate();
- var /** @type {?} */ templateUrl = '';
- var /** @type {?} */ htmlAst = this._htmlParser.parse(template, templateUrl);
- return CompileDirectiveMetadata.create({
- isHost: true,
- type: { reference: hostType, diDeps: [], lifecycleHooks: [] },
- template: new CompileTemplateMetadata({
- encapsulation: ViewEncapsulation.None,
- template: template,
- templateUrl: templateUrl,
- htmlAst: htmlAst,
- styles: [],
- styleUrls: [],
- ngContentSelectors: [],
- animations: [],
- isInline: true,
- externalStylesheets: [],
- interpolation: null,
- preserveWhitespaces: false,
- }),
- exportAs: null,
- changeDetection: ChangeDetectionStrategy.Default,
- inputs: [],
- outputs: [],
- host: {},
- isComponent: true,
- selector: '*',
- providers: [],
- viewProviders: [],
- queries: [],
- guards: {},
- viewQueries: [],
- componentViewType: hostViewType,
- rendererType: /** @type {?} */ ({ id: '__Host__', encapsulation: ViewEncapsulation.None, styles: [], data: {} }),
- entryComponents: [],
- componentFactory: null
- });
- };
- /**
- * @param {?} ngModuleType
- * @param {?} directiveType
- * @param {?} isSync
- * @return {?}
- */
- CompileMetadataResolver.prototype.loadDirectiveMetadata = /**
- * @param {?} ngModuleType
- * @param {?} directiveType
- * @param {?} isSync
- * @return {?}
- */
- function (ngModuleType, directiveType, isSync) {
- var _this = this;
- if (this._directiveCache.has(directiveType)) {
- return null;
- }
- directiveType = resolveForwardRef(directiveType);
- var _a = /** @type {?} */ ((this.getNonNormalizedDirectiveMetadata(directiveType))), annotation = _a.annotation, metadata = _a.metadata;
- var /** @type {?} */ createDirectiveMetadata = function (templateMetadata) {
- var /** @type {?} */ normalizedDirMeta = new CompileDirectiveMetadata({
- isHost: false,
- type: metadata.type,
- isComponent: metadata.isComponent,
- selector: metadata.selector,
- exportAs: metadata.exportAs,
- changeDetection: metadata.changeDetection,
- inputs: metadata.inputs,
- outputs: metadata.outputs,
- hostListeners: metadata.hostListeners,
- hostProperties: metadata.hostProperties,
- hostAttributes: metadata.hostAttributes,
- providers: metadata.providers,
- viewProviders: metadata.viewProviders,
- queries: metadata.queries,
- guards: metadata.guards,
- viewQueries: metadata.viewQueries,
- entryComponents: metadata.entryComponents,
- componentViewType: metadata.componentViewType,
- rendererType: metadata.rendererType,
- componentFactory: metadata.componentFactory,
- template: templateMetadata
- });
- if (templateMetadata) {
- _this.initComponentFactory(/** @type {?} */ ((metadata.componentFactory)), templateMetadata.ngContentSelectors);
- }
- _this._directiveCache.set(directiveType, normalizedDirMeta);
- _this._summaryCache.set(directiveType, normalizedDirMeta.toSummary());
- return null;
- };
- if (metadata.isComponent) {
- var /** @type {?} */ template = /** @type {?} */ ((metadata.template));
- var /** @type {?} */ templateMeta = this._directiveNormalizer.normalizeTemplate({
- ngModuleType: ngModuleType,
- componentType: directiveType,
- moduleUrl: this._reflector.componentModuleUrl(directiveType, annotation),
- encapsulation: template.encapsulation,
- template: template.template,
- templateUrl: template.templateUrl,
- styles: template.styles,
- styleUrls: template.styleUrls,
- animations: template.animations,
- interpolation: template.interpolation,
- preserveWhitespaces: template.preserveWhitespaces
- });
- if (isPromise(templateMeta) && isSync) {
- this._reportError(componentStillLoadingError(directiveType), directiveType);
- return null;
- }
- return SyncAsync.then(templateMeta, createDirectiveMetadata);
- }
- else {
- // directive
- createDirectiveMetadata(null);
- return null;
- }
- };
- /**
- * @param {?} directiveType
- * @return {?}
- */
- CompileMetadataResolver.prototype.getNonNormalizedDirectiveMetadata = /**
- * @param {?} directiveType
- * @return {?}
- */
- function (directiveType) {
- var _this = this;
- directiveType = resolveForwardRef(directiveType);
- if (!directiveType) {
- return null;
- }
- var /** @type {?} */ cacheEntry = this._nonNormalizedDirectiveCache.get(directiveType);
- if (cacheEntry) {
- return cacheEntry;
- }
- var /** @type {?} */ dirMeta = this._directiveResolver.resolve(directiveType, false);
- if (!dirMeta) {
- return null;
- }
- var /** @type {?} */ nonNormalizedTemplateMetadata = /** @type {?} */ ((undefined));
- if (createComponent.isTypeOf(dirMeta)) {
- // component
- var /** @type {?} */ compMeta = /** @type {?} */ (dirMeta);
- assertArrayOfStrings('styles', compMeta.styles);
- assertArrayOfStrings('styleUrls', compMeta.styleUrls);
- assertInterpolationSymbols('interpolation', compMeta.interpolation);
- var /** @type {?} */ animations = compMeta.animations;
- nonNormalizedTemplateMetadata = new CompileTemplateMetadata({
- encapsulation: noUndefined(compMeta.encapsulation),
- template: noUndefined(compMeta.template),
- templateUrl: noUndefined(compMeta.templateUrl),
- htmlAst: null,
- styles: compMeta.styles || [],
- styleUrls: compMeta.styleUrls || [],
- animations: animations || [],
- interpolation: noUndefined(compMeta.interpolation),
- isInline: !!compMeta.template,
- externalStylesheets: [],
- ngContentSelectors: [],
- preserveWhitespaces: noUndefined(dirMeta.preserveWhitespaces),
- });
- }
- var /** @type {?} */ changeDetectionStrategy = /** @type {?} */ ((null));
- var /** @type {?} */ viewProviders = [];
- var /** @type {?} */ entryComponentMetadata = [];
- var /** @type {?} */ selector = dirMeta.selector;
- if (createComponent.isTypeOf(dirMeta)) {
- // Component
- var /** @type {?} */ compMeta = /** @type {?} */ (dirMeta);
- changeDetectionStrategy = /** @type {?} */ ((compMeta.changeDetection));
- if (compMeta.viewProviders) {
- viewProviders = this._getProvidersMetadata(compMeta.viewProviders, entryComponentMetadata, "viewProviders for \"" + stringifyType(directiveType) + "\"", [], directiveType);
- }
- if (compMeta.entryComponents) {
- entryComponentMetadata = flattenAndDedupeArray(compMeta.entryComponents)
- .map(function (type) { return ((_this._getEntryComponentMetadata(type))); })
- .concat(entryComponentMetadata);
- }
- if (!selector) {
- selector = this._schemaRegistry.getDefaultComponentElementName();
- }
- }
- else {
- // Directive
- if (!selector) {
- this._reportError(syntaxError("Directive " + stringifyType(directiveType) + " has no selector, please add it!"), directiveType);
- selector = 'error';
- }
- }
- var /** @type {?} */ providers = [];
- if (dirMeta.providers != null) {
- providers = this._getProvidersMetadata(dirMeta.providers, entryComponentMetadata, "providers for \"" + stringifyType(directiveType) + "\"", [], directiveType);
- }
- var /** @type {?} */ queries = [];
- var /** @type {?} */ viewQueries = [];
- if (dirMeta.queries != null) {
- queries = this._getQueriesMetadata(dirMeta.queries, false, directiveType);
- viewQueries = this._getQueriesMetadata(dirMeta.queries, true, directiveType);
- }
- var /** @type {?} */ metadata = CompileDirectiveMetadata.create({
- isHost: false,
- selector: selector,
- exportAs: noUndefined(dirMeta.exportAs),
- isComponent: !!nonNormalizedTemplateMetadata,
- type: this._getTypeMetadata(directiveType),
- template: nonNormalizedTemplateMetadata,
- changeDetection: changeDetectionStrategy,
- inputs: dirMeta.inputs || [],
- outputs: dirMeta.outputs || [],
- host: dirMeta.host || {},
- providers: providers || [],
- viewProviders: viewProviders || [],
- queries: queries || [],
- guards: dirMeta.guards || {},
- viewQueries: viewQueries || [],
- entryComponents: entryComponentMetadata,
- componentViewType: nonNormalizedTemplateMetadata ? this.getComponentViewClass(directiveType) :
- null,
- rendererType: nonNormalizedTemplateMetadata ? this.getRendererType(directiveType) : null,
- componentFactory: null
- });
- if (nonNormalizedTemplateMetadata) {
- metadata.componentFactory =
- this.getComponentFactory(selector, directiveType, metadata.inputs, metadata.outputs);
- }
- cacheEntry = { metadata: metadata, annotation: dirMeta };
- this._nonNormalizedDirectiveCache.set(directiveType, cacheEntry);
- return cacheEntry;
- };
- /**
- * Gets the metadata for the given directive.
- * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
- */
- /**
- * Gets the metadata for the given directive.
- * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
- * @param {?} directiveType
- * @return {?}
- */
- CompileMetadataResolver.prototype.getDirectiveMetadata = /**
- * Gets the metadata for the given directive.
- * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
- * @param {?} directiveType
- * @return {?}
- */
- function (directiveType) {
- var /** @type {?} */ dirMeta = /** @type {?} */ ((this._directiveCache.get(directiveType)));
- if (!dirMeta) {
- this._reportError(syntaxError("Illegal state: getDirectiveMetadata can only be called after loadNgModuleDirectiveAndPipeMetadata for a module that declares it. Directive " + stringifyType(directiveType) + "."), directiveType);
- }
- return dirMeta;
- };
- /**
- * @param {?} dirType
- * @return {?}
- */
- CompileMetadataResolver.prototype.getDirectiveSummary = /**
- * @param {?} dirType
- * @return {?}
- */
- function (dirType) {
- var /** @type {?} */ dirSummary = /** @type {?} */ (this._loadSummary(dirType, CompileSummaryKind.Directive));
- if (!dirSummary) {
- this._reportError(syntaxError("Illegal state: Could not load the summary for directive " + stringifyType(dirType) + "."), dirType);
- }
- return dirSummary;
- };
- /**
- * @param {?} type
- * @return {?}
- */
- CompileMetadataResolver.prototype.isDirective = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- return !!this._loadSummary(type, CompileSummaryKind.Directive) ||
- this._directiveResolver.isDirective(type);
- };
- /**
- * @param {?} type
- * @return {?}
- */
- CompileMetadataResolver.prototype.isPipe = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- return !!this._loadSummary(type, CompileSummaryKind.Pipe) ||
- this._pipeResolver.isPipe(type);
- };
- /**
- * @param {?} type
- * @return {?}
- */
- CompileMetadataResolver.prototype.isNgModule = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- return !!this._loadSummary(type, CompileSummaryKind.NgModule) ||
- this._ngModuleResolver.isNgModule(type);
- };
- /**
- * @param {?} moduleType
- * @param {?=} alreadyCollecting
- * @return {?}
- */
- CompileMetadataResolver.prototype.getNgModuleSummary = /**
- * @param {?} moduleType
- * @param {?=} alreadyCollecting
- * @return {?}
- */
- function (moduleType, alreadyCollecting) {
- if (alreadyCollecting === void 0) { alreadyCollecting = null; }
- var /** @type {?} */ moduleSummary = /** @type {?} */ (this._loadSummary(moduleType, CompileSummaryKind.NgModule));
- if (!moduleSummary) {
- var /** @type {?} */ moduleMeta = this.getNgModuleMetadata(moduleType, false, alreadyCollecting);
- moduleSummary = moduleMeta ? moduleMeta.toSummary() : null;
- if (moduleSummary) {
- this._summaryCache.set(moduleType, moduleSummary);
- }
- }
- return moduleSummary;
- };
- /**
- * Loads the declared directives and pipes of an NgModule.
- */
- /**
- * Loads the declared directives and pipes of an NgModule.
- * @param {?} moduleType
- * @param {?} isSync
- * @param {?=} throwIfNotFound
- * @return {?}
- */
- CompileMetadataResolver.prototype.loadNgModuleDirectiveAndPipeMetadata = /**
- * Loads the declared directives and pipes of an NgModule.
- * @param {?} moduleType
- * @param {?} isSync
- * @param {?=} throwIfNotFound
- * @return {?}
- */
- function (moduleType, isSync, throwIfNotFound) {
- var _this = this;
- if (throwIfNotFound === void 0) { throwIfNotFound = true; }
- var /** @type {?} */ ngModule = this.getNgModuleMetadata(moduleType, throwIfNotFound);
- var /** @type {?} */ loading = [];
- if (ngModule) {
- ngModule.declaredDirectives.forEach(function (id) {
- var /** @type {?} */ promise = _this.loadDirectiveMetadata(moduleType, id.reference, isSync);
- if (promise) {
- loading.push(promise);
- }
- });
- ngModule.declaredPipes.forEach(function (id) { return _this._loadPipeMetadata(id.reference); });
- }
- return Promise.all(loading);
- };
- /**
- * @param {?} moduleType
- * @param {?=} throwIfNotFound
- * @param {?=} alreadyCollecting
- * @return {?}
- */
- CompileMetadataResolver.prototype.getNgModuleMetadata = /**
- * @param {?} moduleType
- * @param {?=} throwIfNotFound
- * @param {?=} alreadyCollecting
- * @return {?}
- */
- function (moduleType, throwIfNotFound, alreadyCollecting) {
- var _this = this;
- if (throwIfNotFound === void 0) { throwIfNotFound = true; }
- if (alreadyCollecting === void 0) { alreadyCollecting = null; }
- moduleType = resolveForwardRef(moduleType);
- var /** @type {?} */ compileMeta = this._ngModuleCache.get(moduleType);
- if (compileMeta) {
- return compileMeta;
- }
- var /** @type {?} */ meta = this._ngModuleResolver.resolve(moduleType, throwIfNotFound);
- if (!meta) {
- return null;
- }
- var /** @type {?} */ declaredDirectives = [];
- var /** @type {?} */ exportedNonModuleIdentifiers = [];
- var /** @type {?} */ declaredPipes = [];
- var /** @type {?} */ importedModules = [];
- var /** @type {?} */ exportedModules = [];
- var /** @type {?} */ providers = [];
- var /** @type {?} */ entryComponents = [];
- var /** @type {?} */ bootstrapComponents = [];
- var /** @type {?} */ schemas = [];
- if (meta.imports) {
- flattenAndDedupeArray(meta.imports).forEach(function (importedType) {
- var /** @type {?} */ importedModuleType = /** @type {?} */ ((undefined));
- if (isValidType(importedType)) {
- importedModuleType = importedType;
- }
- else if (importedType && importedType.ngModule) {
- var /** @type {?} */ moduleWithProviders = importedType;
- importedModuleType = moduleWithProviders.ngModule;
- if (moduleWithProviders.providers) {
- providers.push.apply(providers, _this._getProvidersMetadata(moduleWithProviders.providers, entryComponents, "provider for the NgModule '" + stringifyType(importedModuleType) + "'", [], importedType));
- }
- }
- if (importedModuleType) {
- if (_this._checkSelfImport(moduleType, importedModuleType))
- return;
- if (!alreadyCollecting)
- alreadyCollecting = new Set();
- if (alreadyCollecting.has(importedModuleType)) {
- _this._reportError(syntaxError(_this._getTypeDescriptor(importedModuleType) + " '" + stringifyType(importedType) + "' is imported recursively by the module '" + stringifyType(moduleType) + "'."), moduleType);
- return;
- }
- alreadyCollecting.add(importedModuleType);
- var /** @type {?} */ importedModuleSummary = _this.getNgModuleSummary(importedModuleType, alreadyCollecting);
- alreadyCollecting.delete(importedModuleType);
- if (!importedModuleSummary) {
- _this._reportError(syntaxError("Unexpected " + _this._getTypeDescriptor(importedType) + " '" + stringifyType(importedType) + "' imported by the module '" + stringifyType(moduleType) + "'. Please add a @NgModule annotation."), moduleType);
- return;
- }
- importedModules.push(importedModuleSummary);
- }
- else {
- _this._reportError(syntaxError("Unexpected value '" + stringifyType(importedType) + "' imported by the module '" + stringifyType(moduleType) + "'"), moduleType);
- return;
- }
- });
- }
- if (meta.exports) {
- flattenAndDedupeArray(meta.exports).forEach(function (exportedType) {
- if (!isValidType(exportedType)) {
- _this._reportError(syntaxError("Unexpected value '" + stringifyType(exportedType) + "' exported by the module '" + stringifyType(moduleType) + "'"), moduleType);
- return;
- }
- if (!alreadyCollecting)
- alreadyCollecting = new Set();
- if (alreadyCollecting.has(exportedType)) {
- _this._reportError(syntaxError(_this._getTypeDescriptor(exportedType) + " '" + stringify(exportedType) + "' is exported recursively by the module '" + stringifyType(moduleType) + "'"), moduleType);
- return;
- }
- alreadyCollecting.add(exportedType);
- var /** @type {?} */ exportedModuleSummary = _this.getNgModuleSummary(exportedType, alreadyCollecting);
- alreadyCollecting.delete(exportedType);
- if (exportedModuleSummary) {
- exportedModules.push(exportedModuleSummary);
- }
- else {
- exportedNonModuleIdentifiers.push(_this._getIdentifierMetadata(exportedType));
- }
- });
- }
- // Note: This will be modified later, so we rely on
- // getting a new instance every time!
- var /** @type {?} */ transitiveModule = this._getTransitiveNgModuleMetadata(importedModules, exportedModules);
- if (meta.declarations) {
- flattenAndDedupeArray(meta.declarations).forEach(function (declaredType) {
- if (!isValidType(declaredType)) {
- _this._reportError(syntaxError("Unexpected value '" + stringifyType(declaredType) + "' declared by the module '" + stringifyType(moduleType) + "'"), moduleType);
- return;
- }
- var /** @type {?} */ declaredIdentifier = _this._getIdentifierMetadata(declaredType);
- if (_this.isDirective(declaredType)) {
- transitiveModule.addDirective(declaredIdentifier);
- declaredDirectives.push(declaredIdentifier);
- _this._addTypeToModule(declaredType, moduleType);
- }
- else if (_this.isPipe(declaredType)) {
- transitiveModule.addPipe(declaredIdentifier);
- transitiveModule.pipes.push(declaredIdentifier);
- declaredPipes.push(declaredIdentifier);
- _this._addTypeToModule(declaredType, moduleType);
- }
- else {
- _this._reportError(syntaxError("Unexpected " + _this._getTypeDescriptor(declaredType) + " '" + stringifyType(declaredType) + "' declared by the module '" + stringifyType(moduleType) + "'. Please add a @Pipe/@Directive/@Component annotation."), moduleType);
- return;
- }
- });
- }
- var /** @type {?} */ exportedDirectives = [];
- var /** @type {?} */ exportedPipes = [];
- exportedNonModuleIdentifiers.forEach(function (exportedId) {
- if (transitiveModule.directivesSet.has(exportedId.reference)) {
- exportedDirectives.push(exportedId);
- transitiveModule.addExportedDirective(exportedId);
- }
- else if (transitiveModule.pipesSet.has(exportedId.reference)) {
- exportedPipes.push(exportedId);
- transitiveModule.addExportedPipe(exportedId);
- }
- else {
- _this._reportError(syntaxError("Can't export " + _this._getTypeDescriptor(exportedId.reference) + " " + stringifyType(exportedId.reference) + " from " + stringifyType(moduleType) + " as it was neither declared nor imported!"), moduleType);
- return;
- }
- });
- // The providers of the module have to go last
- // so that they overwrite any other provider we already added.
- if (meta.providers) {
- providers.push.apply(providers, this._getProvidersMetadata(meta.providers, entryComponents, "provider for the NgModule '" + stringifyType(moduleType) + "'", [], moduleType));
- }
- if (meta.entryComponents) {
- entryComponents.push.apply(entryComponents, flattenAndDedupeArray(meta.entryComponents)
- .map(function (type) { return ((_this._getEntryComponentMetadata(type))); }));
- }
- if (meta.bootstrap) {
- flattenAndDedupeArray(meta.bootstrap).forEach(function (type) {
- if (!isValidType(type)) {
- _this._reportError(syntaxError("Unexpected value '" + stringifyType(type) + "' used in the bootstrap property of module '" + stringifyType(moduleType) + "'"), moduleType);
- return;
- }
- bootstrapComponents.push(_this._getIdentifierMetadata(type));
- });
- }
- entryComponents.push.apply(entryComponents, bootstrapComponents.map(function (type) { return ((_this._getEntryComponentMetadata(type.reference))); }));
- if (meta.schemas) {
- schemas.push.apply(schemas, flattenAndDedupeArray(meta.schemas));
- }
- compileMeta = new CompileNgModuleMetadata({
- type: this._getTypeMetadata(moduleType),
- providers: providers,
- entryComponents: entryComponents,
- bootstrapComponents: bootstrapComponents,
- schemas: schemas,
- declaredDirectives: declaredDirectives,
- exportedDirectives: exportedDirectives,
- declaredPipes: declaredPipes,
- exportedPipes: exportedPipes,
- importedModules: importedModules,
- exportedModules: exportedModules,
- transitiveModule: transitiveModule,
- id: meta.id || null,
- });
- entryComponents.forEach(function (id) { return transitiveModule.addEntryComponent(id); });
- providers.forEach(function (provider) { return transitiveModule.addProvider(provider, /** @type {?} */ ((compileMeta)).type); });
- transitiveModule.addModule(compileMeta.type);
- this._ngModuleCache.set(moduleType, compileMeta);
- return compileMeta;
- };
- /**
- * @param {?} moduleType
- * @param {?} importedModuleType
- * @return {?}
- */
- CompileMetadataResolver.prototype._checkSelfImport = /**
- * @param {?} moduleType
- * @param {?} importedModuleType
- * @return {?}
- */
- function (moduleType, importedModuleType) {
- if (moduleType === importedModuleType) {
- this._reportError(syntaxError("'" + stringifyType(moduleType) + "' module can't import itself"), moduleType);
- return true;
- }
- return false;
- };
- /**
- * @param {?} type
- * @return {?}
- */
- CompileMetadataResolver.prototype._getTypeDescriptor = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- if (isValidType(type)) {
- if (this.isDirective(type)) {
- return 'directive';
- }
- if (this.isPipe(type)) {
- return 'pipe';
- }
- if (this.isNgModule(type)) {
- return 'module';
- }
- }
- if ((/** @type {?} */ (type)).provide) {
- return 'provider';
- }
- return 'value';
- };
- /**
- * @param {?} type
- * @param {?} moduleType
- * @return {?}
- */
- CompileMetadataResolver.prototype._addTypeToModule = /**
- * @param {?} type
- * @param {?} moduleType
- * @return {?}
- */
- function (type, moduleType) {
- var /** @type {?} */ oldModule = this._ngModuleOfTypes.get(type);
- if (oldModule && oldModule !== moduleType) {
- this._reportError(syntaxError("Type " + stringifyType(type) + " is part of the declarations of 2 modules: " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + "! " +
- ("Please consider moving " + stringifyType(type) + " to a higher module that imports " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + ". ") +
- ("You can also create a new NgModule that exports and includes " + stringifyType(type) + " then import that NgModule in " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + ".")), moduleType);
- return;
- }
- this._ngModuleOfTypes.set(type, moduleType);
- };
- /**
- * @param {?} importedModules
- * @param {?} exportedModules
- * @return {?}
- */
- CompileMetadataResolver.prototype._getTransitiveNgModuleMetadata = /**
- * @param {?} importedModules
- * @param {?} exportedModules
- * @return {?}
- */
- function (importedModules, exportedModules) {
- // collect `providers` / `entryComponents` from all imported and all exported modules
- var /** @type {?} */ result = new TransitiveCompileNgModuleMetadata();
- var /** @type {?} */ modulesByToken = new Map();
- importedModules.concat(exportedModules).forEach(function (modSummary) {
- modSummary.modules.forEach(function (mod) { return result.addModule(mod); });
- modSummary.entryComponents.forEach(function (comp) { return result.addEntryComponent(comp); });
- var /** @type {?} */ addedTokens = new Set();
- modSummary.providers.forEach(function (entry) {
- var /** @type {?} */ tokenRef = tokenReference(entry.provider.token);
- var /** @type {?} */ prevModules = modulesByToken.get(tokenRef);
- if (!prevModules) {
- prevModules = new Set();
- modulesByToken.set(tokenRef, prevModules);
- }
- var /** @type {?} */ moduleRef = entry.module.reference;
- // Note: the providers of one module may still contain multiple providers
- // per token (e.g. for multi providers), and we need to preserve these.
- if (addedTokens.has(tokenRef) || !prevModules.has(moduleRef)) {
- prevModules.add(moduleRef);
- addedTokens.add(tokenRef);
- result.addProvider(entry.provider, entry.module);
- }
- });
- });
- exportedModules.forEach(function (modSummary) {
- modSummary.exportedDirectives.forEach(function (id) { return result.addExportedDirective(id); });
- modSummary.exportedPipes.forEach(function (id) { return result.addExportedPipe(id); });
- });
- importedModules.forEach(function (modSummary) {
- modSummary.exportedDirectives.forEach(function (id) { return result.addDirective(id); });
- modSummary.exportedPipes.forEach(function (id) { return result.addPipe(id); });
- });
- return result;
- };
- /**
- * @param {?} type
- * @return {?}
- */
- CompileMetadataResolver.prototype._getIdentifierMetadata = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- type = resolveForwardRef(type);
- return { reference: type };
- };
- /**
- * @param {?} type
- * @return {?}
- */
- CompileMetadataResolver.prototype.isInjectable = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- var /** @type {?} */ annotations = this._reflector.annotations(type);
- return annotations.some(function (ann) { return createInjectable.isTypeOf(ann); });
- };
- /**
- * @param {?} type
- * @return {?}
- */
- CompileMetadataResolver.prototype.getInjectableSummary = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- return {
- summaryKind: CompileSummaryKind.Injectable,
- type: this._getTypeMetadata(type, null, false)
- };
- };
- /**
- * @param {?} type
- * @param {?=} dependencies
- * @return {?}
- */
- CompileMetadataResolver.prototype._getInjectableMetadata = /**
- * @param {?} type
- * @param {?=} dependencies
- * @return {?}
- */
- function (type, dependencies) {
- if (dependencies === void 0) { dependencies = null; }
- var /** @type {?} */ typeSummary = this._loadSummary(type, CompileSummaryKind.Injectable);
- if (typeSummary) {
- return typeSummary.type;
- }
- return this._getTypeMetadata(type, dependencies);
- };
- /**
- * @param {?} type
- * @param {?=} dependencies
- * @param {?=} throwOnUnknownDeps
- * @return {?}
- */
- CompileMetadataResolver.prototype._getTypeMetadata = /**
- * @param {?} type
- * @param {?=} dependencies
- * @param {?=} throwOnUnknownDeps
- * @return {?}
- */
- function (type, dependencies, throwOnUnknownDeps) {
- if (dependencies === void 0) { dependencies = null; }
- if (throwOnUnknownDeps === void 0) { throwOnUnknownDeps = true; }
- var /** @type {?} */ identifier = this._getIdentifierMetadata(type);
- return {
- reference: identifier.reference,
- diDeps: this._getDependenciesMetadata(identifier.reference, dependencies, throwOnUnknownDeps),
- lifecycleHooks: getAllLifecycleHooks(this._reflector, identifier.reference),
- };
- };
- /**
- * @param {?} factory
- * @param {?=} dependencies
- * @return {?}
- */
- CompileMetadataResolver.prototype._getFactoryMetadata = /**
- * @param {?} factory
- * @param {?=} dependencies
- * @return {?}
- */
- function (factory, dependencies) {
- if (dependencies === void 0) { dependencies = null; }
- factory = resolveForwardRef(factory);
- return { reference: factory, diDeps: this._getDependenciesMetadata(factory, dependencies) };
- };
- /**
- * Gets the metadata for the given pipe.
- * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
- */
- /**
- * Gets the metadata for the given pipe.
- * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
- * @param {?} pipeType
- * @return {?}
- */
- CompileMetadataResolver.prototype.getPipeMetadata = /**
- * Gets the metadata for the given pipe.
- * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
- * @param {?} pipeType
- * @return {?}
- */
- function (pipeType) {
- var /** @type {?} */ pipeMeta = this._pipeCache.get(pipeType);
- if (!pipeMeta) {
- this._reportError(syntaxError("Illegal state: getPipeMetadata can only be called after loadNgModuleDirectiveAndPipeMetadata for a module that declares it. Pipe " + stringifyType(pipeType) + "."), pipeType);
- }
- return pipeMeta || null;
- };
- /**
- * @param {?} pipeType
- * @return {?}
- */
- CompileMetadataResolver.prototype.getPipeSummary = /**
- * @param {?} pipeType
- * @return {?}
- */
- function (pipeType) {
- var /** @type {?} */ pipeSummary = /** @type {?} */ (this._loadSummary(pipeType, CompileSummaryKind.Pipe));
- if (!pipeSummary) {
- this._reportError(syntaxError("Illegal state: Could not load the summary for pipe " + stringifyType(pipeType) + "."), pipeType);
- }
- return pipeSummary;
- };
- /**
- * @param {?} pipeType
- * @return {?}
- */
- CompileMetadataResolver.prototype.getOrLoadPipeMetadata = /**
- * @param {?} pipeType
- * @return {?}
- */
- function (pipeType) {
- var /** @type {?} */ pipeMeta = this._pipeCache.get(pipeType);
- if (!pipeMeta) {
- pipeMeta = this._loadPipeMetadata(pipeType);
- }
- return pipeMeta;
- };
- /**
- * @param {?} pipeType
- * @return {?}
- */
- CompileMetadataResolver.prototype._loadPipeMetadata = /**
- * @param {?} pipeType
- * @return {?}
- */
- function (pipeType) {
- pipeType = resolveForwardRef(pipeType);
- var /** @type {?} */ pipeAnnotation = /** @type {?} */ ((this._pipeResolver.resolve(pipeType)));
- var /** @type {?} */ pipeMeta = new CompilePipeMetadata({
- type: this._getTypeMetadata(pipeType),
- name: pipeAnnotation.name,
- pure: !!pipeAnnotation.pure
- });
- this._pipeCache.set(pipeType, pipeMeta);
- this._summaryCache.set(pipeType, pipeMeta.toSummary());
- return pipeMeta;
- };
- /**
- * @param {?} typeOrFunc
- * @param {?} dependencies
- * @param {?=} throwOnUnknownDeps
- * @return {?}
- */
- CompileMetadataResolver.prototype._getDependenciesMetadata = /**
- * @param {?} typeOrFunc
- * @param {?} dependencies
- * @param {?=} throwOnUnknownDeps
- * @return {?}
- */
- function (typeOrFunc, dependencies, throwOnUnknownDeps) {
- var _this = this;
- if (throwOnUnknownDeps === void 0) { throwOnUnknownDeps = true; }
- var /** @type {?} */ hasUnknownDeps = false;
- var /** @type {?} */ params = dependencies || this._reflector.parameters(typeOrFunc) || [];
- var /** @type {?} */ dependenciesMetadata = params.map(function (param) {
- var /** @type {?} */ isAttribute = false;
- var /** @type {?} */ isHost = false;
- var /** @type {?} */ isSelf = false;
- var /** @type {?} */ isSkipSelf = false;
- var /** @type {?} */ isOptional = false;
- var /** @type {?} */ token = null;
- if (Array.isArray(param)) {
- param.forEach(function (paramEntry) {
- if (createHost.isTypeOf(paramEntry)) {
- isHost = true;
- }
- else if (createSelf.isTypeOf(paramEntry)) {
- isSelf = true;
- }
- else if (createSkipSelf.isTypeOf(paramEntry)) {
- isSkipSelf = true;
- }
- else if (createOptional.isTypeOf(paramEntry)) {
- isOptional = true;
- }
- else if (createAttribute.isTypeOf(paramEntry)) {
- isAttribute = true;
- token = paramEntry.attributeName;
- }
- else if (createInject.isTypeOf(paramEntry)) {
- token = paramEntry.token;
- }
- else if (createInjectionToken.isTypeOf(paramEntry) || paramEntry instanceof StaticSymbol) {
- token = paramEntry;
- }
- else if (isValidType(paramEntry) && token == null) {
- token = paramEntry;
- }
- });
- }
- else {
- token = param;
- }
- if (token == null) {
- hasUnknownDeps = true;
- return /** @type {?} */ ((null));
- }
- return {
- isAttribute: isAttribute,
- isHost: isHost,
- isSelf: isSelf,
- isSkipSelf: isSkipSelf,
- isOptional: isOptional,
- token: _this._getTokenMetadata(token)
- };
- });
- if (hasUnknownDeps) {
- var /** @type {?} */ depsTokens = dependenciesMetadata.map(function (dep) { return dep ? stringifyType(dep.token) : '?'; }).join(', ');
- var /** @type {?} */ message = "Can't resolve all parameters for " + stringifyType(typeOrFunc) + ": (" + depsTokens + ").";
- if (throwOnUnknownDeps || this._config.strictInjectionParameters) {
- this._reportError(syntaxError(message), typeOrFunc);
- }
- else {
- this._console.warn("Warning: " + message + " This will become an error in Angular v6.x");
- }
- }
- return dependenciesMetadata;
- };
- /**
- * @param {?} token
- * @return {?}
- */
- CompileMetadataResolver.prototype._getTokenMetadata = /**
- * @param {?} token
- * @return {?}
- */
- function (token) {
- token = resolveForwardRef(token);
- var /** @type {?} */ compileToken;
- if (typeof token === 'string') {
- compileToken = { value: token };
- }
- else {
- compileToken = { identifier: { reference: token } };
- }
- return compileToken;
- };
- /**
- * @param {?} providers
- * @param {?} targetEntryComponents
- * @param {?=} debugInfo
- * @param {?=} compileProviders
- * @param {?=} type
- * @return {?}
- */
- CompileMetadataResolver.prototype._getProvidersMetadata = /**
- * @param {?} providers
- * @param {?} targetEntryComponents
- * @param {?=} debugInfo
- * @param {?=} compileProviders
- * @param {?=} type
- * @return {?}
- */
- function (providers, targetEntryComponents, debugInfo, compileProviders, type) {
- var _this = this;
- if (compileProviders === void 0) { compileProviders = []; }
- providers.forEach(function (provider, providerIdx) {
- if (Array.isArray(provider)) {
- _this._getProvidersMetadata(provider, targetEntryComponents, debugInfo, compileProviders);
- }
- else {
- provider = resolveForwardRef(provider);
- var /** @type {?} */ providerMeta = /** @type {?} */ ((undefined));
- if (provider && typeof provider === 'object' && provider.hasOwnProperty('provide')) {
- _this._validateProvider(provider);
- providerMeta = new ProviderMeta(provider.provide, provider);
- }
- else if (isValidType(provider)) {
- providerMeta = new ProviderMeta(provider, { useClass: provider });
- }
- else if (provider === void 0) {
- _this._reportError(syntaxError("Encountered undefined provider! Usually this means you have a circular dependencies (might be caused by using 'barrel' index.ts files."));
- return;
- }
- else {
- var /** @type {?} */ providersInfo = (/** @type {?} */ (providers.reduce(function (soFar, seenProvider, seenProviderIdx) {
- if (seenProviderIdx < providerIdx) {
- soFar.push("" + stringifyType(seenProvider));
- }
- else if (seenProviderIdx == providerIdx) {
- soFar.push("?" + stringifyType(seenProvider) + "?");
- }
- else if (seenProviderIdx == providerIdx + 1) {
- soFar.push('...');
- }
- return soFar;
- }, [])))
- .join(', ');
- _this._reportError(syntaxError("Invalid " + (debugInfo ? debugInfo : 'provider') + " - only instances of Provider and Type are allowed, got: [" + providersInfo + "]"), type);
- return;
- }
- if (providerMeta.token ===
- _this._reflector.resolveExternalReference(Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS)) {
- targetEntryComponents.push.apply(targetEntryComponents, _this._getEntryComponentsFromProvider(providerMeta, type));
- }
- else {
- compileProviders.push(_this.getProviderMetadata(providerMeta));
- }
- }
- });
- return compileProviders;
- };
- /**
- * @param {?} provider
- * @return {?}
- */
- CompileMetadataResolver.prototype._validateProvider = /**
- * @param {?} provider
- * @return {?}
- */
- function (provider) {
- if (provider.hasOwnProperty('useClass') && provider.useClass == null) {
- this._reportError(syntaxError("Invalid provider for " + stringifyType(provider.provide) + ". useClass cannot be " + provider.useClass + ".\n Usually it happens when:\n 1. There's a circular dependency (might be caused by using index.ts (barrel) files).\n 2. Class was used before it was declared. Use forwardRef in this case."));
- }
- };
- /**
- * @param {?} provider
- * @param {?=} type
- * @return {?}
- */
- CompileMetadataResolver.prototype._getEntryComponentsFromProvider = /**
- * @param {?} provider
- * @param {?=} type
- * @return {?}
- */
- function (provider, type) {
- var _this = this;
- var /** @type {?} */ components = [];
- var /** @type {?} */ collectedIdentifiers = [];
- if (provider.useFactory || provider.useExisting || provider.useClass) {
- this._reportError(syntaxError("The ANALYZE_FOR_ENTRY_COMPONENTS token only supports useValue!"), type);
- return [];
- }
- if (!provider.multi) {
- this._reportError(syntaxError("The ANALYZE_FOR_ENTRY_COMPONENTS token only supports 'multi = true'!"), type);
- return [];
- }
- extractIdentifiers(provider.useValue, collectedIdentifiers);
- collectedIdentifiers.forEach(function (identifier) {
- var /** @type {?} */ entry = _this._getEntryComponentMetadata(identifier.reference, false);
- if (entry) {
- components.push(entry);
- }
- });
- return components;
- };
- /**
- * @param {?} dirType
- * @param {?=} throwIfNotFound
- * @return {?}
- */
- CompileMetadataResolver.prototype._getEntryComponentMetadata = /**
- * @param {?} dirType
- * @param {?=} throwIfNotFound
- * @return {?}
- */
- function (dirType, throwIfNotFound) {
- if (throwIfNotFound === void 0) { throwIfNotFound = true; }
- var /** @type {?} */ dirMeta = this.getNonNormalizedDirectiveMetadata(dirType);
- if (dirMeta && dirMeta.metadata.isComponent) {
- return { componentType: dirType, componentFactory: /** @type {?} */ ((dirMeta.metadata.componentFactory)) };
- }
- var /** @type {?} */ dirSummary = /** @type {?} */ (this._loadSummary(dirType, CompileSummaryKind.Directive));
- if (dirSummary && dirSummary.isComponent) {
- return { componentType: dirType, componentFactory: /** @type {?} */ ((dirSummary.componentFactory)) };
- }
- if (throwIfNotFound) {
- throw syntaxError(dirType.name + " cannot be used as an entry component.");
- }
- return null;
- };
- /**
- * @param {?} provider
- * @return {?}
- */
- CompileMetadataResolver.prototype.getProviderMetadata = /**
- * @param {?} provider
- * @return {?}
- */
- function (provider) {
- var /** @type {?} */ compileDeps = /** @type {?} */ ((undefined));
- var /** @type {?} */ compileTypeMetadata = /** @type {?} */ ((null));
- var /** @type {?} */ compileFactoryMetadata = /** @type {?} */ ((null));
- var /** @type {?} */ token = this._getTokenMetadata(provider.token);
- if (provider.useClass) {
- compileTypeMetadata = this._getInjectableMetadata(provider.useClass, provider.dependencies);
- compileDeps = compileTypeMetadata.diDeps;
- if (provider.token === provider.useClass) {
- // use the compileTypeMetadata as it contains information about lifecycleHooks...
- token = { identifier: compileTypeMetadata };
- }
- }
- else if (provider.useFactory) {
- compileFactoryMetadata = this._getFactoryMetadata(provider.useFactory, provider.dependencies);
- compileDeps = compileFactoryMetadata.diDeps;
- }
- return {
- token: token,
- useClass: compileTypeMetadata,
- useValue: provider.useValue,
- useFactory: compileFactoryMetadata,
- useExisting: provider.useExisting ? this._getTokenMetadata(provider.useExisting) : undefined,
- deps: compileDeps,
- multi: provider.multi
- };
- };
- /**
- * @param {?} queries
- * @param {?} isViewQuery
- * @param {?} directiveType
- * @return {?}
- */
- CompileMetadataResolver.prototype._getQueriesMetadata = /**
- * @param {?} queries
- * @param {?} isViewQuery
- * @param {?} directiveType
- * @return {?}
- */
- function (queries, isViewQuery, directiveType) {
- var _this = this;
- var /** @type {?} */ res = [];
- Object.keys(queries).forEach(function (propertyName) {
- var /** @type {?} */ query = queries[propertyName];
- if (query.isViewQuery === isViewQuery) {
- res.push(_this._getQueryMetadata(query, propertyName, directiveType));
- }
- });
- return res;
- };
- /**
- * @param {?} selector
- * @return {?}
- */
- CompileMetadataResolver.prototype._queryVarBindings = /**
- * @param {?} selector
- * @return {?}
- */
- function (selector) { return selector.split(/\s*,\s*/); };
- /**
- * @param {?} q
- * @param {?} propertyName
- * @param {?} typeOrFunc
- * @return {?}
- */
- CompileMetadataResolver.prototype._getQueryMetadata = /**
- * @param {?} q
- * @param {?} propertyName
- * @param {?} typeOrFunc
- * @return {?}
- */
- function (q, propertyName, typeOrFunc) {
- var _this = this;
- var /** @type {?} */ selectors;
- if (typeof q.selector === 'string') {
- selectors =
- this._queryVarBindings(q.selector).map(function (varName) { return _this._getTokenMetadata(varName); });
- }
- else {
- if (!q.selector) {
- this._reportError(syntaxError("Can't construct a query for the property \"" + propertyName + "\" of \"" + stringifyType(typeOrFunc) + "\" since the query selector wasn't defined."), typeOrFunc);
- selectors = [];
- }
- else {
- selectors = [this._getTokenMetadata(q.selector)];
- }
- }
- return {
- selectors: selectors,
- first: q.first,
- descendants: q.descendants, propertyName: propertyName,
- read: q.read ? this._getTokenMetadata(q.read) : /** @type {?} */ ((null))
- };
- };
- /**
- * @param {?} error
- * @param {?=} type
- * @param {?=} otherType
- * @return {?}
- */
- CompileMetadataResolver.prototype._reportError = /**
- * @param {?} error
- * @param {?=} type
- * @param {?=} otherType
- * @return {?}
- */
- function (error, type, otherType) {
- if (this._errorCollector) {
- this._errorCollector(error, type);
- if (otherType) {
- this._errorCollector(error, otherType);
- }
- }
- else {
- throw error;
- }
- };
- return CompileMetadataResolver;
- }());
- /**
- * @param {?} tree
- * @param {?=} out
- * @return {?}
- */
- function flattenArray(tree, out) {
- if (out === void 0) { out = []; }
- if (tree) {
- for (var /** @type {?} */ i = 0; i < tree.length; i++) {
- var /** @type {?} */ item = resolveForwardRef(tree[i]);
- if (Array.isArray(item)) {
- flattenArray(item, out);
- }
- else {
- out.push(item);
- }
- }
- }
- return out;
- }
- /**
- * @param {?} array
- * @return {?}
- */
- function dedupeArray(array) {
- if (array) {
- return Array.from(new Set(array));
- }
- return [];
- }
- /**
- * @param {?} tree
- * @return {?}
- */
- function flattenAndDedupeArray(tree) {
- return dedupeArray(flattenArray(tree));
- }
- /**
- * @param {?} value
- * @return {?}
- */
- function isValidType(value) {
- return (value instanceof StaticSymbol) || (value instanceof Type);
- }
- /**
- * @param {?} value
- * @param {?} targetIdentifiers
- * @return {?}
- */
- function extractIdentifiers(value, targetIdentifiers) {
- visitValue(value, new _CompileValueConverter(), targetIdentifiers);
- }
- var _CompileValueConverter = /** @class */ (function (_super) {
- __extends(_CompileValueConverter, _super);
- function _CompileValueConverter() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} value
- * @param {?} targetIdentifiers
- * @return {?}
- */
- _CompileValueConverter.prototype.visitOther = /**
- * @param {?} value
- * @param {?} targetIdentifiers
- * @return {?}
- */
- function (value, targetIdentifiers) {
- targetIdentifiers.push({ reference: value });
- };
- return _CompileValueConverter;
- }(ValueTransformer));
- /**
- * @param {?} type
- * @return {?}
- */
- function stringifyType(type) {
- if (type instanceof StaticSymbol) {
- return type.name + " in " + type.filePath;
- }
- else {
- return stringify(type);
- }
- }
- /**
- * Indicates that a component is still being loaded in a synchronous compile.
- * @param {?} compType
- * @return {?}
- */
- function componentStillLoadingError(compType) {
- var /** @type {?} */ error = Error("Can't compile synchronously as " + stringify(compType) + " is still being loaded!");
- (/** @type {?} */ (error))[ERROR_COMPONENT_TYPE] = compType;
- return error;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /** @enum {number} */
- var TypeModifier = {
- Const: 0,
- };
- TypeModifier[TypeModifier.Const] = "Const";
- /**
- * @abstract
- */
- var Type$1 = /** @class */ (function () {
- function Type(modifiers) {
- if (modifiers === void 0) { modifiers = null; }
- this.modifiers = modifiers;
- if (!modifiers) {
- this.modifiers = [];
- }
- }
- /**
- * @param {?} modifier
- * @return {?}
- */
- Type.prototype.hasModifier = /**
- * @param {?} modifier
- * @return {?}
- */
- function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; };
- return Type;
- }());
- /** @enum {number} */
- var BuiltinTypeName = {
- Dynamic: 0,
- Bool: 1,
- String: 2,
- Int: 3,
- Number: 4,
- Function: 5,
- Inferred: 6,
- };
- BuiltinTypeName[BuiltinTypeName.Dynamic] = "Dynamic";
- BuiltinTypeName[BuiltinTypeName.Bool] = "Bool";
- BuiltinTypeName[BuiltinTypeName.String] = "String";
- BuiltinTypeName[BuiltinTypeName.Int] = "Int";
- BuiltinTypeName[BuiltinTypeName.Number] = "Number";
- BuiltinTypeName[BuiltinTypeName.Function] = "Function";
- BuiltinTypeName[BuiltinTypeName.Inferred] = "Inferred";
- var BuiltinType = /** @class */ (function (_super) {
- __extends(BuiltinType, _super);
- function BuiltinType(name, modifiers) {
- if (modifiers === void 0) { modifiers = null; }
- var _this = _super.call(this, modifiers) || this;
- _this.name = name;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- BuiltinType.prototype.visitType = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitBuiltintType(this, context);
- };
- return BuiltinType;
- }(Type$1));
- var ExpressionType = /** @class */ (function (_super) {
- __extends(ExpressionType, _super);
- function ExpressionType(value, modifiers) {
- if (modifiers === void 0) { modifiers = null; }
- var _this = _super.call(this, modifiers) || this;
- _this.value = value;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ExpressionType.prototype.visitType = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitExpressionType(this, context);
- };
- return ExpressionType;
- }(Type$1));
- var ArrayType = /** @class */ (function (_super) {
- __extends(ArrayType, _super);
- function ArrayType(of, modifiers) {
- if (modifiers === void 0) { modifiers = null; }
- var _this = _super.call(this, modifiers) || this;
- _this.of = of;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ArrayType.prototype.visitType = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitArrayType(this, context);
- };
- return ArrayType;
- }(Type$1));
- var MapType = /** @class */ (function (_super) {
- __extends(MapType, _super);
- function MapType(valueType, modifiers) {
- if (modifiers === void 0) { modifiers = null; }
- var _this = _super.call(this, modifiers) || this;
- _this.valueType = valueType || null;
- return _this;
- }
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- MapType.prototype.visitType = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) { return visitor.visitMapType(this, context); };
- return MapType;
- }(Type$1));
- var DYNAMIC_TYPE = new BuiltinType(BuiltinTypeName.Dynamic);
- var INFERRED_TYPE = new BuiltinType(BuiltinTypeName.Inferred);
- var BOOL_TYPE = new BuiltinType(BuiltinTypeName.Bool);
- var INT_TYPE = new BuiltinType(BuiltinTypeName.Int);
- var NUMBER_TYPE = new BuiltinType(BuiltinTypeName.Number);
- var STRING_TYPE = new BuiltinType(BuiltinTypeName.String);
- var FUNCTION_TYPE = new BuiltinType(BuiltinTypeName.Function);
- /**
- * @record
- */
-
- /** @enum {number} */
- var BinaryOperator = {
- Equals: 0,
- NotEquals: 1,
- Identical: 2,
- NotIdentical: 3,
- Minus: 4,
- Plus: 5,
- Divide: 6,
- Multiply: 7,
- Modulo: 8,
- And: 9,
- Or: 10,
- Lower: 11,
- LowerEquals: 12,
- Bigger: 13,
- BiggerEquals: 14,
- };
- BinaryOperator[BinaryOperator.Equals] = "Equals";
- BinaryOperator[BinaryOperator.NotEquals] = "NotEquals";
- BinaryOperator[BinaryOperator.Identical] = "Identical";
- BinaryOperator[BinaryOperator.NotIdentical] = "NotIdentical";
- BinaryOperator[BinaryOperator.Minus] = "Minus";
- BinaryOperator[BinaryOperator.Plus] = "Plus";
- BinaryOperator[BinaryOperator.Divide] = "Divide";
- BinaryOperator[BinaryOperator.Multiply] = "Multiply";
- BinaryOperator[BinaryOperator.Modulo] = "Modulo";
- BinaryOperator[BinaryOperator.And] = "And";
- BinaryOperator[BinaryOperator.Or] = "Or";
- BinaryOperator[BinaryOperator.Lower] = "Lower";
- BinaryOperator[BinaryOperator.LowerEquals] = "LowerEquals";
- BinaryOperator[BinaryOperator.Bigger] = "Bigger";
- BinaryOperator[BinaryOperator.BiggerEquals] = "BiggerEquals";
- /**
- * @template T
- * @param {?} base
- * @param {?} other
- * @return {?}
- */
- function nullSafeIsEquivalent(base, other) {
- if (base == null || other == null) {
- return base == other;
- }
- return base.isEquivalent(other);
- }
- /**
- * @template T
- * @param {?} base
- * @param {?} other
- * @return {?}
- */
- function areAllEquivalent(base, other) {
- var /** @type {?} */ len = base.length;
- if (len !== other.length) {
- return false;
- }
- for (var /** @type {?} */ i = 0; i < len; i++) {
- if (!base[i].isEquivalent(other[i])) {
- return false;
- }
- }
- return true;
- }
- /**
- * @abstract
- */
- var Expression = /** @class */ (function () {
- function Expression(type, sourceSpan) {
- this.type = type || null;
- this.sourceSpan = sourceSpan || null;
- }
- /**
- * @param {?} name
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.prop = /**
- * @param {?} name
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (name, sourceSpan) {
- return new ReadPropExpr(this, name, null, sourceSpan);
- };
- /**
- * @param {?} index
- * @param {?=} type
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.key = /**
- * @param {?} index
- * @param {?=} type
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (index, type, sourceSpan) {
- return new ReadKeyExpr(this, index, type, sourceSpan);
- };
- /**
- * @param {?} name
- * @param {?} params
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.callMethod = /**
- * @param {?} name
- * @param {?} params
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (name, params, sourceSpan) {
- return new InvokeMethodExpr(this, name, params, null, sourceSpan);
- };
- /**
- * @param {?} params
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.callFn = /**
- * @param {?} params
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (params, sourceSpan) {
- return new InvokeFunctionExpr(this, params, null, sourceSpan);
- };
- /**
- * @param {?} params
- * @param {?=} type
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.instantiate = /**
- * @param {?} params
- * @param {?=} type
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (params, type, sourceSpan) {
- return new InstantiateExpr(this, params, type, sourceSpan);
- };
- /**
- * @param {?} trueCase
- * @param {?=} falseCase
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.conditional = /**
- * @param {?} trueCase
- * @param {?=} falseCase
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (trueCase, falseCase, sourceSpan) {
- if (falseCase === void 0) { falseCase = null; }
- return new ConditionalExpr(this, trueCase, falseCase, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.equals = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.Equals, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.notEquals = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.NotEquals, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.identical = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.Identical, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.notIdentical = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.NotIdentical, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.minus = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.Minus, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.plus = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.Plus, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.divide = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.Divide, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.multiply = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.Multiply, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.modulo = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.Modulo, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.and = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.or = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.Or, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.lower = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.Lower, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.lowerEquals = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.LowerEquals, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.bigger = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.Bigger, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.biggerEquals = /**
- * @param {?} rhs
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (rhs, sourceSpan) {
- return new BinaryOperatorExpr(BinaryOperator.BiggerEquals, this, rhs, null, sourceSpan);
- };
- /**
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.isBlank = /**
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (sourceSpan) {
- // Note: We use equals by purpose here to compare to null and undefined in JS.
- // We use the typed null to allow strictNullChecks to narrow types.
- return this.equals(TYPED_NULL_EXPR, sourceSpan);
- };
- /**
- * @param {?} type
- * @param {?=} sourceSpan
- * @return {?}
- */
- Expression.prototype.cast = /**
- * @param {?} type
- * @param {?=} sourceSpan
- * @return {?}
- */
- function (type, sourceSpan) {
- return new CastExpr(this, type, sourceSpan);
- };
- /**
- * @return {?}
- */
- Expression.prototype.toStmt = /**
- * @return {?}
- */
- function () { return new ExpressionStatement(this, null); };
- return Expression;
- }());
- /** @enum {number} */
- var BuiltinVar = {
- This: 0,
- Super: 1,
- CatchError: 2,
- CatchStack: 3,
- };
- BuiltinVar[BuiltinVar.This] = "This";
- BuiltinVar[BuiltinVar.Super] = "Super";
- BuiltinVar[BuiltinVar.CatchError] = "CatchError";
- BuiltinVar[BuiltinVar.CatchStack] = "CatchStack";
- var ReadVarExpr = /** @class */ (function (_super) {
- __extends(ReadVarExpr, _super);
- function ReadVarExpr(name, type, sourceSpan) {
- var _this = _super.call(this, type, sourceSpan) || this;
- if (typeof name === 'string') {
- _this.name = name;
- _this.builtin = null;
- }
- else {
- _this.name = null;
- _this.builtin = /** @type {?} */ (name);
- }
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- ReadVarExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof ReadVarExpr && this.name === e.name && this.builtin === e.builtin;
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ReadVarExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitReadVarExpr(this, context);
- };
- /**
- * @param {?} value
- * @return {?}
- */
- ReadVarExpr.prototype.set = /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- if (!this.name) {
- throw new Error("Built in variable " + this.builtin + " can not be assigned to.");
- }
- return new WriteVarExpr(this.name, value, null, this.sourceSpan);
- };
- return ReadVarExpr;
- }(Expression));
- var WriteVarExpr = /** @class */ (function (_super) {
- __extends(WriteVarExpr, _super);
- function WriteVarExpr(name, value, type, sourceSpan) {
- var _this = _super.call(this, type || value.type, sourceSpan) || this;
- _this.name = name;
- _this.value = value;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- WriteVarExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof WriteVarExpr && this.name === e.name && this.value.isEquivalent(e.value);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- WriteVarExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitWriteVarExpr(this, context);
- };
- /**
- * @param {?=} type
- * @param {?=} modifiers
- * @return {?}
- */
- WriteVarExpr.prototype.toDeclStmt = /**
- * @param {?=} type
- * @param {?=} modifiers
- * @return {?}
- */
- function (type, modifiers) {
- return new DeclareVarStmt(this.name, this.value, type, modifiers, this.sourceSpan);
- };
- return WriteVarExpr;
- }(Expression));
- var WriteKeyExpr = /** @class */ (function (_super) {
- __extends(WriteKeyExpr, _super);
- function WriteKeyExpr(receiver, index, value, type, sourceSpan) {
- var _this = _super.call(this, type || value.type, sourceSpan) || this;
- _this.receiver = receiver;
- _this.index = index;
- _this.value = value;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- WriteKeyExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof WriteKeyExpr && this.receiver.isEquivalent(e.receiver) &&
- this.index.isEquivalent(e.index) && this.value.isEquivalent(e.value);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- WriteKeyExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitWriteKeyExpr(this, context);
- };
- return WriteKeyExpr;
- }(Expression));
- var WritePropExpr = /** @class */ (function (_super) {
- __extends(WritePropExpr, _super);
- function WritePropExpr(receiver, name, value, type, sourceSpan) {
- var _this = _super.call(this, type || value.type, sourceSpan) || this;
- _this.receiver = receiver;
- _this.name = name;
- _this.value = value;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- WritePropExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof WritePropExpr && this.receiver.isEquivalent(e.receiver) &&
- this.name === e.name && this.value.isEquivalent(e.value);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- WritePropExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitWritePropExpr(this, context);
- };
- return WritePropExpr;
- }(Expression));
- /** @enum {number} */
- var BuiltinMethod = {
- ConcatArray: 0,
- SubscribeObservable: 1,
- Bind: 2,
- };
- BuiltinMethod[BuiltinMethod.ConcatArray] = "ConcatArray";
- BuiltinMethod[BuiltinMethod.SubscribeObservable] = "SubscribeObservable";
- BuiltinMethod[BuiltinMethod.Bind] = "Bind";
- var InvokeMethodExpr = /** @class */ (function (_super) {
- __extends(InvokeMethodExpr, _super);
- function InvokeMethodExpr(receiver, method, args, type, sourceSpan) {
- var _this = _super.call(this, type, sourceSpan) || this;
- _this.receiver = receiver;
- _this.args = args;
- if (typeof method === 'string') {
- _this.name = method;
- _this.builtin = null;
- }
- else {
- _this.name = null;
- _this.builtin = /** @type {?} */ (method);
- }
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- InvokeMethodExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof InvokeMethodExpr && this.receiver.isEquivalent(e.receiver) &&
- this.name === e.name && this.builtin === e.builtin && areAllEquivalent(this.args, e.args);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- InvokeMethodExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitInvokeMethodExpr(this, context);
- };
- return InvokeMethodExpr;
- }(Expression));
- var InvokeFunctionExpr = /** @class */ (function (_super) {
- __extends(InvokeFunctionExpr, _super);
- function InvokeFunctionExpr(fn, args, type, sourceSpan) {
- var _this = _super.call(this, type, sourceSpan) || this;
- _this.fn = fn;
- _this.args = args;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- InvokeFunctionExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof InvokeFunctionExpr && this.fn.isEquivalent(e.fn) &&
- areAllEquivalent(this.args, e.args);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- InvokeFunctionExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitInvokeFunctionExpr(this, context);
- };
- return InvokeFunctionExpr;
- }(Expression));
- var InstantiateExpr = /** @class */ (function (_super) {
- __extends(InstantiateExpr, _super);
- function InstantiateExpr(classExpr, args, type, sourceSpan) {
- var _this = _super.call(this, type, sourceSpan) || this;
- _this.classExpr = classExpr;
- _this.args = args;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- InstantiateExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof InstantiateExpr && this.classExpr.isEquivalent(e.classExpr) &&
- areAllEquivalent(this.args, e.args);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- InstantiateExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitInstantiateExpr(this, context);
- };
- return InstantiateExpr;
- }(Expression));
- var LiteralExpr = /** @class */ (function (_super) {
- __extends(LiteralExpr, _super);
- function LiteralExpr(value, type, sourceSpan) {
- var _this = _super.call(this, type, sourceSpan) || this;
- _this.value = value;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- LiteralExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof LiteralExpr && this.value === e.value;
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- LiteralExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitLiteralExpr(this, context);
- };
- return LiteralExpr;
- }(Expression));
- var ExternalExpr = /** @class */ (function (_super) {
- __extends(ExternalExpr, _super);
- function ExternalExpr(value, type, typeParams, sourceSpan) {
- if (typeParams === void 0) { typeParams = null; }
- var _this = _super.call(this, type, sourceSpan) || this;
- _this.value = value;
- _this.typeParams = typeParams;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- ExternalExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof ExternalExpr && this.value.name === e.value.name &&
- this.value.moduleName === e.value.moduleName && this.value.runtime === e.value.runtime;
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ExternalExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitExternalExpr(this, context);
- };
- return ExternalExpr;
- }(Expression));
- var ExternalReference = /** @class */ (function () {
- function ExternalReference(moduleName, name, runtime) {
- this.moduleName = moduleName;
- this.name = name;
- this.runtime = runtime;
- }
- return ExternalReference;
- }());
- var ConditionalExpr = /** @class */ (function (_super) {
- __extends(ConditionalExpr, _super);
- function ConditionalExpr(condition, trueCase, falseCase, type, sourceSpan) {
- if (falseCase === void 0) { falseCase = null; }
- var _this = _super.call(this, type || trueCase.type, sourceSpan) || this;
- _this.condition = condition;
- _this.falseCase = falseCase;
- _this.trueCase = trueCase;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- ConditionalExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof ConditionalExpr && this.condition.isEquivalent(e.condition) &&
- this.trueCase.isEquivalent(e.trueCase) && nullSafeIsEquivalent(this.falseCase, e.falseCase);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ConditionalExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitConditionalExpr(this, context);
- };
- return ConditionalExpr;
- }(Expression));
- var NotExpr = /** @class */ (function (_super) {
- __extends(NotExpr, _super);
- function NotExpr(condition, sourceSpan) {
- var _this = _super.call(this, BOOL_TYPE, sourceSpan) || this;
- _this.condition = condition;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- NotExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof NotExpr && this.condition.isEquivalent(e.condition);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- NotExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitNotExpr(this, context);
- };
- return NotExpr;
- }(Expression));
- var AssertNotNull = /** @class */ (function (_super) {
- __extends(AssertNotNull, _super);
- function AssertNotNull(condition, sourceSpan) {
- var _this = _super.call(this, condition.type, sourceSpan) || this;
- _this.condition = condition;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- AssertNotNull.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof AssertNotNull && this.condition.isEquivalent(e.condition);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- AssertNotNull.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitAssertNotNullExpr(this, context);
- };
- return AssertNotNull;
- }(Expression));
- var CastExpr = /** @class */ (function (_super) {
- __extends(CastExpr, _super);
- function CastExpr(value, type, sourceSpan) {
- var _this = _super.call(this, type, sourceSpan) || this;
- _this.value = value;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- CastExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof CastExpr && this.value.isEquivalent(e.value);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- CastExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitCastExpr(this, context);
- };
- return CastExpr;
- }(Expression));
- var FnParam = /** @class */ (function () {
- function FnParam(name, type) {
- if (type === void 0) { type = null; }
- this.name = name;
- this.type = type;
- }
- /**
- * @param {?} param
- * @return {?}
- */
- FnParam.prototype.isEquivalent = /**
- * @param {?} param
- * @return {?}
- */
- function (param) { return this.name === param.name; };
- return FnParam;
- }());
- var FunctionExpr = /** @class */ (function (_super) {
- __extends(FunctionExpr, _super);
- function FunctionExpr(params, statements, type, sourceSpan) {
- var _this = _super.call(this, type, sourceSpan) || this;
- _this.params = params;
- _this.statements = statements;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- FunctionExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof FunctionExpr && areAllEquivalent(this.params, e.params) &&
- areAllEquivalent(this.statements, e.statements);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- FunctionExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitFunctionExpr(this, context);
- };
- /**
- * @param {?} name
- * @param {?=} modifiers
- * @return {?}
- */
- FunctionExpr.prototype.toDeclStmt = /**
- * @param {?} name
- * @param {?=} modifiers
- * @return {?}
- */
- function (name, modifiers) {
- if (modifiers === void 0) { modifiers = null; }
- return new DeclareFunctionStmt(name, this.params, this.statements, this.type, modifiers, this.sourceSpan);
- };
- return FunctionExpr;
- }(Expression));
- var BinaryOperatorExpr = /** @class */ (function (_super) {
- __extends(BinaryOperatorExpr, _super);
- function BinaryOperatorExpr(operator, lhs, rhs, type, sourceSpan) {
- var _this = _super.call(this, type || lhs.type, sourceSpan) || this;
- _this.operator = operator;
- _this.rhs = rhs;
- _this.lhs = lhs;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- BinaryOperatorExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof BinaryOperatorExpr && this.operator === e.operator &&
- this.lhs.isEquivalent(e.lhs) && this.rhs.isEquivalent(e.rhs);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- BinaryOperatorExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitBinaryOperatorExpr(this, context);
- };
- return BinaryOperatorExpr;
- }(Expression));
- var ReadPropExpr = /** @class */ (function (_super) {
- __extends(ReadPropExpr, _super);
- function ReadPropExpr(receiver, name, type, sourceSpan) {
- var _this = _super.call(this, type, sourceSpan) || this;
- _this.receiver = receiver;
- _this.name = name;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- ReadPropExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof ReadPropExpr && this.receiver.isEquivalent(e.receiver) &&
- this.name === e.name;
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ReadPropExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitReadPropExpr(this, context);
- };
- /**
- * @param {?} value
- * @return {?}
- */
- ReadPropExpr.prototype.set = /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- return new WritePropExpr(this.receiver, this.name, value, null, this.sourceSpan);
- };
- return ReadPropExpr;
- }(Expression));
- var ReadKeyExpr = /** @class */ (function (_super) {
- __extends(ReadKeyExpr, _super);
- function ReadKeyExpr(receiver, index, type, sourceSpan) {
- var _this = _super.call(this, type, sourceSpan) || this;
- _this.receiver = receiver;
- _this.index = index;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- ReadKeyExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof ReadKeyExpr && this.receiver.isEquivalent(e.receiver) &&
- this.index.isEquivalent(e.index);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ReadKeyExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitReadKeyExpr(this, context);
- };
- /**
- * @param {?} value
- * @return {?}
- */
- ReadKeyExpr.prototype.set = /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- return new WriteKeyExpr(this.receiver, this.index, value, null, this.sourceSpan);
- };
- return ReadKeyExpr;
- }(Expression));
- var LiteralArrayExpr = /** @class */ (function (_super) {
- __extends(LiteralArrayExpr, _super);
- function LiteralArrayExpr(entries, type, sourceSpan) {
- var _this = _super.call(this, type, sourceSpan) || this;
- _this.entries = entries;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- LiteralArrayExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof LiteralArrayExpr && areAllEquivalent(this.entries, e.entries);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- LiteralArrayExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitLiteralArrayExpr(this, context);
- };
- return LiteralArrayExpr;
- }(Expression));
- var LiteralMapEntry = /** @class */ (function () {
- function LiteralMapEntry(key, value, quoted) {
- this.key = key;
- this.value = value;
- this.quoted = quoted;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- LiteralMapEntry.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return this.key === e.key && this.value.isEquivalent(e.value);
- };
- return LiteralMapEntry;
- }());
- var LiteralMapExpr = /** @class */ (function (_super) {
- __extends(LiteralMapExpr, _super);
- function LiteralMapExpr(entries, type, sourceSpan) {
- var _this = _super.call(this, type, sourceSpan) || this;
- _this.entries = entries;
- _this.valueType = null;
- if (type) {
- _this.valueType = type.valueType;
- }
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- LiteralMapExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof LiteralMapExpr && areAllEquivalent(this.entries, e.entries);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- LiteralMapExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitLiteralMapExpr(this, context);
- };
- return LiteralMapExpr;
- }(Expression));
- var CommaExpr = /** @class */ (function (_super) {
- __extends(CommaExpr, _super);
- function CommaExpr(parts, sourceSpan) {
- var _this = _super.call(this, parts[parts.length - 1].type, sourceSpan) || this;
- _this.parts = parts;
- return _this;
- }
- /**
- * @param {?} e
- * @return {?}
- */
- CommaExpr.prototype.isEquivalent = /**
- * @param {?} e
- * @return {?}
- */
- function (e) {
- return e instanceof CommaExpr && areAllEquivalent(this.parts, e.parts);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- CommaExpr.prototype.visitExpression = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitCommaExpr(this, context);
- };
- return CommaExpr;
- }(Expression));
- /**
- * @record
- */
-
- var THIS_EXPR = new ReadVarExpr(BuiltinVar.This, null, null);
- var SUPER_EXPR = new ReadVarExpr(BuiltinVar.Super, null, null);
- var CATCH_ERROR_VAR = new ReadVarExpr(BuiltinVar.CatchError, null, null);
- var CATCH_STACK_VAR = new ReadVarExpr(BuiltinVar.CatchStack, null, null);
- var NULL_EXPR = new LiteralExpr(null, null, null);
- var TYPED_NULL_EXPR = new LiteralExpr(null, INFERRED_TYPE, null);
- /** @enum {number} */
- var StmtModifier = {
- Final: 0,
- Private: 1,
- Exported: 2,
- };
- StmtModifier[StmtModifier.Final] = "Final";
- StmtModifier[StmtModifier.Private] = "Private";
- StmtModifier[StmtModifier.Exported] = "Exported";
- /**
- * @abstract
- */
- var Statement = /** @class */ (function () {
- function Statement(modifiers, sourceSpan) {
- this.modifiers = modifiers || [];
- this.sourceSpan = sourceSpan || null;
- }
- /**
- * @param {?} modifier
- * @return {?}
- */
- Statement.prototype.hasModifier = /**
- * @param {?} modifier
- * @return {?}
- */
- function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; };
- return Statement;
- }());
- var DeclareVarStmt = /** @class */ (function (_super) {
- __extends(DeclareVarStmt, _super);
- function DeclareVarStmt(name, value, type, modifiers, sourceSpan) {
- if (modifiers === void 0) { modifiers = null; }
- var _this = _super.call(this, modifiers, sourceSpan) || this;
- _this.name = name;
- _this.value = value;
- _this.type = type || value.type;
- return _this;
- }
- /**
- * @param {?} stmt
- * @return {?}
- */
- DeclareVarStmt.prototype.isEquivalent = /**
- * @param {?} stmt
- * @return {?}
- */
- function (stmt) {
- return stmt instanceof DeclareVarStmt && this.name === stmt.name &&
- this.value.isEquivalent(stmt.value);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- DeclareVarStmt.prototype.visitStatement = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitDeclareVarStmt(this, context);
- };
- return DeclareVarStmt;
- }(Statement));
- var DeclareFunctionStmt = /** @class */ (function (_super) {
- __extends(DeclareFunctionStmt, _super);
- function DeclareFunctionStmt(name, params, statements, type, modifiers, sourceSpan) {
- if (modifiers === void 0) { modifiers = null; }
- var _this = _super.call(this, modifiers, sourceSpan) || this;
- _this.name = name;
- _this.params = params;
- _this.statements = statements;
- _this.type = type || null;
- return _this;
- }
- /**
- * @param {?} stmt
- * @return {?}
- */
- DeclareFunctionStmt.prototype.isEquivalent = /**
- * @param {?} stmt
- * @return {?}
- */
- function (stmt) {
- return stmt instanceof DeclareFunctionStmt && areAllEquivalent(this.params, stmt.params) &&
- areAllEquivalent(this.statements, stmt.statements);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- DeclareFunctionStmt.prototype.visitStatement = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitDeclareFunctionStmt(this, context);
- };
- return DeclareFunctionStmt;
- }(Statement));
- var ExpressionStatement = /** @class */ (function (_super) {
- __extends(ExpressionStatement, _super);
- function ExpressionStatement(expr, sourceSpan) {
- var _this = _super.call(this, null, sourceSpan) || this;
- _this.expr = expr;
- return _this;
- }
- /**
- * @param {?} stmt
- * @return {?}
- */
- ExpressionStatement.prototype.isEquivalent = /**
- * @param {?} stmt
- * @return {?}
- */
- function (stmt) {
- return stmt instanceof ExpressionStatement && this.expr.isEquivalent(stmt.expr);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ExpressionStatement.prototype.visitStatement = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitExpressionStmt(this, context);
- };
- return ExpressionStatement;
- }(Statement));
- var ReturnStatement = /** @class */ (function (_super) {
- __extends(ReturnStatement, _super);
- function ReturnStatement(value, sourceSpan) {
- var _this = _super.call(this, null, sourceSpan) || this;
- _this.value = value;
- return _this;
- }
- /**
- * @param {?} stmt
- * @return {?}
- */
- ReturnStatement.prototype.isEquivalent = /**
- * @param {?} stmt
- * @return {?}
- */
- function (stmt) {
- return stmt instanceof ReturnStatement && this.value.isEquivalent(stmt.value);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ReturnStatement.prototype.visitStatement = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitReturnStmt(this, context);
- };
- return ReturnStatement;
- }(Statement));
- var AbstractClassPart = /** @class */ (function () {
- function AbstractClassPart(type, modifiers) {
- this.modifiers = modifiers;
- if (!modifiers) {
- this.modifiers = [];
- }
- this.type = type || null;
- }
- /**
- * @param {?} modifier
- * @return {?}
- */
- AbstractClassPart.prototype.hasModifier = /**
- * @param {?} modifier
- * @return {?}
- */
- function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; };
- return AbstractClassPart;
- }());
- var ClassField = /** @class */ (function (_super) {
- __extends(ClassField, _super);
- function ClassField(name, type, modifiers) {
- if (modifiers === void 0) { modifiers = null; }
- var _this = _super.call(this, type, modifiers) || this;
- _this.name = name;
- return _this;
- }
- /**
- * @param {?} f
- * @return {?}
- */
- ClassField.prototype.isEquivalent = /**
- * @param {?} f
- * @return {?}
- */
- function (f) { return this.name === f.name; };
- return ClassField;
- }(AbstractClassPart));
- var ClassMethod = /** @class */ (function (_super) {
- __extends(ClassMethod, _super);
- function ClassMethod(name, params, body, type, modifiers) {
- if (modifiers === void 0) { modifiers = null; }
- var _this = _super.call(this, type, modifiers) || this;
- _this.name = name;
- _this.params = params;
- _this.body = body;
- return _this;
- }
- /**
- * @param {?} m
- * @return {?}
- */
- ClassMethod.prototype.isEquivalent = /**
- * @param {?} m
- * @return {?}
- */
- function (m) {
- return this.name === m.name && areAllEquivalent(this.body, m.body);
- };
- return ClassMethod;
- }(AbstractClassPart));
- var ClassGetter = /** @class */ (function (_super) {
- __extends(ClassGetter, _super);
- function ClassGetter(name, body, type, modifiers) {
- if (modifiers === void 0) { modifiers = null; }
- var _this = _super.call(this, type, modifiers) || this;
- _this.name = name;
- _this.body = body;
- return _this;
- }
- /**
- * @param {?} m
- * @return {?}
- */
- ClassGetter.prototype.isEquivalent = /**
- * @param {?} m
- * @return {?}
- */
- function (m) {
- return this.name === m.name && areAllEquivalent(this.body, m.body);
- };
- return ClassGetter;
- }(AbstractClassPart));
- var ClassStmt = /** @class */ (function (_super) {
- __extends(ClassStmt, _super);
- function ClassStmt(name, parent, fields, getters, constructorMethod, methods, modifiers, sourceSpan) {
- if (modifiers === void 0) { modifiers = null; }
- var _this = _super.call(this, modifiers, sourceSpan) || this;
- _this.name = name;
- _this.parent = parent;
- _this.fields = fields;
- _this.getters = getters;
- _this.constructorMethod = constructorMethod;
- _this.methods = methods;
- return _this;
- }
- /**
- * @param {?} stmt
- * @return {?}
- */
- ClassStmt.prototype.isEquivalent = /**
- * @param {?} stmt
- * @return {?}
- */
- function (stmt) {
- return stmt instanceof ClassStmt && this.name === stmt.name &&
- nullSafeIsEquivalent(this.parent, stmt.parent) &&
- areAllEquivalent(this.fields, stmt.fields) &&
- areAllEquivalent(this.getters, stmt.getters) &&
- this.constructorMethod.isEquivalent(stmt.constructorMethod) &&
- areAllEquivalent(this.methods, stmt.methods);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ClassStmt.prototype.visitStatement = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitDeclareClassStmt(this, context);
- };
- return ClassStmt;
- }(Statement));
- var IfStmt = /** @class */ (function (_super) {
- __extends(IfStmt, _super);
- function IfStmt(condition, trueCase, falseCase, sourceSpan) {
- if (falseCase === void 0) { falseCase = []; }
- var _this = _super.call(this, null, sourceSpan) || this;
- _this.condition = condition;
- _this.trueCase = trueCase;
- _this.falseCase = falseCase;
- return _this;
- }
- /**
- * @param {?} stmt
- * @return {?}
- */
- IfStmt.prototype.isEquivalent = /**
- * @param {?} stmt
- * @return {?}
- */
- function (stmt) {
- return stmt instanceof IfStmt && this.condition.isEquivalent(stmt.condition) &&
- areAllEquivalent(this.trueCase, stmt.trueCase) &&
- areAllEquivalent(this.falseCase, stmt.falseCase);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- IfStmt.prototype.visitStatement = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitIfStmt(this, context);
- };
- return IfStmt;
- }(Statement));
- var CommentStmt = /** @class */ (function (_super) {
- __extends(CommentStmt, _super);
- function CommentStmt(comment, sourceSpan) {
- var _this = _super.call(this, null, sourceSpan) || this;
- _this.comment = comment;
- return _this;
- }
- /**
- * @param {?} stmt
- * @return {?}
- */
- CommentStmt.prototype.isEquivalent = /**
- * @param {?} stmt
- * @return {?}
- */
- function (stmt) { return stmt instanceof CommentStmt; };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- CommentStmt.prototype.visitStatement = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitCommentStmt(this, context);
- };
- return CommentStmt;
- }(Statement));
- var TryCatchStmt = /** @class */ (function (_super) {
- __extends(TryCatchStmt, _super);
- function TryCatchStmt(bodyStmts, catchStmts, sourceSpan) {
- var _this = _super.call(this, null, sourceSpan) || this;
- _this.bodyStmts = bodyStmts;
- _this.catchStmts = catchStmts;
- return _this;
- }
- /**
- * @param {?} stmt
- * @return {?}
- */
- TryCatchStmt.prototype.isEquivalent = /**
- * @param {?} stmt
- * @return {?}
- */
- function (stmt) {
- return stmt instanceof TryCatchStmt && areAllEquivalent(this.bodyStmts, stmt.bodyStmts) &&
- areAllEquivalent(this.catchStmts, stmt.catchStmts);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- TryCatchStmt.prototype.visitStatement = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitTryCatchStmt(this, context);
- };
- return TryCatchStmt;
- }(Statement));
- var ThrowStmt = /** @class */ (function (_super) {
- __extends(ThrowStmt, _super);
- function ThrowStmt(error, sourceSpan) {
- var _this = _super.call(this, null, sourceSpan) || this;
- _this.error = error;
- return _this;
- }
- /**
- * @param {?} stmt
- * @return {?}
- */
- ThrowStmt.prototype.isEquivalent = /**
- * @param {?} stmt
- * @return {?}
- */
- function (stmt) {
- return stmt instanceof TryCatchStmt && this.error.isEquivalent(stmt.error);
- };
- /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- ThrowStmt.prototype.visitStatement = /**
- * @param {?} visitor
- * @param {?} context
- * @return {?}
- */
- function (visitor, context) {
- return visitor.visitThrowStmt(this, context);
- };
- return ThrowStmt;
- }(Statement));
- /**
- * @record
- */
-
- var AstTransformer$1 = /** @class */ (function () {
- function AstTransformer() {
- }
- /**
- * @param {?} expr
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.transformExpr = /**
- * @param {?} expr
- * @param {?} context
- * @return {?}
- */
- function (expr, context) { return expr; };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.transformStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) { return stmt; };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitReadVarExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return this.transformExpr(ast, context); };
- /**
- * @param {?} expr
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitWriteVarExpr = /**
- * @param {?} expr
- * @param {?} context
- * @return {?}
- */
- function (expr, context) {
- return this.transformExpr(new WriteVarExpr(expr.name, expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context);
- };
- /**
- * @param {?} expr
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitWriteKeyExpr = /**
- * @param {?} expr
- * @param {?} context
- * @return {?}
- */
- function (expr, context) {
- return this.transformExpr(new WriteKeyExpr(expr.receiver.visitExpression(this, context), expr.index.visitExpression(this, context), expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context);
- };
- /**
- * @param {?} expr
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitWritePropExpr = /**
- * @param {?} expr
- * @param {?} context
- * @return {?}
- */
- function (expr, context) {
- return this.transformExpr(new WritePropExpr(expr.receiver.visitExpression(this, context), expr.name, expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitInvokeMethodExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var /** @type {?} */ method = ast.builtin || ast.name;
- return this.transformExpr(new InvokeMethodExpr(ast.receiver.visitExpression(this, context), /** @type {?} */ ((method)), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitInvokeFunctionExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new InvokeFunctionExpr(ast.fn.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitInstantiateExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new InstantiateExpr(ast.classExpr.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitLiteralExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return this.transformExpr(ast, context); };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitExternalExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitConditionalExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new ConditionalExpr(ast.condition.visitExpression(this, context), ast.trueCase.visitExpression(this, context), /** @type {?} */ ((ast.falseCase)).visitExpression(this, context), ast.type, ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitNotExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new NotExpr(ast.condition.visitExpression(this, context), ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitAssertNotNullExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new AssertNotNull(ast.condition.visitExpression(this, context), ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitCastExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new CastExpr(ast.value.visitExpression(this, context), ast.type, ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitFunctionExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new FunctionExpr(ast.params, this.visitAllStatements(ast.statements, context), ast.type, ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitBinaryOperatorExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new BinaryOperatorExpr(ast.operator, ast.lhs.visitExpression(this, context), ast.rhs.visitExpression(this, context), ast.type, ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitReadPropExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new ReadPropExpr(ast.receiver.visitExpression(this, context), ast.name, ast.type, ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitReadKeyExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new ReadKeyExpr(ast.receiver.visitExpression(this, context), ast.index.visitExpression(this, context), ast.type, ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitLiteralArrayExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new LiteralArrayExpr(this.visitAllExpressions(ast.entries, context), ast.type, ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitLiteralMapExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var _this = this;
- var /** @type {?} */ entries = ast.entries.map(function (entry) {
- return new LiteralMapEntry(entry.key, entry.value.visitExpression(_this, context), entry.quoted);
- });
- var /** @type {?} */ mapType = new MapType(ast.valueType, null);
- return this.transformExpr(new LiteralMapExpr(entries, mapType, ast.sourceSpan), context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitCommaExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.transformExpr(new CommaExpr(this.visitAllExpressions(ast.parts, context), ast.sourceSpan), context);
- };
- /**
- * @param {?} exprs
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitAllExpressions = /**
- * @param {?} exprs
- * @param {?} context
- * @return {?}
- */
- function (exprs, context) {
- var _this = this;
- return exprs.map(function (expr) { return expr.visitExpression(_this, context); });
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitDeclareVarStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- return this.transformStmt(new DeclareVarStmt(stmt.name, stmt.value.visitExpression(this, context), stmt.type, stmt.modifiers, stmt.sourceSpan), context);
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitDeclareFunctionStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- return this.transformStmt(new DeclareFunctionStmt(stmt.name, stmt.params, this.visitAllStatements(stmt.statements, context), stmt.type, stmt.modifiers, stmt.sourceSpan), context);
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitExpressionStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- return this.transformStmt(new ExpressionStatement(stmt.expr.visitExpression(this, context), stmt.sourceSpan), context);
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitReturnStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- return this.transformStmt(new ReturnStatement(stmt.value.visitExpression(this, context), stmt.sourceSpan), context);
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitDeclareClassStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- var _this = this;
- var /** @type {?} */ parent = /** @type {?} */ ((stmt.parent)).visitExpression(this, context);
- var /** @type {?} */ getters = stmt.getters.map(function (getter) {
- return new ClassGetter(getter.name, _this.visitAllStatements(getter.body, context), getter.type, getter.modifiers);
- });
- var /** @type {?} */ ctorMethod = stmt.constructorMethod &&
- new ClassMethod(stmt.constructorMethod.name, stmt.constructorMethod.params, this.visitAllStatements(stmt.constructorMethod.body, context), stmt.constructorMethod.type, stmt.constructorMethod.modifiers);
- var /** @type {?} */ methods = stmt.methods.map(function (method) {
- return new ClassMethod(method.name, method.params, _this.visitAllStatements(method.body, context), method.type, method.modifiers);
- });
- return this.transformStmt(new ClassStmt(stmt.name, parent, stmt.fields, getters, ctorMethod, methods, stmt.modifiers, stmt.sourceSpan), context);
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitIfStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- return this.transformStmt(new IfStmt(stmt.condition.visitExpression(this, context), this.visitAllStatements(stmt.trueCase, context), this.visitAllStatements(stmt.falseCase, context), stmt.sourceSpan), context);
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitTryCatchStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- return this.transformStmt(new TryCatchStmt(this.visitAllStatements(stmt.bodyStmts, context), this.visitAllStatements(stmt.catchStmts, context), stmt.sourceSpan), context);
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitThrowStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- return this.transformStmt(new ThrowStmt(stmt.error.visitExpression(this, context), stmt.sourceSpan), context);
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitCommentStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- return this.transformStmt(stmt, context);
- };
- /**
- * @param {?} stmts
- * @param {?} context
- * @return {?}
- */
- AstTransformer.prototype.visitAllStatements = /**
- * @param {?} stmts
- * @param {?} context
- * @return {?}
- */
- function (stmts, context) {
- var _this = this;
- return stmts.map(function (stmt) { return stmt.visitStatement(_this, context); });
- };
- return AstTransformer;
- }());
- var RecursiveAstVisitor$1 = /** @class */ (function () {
- function RecursiveAstVisitor() {
- }
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitType = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { return ast; };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitExpression = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- if (ast.type) {
- ast.type.visitType(this, context);
- }
- return ast;
- };
- /**
- * @param {?} type
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitBuiltintType = /**
- * @param {?} type
- * @param {?} context
- * @return {?}
- */
- function (type, context) { return this.visitType(type, context); };
- /**
- * @param {?} type
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitExpressionType = /**
- * @param {?} type
- * @param {?} context
- * @return {?}
- */
- function (type, context) {
- type.value.visitExpression(this, context);
- return this.visitType(type, context);
- };
- /**
- * @param {?} type
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitArrayType = /**
- * @param {?} type
- * @param {?} context
- * @return {?}
- */
- function (type, context) { return this.visitType(type, context); };
- /**
- * @param {?} type
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitMapType = /**
- * @param {?} type
- * @param {?} context
- * @return {?}
- */
- function (type, context) { return this.visitType(type, context); };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitReadVarExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitWriteVarExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.value.visitExpression(this, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitWriteKeyExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.receiver.visitExpression(this, context);
- ast.index.visitExpression(this, context);
- ast.value.visitExpression(this, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitWritePropExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.receiver.visitExpression(this, context);
- ast.value.visitExpression(this, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitInvokeMethodExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.receiver.visitExpression(this, context);
- this.visitAllExpressions(ast.args, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitInvokeFunctionExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.fn.visitExpression(this, context);
- this.visitAllExpressions(ast.args, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitInstantiateExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.classExpr.visitExpression(this, context);
- this.visitAllExpressions(ast.args, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitLiteralExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitExternalExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var _this = this;
- if (ast.typeParams) {
- ast.typeParams.forEach(function (type) { return type.visitType(_this, context); });
- }
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitConditionalExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.condition.visitExpression(this, context);
- ast.trueCase.visitExpression(this, context); /** @type {?} */
- ((ast.falseCase)).visitExpression(this, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitNotExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.condition.visitExpression(this, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitAssertNotNullExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.condition.visitExpression(this, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitCastExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.value.visitExpression(this, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitFunctionExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- this.visitAllStatements(ast.statements, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitBinaryOperatorExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.lhs.visitExpression(this, context);
- ast.rhs.visitExpression(this, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitReadPropExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.receiver.visitExpression(this, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitReadKeyExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- ast.receiver.visitExpression(this, context);
- ast.index.visitExpression(this, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitLiteralArrayExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- this.visitAllExpressions(ast.entries, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitLiteralMapExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var _this = this;
- ast.entries.forEach(function (entry) { return entry.value.visitExpression(_this, context); });
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitCommaExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- this.visitAllExpressions(ast.parts, context);
- return this.visitExpression(ast, context);
- };
- /**
- * @param {?} exprs
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitAllExpressions = /**
- * @param {?} exprs
- * @param {?} context
- * @return {?}
- */
- function (exprs, context) {
- var _this = this;
- exprs.forEach(function (expr) { return expr.visitExpression(_this, context); });
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitDeclareVarStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- stmt.value.visitExpression(this, context);
- if (stmt.type) {
- stmt.type.visitType(this, context);
- }
- return stmt;
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitDeclareFunctionStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- this.visitAllStatements(stmt.statements, context);
- if (stmt.type) {
- stmt.type.visitType(this, context);
- }
- return stmt;
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitExpressionStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- stmt.expr.visitExpression(this, context);
- return stmt;
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitReturnStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- stmt.value.visitExpression(this, context);
- return stmt;
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitDeclareClassStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- var _this = this;
- /** @type {?} */ ((stmt.parent)).visitExpression(this, context);
- stmt.getters.forEach(function (getter) { return _this.visitAllStatements(getter.body, context); });
- if (stmt.constructorMethod) {
- this.visitAllStatements(stmt.constructorMethod.body, context);
- }
- stmt.methods.forEach(function (method) { return _this.visitAllStatements(method.body, context); });
- return stmt;
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitIfStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- stmt.condition.visitExpression(this, context);
- this.visitAllStatements(stmt.trueCase, context);
- this.visitAllStatements(stmt.falseCase, context);
- return stmt;
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitTryCatchStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- this.visitAllStatements(stmt.bodyStmts, context);
- this.visitAllStatements(stmt.catchStmts, context);
- return stmt;
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitThrowStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- stmt.error.visitExpression(this, context);
- return stmt;
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitCommentStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) { return stmt; };
- /**
- * @param {?} stmts
- * @param {?} context
- * @return {?}
- */
- RecursiveAstVisitor.prototype.visitAllStatements = /**
- * @param {?} stmts
- * @param {?} context
- * @return {?}
- */
- function (stmts, context) {
- var _this = this;
- stmts.forEach(function (stmt) { return stmt.visitStatement(_this, context); });
- };
- return RecursiveAstVisitor;
- }());
- /**
- * @param {?} stmts
- * @return {?}
- */
- function findReadVarNames(stmts) {
- var /** @type {?} */ visitor = new _ReadVarVisitor();
- visitor.visitAllStatements(stmts, null);
- return visitor.varNames;
- }
- var _ReadVarVisitor = /** @class */ (function (_super) {
- __extends(_ReadVarVisitor, _super);
- function _ReadVarVisitor() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.varNames = new Set();
- return _this;
- }
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- _ReadVarVisitor.prototype.visitDeclareFunctionStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- // Don't descend into nested functions
- return stmt;
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- _ReadVarVisitor.prototype.visitDeclareClassStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- // Don't descend into nested classes
- return stmt;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- _ReadVarVisitor.prototype.visitReadVarExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- if (ast.name) {
- this.varNames.add(ast.name);
- }
- return null;
- };
- return _ReadVarVisitor;
- }(RecursiveAstVisitor$1));
- /**
- * @param {?} stmts
- * @return {?}
- */
- function collectExternalReferences(stmts) {
- var /** @type {?} */ visitor = new _FindExternalReferencesVisitor();
- visitor.visitAllStatements(stmts, null);
- return visitor.externalReferences;
- }
- var _FindExternalReferencesVisitor = /** @class */ (function (_super) {
- __extends(_FindExternalReferencesVisitor, _super);
- function _FindExternalReferencesVisitor() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.externalReferences = [];
- return _this;
- }
- /**
- * @param {?} e
- * @param {?} context
- * @return {?}
- */
- _FindExternalReferencesVisitor.prototype.visitExternalExpr = /**
- * @param {?} e
- * @param {?} context
- * @return {?}
- */
- function (e, context) {
- this.externalReferences.push(e.value);
- return _super.prototype.visitExternalExpr.call(this, e, context);
- };
- return _FindExternalReferencesVisitor;
- }(RecursiveAstVisitor$1));
- /**
- * @param {?} stmt
- * @param {?} sourceSpan
- * @return {?}
- */
- function applySourceSpanToStatementIfNeeded(stmt, sourceSpan) {
- if (!sourceSpan) {
- return stmt;
- }
- var /** @type {?} */ transformer = new _ApplySourceSpanTransformer(sourceSpan);
- return stmt.visitStatement(transformer, null);
- }
- /**
- * @param {?} expr
- * @param {?} sourceSpan
- * @return {?}
- */
- function applySourceSpanToExpressionIfNeeded(expr, sourceSpan) {
- if (!sourceSpan) {
- return expr;
- }
- var /** @type {?} */ transformer = new _ApplySourceSpanTransformer(sourceSpan);
- return expr.visitExpression(transformer, null);
- }
- var _ApplySourceSpanTransformer = /** @class */ (function (_super) {
- __extends(_ApplySourceSpanTransformer, _super);
- function _ApplySourceSpanTransformer(sourceSpan) {
- var _this = _super.call(this) || this;
- _this.sourceSpan = sourceSpan;
- return _this;
- }
- /**
- * @param {?} obj
- * @return {?}
- */
- _ApplySourceSpanTransformer.prototype._clone = /**
- * @param {?} obj
- * @return {?}
- */
- function (obj) {
- var /** @type {?} */ clone = Object.create(obj.constructor.prototype);
- for (var /** @type {?} */ prop in obj) {
- clone[prop] = obj[prop];
- }
- return clone;
- };
- /**
- * @param {?} expr
- * @param {?} context
- * @return {?}
- */
- _ApplySourceSpanTransformer.prototype.transformExpr = /**
- * @param {?} expr
- * @param {?} context
- * @return {?}
- */
- function (expr, context) {
- if (!expr.sourceSpan) {
- expr = this._clone(expr);
- expr.sourceSpan = this.sourceSpan;
- }
- return expr;
- };
- /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- _ApplySourceSpanTransformer.prototype.transformStmt = /**
- * @param {?} stmt
- * @param {?} context
- * @return {?}
- */
- function (stmt, context) {
- if (!stmt.sourceSpan) {
- stmt = this._clone(stmt);
- stmt.sourceSpan = this.sourceSpan;
- }
- return stmt;
- };
- return _ApplySourceSpanTransformer;
- }(AstTransformer$1));
- /**
- * @param {?} name
- * @param {?=} type
- * @param {?=} sourceSpan
- * @return {?}
- */
- function variable(name, type, sourceSpan) {
- return new ReadVarExpr(name, type, sourceSpan);
- }
- /**
- * @param {?} id
- * @param {?=} typeParams
- * @param {?=} sourceSpan
- * @return {?}
- */
- function importExpr(id, typeParams, sourceSpan) {
- if (typeParams === void 0) { typeParams = null; }
- return new ExternalExpr(id, null, typeParams, sourceSpan);
- }
- /**
- * @param {?} id
- * @param {?=} typeParams
- * @param {?=} typeModifiers
- * @return {?}
- */
- function importType(id, typeParams, typeModifiers) {
- if (typeParams === void 0) { typeParams = null; }
- if (typeModifiers === void 0) { typeModifiers = null; }
- return id != null ? expressionType(importExpr(id, typeParams, null), typeModifiers) : null;
- }
- /**
- * @param {?} expr
- * @param {?=} typeModifiers
- * @return {?}
- */
- function expressionType(expr, typeModifiers) {
- if (typeModifiers === void 0) { typeModifiers = null; }
- return new ExpressionType(expr, typeModifiers);
- }
- /**
- * @param {?} values
- * @param {?=} type
- * @param {?=} sourceSpan
- * @return {?}
- */
- function literalArr(values, type, sourceSpan) {
- return new LiteralArrayExpr(values, type, sourceSpan);
- }
- /**
- * @param {?} values
- * @param {?=} type
- * @return {?}
- */
- function literalMap(values, type) {
- if (type === void 0) { type = null; }
- return new LiteralMapExpr(values.map(function (e) { return new LiteralMapEntry(e.key, e.value, e.quoted); }), type, null);
- }
- /**
- * @param {?} expr
- * @param {?=} sourceSpan
- * @return {?}
- */
- function not(expr, sourceSpan) {
- return new NotExpr(expr, sourceSpan);
- }
- /**
- * @param {?} expr
- * @param {?=} sourceSpan
- * @return {?}
- */
- function assertNotNull(expr, sourceSpan) {
- return new AssertNotNull(expr, sourceSpan);
- }
- /**
- * @param {?} params
- * @param {?} body
- * @param {?=} type
- * @param {?=} sourceSpan
- * @return {?}
- */
- function fn(params, body, type, sourceSpan) {
- return new FunctionExpr(params, body, type, sourceSpan);
- }
- /**
- * @param {?} value
- * @param {?=} type
- * @param {?=} sourceSpan
- * @return {?}
- */
- function literal(value, type, sourceSpan) {
- return new LiteralExpr(value, type, sourceSpan);
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var ProviderError = /** @class */ (function (_super) {
- __extends(ProviderError, _super);
- function ProviderError(message, span) {
- return _super.call(this, span, message) || this;
- }
- return ProviderError;
- }(ParseError));
- /**
- * @record
- */
-
- var ProviderViewContext = /** @class */ (function () {
- function ProviderViewContext(reflector, component) {
- var _this = this;
- this.reflector = reflector;
- this.component = component;
- this.errors = [];
- this.viewQueries = _getViewQueries(component);
- this.viewProviders = new Map();
- component.viewProviders.forEach(function (provider) {
- if (_this.viewProviders.get(tokenReference(provider.token)) == null) {
- _this.viewProviders.set(tokenReference(provider.token), true);
- }
- });
- }
- return ProviderViewContext;
- }());
- var ProviderElementContext = /** @class */ (function () {
- function ProviderElementContext(viewContext, _parent, _isViewRoot, _directiveAsts, attrs, refs, isTemplate, contentQueryStartId, _sourceSpan) {
- var _this = this;
- this.viewContext = viewContext;
- this._parent = _parent;
- this._isViewRoot = _isViewRoot;
- this._directiveAsts = _directiveAsts;
- this._sourceSpan = _sourceSpan;
- this._transformedProviders = new Map();
- this._seenProviders = new Map();
- this._queriedTokens = new Map();
- this.transformedHasViewContainer = false;
- this._attrs = {};
- attrs.forEach(function (attrAst) { return _this._attrs[attrAst.name] = attrAst.value; });
- var /** @type {?} */ directivesMeta = _directiveAsts.map(function (directiveAst) { return directiveAst.directive; });
- this._allProviders =
- _resolveProvidersFromDirectives(directivesMeta, _sourceSpan, viewContext.errors);
- this._contentQueries = _getContentQueries(contentQueryStartId, directivesMeta);
- Array.from(this._allProviders.values()).forEach(function (provider) {
- _this._addQueryReadsTo(provider.token, provider.token, _this._queriedTokens);
- });
- if (isTemplate) {
- var /** @type {?} */ templateRefId = createTokenForExternalReference(this.viewContext.reflector, Identifiers.TemplateRef);
- this._addQueryReadsTo(templateRefId, templateRefId, this._queriedTokens);
- }
- refs.forEach(function (refAst) {
- var /** @type {?} */ defaultQueryValue = refAst.value ||
- createTokenForExternalReference(_this.viewContext.reflector, Identifiers.ElementRef);
- _this._addQueryReadsTo({ value: refAst.name }, defaultQueryValue, _this._queriedTokens);
- });
- if (this._queriedTokens.get(this.viewContext.reflector.resolveExternalReference(Identifiers.ViewContainerRef))) {
- this.transformedHasViewContainer = true;
- }
- // create the providers that we know are eager first
- Array.from(this._allProviders.values()).forEach(function (provider) {
- var /** @type {?} */ eager = provider.eager || _this._queriedTokens.get(tokenReference(provider.token));
- if (eager) {
- _this._getOrCreateLocalProvider(provider.providerType, provider.token, true);
- }
- });
- }
- /**
- * @return {?}
- */
- ProviderElementContext.prototype.afterElement = /**
- * @return {?}
- */
- function () {
- var _this = this;
- // collect lazy providers
- Array.from(this._allProviders.values()).forEach(function (provider) {
- _this._getOrCreateLocalProvider(provider.providerType, provider.token, false);
- });
- };
- Object.defineProperty(ProviderElementContext.prototype, "transformProviders", {
- get: /**
- * @return {?}
- */
- function () {
- // Note: Maps keep their insertion order.
- var /** @type {?} */ lazyProviders = [];
- var /** @type {?} */ eagerProviders = [];
- this._transformedProviders.forEach(function (provider) {
- if (provider.eager) {
- eagerProviders.push(provider);
- }
- else {
- lazyProviders.push(provider);
- }
- });
- return lazyProviders.concat(eagerProviders);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ProviderElementContext.prototype, "transformedDirectiveAsts", {
- get: /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ sortedProviderTypes = this.transformProviders.map(function (provider) { return provider.token.identifier; });
- var /** @type {?} */ sortedDirectives = this._directiveAsts.slice();
- sortedDirectives.sort(function (dir1, dir2) {
- return sortedProviderTypes.indexOf(dir1.directive.type) -
- sortedProviderTypes.indexOf(dir2.directive.type);
- });
- return sortedDirectives;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ProviderElementContext.prototype, "queryMatches", {
- get: /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ allMatches = [];
- this._queriedTokens.forEach(function (matches) { allMatches.push.apply(allMatches, matches); });
- return allMatches;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} token
- * @param {?} defaultValue
- * @param {?} queryReadTokens
- * @return {?}
- */
- ProviderElementContext.prototype._addQueryReadsTo = /**
- * @param {?} token
- * @param {?} defaultValue
- * @param {?} queryReadTokens
- * @return {?}
- */
- function (token, defaultValue, queryReadTokens) {
- this._getQueriesFor(token).forEach(function (query) {
- var /** @type {?} */ queryValue = query.meta.read || defaultValue;
- var /** @type {?} */ tokenRef = tokenReference(queryValue);
- var /** @type {?} */ queryMatches = queryReadTokens.get(tokenRef);
- if (!queryMatches) {
- queryMatches = [];
- queryReadTokens.set(tokenRef, queryMatches);
- }
- queryMatches.push({ queryId: query.queryId, value: queryValue });
- });
- };
- /**
- * @param {?} token
- * @return {?}
- */
- ProviderElementContext.prototype._getQueriesFor = /**
- * @param {?} token
- * @return {?}
- */
- function (token) {
- var /** @type {?} */ result = [];
- var /** @type {?} */ currentEl = this;
- var /** @type {?} */ distance = 0;
- var /** @type {?} */ queries;
- while (currentEl !== null) {
- queries = currentEl._contentQueries.get(tokenReference(token));
- if (queries) {
- result.push.apply(result, queries.filter(function (query) { return query.meta.descendants || distance <= 1; }));
- }
- if (currentEl._directiveAsts.length > 0) {
- distance++;
- }
- currentEl = currentEl._parent;
- }
- queries = this.viewContext.viewQueries.get(tokenReference(token));
- if (queries) {
- result.push.apply(result, queries);
- }
- return result;
- };
- /**
- * @param {?} requestingProviderType
- * @param {?} token
- * @param {?} eager
- * @return {?}
- */
- ProviderElementContext.prototype._getOrCreateLocalProvider = /**
- * @param {?} requestingProviderType
- * @param {?} token
- * @param {?} eager
- * @return {?}
- */
- function (requestingProviderType, token, eager) {
- var _this = this;
- var /** @type {?} */ resolvedProvider = this._allProviders.get(tokenReference(token));
- if (!resolvedProvider || ((requestingProviderType === ProviderAstType.Directive ||
- requestingProviderType === ProviderAstType.PublicService) &&
- resolvedProvider.providerType === ProviderAstType.PrivateService) ||
- ((requestingProviderType === ProviderAstType.PrivateService ||
- requestingProviderType === ProviderAstType.PublicService) &&
- resolvedProvider.providerType === ProviderAstType.Builtin)) {
- return null;
- }
- var /** @type {?} */ transformedProviderAst = this._transformedProviders.get(tokenReference(token));
- if (transformedProviderAst) {
- return transformedProviderAst;
- }
- if (this._seenProviders.get(tokenReference(token)) != null) {
- this.viewContext.errors.push(new ProviderError("Cannot instantiate cyclic dependency! " + tokenName(token), this._sourceSpan));
- return null;
- }
- this._seenProviders.set(tokenReference(token), true);
- var /** @type {?} */ transformedProviders = resolvedProvider.providers.map(function (provider) {
- var /** @type {?} */ transformedUseValue = provider.useValue;
- var /** @type {?} */ transformedUseExisting = /** @type {?} */ ((provider.useExisting));
- var /** @type {?} */ transformedDeps = /** @type {?} */ ((undefined));
- if (provider.useExisting != null) {
- var /** @type {?} */ existingDiDep = /** @type {?} */ ((_this._getDependency(resolvedProvider.providerType, { token: provider.useExisting }, eager)));
- if (existingDiDep.token != null) {
- transformedUseExisting = existingDiDep.token;
- }
- else {
- transformedUseExisting = /** @type {?} */ ((null));
- transformedUseValue = existingDiDep.value;
- }
- }
- else if (provider.useFactory) {
- var /** @type {?} */ deps = provider.deps || provider.useFactory.diDeps;
- transformedDeps =
- deps.map(function (dep) { return ((_this._getDependency(resolvedProvider.providerType, dep, eager))); });
- }
- else if (provider.useClass) {
- var /** @type {?} */ deps = provider.deps || provider.useClass.diDeps;
- transformedDeps =
- deps.map(function (dep) { return ((_this._getDependency(resolvedProvider.providerType, dep, eager))); });
- }
- return _transformProvider(provider, {
- useExisting: transformedUseExisting,
- useValue: transformedUseValue,
- deps: transformedDeps
- });
- });
- transformedProviderAst =
- _transformProviderAst(resolvedProvider, { eager: eager, providers: transformedProviders });
- this._transformedProviders.set(tokenReference(token), transformedProviderAst);
- return transformedProviderAst;
- };
- /**
- * @param {?} requestingProviderType
- * @param {?} dep
- * @param {?=} eager
- * @return {?}
- */
- ProviderElementContext.prototype._getLocalDependency = /**
- * @param {?} requestingProviderType
- * @param {?} dep
- * @param {?=} eager
- * @return {?}
- */
- function (requestingProviderType, dep, eager) {
- if (eager === void 0) { eager = false; }
- if (dep.isAttribute) {
- var /** @type {?} */ attrValue = this._attrs[/** @type {?} */ ((dep.token)).value];
- return { isValue: true, value: attrValue == null ? null : attrValue };
- }
- if (dep.token != null) {
- // access builtints
- if ((requestingProviderType === ProviderAstType.Directive ||
- requestingProviderType === ProviderAstType.Component)) {
- if (tokenReference(dep.token) ===
- this.viewContext.reflector.resolveExternalReference(Identifiers.Renderer) ||
- tokenReference(dep.token) ===
- this.viewContext.reflector.resolveExternalReference(Identifiers.ElementRef) ||
- tokenReference(dep.token) ===
- this.viewContext.reflector.resolveExternalReference(Identifiers.ChangeDetectorRef) ||
- tokenReference(dep.token) ===
- this.viewContext.reflector.resolveExternalReference(Identifiers.TemplateRef)) {
- return dep;
- }
- if (tokenReference(dep.token) ===
- this.viewContext.reflector.resolveExternalReference(Identifiers.ViewContainerRef)) {
- (/** @type {?} */ (this)).transformedHasViewContainer = true;
- }
- }
- // access the injector
- if (tokenReference(dep.token) ===
- this.viewContext.reflector.resolveExternalReference(Identifiers.Injector)) {
- return dep;
- }
- // access providers
- if (this._getOrCreateLocalProvider(requestingProviderType, dep.token, eager) != null) {
- return dep;
- }
- }
- return null;
- };
- /**
- * @param {?} requestingProviderType
- * @param {?} dep
- * @param {?=} eager
- * @return {?}
- */
- ProviderElementContext.prototype._getDependency = /**
- * @param {?} requestingProviderType
- * @param {?} dep
- * @param {?=} eager
- * @return {?}
- */
- function (requestingProviderType, dep, eager) {
- if (eager === void 0) { eager = false; }
- var /** @type {?} */ currElement = this;
- var /** @type {?} */ currEager = eager;
- var /** @type {?} */ result = null;
- if (!dep.isSkipSelf) {
- result = this._getLocalDependency(requestingProviderType, dep, eager);
- }
- if (dep.isSelf) {
- if (!result && dep.isOptional) {
- result = { isValue: true, value: null };
- }
- }
- else {
- // check parent elements
- while (!result && currElement._parent) {
- var /** @type {?} */ prevElement = currElement;
- currElement = currElement._parent;
- if (prevElement._isViewRoot) {
- currEager = false;
- }
- result = currElement._getLocalDependency(ProviderAstType.PublicService, dep, currEager);
- }
- // check @Host restriction
- if (!result) {
- if (!dep.isHost || this.viewContext.component.isHost ||
- this.viewContext.component.type.reference === tokenReference(/** @type {?} */ ((dep.token))) ||
- this.viewContext.viewProviders.get(tokenReference(/** @type {?} */ ((dep.token)))) != null) {
- result = dep;
- }
- else {
- result = dep.isOptional ? result = { isValue: true, value: null } : null;
- }
- }
- }
- if (!result) {
- this.viewContext.errors.push(new ProviderError("No provider for " + tokenName((/** @type {?} */ ((dep.token)))), this._sourceSpan));
- }
- return result;
- };
- return ProviderElementContext;
- }());
- var NgModuleProviderAnalyzer = /** @class */ (function () {
- function NgModuleProviderAnalyzer(reflector, ngModule, extraProviders, sourceSpan) {
- var _this = this;
- this.reflector = reflector;
- this._transformedProviders = new Map();
- this._seenProviders = new Map();
- this._errors = [];
- this._allProviders = new Map();
- ngModule.transitiveModule.modules.forEach(function (ngModuleType) {
- var /** @type {?} */ ngModuleProvider = { token: { identifier: ngModuleType }, useClass: ngModuleType };
- _resolveProviders([ngModuleProvider], ProviderAstType.PublicService, true, sourceSpan, _this._errors, _this._allProviders);
- });
- _resolveProviders(ngModule.transitiveModule.providers.map(function (entry) { return entry.provider; }).concat(extraProviders), ProviderAstType.PublicService, false, sourceSpan, this._errors, this._allProviders);
- }
- /**
- * @return {?}
- */
- NgModuleProviderAnalyzer.prototype.parse = /**
- * @return {?}
- */
- function () {
- var _this = this;
- Array.from(this._allProviders.values()).forEach(function (provider) {
- _this._getOrCreateLocalProvider(provider.token, provider.eager);
- });
- if (this._errors.length > 0) {
- var /** @type {?} */ errorString = this._errors.join('\n');
- throw new Error("Provider parse errors:\n" + errorString);
- }
- // Note: Maps keep their insertion order.
- var /** @type {?} */ lazyProviders = [];
- var /** @type {?} */ eagerProviders = [];
- this._transformedProviders.forEach(function (provider) {
- if (provider.eager) {
- eagerProviders.push(provider);
- }
- else {
- lazyProviders.push(provider);
- }
- });
- return lazyProviders.concat(eagerProviders);
- };
- /**
- * @param {?} token
- * @param {?} eager
- * @return {?}
- */
- NgModuleProviderAnalyzer.prototype._getOrCreateLocalProvider = /**
- * @param {?} token
- * @param {?} eager
- * @return {?}
- */
- function (token, eager) {
- var _this = this;
- var /** @type {?} */ resolvedProvider = this._allProviders.get(tokenReference(token));
- if (!resolvedProvider) {
- return null;
- }
- var /** @type {?} */ transformedProviderAst = this._transformedProviders.get(tokenReference(token));
- if (transformedProviderAst) {
- return transformedProviderAst;
- }
- if (this._seenProviders.get(tokenReference(token)) != null) {
- this._errors.push(new ProviderError("Cannot instantiate cyclic dependency! " + tokenName(token), resolvedProvider.sourceSpan));
- return null;
- }
- this._seenProviders.set(tokenReference(token), true);
- var /** @type {?} */ transformedProviders = resolvedProvider.providers.map(function (provider) {
- var /** @type {?} */ transformedUseValue = provider.useValue;
- var /** @type {?} */ transformedUseExisting = /** @type {?} */ ((provider.useExisting));
- var /** @type {?} */ transformedDeps = /** @type {?} */ ((undefined));
- if (provider.useExisting != null) {
- var /** @type {?} */ existingDiDep = _this._getDependency({ token: provider.useExisting }, eager, resolvedProvider.sourceSpan);
- if (existingDiDep.token != null) {
- transformedUseExisting = existingDiDep.token;
- }
- else {
- transformedUseExisting = /** @type {?} */ ((null));
- transformedUseValue = existingDiDep.value;
- }
- }
- else if (provider.useFactory) {
- var /** @type {?} */ deps = provider.deps || provider.useFactory.diDeps;
- transformedDeps =
- deps.map(function (dep) { return _this._getDependency(dep, eager, resolvedProvider.sourceSpan); });
- }
- else if (provider.useClass) {
- var /** @type {?} */ deps = provider.deps || provider.useClass.diDeps;
- transformedDeps =
- deps.map(function (dep) { return _this._getDependency(dep, eager, resolvedProvider.sourceSpan); });
- }
- return _transformProvider(provider, {
- useExisting: transformedUseExisting,
- useValue: transformedUseValue,
- deps: transformedDeps
- });
- });
- transformedProviderAst =
- _transformProviderAst(resolvedProvider, { eager: eager, providers: transformedProviders });
- this._transformedProviders.set(tokenReference(token), transformedProviderAst);
- return transformedProviderAst;
- };
- /**
- * @param {?} dep
- * @param {?=} eager
- * @param {?=} requestorSourceSpan
- * @return {?}
- */
- NgModuleProviderAnalyzer.prototype._getDependency = /**
- * @param {?} dep
- * @param {?=} eager
- * @param {?=} requestorSourceSpan
- * @return {?}
- */
- function (dep, eager, requestorSourceSpan) {
- if (eager === void 0) { eager = false; }
- var /** @type {?} */ foundLocal = false;
- if (!dep.isSkipSelf && dep.token != null) {
- // access the injector
- if (tokenReference(dep.token) ===
- this.reflector.resolveExternalReference(Identifiers.Injector) ||
- tokenReference(dep.token) ===
- this.reflector.resolveExternalReference(Identifiers.ComponentFactoryResolver)) {
- foundLocal = true;
- // access providers
- }
- else if (this._getOrCreateLocalProvider(dep.token, eager) != null) {
- foundLocal = true;
- }
- }
- var /** @type {?} */ result = dep;
- if (dep.isSelf && !foundLocal) {
- if (dep.isOptional) {
- result = { isValue: true, value: null };
- }
- else {
- this._errors.push(new ProviderError("No provider for " + tokenName((/** @type {?} */ ((dep.token)))), requestorSourceSpan));
- }
- }
- return result;
- };
- return NgModuleProviderAnalyzer;
- }());
- /**
- * @param {?} provider
- * @param {?} __1
- * @return {?}
- */
- function _transformProvider(provider, _a) {
- var useExisting = _a.useExisting, useValue = _a.useValue, deps = _a.deps;
- return {
- token: provider.token,
- useClass: provider.useClass,
- useExisting: useExisting,
- useFactory: provider.useFactory,
- useValue: useValue,
- deps: deps,
- multi: provider.multi
- };
- }
- /**
- * @param {?} provider
- * @param {?} __1
- * @return {?}
- */
- function _transformProviderAst(provider, _a) {
- var eager = _a.eager, providers = _a.providers;
- return new ProviderAst(provider.token, provider.multiProvider, provider.eager || eager, providers, provider.providerType, provider.lifecycleHooks, provider.sourceSpan);
- }
- /**
- * @param {?} directives
- * @param {?} sourceSpan
- * @param {?} targetErrors
- * @return {?}
- */
- function _resolveProvidersFromDirectives(directives, sourceSpan, targetErrors) {
- var /** @type {?} */ providersByToken = new Map();
- directives.forEach(function (directive) {
- var /** @type {?} */ dirProvider = { token: { identifier: directive.type }, useClass: directive.type };
- _resolveProviders([dirProvider], directive.isComponent ? ProviderAstType.Component : ProviderAstType.Directive, true, sourceSpan, targetErrors, providersByToken);
- });
- // Note: directives need to be able to overwrite providers of a component!
- var /** @type {?} */ directivesWithComponentFirst = directives.filter(function (dir) { return dir.isComponent; }).concat(directives.filter(function (dir) { return !dir.isComponent; }));
- directivesWithComponentFirst.forEach(function (directive) {
- _resolveProviders(directive.providers, ProviderAstType.PublicService, false, sourceSpan, targetErrors, providersByToken);
- _resolveProviders(directive.viewProviders, ProviderAstType.PrivateService, false, sourceSpan, targetErrors, providersByToken);
- });
- return providersByToken;
- }
- /**
- * @param {?} providers
- * @param {?} providerType
- * @param {?} eager
- * @param {?} sourceSpan
- * @param {?} targetErrors
- * @param {?} targetProvidersByToken
- * @return {?}
- */
- function _resolveProviders(providers, providerType, eager, sourceSpan, targetErrors, targetProvidersByToken) {
- providers.forEach(function (provider) {
- var /** @type {?} */ resolvedProvider = targetProvidersByToken.get(tokenReference(provider.token));
- if (resolvedProvider != null && !!resolvedProvider.multiProvider !== !!provider.multi) {
- targetErrors.push(new ProviderError("Mixing multi and non multi provider is not possible for token " + tokenName(resolvedProvider.token), sourceSpan));
- }
- if (!resolvedProvider) {
- var /** @type {?} */ lifecycleHooks = provider.token.identifier &&
- (/** @type {?} */ (provider.token.identifier)).lifecycleHooks ?
- (/** @type {?} */ (provider.token.identifier)).lifecycleHooks :
- [];
- var /** @type {?} */ isUseValue = !(provider.useClass || provider.useExisting || provider.useFactory);
- resolvedProvider = new ProviderAst(provider.token, !!provider.multi, eager || isUseValue, [provider], providerType, lifecycleHooks, sourceSpan);
- targetProvidersByToken.set(tokenReference(provider.token), resolvedProvider);
- }
- else {
- if (!provider.multi) {
- resolvedProvider.providers.length = 0;
- }
- resolvedProvider.providers.push(provider);
- }
- });
- }
- /**
- * @param {?} component
- * @return {?}
- */
- function _getViewQueries(component) {
- // Note: queries start with id 1 so we can use the number in a Bloom filter!
- var /** @type {?} */ viewQueryId = 1;
- var /** @type {?} */ viewQueries = new Map();
- if (component.viewQueries) {
- component.viewQueries.forEach(function (query) { return _addQueryToTokenMap(viewQueries, { meta: query, queryId: viewQueryId++ }); });
- }
- return viewQueries;
- }
- /**
- * @param {?} contentQueryStartId
- * @param {?} directives
- * @return {?}
- */
- function _getContentQueries(contentQueryStartId, directives) {
- var /** @type {?} */ contentQueryId = contentQueryStartId;
- var /** @type {?} */ contentQueries = new Map();
- directives.forEach(function (directive, directiveIndex) {
- if (directive.queries) {
- directive.queries.forEach(function (query) { return _addQueryToTokenMap(contentQueries, { meta: query, queryId: contentQueryId++ }); });
- }
- });
- return contentQueries;
- }
- /**
- * @param {?} map
- * @param {?} query
- * @return {?}
- */
- function _addQueryToTokenMap(map, query) {
- query.meta.selectors.forEach(function (token) {
- var /** @type {?} */ entry = map.get(tokenReference(token));
- if (!entry) {
- entry = [];
- map.set(tokenReference(token), entry);
- }
- entry.push(query);
- });
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var QUOTED_KEYS = '$quoted$';
- /**
- * @param {?} ctx
- * @param {?} value
- * @param {?=} type
- * @return {?}
- */
- function convertValueToOutputAst(ctx, value, type) {
- if (type === void 0) { type = null; }
- return visitValue(value, new _ValueOutputAstTransformer(ctx), type);
- }
- var _ValueOutputAstTransformer = /** @class */ (function () {
- function _ValueOutputAstTransformer(ctx) {
- this.ctx = ctx;
- }
- /**
- * @param {?} arr
- * @param {?} type
- * @return {?}
- */
- _ValueOutputAstTransformer.prototype.visitArray = /**
- * @param {?} arr
- * @param {?} type
- * @return {?}
- */
- function (arr, type) {
- var _this = this;
- return literalArr(arr.map(function (value) { return visitValue(value, _this, null); }), type);
- };
- /**
- * @param {?} map
- * @param {?} type
- * @return {?}
- */
- _ValueOutputAstTransformer.prototype.visitStringMap = /**
- * @param {?} map
- * @param {?} type
- * @return {?}
- */
- function (map, type) {
- var _this = this;
- var /** @type {?} */ entries = [];
- var /** @type {?} */ quotedSet = new Set(map && map[QUOTED_KEYS]);
- Object.keys(map).forEach(function (key) {
- entries.push(new LiteralMapEntry(key, visitValue(map[key], _this, null), quotedSet.has(key)));
- });
- return new LiteralMapExpr(entries, type);
- };
- /**
- * @param {?} value
- * @param {?} type
- * @return {?}
- */
- _ValueOutputAstTransformer.prototype.visitPrimitive = /**
- * @param {?} value
- * @param {?} type
- * @return {?}
- */
- function (value, type) { return literal(value, type); };
- /**
- * @param {?} value
- * @param {?} type
- * @return {?}
- */
- _ValueOutputAstTransformer.prototype.visitOther = /**
- * @param {?} value
- * @param {?} type
- * @return {?}
- */
- function (value, type) {
- if (value instanceof Expression) {
- return value;
- }
- else {
- return this.ctx.importExpr(value);
- }
- };
- return _ValueOutputAstTransformer;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} ctx
- * @param {?} providerAst
- * @return {?}
- */
- function providerDef(ctx, providerAst) {
- var /** @type {?} */ flags = 0;
- if (!providerAst.eager) {
- flags |= 4096 /* LazyProvider */;
- }
- if (providerAst.providerType === ProviderAstType.PrivateService) {
- flags |= 8192 /* PrivateProvider */;
- }
- providerAst.lifecycleHooks.forEach(function (lifecycleHook) {
- // for regular providers, we only support ngOnDestroy
- if (lifecycleHook === LifecycleHooks.OnDestroy ||
- providerAst.providerType === ProviderAstType.Directive ||
- providerAst.providerType === ProviderAstType.Component) {
- flags |= lifecycleHookToNodeFlag(lifecycleHook);
- }
- });
- var _a = providerAst.multiProvider ?
- multiProviderDef(ctx, flags, providerAst.providers) :
- singleProviderDef(ctx, flags, providerAst.providerType, providerAst.providers[0]), providerExpr = _a.providerExpr, providerFlags = _a.flags, depsExpr = _a.depsExpr;
- return {
- providerExpr: providerExpr,
- flags: providerFlags, depsExpr: depsExpr,
- tokenExpr: tokenExpr(ctx, providerAst.token),
- };
- }
- /**
- * @param {?} ctx
- * @param {?} flags
- * @param {?} providers
- * @return {?}
- */
- function multiProviderDef(ctx, flags, providers) {
- var /** @type {?} */ allDepDefs = [];
- var /** @type {?} */ allParams = [];
- var /** @type {?} */ exprs = providers.map(function (provider, providerIndex) {
- var /** @type {?} */ expr;
- if (provider.useClass) {
- var /** @type {?} */ depExprs = convertDeps(providerIndex, provider.deps || provider.useClass.diDeps);
- expr = ctx.importExpr(provider.useClass.reference).instantiate(depExprs);
- }
- else if (provider.useFactory) {
- var /** @type {?} */ depExprs = convertDeps(providerIndex, provider.deps || provider.useFactory.diDeps);
- expr = ctx.importExpr(provider.useFactory.reference).callFn(depExprs);
- }
- else if (provider.useExisting) {
- var /** @type {?} */ depExprs = convertDeps(providerIndex, [{ token: provider.useExisting }]);
- expr = depExprs[0];
- }
- else {
- expr = convertValueToOutputAst(ctx, provider.useValue);
- }
- return expr;
- });
- var /** @type {?} */ providerExpr = fn(allParams, [new ReturnStatement(literalArr(exprs))], INFERRED_TYPE);
- return {
- providerExpr: providerExpr,
- flags: flags | 1024 /* TypeFactoryProvider */,
- depsExpr: literalArr(allDepDefs)
- };
- /**
- * @param {?} providerIndex
- * @param {?} deps
- * @return {?}
- */
- function convertDeps(providerIndex, deps) {
- return deps.map(function (dep, depIndex) {
- var /** @type {?} */ paramName = "p" + providerIndex + "_" + depIndex;
- allParams.push(new FnParam(paramName, DYNAMIC_TYPE));
- allDepDefs.push(depDef(ctx, dep));
- return variable(paramName);
- });
- }
- }
- /**
- * @param {?} ctx
- * @param {?} flags
- * @param {?} providerType
- * @param {?} providerMeta
- * @return {?}
- */
- function singleProviderDef(ctx, flags, providerType, providerMeta) {
- var /** @type {?} */ providerExpr;
- var /** @type {?} */ deps;
- if (providerType === ProviderAstType.Directive || providerType === ProviderAstType.Component) {
- providerExpr = ctx.importExpr(/** @type {?} */ ((providerMeta.useClass)).reference);
- flags |= 16384 /* TypeDirective */;
- deps = providerMeta.deps || /** @type {?} */ ((providerMeta.useClass)).diDeps;
- }
- else {
- if (providerMeta.useClass) {
- providerExpr = ctx.importExpr(providerMeta.useClass.reference);
- flags |= 512 /* TypeClassProvider */;
- deps = providerMeta.deps || providerMeta.useClass.diDeps;
- }
- else if (providerMeta.useFactory) {
- providerExpr = ctx.importExpr(providerMeta.useFactory.reference);
- flags |= 1024 /* TypeFactoryProvider */;
- deps = providerMeta.deps || providerMeta.useFactory.diDeps;
- }
- else if (providerMeta.useExisting) {
- providerExpr = NULL_EXPR;
- flags |= 2048 /* TypeUseExistingProvider */;
- deps = [{ token: providerMeta.useExisting }];
- }
- else {
- providerExpr = convertValueToOutputAst(ctx, providerMeta.useValue);
- flags |= 256 /* TypeValueProvider */;
- deps = [];
- }
- }
- var /** @type {?} */ depsExpr = literalArr(deps.map(function (dep) { return depDef(ctx, dep); }));
- return { providerExpr: providerExpr, flags: flags, depsExpr: depsExpr };
- }
- /**
- * @param {?} ctx
- * @param {?} tokenMeta
- * @return {?}
- */
- function tokenExpr(ctx, tokenMeta) {
- return tokenMeta.identifier ? ctx.importExpr(tokenMeta.identifier.reference) :
- literal(tokenMeta.value);
- }
- /**
- * @param {?} ctx
- * @param {?} dep
- * @return {?}
- */
- function depDef(ctx, dep) {
- // Note: the following fields have already been normalized out by provider_analyzer:
- // - isAttribute, isSelf, isHost
- var /** @type {?} */ expr = dep.isValue ? convertValueToOutputAst(ctx, dep.value) : tokenExpr(ctx, /** @type {?} */ ((dep.token)));
- var /** @type {?} */ flags = 0;
- if (dep.isSkipSelf) {
- flags |= 1 /* SkipSelf */;
- }
- if (dep.isOptional) {
- flags |= 2 /* Optional */;
- }
- if (dep.isValue) {
- flags |= 8 /* Value */;
- }
- return flags === 0 /* None */ ? expr : literalArr([literal(flags), expr]);
- }
- /**
- * @param {?} lifecycleHook
- * @return {?}
- */
- function lifecycleHookToNodeFlag(lifecycleHook) {
- var /** @type {?} */ nodeFlag = 0;
- switch (lifecycleHook) {
- case LifecycleHooks.AfterContentChecked:
- nodeFlag = 2097152 /* AfterContentChecked */;
- break;
- case LifecycleHooks.AfterContentInit:
- nodeFlag = 1048576 /* AfterContentInit */;
- break;
- case LifecycleHooks.AfterViewChecked:
- nodeFlag = 8388608 /* AfterViewChecked */;
- break;
- case LifecycleHooks.AfterViewInit:
- nodeFlag = 4194304 /* AfterViewInit */;
- break;
- case LifecycleHooks.DoCheck:
- nodeFlag = 262144 /* DoCheck */;
- break;
- case LifecycleHooks.OnChanges:
- nodeFlag = 524288 /* OnChanges */;
- break;
- case LifecycleHooks.OnDestroy:
- nodeFlag = 131072 /* OnDestroy */;
- break;
- case LifecycleHooks.OnInit:
- nodeFlag = 65536 /* OnInit */;
- break;
- }
- return nodeFlag;
- }
- /**
- * @param {?} reflector
- * @param {?} ctx
- * @param {?} flags
- * @param {?} entryComponents
- * @return {?}
- */
- function componentFactoryResolverProviderDef(reflector, ctx, flags, entryComponents) {
- var /** @type {?} */ entryComponentFactories = entryComponents.map(function (entryComponent) { return ctx.importExpr(entryComponent.componentFactory); });
- var /** @type {?} */ token = createTokenForExternalReference(reflector, Identifiers.ComponentFactoryResolver);
- var /** @type {?} */ classMeta = {
- diDeps: [
- { isValue: true, value: literalArr(entryComponentFactories) },
- { token: token, isSkipSelf: true, isOptional: true },
- { token: createTokenForExternalReference(reflector, Identifiers.NgModuleRef) },
- ],
- lifecycleHooks: [],
- reference: reflector.resolveExternalReference(Identifiers.CodegenComponentFactoryResolver)
- };
- var _a = singleProviderDef(ctx, flags, ProviderAstType.PrivateService, {
- token: token,
- multi: false,
- useClass: classMeta,
- }), providerExpr = _a.providerExpr, providerFlags = _a.flags, depsExpr = _a.depsExpr;
- return { providerExpr: providerExpr, flags: providerFlags, depsExpr: depsExpr, tokenExpr: tokenExpr(ctx, token) };
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var NgModuleCompileResult = /** @class */ (function () {
- function NgModuleCompileResult(ngModuleFactoryVar) {
- this.ngModuleFactoryVar = ngModuleFactoryVar;
- }
- return NgModuleCompileResult;
- }());
- var LOG_VAR = variable('_l');
- var NgModuleCompiler = /** @class */ (function () {
- function NgModuleCompiler(reflector) {
- this.reflector = reflector;
- }
- /**
- * @param {?} ctx
- * @param {?} ngModuleMeta
- * @param {?} extraProviders
- * @return {?}
- */
- NgModuleCompiler.prototype.compile = /**
- * @param {?} ctx
- * @param {?} ngModuleMeta
- * @param {?} extraProviders
- * @return {?}
- */
- function (ctx, ngModuleMeta, extraProviders) {
- var /** @type {?} */ sourceSpan = typeSourceSpan('NgModule', ngModuleMeta.type);
- var /** @type {?} */ entryComponentFactories = ngModuleMeta.transitiveModule.entryComponents;
- var /** @type {?} */ bootstrapComponents = ngModuleMeta.bootstrapComponents;
- var /** @type {?} */ providerParser = new NgModuleProviderAnalyzer(this.reflector, ngModuleMeta, extraProviders, sourceSpan);
- var /** @type {?} */ providerDefs = [componentFactoryResolverProviderDef(this.reflector, ctx, 0 /* None */, entryComponentFactories)]
- .concat(providerParser.parse().map(function (provider) { return providerDef(ctx, provider); }))
- .map(function (_a) {
- var providerExpr = _a.providerExpr, depsExpr = _a.depsExpr, flags = _a.flags, tokenExpr = _a.tokenExpr;
- return importExpr(Identifiers.moduleProviderDef).callFn([
- literal(flags), tokenExpr, providerExpr, depsExpr
- ]);
- });
- var /** @type {?} */ ngModuleDef = importExpr(Identifiers.moduleDef).callFn([literalArr(providerDefs)]);
- var /** @type {?} */ ngModuleDefFactory = fn([new FnParam(/** @type {?} */ ((LOG_VAR.name)))], [new ReturnStatement(ngModuleDef)], INFERRED_TYPE);
- var /** @type {?} */ ngModuleFactoryVar = identifierName(ngModuleMeta.type) + "NgFactory";
- this._createNgModuleFactory(ctx, ngModuleMeta.type.reference, importExpr(Identifiers.createModuleFactory).callFn([
- ctx.importExpr(ngModuleMeta.type.reference),
- literalArr(bootstrapComponents.map(function (id) { return ctx.importExpr(id.reference); })),
- ngModuleDefFactory
- ]));
- if (ngModuleMeta.id) {
- var /** @type {?} */ registerFactoryStmt = importExpr(Identifiers.RegisterModuleFactoryFn)
- .callFn([literal(ngModuleMeta.id), variable(ngModuleFactoryVar)])
- .toStmt();
- ctx.statements.push(registerFactoryStmt);
- }
- return new NgModuleCompileResult(ngModuleFactoryVar);
- };
- /**
- * @param {?} ctx
- * @param {?} ngModuleReference
- * @return {?}
- */
- NgModuleCompiler.prototype.createStub = /**
- * @param {?} ctx
- * @param {?} ngModuleReference
- * @return {?}
- */
- function (ctx, ngModuleReference) {
- this._createNgModuleFactory(ctx, ngModuleReference, NULL_EXPR);
- };
- /**
- * @param {?} ctx
- * @param {?} reference
- * @param {?} value
- * @return {?}
- */
- NgModuleCompiler.prototype._createNgModuleFactory = /**
- * @param {?} ctx
- * @param {?} reference
- * @param {?} value
- * @return {?}
- */
- function (ctx, reference, value) {
- var /** @type {?} */ ngModuleFactoryVar = identifierName({ reference: reference }) + "NgFactory";
- var /** @type {?} */ ngModuleFactoryStmt = variable(ngModuleFactoryVar)
- .set(value)
- .toDeclStmt(importType(Identifiers.NgModuleFactory, [/** @type {?} */ ((expressionType(ctx.importExpr(reference))))], [TypeModifier.Const]), [StmtModifier.Final, StmtModifier.Exported]);
- ctx.statements.push(ngModuleFactoryStmt);
- };
- return NgModuleCompiler;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Resolves types to {\@link NgModule}.
- */
- var NgModuleResolver = /** @class */ (function () {
- function NgModuleResolver(_reflector) {
- this._reflector = _reflector;
- }
- /**
- * @param {?} type
- * @return {?}
- */
- NgModuleResolver.prototype.isNgModule = /**
- * @param {?} type
- * @return {?}
- */
- function (type) { return this._reflector.annotations(type).some(createNgModule.isTypeOf); };
- /**
- * @param {?} type
- * @param {?=} throwIfNotFound
- * @return {?}
- */
- NgModuleResolver.prototype.resolve = /**
- * @param {?} type
- * @param {?=} throwIfNotFound
- * @return {?}
- */
- function (type, throwIfNotFound) {
- if (throwIfNotFound === void 0) { throwIfNotFound = true; }
- var /** @type {?} */ ngModuleMeta = findLast(this._reflector.annotations(type), createNgModule.isTypeOf);
- if (ngModuleMeta) {
- return ngModuleMeta;
- }
- else {
- if (throwIfNotFound) {
- throw new Error("No NgModule metadata found for '" + stringify(type) + "'.");
- }
- return null;
- }
- };
- return NgModuleResolver;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- // https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
- var VERSION$1 = 3;
- var JS_B64_PREFIX = '# sourceMappingURL=data:application/json;base64,';
- var SourceMapGenerator = /** @class */ (function () {
- function SourceMapGenerator(file) {
- if (file === void 0) { file = null; }
- this.file = file;
- this.sourcesContent = new Map();
- this.lines = [];
- this.lastCol0 = 0;
- this.hasMappings = false;
- }
- // The content is `null` when the content is expected to be loaded using the URL
- /**
- * @param {?} url
- * @param {?=} content
- * @return {?}
- */
- SourceMapGenerator.prototype.addSource = /**
- * @param {?} url
- * @param {?=} content
- * @return {?}
- */
- function (url, content) {
- if (content === void 0) { content = null; }
- if (!this.sourcesContent.has(url)) {
- this.sourcesContent.set(url, content);
- }
- return this;
- };
- /**
- * @return {?}
- */
- SourceMapGenerator.prototype.addLine = /**
- * @return {?}
- */
- function () {
- this.lines.push([]);
- this.lastCol0 = 0;
- return this;
- };
- /**
- * @param {?} col0
- * @param {?=} sourceUrl
- * @param {?=} sourceLine0
- * @param {?=} sourceCol0
- * @return {?}
- */
- SourceMapGenerator.prototype.addMapping = /**
- * @param {?} col0
- * @param {?=} sourceUrl
- * @param {?=} sourceLine0
- * @param {?=} sourceCol0
- * @return {?}
- */
- function (col0, sourceUrl, sourceLine0, sourceCol0) {
- if (!this.currentLine) {
- throw new Error("A line must be added before mappings can be added");
- }
- if (sourceUrl != null && !this.sourcesContent.has(sourceUrl)) {
- throw new Error("Unknown source file \"" + sourceUrl + "\"");
- }
- if (col0 == null) {
- throw new Error("The column in the generated code must be provided");
- }
- if (col0 < this.lastCol0) {
- throw new Error("Mapping should be added in output order");
- }
- if (sourceUrl && (sourceLine0 == null || sourceCol0 == null)) {
- throw new Error("The source location must be provided when a source url is provided");
- }
- this.hasMappings = true;
- this.lastCol0 = col0;
- this.currentLine.push({ col0: col0, sourceUrl: sourceUrl, sourceLine0: sourceLine0, sourceCol0: sourceCol0 });
- return this;
- };
- Object.defineProperty(SourceMapGenerator.prototype, "currentLine", {
- get: /**
- * @return {?}
- */
- function () { return this.lines.slice(-1)[0]; },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- SourceMapGenerator.prototype.toJSON = /**
- * @return {?}
- */
- function () {
- var _this = this;
- if (!this.hasMappings) {
- return null;
- }
- var /** @type {?} */ sourcesIndex = new Map();
- var /** @type {?} */ sources = [];
- var /** @type {?} */ sourcesContent = [];
- Array.from(this.sourcesContent.keys()).forEach(function (url, i) {
- sourcesIndex.set(url, i);
- sources.push(url);
- sourcesContent.push(_this.sourcesContent.get(url) || null);
- });
- var /** @type {?} */ mappings = '';
- var /** @type {?} */ lastCol0 = 0;
- var /** @type {?} */ lastSourceIndex = 0;
- var /** @type {?} */ lastSourceLine0 = 0;
- var /** @type {?} */ lastSourceCol0 = 0;
- this.lines.forEach(function (segments) {
- lastCol0 = 0;
- mappings += segments
- .map(function (segment) {
- // zero-based starting column of the line in the generated code
- var /** @type {?} */ segAsStr = toBase64VLQ(segment.col0 - lastCol0);
- lastCol0 = segment.col0;
- if (segment.sourceUrl != null) {
- // zero-based index into the “sources” list
- segAsStr +=
- toBase64VLQ(/** @type {?} */ ((sourcesIndex.get(segment.sourceUrl))) - lastSourceIndex);
- lastSourceIndex = /** @type {?} */ ((sourcesIndex.get(segment.sourceUrl)));
- // the zero-based starting line in the original source
- segAsStr += toBase64VLQ(/** @type {?} */ ((segment.sourceLine0)) - lastSourceLine0);
- lastSourceLine0 = /** @type {?} */ ((segment.sourceLine0));
- // the zero-based starting column in the original source
- segAsStr += toBase64VLQ(/** @type {?} */ ((segment.sourceCol0)) - lastSourceCol0);
- lastSourceCol0 = /** @type {?} */ ((segment.sourceCol0));
- }
- return segAsStr;
- })
- .join(',');
- mappings += ';';
- });
- mappings = mappings.slice(0, -1);
- return {
- 'file': this.file || '',
- 'version': VERSION$1,
- 'sourceRoot': '',
- 'sources': sources,
- 'sourcesContent': sourcesContent,
- 'mappings': mappings,
- };
- };
- /**
- * @return {?}
- */
- SourceMapGenerator.prototype.toJsComment = /**
- * @return {?}
- */
- function () {
- return this.hasMappings ? '//' + JS_B64_PREFIX + toBase64String(JSON.stringify(this, null, 0)) :
- '';
- };
- return SourceMapGenerator;
- }());
- /**
- * @param {?} value
- * @return {?}
- */
- function toBase64String(value) {
- var /** @type {?} */ b64 = '';
- value = utf8Encode(value);
- for (var /** @type {?} */ i = 0; i < value.length;) {
- var /** @type {?} */ i1 = value.charCodeAt(i++);
- var /** @type {?} */ i2 = value.charCodeAt(i++);
- var /** @type {?} */ i3 = value.charCodeAt(i++);
- b64 += toBase64Digit(i1 >> 2);
- b64 += toBase64Digit(((i1 & 3) << 4) | (isNaN(i2) ? 0 : i2 >> 4));
- b64 += isNaN(i2) ? '=' : toBase64Digit(((i2 & 15) << 2) | (i3 >> 6));
- b64 += isNaN(i2) || isNaN(i3) ? '=' : toBase64Digit(i3 & 63);
- }
- return b64;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- function toBase64VLQ(value) {
- value = value < 0 ? ((-value) << 1) + 1 : value << 1;
- var /** @type {?} */ out = '';
- do {
- var /** @type {?} */ digit = value & 31;
- value = value >> 5;
- if (value > 0) {
- digit = digit | 32;
- }
- out += toBase64Digit(digit);
- } while (value > 0);
- return out;
- }
- var B64_DIGITS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
- /**
- * @param {?} value
- * @return {?}
- */
- function toBase64Digit(value) {
- if (value < 0 || value >= 64) {
- throw new Error("Can only encode value in the range [0, 63]");
- }
- return B64_DIGITS[value];
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _SINGLE_QUOTE_ESCAPE_STRING_RE = /'|\\|\n|\r|\$/g;
- var _LEGAL_IDENTIFIER_RE = /^[$A-Z_][0-9A-Z_$]*$/i;
- var _INDENT_WITH = ' ';
- var CATCH_ERROR_VAR$1 = variable('error', null, null);
- var CATCH_STACK_VAR$1 = variable('stack', null, null);
- /**
- * @record
- */
-
- var _EmittedLine = /** @class */ (function () {
- function _EmittedLine(indent) {
- this.indent = indent;
- this.partsLength = 0;
- this.parts = [];
- this.srcSpans = [];
- }
- return _EmittedLine;
- }());
- var EmitterVisitorContext = /** @class */ (function () {
- function EmitterVisitorContext(_indent) {
- this._indent = _indent;
- this._classes = [];
- this._preambleLineCount = 0;
- this._lines = [new _EmittedLine(_indent)];
- }
- /**
- * @return {?}
- */
- EmitterVisitorContext.createRoot = /**
- * @return {?}
- */
- function () { return new EmitterVisitorContext(0); };
- Object.defineProperty(EmitterVisitorContext.prototype, "_currentLine", {
- get: /**
- * @return {?}
- */
- function () { return this._lines[this._lines.length - 1]; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?=} from
- * @param {?=} lastPart
- * @return {?}
- */
- EmitterVisitorContext.prototype.println = /**
- * @param {?=} from
- * @param {?=} lastPart
- * @return {?}
- */
- function (from, lastPart) {
- if (lastPart === void 0) { lastPart = ''; }
- this.print(from || null, lastPart, true);
- };
- /**
- * @return {?}
- */
- EmitterVisitorContext.prototype.lineIsEmpty = /**
- * @return {?}
- */
- function () { return this._currentLine.parts.length === 0; };
- /**
- * @return {?}
- */
- EmitterVisitorContext.prototype.lineLength = /**
- * @return {?}
- */
- function () {
- return this._currentLine.indent * _INDENT_WITH.length + this._currentLine.partsLength;
- };
- /**
- * @param {?} from
- * @param {?} part
- * @param {?=} newLine
- * @return {?}
- */
- EmitterVisitorContext.prototype.print = /**
- * @param {?} from
- * @param {?} part
- * @param {?=} newLine
- * @return {?}
- */
- function (from, part, newLine) {
- if (newLine === void 0) { newLine = false; }
- if (part.length > 0) {
- this._currentLine.parts.push(part);
- this._currentLine.partsLength += part.length;
- this._currentLine.srcSpans.push(from && from.sourceSpan || null);
- }
- if (newLine) {
- this._lines.push(new _EmittedLine(this._indent));
- }
- };
- /**
- * @return {?}
- */
- EmitterVisitorContext.prototype.removeEmptyLastLine = /**
- * @return {?}
- */
- function () {
- if (this.lineIsEmpty()) {
- this._lines.pop();
- }
- };
- /**
- * @return {?}
- */
- EmitterVisitorContext.prototype.incIndent = /**
- * @return {?}
- */
- function () {
- this._indent++;
- if (this.lineIsEmpty()) {
- this._currentLine.indent = this._indent;
- }
- };
- /**
- * @return {?}
- */
- EmitterVisitorContext.prototype.decIndent = /**
- * @return {?}
- */
- function () {
- this._indent--;
- if (this.lineIsEmpty()) {
- this._currentLine.indent = this._indent;
- }
- };
- /**
- * @param {?} clazz
- * @return {?}
- */
- EmitterVisitorContext.prototype.pushClass = /**
- * @param {?} clazz
- * @return {?}
- */
- function (clazz) { this._classes.push(clazz); };
- /**
- * @return {?}
- */
- EmitterVisitorContext.prototype.popClass = /**
- * @return {?}
- */
- function () { return /** @type {?} */ ((this._classes.pop())); };
- Object.defineProperty(EmitterVisitorContext.prototype, "currentClass", {
- get: /**
- * @return {?}
- */
- function () {
- return this._classes.length > 0 ? this._classes[this._classes.length - 1] : null;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- EmitterVisitorContext.prototype.toSource = /**
- * @return {?}
- */
- function () {
- return this.sourceLines
- .map(function (l) { return l.parts.length > 0 ? _createIndent(l.indent) + l.parts.join('') : ''; })
- .join('\n');
- };
- /**
- * @param {?} genFilePath
- * @param {?=} startsAtLine
- * @return {?}
- */
- EmitterVisitorContext.prototype.toSourceMapGenerator = /**
- * @param {?} genFilePath
- * @param {?=} startsAtLine
- * @return {?}
- */
- function (genFilePath, startsAtLine) {
- if (startsAtLine === void 0) { startsAtLine = 0; }
- var /** @type {?} */ map = new SourceMapGenerator(genFilePath);
- var /** @type {?} */ firstOffsetMapped = false;
- var /** @type {?} */ mapFirstOffsetIfNeeded = function () {
- if (!firstOffsetMapped) {
- // Add a single space so that tools won't try to load the file from disk.
- // Note: We are using virtual urls like `ng:///`, so we have to
- // provide a content here.
- map.addSource(genFilePath, ' ').addMapping(0, genFilePath, 0, 0);
- firstOffsetMapped = true;
- }
- };
- for (var /** @type {?} */ i = 0; i < startsAtLine; i++) {
- map.addLine();
- mapFirstOffsetIfNeeded();
- }
- this.sourceLines.forEach(function (line, lineIdx) {
- map.addLine();
- var /** @type {?} */ spans = line.srcSpans;
- var /** @type {?} */ parts = line.parts;
- var /** @type {?} */ col0 = line.indent * _INDENT_WITH.length;
- var /** @type {?} */ spanIdx = 0;
- // skip leading parts without source spans
- while (spanIdx < spans.length && !spans[spanIdx]) {
- col0 += parts[spanIdx].length;
- spanIdx++;
- }
- if (spanIdx < spans.length && lineIdx === 0 && col0 === 0) {
- firstOffsetMapped = true;
- }
- else {
- mapFirstOffsetIfNeeded();
- }
- while (spanIdx < spans.length) {
- var /** @type {?} */ span = /** @type {?} */ ((spans[spanIdx]));
- var /** @type {?} */ source = span.start.file;
- var /** @type {?} */ sourceLine = span.start.line;
- var /** @type {?} */ sourceCol = span.start.col;
- map.addSource(source.url, source.content)
- .addMapping(col0, source.url, sourceLine, sourceCol);
- col0 += parts[spanIdx].length;
- spanIdx++;
- // assign parts without span or the same span to the previous segment
- while (spanIdx < spans.length && (span === spans[spanIdx] || !spans[spanIdx])) {
- col0 += parts[spanIdx].length;
- spanIdx++;
- }
- }
- });
- return map;
- };
- /**
- * @param {?} count
- * @return {?}
- */
- EmitterVisitorContext.prototype.setPreambleLineCount = /**
- * @param {?} count
- * @return {?}
- */
- function (count) { return this._preambleLineCount = count; };
- /**
- * @param {?} line
- * @param {?} column
- * @return {?}
- */
- EmitterVisitorContext.prototype.spanOf = /**
- * @param {?} line
- * @param {?} column
- * @return {?}
- */
- function (line, column) {
- var /** @type {?} */ emittedLine = this._lines[line - this._preambleLineCount];
- if (emittedLine) {
- var /** @type {?} */ columnsLeft = column - _createIndent(emittedLine.indent).length;
- for (var /** @type {?} */ partIndex = 0; partIndex < emittedLine.parts.length; partIndex++) {
- var /** @type {?} */ part = emittedLine.parts[partIndex];
- if (part.length > columnsLeft) {
- return emittedLine.srcSpans[partIndex];
- }
- columnsLeft -= part.length;
- }
- }
- return null;
- };
- Object.defineProperty(EmitterVisitorContext.prototype, "sourceLines", {
- get: /**
- * @return {?}
- */
- function () {
- if (this._lines.length && this._lines[this._lines.length - 1].parts.length === 0) {
- return this._lines.slice(0, -1);
- }
- return this._lines;
- },
- enumerable: true,
- configurable: true
- });
- return EmitterVisitorContext;
- }());
- /**
- * @abstract
- */
- var AbstractEmitterVisitor = /** @class */ (function () {
- function AbstractEmitterVisitor(_escapeDollarInStrings) {
- this._escapeDollarInStrings = _escapeDollarInStrings;
- }
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitExpressionStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- stmt.expr.visitExpression(this, ctx);
- ctx.println(stmt, ';');
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitReturnStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- ctx.print(stmt, "return ");
- stmt.value.visitExpression(this, ctx);
- ctx.println(stmt, ';');
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitIfStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- ctx.print(stmt, "if (");
- stmt.condition.visitExpression(this, ctx);
- ctx.print(stmt, ") {");
- var /** @type {?} */ hasElseCase = stmt.falseCase != null && stmt.falseCase.length > 0;
- if (stmt.trueCase.length <= 1 && !hasElseCase) {
- ctx.print(stmt, " ");
- this.visitAllStatements(stmt.trueCase, ctx);
- ctx.removeEmptyLastLine();
- ctx.print(stmt, " ");
- }
- else {
- ctx.println();
- ctx.incIndent();
- this.visitAllStatements(stmt.trueCase, ctx);
- ctx.decIndent();
- if (hasElseCase) {
- ctx.println(stmt, "} else {");
- ctx.incIndent();
- this.visitAllStatements(stmt.falseCase, ctx);
- ctx.decIndent();
- }
- }
- ctx.println(stmt, "}");
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitThrowStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- ctx.print(stmt, "throw ");
- stmt.error.visitExpression(this, ctx);
- ctx.println(stmt, ";");
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitCommentStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- var /** @type {?} */ lines = stmt.comment.split('\n');
- lines.forEach(function (line) { ctx.println(stmt, "// " + line); });
- return null;
- };
- /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitWriteVarExpr = /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- function (expr, ctx) {
- var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty();
- if (!lineWasEmpty) {
- ctx.print(expr, '(');
- }
- ctx.print(expr, expr.name + " = ");
- expr.value.visitExpression(this, ctx);
- if (!lineWasEmpty) {
- ctx.print(expr, ')');
- }
- return null;
- };
- /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitWriteKeyExpr = /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- function (expr, ctx) {
- var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty();
- if (!lineWasEmpty) {
- ctx.print(expr, '(');
- }
- expr.receiver.visitExpression(this, ctx);
- ctx.print(expr, "[");
- expr.index.visitExpression(this, ctx);
- ctx.print(expr, "] = ");
- expr.value.visitExpression(this, ctx);
- if (!lineWasEmpty) {
- ctx.print(expr, ')');
- }
- return null;
- };
- /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitWritePropExpr = /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- function (expr, ctx) {
- var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty();
- if (!lineWasEmpty) {
- ctx.print(expr, '(');
- }
- expr.receiver.visitExpression(this, ctx);
- ctx.print(expr, "." + expr.name + " = ");
- expr.value.visitExpression(this, ctx);
- if (!lineWasEmpty) {
- ctx.print(expr, ')');
- }
- return null;
- };
- /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitInvokeMethodExpr = /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- function (expr, ctx) {
- expr.receiver.visitExpression(this, ctx);
- var /** @type {?} */ name = expr.name;
- if (expr.builtin != null) {
- name = this.getBuiltinMethodName(expr.builtin);
- if (name == null) {
- // some builtins just mean to skip the call.
- return null;
- }
- }
- ctx.print(expr, "." + name + "(");
- this.visitAllExpressions(expr.args, ctx, ",");
- ctx.print(expr, ")");
- return null;
- };
- /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitInvokeFunctionExpr = /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- function (expr, ctx) {
- expr.fn.visitExpression(this, ctx);
- ctx.print(expr, "(");
- this.visitAllExpressions(expr.args, ctx, ',');
- ctx.print(expr, ")");
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitReadVarExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var /** @type {?} */ varName = /** @type {?} */ ((ast.name));
- if (ast.builtin != null) {
- switch (ast.builtin) {
- case BuiltinVar.Super:
- varName = 'super';
- break;
- case BuiltinVar.This:
- varName = 'this';
- break;
- case BuiltinVar.CatchError:
- varName = /** @type {?} */ ((CATCH_ERROR_VAR$1.name));
- break;
- case BuiltinVar.CatchStack:
- varName = /** @type {?} */ ((CATCH_STACK_VAR$1.name));
- break;
- default:
- throw new Error("Unknown builtin variable " + ast.builtin);
- }
- }
- ctx.print(ast, varName);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitInstantiateExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ctx.print(ast, "new ");
- ast.classExpr.visitExpression(this, ctx);
- ctx.print(ast, "(");
- this.visitAllExpressions(ast.args, ctx, ',');
- ctx.print(ast, ")");
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitLiteralExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var /** @type {?} */ value = ast.value;
- if (typeof value === 'string') {
- ctx.print(ast, escapeIdentifier(value, this._escapeDollarInStrings));
- }
- else {
- ctx.print(ast, "" + value);
- }
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitConditionalExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ctx.print(ast, "(");
- ast.condition.visitExpression(this, ctx);
- ctx.print(ast, '? ');
- ast.trueCase.visitExpression(this, ctx);
- ctx.print(ast, ': '); /** @type {?} */
- ((ast.falseCase)).visitExpression(this, ctx);
- ctx.print(ast, ")");
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitNotExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ctx.print(ast, '!');
- ast.condition.visitExpression(this, ctx);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitAssertNotNullExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ast.condition.visitExpression(this, ctx);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitBinaryOperatorExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var /** @type {?} */ opStr;
- switch (ast.operator) {
- case BinaryOperator.Equals:
- opStr = '==';
- break;
- case BinaryOperator.Identical:
- opStr = '===';
- break;
- case BinaryOperator.NotEquals:
- opStr = '!=';
- break;
- case BinaryOperator.NotIdentical:
- opStr = '!==';
- break;
- case BinaryOperator.And:
- opStr = '&&';
- break;
- case BinaryOperator.Or:
- opStr = '||';
- break;
- case BinaryOperator.Plus:
- opStr = '+';
- break;
- case BinaryOperator.Minus:
- opStr = '-';
- break;
- case BinaryOperator.Divide:
- opStr = '/';
- break;
- case BinaryOperator.Multiply:
- opStr = '*';
- break;
- case BinaryOperator.Modulo:
- opStr = '%';
- break;
- case BinaryOperator.Lower:
- opStr = '<';
- break;
- case BinaryOperator.LowerEquals:
- opStr = '<=';
- break;
- case BinaryOperator.Bigger:
- opStr = '>';
- break;
- case BinaryOperator.BiggerEquals:
- opStr = '>=';
- break;
- default:
- throw new Error("Unknown operator " + ast.operator);
- }
- ctx.print(ast, "(");
- ast.lhs.visitExpression(this, ctx);
- ctx.print(ast, " " + opStr + " ");
- ast.rhs.visitExpression(this, ctx);
- ctx.print(ast, ")");
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitReadPropExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ast.receiver.visitExpression(this, ctx);
- ctx.print(ast, ".");
- ctx.print(ast, ast.name);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitReadKeyExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ast.receiver.visitExpression(this, ctx);
- ctx.print(ast, "[");
- ast.index.visitExpression(this, ctx);
- ctx.print(ast, "]");
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitLiteralArrayExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ctx.print(ast, "[");
- this.visitAllExpressions(ast.entries, ctx, ',');
- ctx.print(ast, "]");
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitLiteralMapExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var _this = this;
- ctx.print(ast, "{");
- this.visitAllObjects(function (entry) {
- ctx.print(ast, escapeIdentifier(entry.key, _this._escapeDollarInStrings, entry.quoted) + ":");
- entry.value.visitExpression(_this, ctx);
- }, ast.entries, ctx, ',');
- ctx.print(ast, "}");
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitCommaExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ctx.print(ast, '(');
- this.visitAllExpressions(ast.parts, ctx, ',');
- ctx.print(ast, ')');
- return null;
- };
- /**
- * @param {?} expressions
- * @param {?} ctx
- * @param {?} separator
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitAllExpressions = /**
- * @param {?} expressions
- * @param {?} ctx
- * @param {?} separator
- * @return {?}
- */
- function (expressions, ctx, separator) {
- var _this = this;
- this.visitAllObjects(function (expr) { return expr.visitExpression(_this, ctx); }, expressions, ctx, separator);
- };
- /**
- * @template T
- * @param {?} handler
- * @param {?} expressions
- * @param {?} ctx
- * @param {?} separator
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitAllObjects = /**
- * @template T
- * @param {?} handler
- * @param {?} expressions
- * @param {?} ctx
- * @param {?} separator
- * @return {?}
- */
- function (handler, expressions, ctx, separator) {
- var /** @type {?} */ incrementedIndent = false;
- for (var /** @type {?} */ i = 0; i < expressions.length; i++) {
- if (i > 0) {
- if (ctx.lineLength() > 80) {
- ctx.print(null, separator, true);
- if (!incrementedIndent) {
- // continuation are marked with double indent.
- ctx.incIndent();
- ctx.incIndent();
- incrementedIndent = true;
- }
- }
- else {
- ctx.print(null, separator, false);
- }
- }
- handler(expressions[i]);
- }
- if (incrementedIndent) {
- // continuation are marked with double indent.
- ctx.decIndent();
- ctx.decIndent();
- }
- };
- /**
- * @param {?} statements
- * @param {?} ctx
- * @return {?}
- */
- AbstractEmitterVisitor.prototype.visitAllStatements = /**
- * @param {?} statements
- * @param {?} ctx
- * @return {?}
- */
- function (statements, ctx) {
- var _this = this;
- statements.forEach(function (stmt) { return stmt.visitStatement(_this, ctx); });
- };
- return AbstractEmitterVisitor;
- }());
- /**
- * @param {?} input
- * @param {?} escapeDollar
- * @param {?=} alwaysQuote
- * @return {?}
- */
- function escapeIdentifier(input, escapeDollar, alwaysQuote) {
- if (alwaysQuote === void 0) { alwaysQuote = true; }
- if (input == null) {
- return null;
- }
- var /** @type {?} */ body = input.replace(_SINGLE_QUOTE_ESCAPE_STRING_RE, function () {
- var match = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- match[_i] = arguments[_i];
- }
- if (match[0] == '$') {
- return escapeDollar ? '\\$' : '$';
- }
- else if (match[0] == '\n') {
- return '\\n';
- }
- else if (match[0] == '\r') {
- return '\\r';
- }
- else {
- return "\\" + match[0];
- }
- });
- var /** @type {?} */ requiresQuotes = alwaysQuote || !_LEGAL_IDENTIFIER_RE.test(body);
- return requiresQuotes ? "'" + body + "'" : body;
- }
- /**
- * @param {?} count
- * @return {?}
- */
- function _createIndent(count) {
- var /** @type {?} */ res = '';
- for (var /** @type {?} */ i = 0; i < count; i++) {
- res += _INDENT_WITH;
- }
- return res;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} ast
- * @return {?}
- */
- function debugOutputAstAsTypeScript(ast) {
- var /** @type {?} */ converter = new _TsEmitterVisitor();
- var /** @type {?} */ ctx = EmitterVisitorContext.createRoot();
- var /** @type {?} */ asts = Array.isArray(ast) ? ast : [ast];
- asts.forEach(function (ast) {
- if (ast instanceof Statement) {
- ast.visitStatement(converter, ctx);
- }
- else if (ast instanceof Expression) {
- ast.visitExpression(converter, ctx);
- }
- else if (ast instanceof Type$1) {
- ast.visitType(converter, ctx);
- }
- else {
- throw new Error("Don't know how to print debug info for " + ast);
- }
- });
- return ctx.toSource();
- }
- var TypeScriptEmitter = /** @class */ (function () {
- function TypeScriptEmitter() {
- }
- /**
- * @param {?} genFilePath
- * @param {?} stmts
- * @param {?=} preamble
- * @param {?=} emitSourceMaps
- * @param {?=} referenceFilter
- * @return {?}
- */
- TypeScriptEmitter.prototype.emitStatementsAndContext = /**
- * @param {?} genFilePath
- * @param {?} stmts
- * @param {?=} preamble
- * @param {?=} emitSourceMaps
- * @param {?=} referenceFilter
- * @return {?}
- */
- function (genFilePath, stmts, preamble, emitSourceMaps, referenceFilter) {
- if (preamble === void 0) { preamble = ''; }
- if (emitSourceMaps === void 0) { emitSourceMaps = true; }
- var /** @type {?} */ converter = new _TsEmitterVisitor(referenceFilter);
- var /** @type {?} */ ctx = EmitterVisitorContext.createRoot();
- converter.visitAllStatements(stmts, ctx);
- var /** @type {?} */ preambleLines = preamble ? preamble.split('\n') : [];
- converter.reexports.forEach(function (reexports, exportedModuleName) {
- var /** @type {?} */ reexportsCode = reexports.map(function (reexport) { return reexport.name + " as " + reexport.as; }).join(',');
- preambleLines.push("export {" + reexportsCode + "} from '" + exportedModuleName + "';");
- });
- converter.importsWithPrefixes.forEach(function (prefix, importedModuleName) {
- // Note: can't write the real word for import as it screws up system.js auto detection...
- preambleLines.push("imp" +
- ("ort * as " + prefix + " from '" + importedModuleName + "';"));
- });
- var /** @type {?} */ sm = emitSourceMaps ?
- ctx.toSourceMapGenerator(genFilePath, preambleLines.length).toJsComment() :
- '';
- var /** @type {?} */ lines = preambleLines.concat([ctx.toSource(), sm]);
- if (sm) {
- // always add a newline at the end, as some tools have bugs without it.
- lines.push('');
- }
- ctx.setPreambleLineCount(preambleLines.length);
- return { sourceText: lines.join('\n'), context: ctx };
- };
- /**
- * @param {?} genFilePath
- * @param {?} stmts
- * @param {?=} preamble
- * @return {?}
- */
- TypeScriptEmitter.prototype.emitStatements = /**
- * @param {?} genFilePath
- * @param {?} stmts
- * @param {?=} preamble
- * @return {?}
- */
- function (genFilePath, stmts, preamble) {
- if (preamble === void 0) { preamble = ''; }
- return this.emitStatementsAndContext(genFilePath, stmts, preamble).sourceText;
- };
- return TypeScriptEmitter;
- }());
- var _TsEmitterVisitor = /** @class */ (function (_super) {
- __extends(_TsEmitterVisitor, _super);
- function _TsEmitterVisitor(referenceFilter) {
- var _this = _super.call(this, false) || this;
- _this.referenceFilter = referenceFilter;
- _this.typeExpression = 0;
- _this.importsWithPrefixes = new Map();
- _this.reexports = new Map();
- return _this;
- }
- /**
- * @param {?} t
- * @param {?} ctx
- * @param {?=} defaultType
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitType = /**
- * @param {?} t
- * @param {?} ctx
- * @param {?=} defaultType
- * @return {?}
- */
- function (t, ctx, defaultType) {
- if (defaultType === void 0) { defaultType = 'any'; }
- if (t) {
- this.typeExpression++;
- t.visitType(this, ctx);
- this.typeExpression--;
- }
- else {
- ctx.print(null, defaultType);
- }
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitLiteralExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var /** @type {?} */ value = ast.value;
- if (value == null && ast.type != INFERRED_TYPE) {
- ctx.print(ast, "(" + value + " as any)");
- return null;
- }
- return _super.prototype.visitLiteralExpr.call(this, ast, ctx);
- };
- // Temporary workaround to support strictNullCheck enabled consumers of ngc emit.
- // In SNC mode, [] have the type never[], so we cast here to any[].
- // TODO: narrow the cast to a more explicit type, or use a pattern that does not
- // start with [].concat. see https://github.com/angular/angular/pull/11846
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitLiteralArrayExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- if (ast.entries.length === 0) {
- ctx.print(ast, '(');
- }
- var /** @type {?} */ result = _super.prototype.visitLiteralArrayExpr.call(this, ast, ctx);
- if (ast.entries.length === 0) {
- ctx.print(ast, ' as any[])');
- }
- return result;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitExternalExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- this._visitIdentifier(ast.value, ast.typeParams, ctx);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitAssertNotNullExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var /** @type {?} */ result = _super.prototype.visitAssertNotNullExpr.call(this, ast, ctx);
- ctx.print(ast, '!');
- return result;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitDeclareVarStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- if (stmt.hasModifier(StmtModifier.Exported) && stmt.value instanceof ExternalExpr &&
- !stmt.type) {
- // check for a reexport
- var _a = stmt.value.value, name_1 = _a.name, moduleName = _a.moduleName;
- if (moduleName) {
- var /** @type {?} */ reexports = this.reexports.get(moduleName);
- if (!reexports) {
- reexports = [];
- this.reexports.set(moduleName, reexports);
- }
- reexports.push({ name: /** @type {?} */ ((name_1)), as: stmt.name });
- return null;
- }
- }
- if (stmt.hasModifier(StmtModifier.Exported)) {
- ctx.print(stmt, "export ");
- }
- if (stmt.hasModifier(StmtModifier.Final)) {
- ctx.print(stmt, "const");
- }
- else {
- ctx.print(stmt, "var");
- }
- ctx.print(stmt, " " + stmt.name);
- this._printColonType(stmt.type, ctx);
- ctx.print(stmt, " = ");
- stmt.value.visitExpression(this, ctx);
- ctx.println(stmt, ";");
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitCastExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ctx.print(ast, "(<"); /** @type {?} */
- ((ast.type)).visitType(this, ctx);
- ctx.print(ast, ">");
- ast.value.visitExpression(this, ctx);
- ctx.print(ast, ")");
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitInstantiateExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ctx.print(ast, "new ");
- this.typeExpression++;
- ast.classExpr.visitExpression(this, ctx);
- this.typeExpression--;
- ctx.print(ast, "(");
- this.visitAllExpressions(ast.args, ctx, ',');
- ctx.print(ast, ")");
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitDeclareClassStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- var _this = this;
- ctx.pushClass(stmt);
- if (stmt.hasModifier(StmtModifier.Exported)) {
- ctx.print(stmt, "export ");
- }
- ctx.print(stmt, "class " + stmt.name);
- if (stmt.parent != null) {
- ctx.print(stmt, " extends ");
- this.typeExpression++;
- stmt.parent.visitExpression(this, ctx);
- this.typeExpression--;
- }
- ctx.println(stmt, " {");
- ctx.incIndent();
- stmt.fields.forEach(function (field) { return _this._visitClassField(field, ctx); });
- if (stmt.constructorMethod != null) {
- this._visitClassConstructor(stmt, ctx);
- }
- stmt.getters.forEach(function (getter) { return _this._visitClassGetter(getter, ctx); });
- stmt.methods.forEach(function (method) { return _this._visitClassMethod(method, ctx); });
- ctx.decIndent();
- ctx.println(stmt, "}");
- ctx.popClass();
- return null;
- };
- /**
- * @param {?} field
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype._visitClassField = /**
- * @param {?} field
- * @param {?} ctx
- * @return {?}
- */
- function (field, ctx) {
- if (field.hasModifier(StmtModifier.Private)) {
- // comment out as a workaround for #10967
- ctx.print(null, "/*private*/ ");
- }
- ctx.print(null, field.name);
- this._printColonType(field.type, ctx);
- ctx.println(null, ";");
- };
- /**
- * @param {?} getter
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype._visitClassGetter = /**
- * @param {?} getter
- * @param {?} ctx
- * @return {?}
- */
- function (getter, ctx) {
- if (getter.hasModifier(StmtModifier.Private)) {
- ctx.print(null, "private ");
- }
- ctx.print(null, "get " + getter.name + "()");
- this._printColonType(getter.type, ctx);
- ctx.println(null, " {");
- ctx.incIndent();
- this.visitAllStatements(getter.body, ctx);
- ctx.decIndent();
- ctx.println(null, "}");
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype._visitClassConstructor = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- ctx.print(stmt, "constructor(");
- this._visitParams(stmt.constructorMethod.params, ctx);
- ctx.println(stmt, ") {");
- ctx.incIndent();
- this.visitAllStatements(stmt.constructorMethod.body, ctx);
- ctx.decIndent();
- ctx.println(stmt, "}");
- };
- /**
- * @param {?} method
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype._visitClassMethod = /**
- * @param {?} method
- * @param {?} ctx
- * @return {?}
- */
- function (method, ctx) {
- if (method.hasModifier(StmtModifier.Private)) {
- ctx.print(null, "private ");
- }
- ctx.print(null, method.name + "(");
- this._visitParams(method.params, ctx);
- ctx.print(null, ")");
- this._printColonType(method.type, ctx, 'void');
- ctx.println(null, " {");
- ctx.incIndent();
- this.visitAllStatements(method.body, ctx);
- ctx.decIndent();
- ctx.println(null, "}");
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitFunctionExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ctx.print(ast, "(");
- this._visitParams(ast.params, ctx);
- ctx.print(ast, ")");
- this._printColonType(ast.type, ctx, 'void');
- ctx.println(ast, " => {");
- ctx.incIndent();
- this.visitAllStatements(ast.statements, ctx);
- ctx.decIndent();
- ctx.print(ast, "}");
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitDeclareFunctionStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- if (stmt.hasModifier(StmtModifier.Exported)) {
- ctx.print(stmt, "export ");
- }
- ctx.print(stmt, "function " + stmt.name + "(");
- this._visitParams(stmt.params, ctx);
- ctx.print(stmt, ")");
- this._printColonType(stmt.type, ctx, 'void');
- ctx.println(stmt, " {");
- ctx.incIndent();
- this.visitAllStatements(stmt.statements, ctx);
- ctx.decIndent();
- ctx.println(stmt, "}");
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitTryCatchStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- ctx.println(stmt, "try {");
- ctx.incIndent();
- this.visitAllStatements(stmt.bodyStmts, ctx);
- ctx.decIndent();
- ctx.println(stmt, "} catch (" + CATCH_ERROR_VAR$1.name + ") {");
- ctx.incIndent();
- var /** @type {?} */ catchStmts = [/** @type {?} */ (CATCH_STACK_VAR$1.set(CATCH_ERROR_VAR$1.prop('stack', null)).toDeclStmt(null, [
- StmtModifier.Final
- ]))].concat(stmt.catchStmts);
- this.visitAllStatements(catchStmts, ctx);
- ctx.decIndent();
- ctx.println(stmt, "}");
- return null;
- };
- /**
- * @param {?} type
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitBuiltintType = /**
- * @param {?} type
- * @param {?} ctx
- * @return {?}
- */
- function (type, ctx) {
- var /** @type {?} */ typeStr;
- switch (type.name) {
- case BuiltinTypeName.Bool:
- typeStr = 'boolean';
- break;
- case BuiltinTypeName.Dynamic:
- typeStr = 'any';
- break;
- case BuiltinTypeName.Function:
- typeStr = 'Function';
- break;
- case BuiltinTypeName.Number:
- typeStr = 'number';
- break;
- case BuiltinTypeName.Int:
- typeStr = 'number';
- break;
- case BuiltinTypeName.String:
- typeStr = 'string';
- break;
- default:
- throw new Error("Unsupported builtin type " + type.name);
- }
- ctx.print(null, typeStr);
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitExpressionType = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ast.value.visitExpression(this, ctx);
- return null;
- };
- /**
- * @param {?} type
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitArrayType = /**
- * @param {?} type
- * @param {?} ctx
- * @return {?}
- */
- function (type, ctx) {
- this.visitType(type.of, ctx);
- ctx.print(null, "[]");
- return null;
- };
- /**
- * @param {?} type
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype.visitMapType = /**
- * @param {?} type
- * @param {?} ctx
- * @return {?}
- */
- function (type, ctx) {
- ctx.print(null, "{[key: string]:");
- this.visitType(type.valueType, ctx);
- ctx.print(null, "}");
- return null;
- };
- /**
- * @param {?} method
- * @return {?}
- */
- _TsEmitterVisitor.prototype.getBuiltinMethodName = /**
- * @param {?} method
- * @return {?}
- */
- function (method) {
- var /** @type {?} */ name;
- switch (method) {
- case BuiltinMethod.ConcatArray:
- name = 'concat';
- break;
- case BuiltinMethod.SubscribeObservable:
- name = 'subscribe';
- break;
- case BuiltinMethod.Bind:
- name = 'bind';
- break;
- default:
- throw new Error("Unknown builtin method: " + method);
- }
- return name;
- };
- /**
- * @param {?} params
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype._visitParams = /**
- * @param {?} params
- * @param {?} ctx
- * @return {?}
- */
- function (params, ctx) {
- var _this = this;
- this.visitAllObjects(function (param) {
- ctx.print(null, param.name);
- _this._printColonType(param.type, ctx);
- }, params, ctx, ',');
- };
- /**
- * @param {?} value
- * @param {?} typeParams
- * @param {?} ctx
- * @return {?}
- */
- _TsEmitterVisitor.prototype._visitIdentifier = /**
- * @param {?} value
- * @param {?} typeParams
- * @param {?} ctx
- * @return {?}
- */
- function (value, typeParams, ctx) {
- var _this = this;
- var name = value.name, moduleName = value.moduleName;
- if (this.referenceFilter && this.referenceFilter(value)) {
- ctx.print(null, '(null as any)');
- return;
- }
- if (moduleName) {
- var /** @type {?} */ prefix = this.importsWithPrefixes.get(moduleName);
- if (prefix == null) {
- prefix = "i" + this.importsWithPrefixes.size;
- this.importsWithPrefixes.set(moduleName, prefix);
- }
- ctx.print(null, prefix + ".");
- }
- ctx.print(null, /** @type {?} */ ((name)));
- if (this.typeExpression > 0) {
- // If we are in a type expression that refers to a generic type then supply
- // the required type parameters. If there were not enough type parameters
- // supplied, supply any as the type. Outside a type expression the reference
- // should not supply type parameters and be treated as a simple value reference
- // to the constructor function itself.
- var /** @type {?} */ suppliedParameters = typeParams || [];
- if (suppliedParameters.length > 0) {
- ctx.print(null, "<");
- this.visitAllObjects(function (type) { return type.visitType(_this, ctx); }, /** @type {?} */ ((typeParams)), ctx, ',');
- ctx.print(null, ">");
- }
- }
- };
- /**
- * @param {?} type
- * @param {?} ctx
- * @param {?=} defaultType
- * @return {?}
- */
- _TsEmitterVisitor.prototype._printColonType = /**
- * @param {?} type
- * @param {?} ctx
- * @param {?=} defaultType
- * @return {?}
- */
- function (type, ctx, defaultType) {
- if (type !== INFERRED_TYPE) {
- ctx.print(null, ':');
- this.visitType(type, ctx, defaultType);
- }
- };
- return _TsEmitterVisitor;
- }(AbstractEmitterVisitor));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Resolve a `Type` for {\@link Pipe}.
- *
- * This interface can be overridden by the application developer to create custom behavior.
- *
- * See {\@link Compiler}
- */
- var PipeResolver = /** @class */ (function () {
- function PipeResolver(_reflector) {
- this._reflector = _reflector;
- }
- /**
- * @param {?} type
- * @return {?}
- */
- PipeResolver.prototype.isPipe = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type));
- return typeMetadata && typeMetadata.some(createPipe.isTypeOf);
- };
- /**
- * Return {@link Pipe} for a given `Type`.
- */
- /**
- * Return {\@link Pipe} for a given `Type`.
- * @param {?} type
- * @param {?=} throwIfNotFound
- * @return {?}
- */
- PipeResolver.prototype.resolve = /**
- * Return {\@link Pipe} for a given `Type`.
- * @param {?} type
- * @param {?=} throwIfNotFound
- * @return {?}
- */
- function (type, throwIfNotFound) {
- if (throwIfNotFound === void 0) { throwIfNotFound = true; }
- var /** @type {?} */ metas = this._reflector.annotations(resolveForwardRef(type));
- if (metas) {
- var /** @type {?} */ annotation = findLast(metas, createPipe.isTypeOf);
- if (annotation) {
- return annotation;
- }
- }
- if (throwIfNotFound) {
- throw new Error("No Pipe decorator found on " + stringify(type));
- }
- return null;
- };
- return PipeResolver;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Map from tagName|propertyName SecurityContext. Properties applying to all tags use '*'.
- */
- var SECURITY_SCHEMA = {};
- /**
- * @param {?} ctx
- * @param {?} specs
- * @return {?}
- */
- function registerContext(ctx, specs) {
- for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
- var spec = specs_1[_i];
- SECURITY_SCHEMA[spec.toLowerCase()] = ctx;
- }
- }
- // Case is insignificant below, all element and attribute names are lower-cased for lookup.
- registerContext(SecurityContext.HTML, [
- 'iframe|srcdoc',
- '*|innerHTML',
- '*|outerHTML',
- ]);
- registerContext(SecurityContext.STYLE, ['*|style']);
- // NB: no SCRIPT contexts here, they are never allowed due to the parser stripping them.
- registerContext(SecurityContext.URL, [
- '*|formAction', 'area|href', 'area|ping', 'audio|src', 'a|href',
- 'a|ping', 'blockquote|cite', 'body|background', 'del|cite', 'form|action',
- 'img|src', 'img|srcset', 'input|src', 'ins|cite', 'q|cite',
- 'source|src', 'source|srcset', 'track|src', 'video|poster', 'video|src',
- ]);
- registerContext(SecurityContext.RESOURCE_URL, [
- 'applet|code',
- 'applet|codebase',
- 'base|href',
- 'embed|src',
- 'frame|src',
- 'head|profile',
- 'html|manifest',
- 'iframe|src',
- 'link|href',
- 'media|src',
- 'object|codebase',
- 'object|data',
- 'script|src',
- ]);
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @abstract
- */
- var ElementSchemaRegistry = /** @class */ (function () {
- function ElementSchemaRegistry() {
- }
- return ElementSchemaRegistry;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var BOOLEAN = 'boolean';
- var NUMBER = 'number';
- var STRING = 'string';
- var OBJECT = 'object';
- /**
- * This array represents the DOM schema. It encodes inheritance, properties, and events.
- *
- * ## Overview
- *
- * Each line represents one kind of element. The `element_inheritance` and properties are joined
- * using `element_inheritance|properties` syntax.
- *
- * ## Element Inheritance
- *
- * The `element_inheritance` can be further subdivided as `element1,element2,...^parentElement`.
- * Here the individual elements are separated by `,` (commas). Every element in the list
- * has identical properties.
- *
- * An `element` may inherit additional properties from `parentElement` If no `^parentElement` is
- * specified then `""` (blank) element is assumed.
- *
- * NOTE: The blank element inherits from root `[Element]` element, the super element of all
- * elements.
- *
- * NOTE an element prefix such as `:svg:` has no special meaning to the schema.
- *
- * ## Properties
- *
- * Each element has a set of properties separated by `,` (commas). Each property can be prefixed
- * by a special character designating its type:
- *
- * - (no prefix): property is a string.
- * - `*`: property represents an event.
- * - `!`: property is a boolean.
- * - `#`: property is a number.
- * - `%`: property is an object.
- *
- * ## Query
- *
- * The class creates an internal squas representation which allows to easily answer the query of
- * if a given property exist on a given element.
- *
- * NOTE: We don't yet support querying for types or events.
- * NOTE: This schema is auto extracted from `schema_extractor.ts` located in the test folder,
- * see dom_element_schema_registry_spec.ts
- */
- var SCHEMA = [
- '[Element]|textContent,%classList,className,id,innerHTML,*beforecopy,*beforecut,*beforepaste,*copy,*cut,*paste,*search,*selectstart,*webkitfullscreenchange,*webkitfullscreenerror,*wheel,outerHTML,#scrollLeft,#scrollTop,slot' +
- ',*message,*mozfullscreenchange,*mozfullscreenerror,*mozpointerlockchange,*mozpointerlockerror,*webglcontextcreationerror,*webglcontextlost,*webglcontextrestored',
- '[HTMLElement]^[Element]|accessKey,contentEditable,dir,!draggable,!hidden,innerText,lang,*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,outerText,!spellcheck,%style,#tabIndex,title,!translate',
- 'abbr,address,article,aside,b,bdi,bdo,cite,code,dd,dfn,dt,em,figcaption,figure,footer,header,i,kbd,main,mark,nav,noscript,rb,rp,rt,rtc,ruby,s,samp,section,small,strong,sub,sup,u,var,wbr^[HTMLElement]|accessKey,contentEditable,dir,!draggable,!hidden,innerText,lang,*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,outerText,!spellcheck,%style,#tabIndex,title,!translate',
- 'media^[HTMLElement]|!autoplay,!controls,%controlsList,%crossOrigin,#currentTime,!defaultMuted,#defaultPlaybackRate,!disableRemotePlayback,!loop,!muted,*encrypted,*waitingforkey,#playbackRate,preload,src,%srcObject,#volume',
- ':svg:^[HTMLElement]|*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,%style,#tabIndex',
- ':svg:graphics^:svg:|',
- ':svg:animation^:svg:|*begin,*end,*repeat',
- ':svg:geometry^:svg:|',
- ':svg:componentTransferFunction^:svg:|',
- ':svg:gradient^:svg:|',
- ':svg:textContent^:svg:graphics|',
- ':svg:textPositioning^:svg:textContent|',
- 'a^[HTMLElement]|charset,coords,download,hash,host,hostname,href,hreflang,name,password,pathname,ping,port,protocol,referrerPolicy,rel,rev,search,shape,target,text,type,username',
- 'area^[HTMLElement]|alt,coords,download,hash,host,hostname,href,!noHref,password,pathname,ping,port,protocol,referrerPolicy,rel,search,shape,target,username',
- 'audio^media|',
- 'br^[HTMLElement]|clear',
- 'base^[HTMLElement]|href,target',
- 'body^[HTMLElement]|aLink,background,bgColor,link,*beforeunload,*blur,*error,*focus,*hashchange,*languagechange,*load,*message,*offline,*online,*pagehide,*pageshow,*popstate,*rejectionhandled,*resize,*scroll,*storage,*unhandledrejection,*unload,text,vLink',
- 'button^[HTMLElement]|!autofocus,!disabled,formAction,formEnctype,formMethod,!formNoValidate,formTarget,name,type,value',
- 'canvas^[HTMLElement]|#height,#width',
- 'content^[HTMLElement]|select',
- 'dl^[HTMLElement]|!compact',
- 'datalist^[HTMLElement]|',
- 'details^[HTMLElement]|!open',
- 'dialog^[HTMLElement]|!open,returnValue',
- 'dir^[HTMLElement]|!compact',
- 'div^[HTMLElement]|align',
- 'embed^[HTMLElement]|align,height,name,src,type,width',
- 'fieldset^[HTMLElement]|!disabled,name',
- 'font^[HTMLElement]|color,face,size',
- 'form^[HTMLElement]|acceptCharset,action,autocomplete,encoding,enctype,method,name,!noValidate,target',
- 'frame^[HTMLElement]|frameBorder,longDesc,marginHeight,marginWidth,name,!noResize,scrolling,src',
- 'frameset^[HTMLElement]|cols,*beforeunload,*blur,*error,*focus,*hashchange,*languagechange,*load,*message,*offline,*online,*pagehide,*pageshow,*popstate,*rejectionhandled,*resize,*scroll,*storage,*unhandledrejection,*unload,rows',
- 'hr^[HTMLElement]|align,color,!noShade,size,width',
- 'head^[HTMLElement]|',
- 'h1,h2,h3,h4,h5,h6^[HTMLElement]|align',
- 'html^[HTMLElement]|version',
- 'iframe^[HTMLElement]|align,!allowFullscreen,frameBorder,height,longDesc,marginHeight,marginWidth,name,referrerPolicy,%sandbox,scrolling,src,srcdoc,width',
- 'img^[HTMLElement]|align,alt,border,%crossOrigin,#height,#hspace,!isMap,longDesc,lowsrc,name,referrerPolicy,sizes,src,srcset,useMap,#vspace,#width',
- 'input^[HTMLElement]|accept,align,alt,autocapitalize,autocomplete,!autofocus,!checked,!defaultChecked,defaultValue,dirName,!disabled,%files,formAction,formEnctype,formMethod,!formNoValidate,formTarget,#height,!incremental,!indeterminate,max,#maxLength,min,#minLength,!multiple,name,pattern,placeholder,!readOnly,!required,selectionDirection,#selectionEnd,#selectionStart,#size,src,step,type,useMap,value,%valueAsDate,#valueAsNumber,#width',
- 'li^[HTMLElement]|type,#value',
- 'label^[HTMLElement]|htmlFor',
- 'legend^[HTMLElement]|align',
- 'link^[HTMLElement]|as,charset,%crossOrigin,!disabled,href,hreflang,integrity,media,referrerPolicy,rel,%relList,rev,%sizes,target,type',
- 'map^[HTMLElement]|name',
- 'marquee^[HTMLElement]|behavior,bgColor,direction,height,#hspace,#loop,#scrollAmount,#scrollDelay,!trueSpeed,#vspace,width',
- 'menu^[HTMLElement]|!compact',
- 'meta^[HTMLElement]|content,httpEquiv,name,scheme',
- 'meter^[HTMLElement]|#high,#low,#max,#min,#optimum,#value',
- 'ins,del^[HTMLElement]|cite,dateTime',
- 'ol^[HTMLElement]|!compact,!reversed,#start,type',
- 'object^[HTMLElement]|align,archive,border,code,codeBase,codeType,data,!declare,height,#hspace,name,standby,type,useMap,#vspace,width',
- 'optgroup^[HTMLElement]|!disabled,label',
- 'option^[HTMLElement]|!defaultSelected,!disabled,label,!selected,text,value',
- 'output^[HTMLElement]|defaultValue,%htmlFor,name,value',
- 'p^[HTMLElement]|align',
- 'param^[HTMLElement]|name,type,value,valueType',
- 'picture^[HTMLElement]|',
- 'pre^[HTMLElement]|#width',
- 'progress^[HTMLElement]|#max,#value',
- 'q,blockquote,cite^[HTMLElement]|',
- 'script^[HTMLElement]|!async,charset,%crossOrigin,!defer,event,htmlFor,integrity,src,text,type',
- 'select^[HTMLElement]|!autofocus,!disabled,#length,!multiple,name,!required,#selectedIndex,#size,value',
- 'shadow^[HTMLElement]|',
- 'slot^[HTMLElement]|name',
- 'source^[HTMLElement]|media,sizes,src,srcset,type',
- 'span^[HTMLElement]|',
- 'style^[HTMLElement]|!disabled,media,type',
- 'caption^[HTMLElement]|align',
- 'th,td^[HTMLElement]|abbr,align,axis,bgColor,ch,chOff,#colSpan,headers,height,!noWrap,#rowSpan,scope,vAlign,width',
- 'col,colgroup^[HTMLElement]|align,ch,chOff,#span,vAlign,width',
- 'table^[HTMLElement]|align,bgColor,border,%caption,cellPadding,cellSpacing,frame,rules,summary,%tFoot,%tHead,width',
- 'tr^[HTMLElement]|align,bgColor,ch,chOff,vAlign',
- 'tfoot,thead,tbody^[HTMLElement]|align,ch,chOff,vAlign',
- 'template^[HTMLElement]|',
- 'textarea^[HTMLElement]|autocapitalize,!autofocus,#cols,defaultValue,dirName,!disabled,#maxLength,#minLength,name,placeholder,!readOnly,!required,#rows,selectionDirection,#selectionEnd,#selectionStart,value,wrap',
- 'title^[HTMLElement]|text',
- 'track^[HTMLElement]|!default,kind,label,src,srclang',
- 'ul^[HTMLElement]|!compact,type',
- 'unknown^[HTMLElement]|',
- 'video^media|#height,poster,#width',
- ':svg:a^:svg:graphics|',
- ':svg:animate^:svg:animation|',
- ':svg:animateMotion^:svg:animation|',
- ':svg:animateTransform^:svg:animation|',
- ':svg:circle^:svg:geometry|',
- ':svg:clipPath^:svg:graphics|',
- ':svg:defs^:svg:graphics|',
- ':svg:desc^:svg:|',
- ':svg:discard^:svg:|',
- ':svg:ellipse^:svg:geometry|',
- ':svg:feBlend^:svg:|',
- ':svg:feColorMatrix^:svg:|',
- ':svg:feComponentTransfer^:svg:|',
- ':svg:feComposite^:svg:|',
- ':svg:feConvolveMatrix^:svg:|',
- ':svg:feDiffuseLighting^:svg:|',
- ':svg:feDisplacementMap^:svg:|',
- ':svg:feDistantLight^:svg:|',
- ':svg:feDropShadow^:svg:|',
- ':svg:feFlood^:svg:|',
- ':svg:feFuncA^:svg:componentTransferFunction|',
- ':svg:feFuncB^:svg:componentTransferFunction|',
- ':svg:feFuncG^:svg:componentTransferFunction|',
- ':svg:feFuncR^:svg:componentTransferFunction|',
- ':svg:feGaussianBlur^:svg:|',
- ':svg:feImage^:svg:|',
- ':svg:feMerge^:svg:|',
- ':svg:feMergeNode^:svg:|',
- ':svg:feMorphology^:svg:|',
- ':svg:feOffset^:svg:|',
- ':svg:fePointLight^:svg:|',
- ':svg:feSpecularLighting^:svg:|',
- ':svg:feSpotLight^:svg:|',
- ':svg:feTile^:svg:|',
- ':svg:feTurbulence^:svg:|',
- ':svg:filter^:svg:|',
- ':svg:foreignObject^:svg:graphics|',
- ':svg:g^:svg:graphics|',
- ':svg:image^:svg:graphics|',
- ':svg:line^:svg:geometry|',
- ':svg:linearGradient^:svg:gradient|',
- ':svg:mpath^:svg:|',
- ':svg:marker^:svg:|',
- ':svg:mask^:svg:|',
- ':svg:metadata^:svg:|',
- ':svg:path^:svg:geometry|',
- ':svg:pattern^:svg:|',
- ':svg:polygon^:svg:geometry|',
- ':svg:polyline^:svg:geometry|',
- ':svg:radialGradient^:svg:gradient|',
- ':svg:rect^:svg:geometry|',
- ':svg:svg^:svg:graphics|#currentScale,#zoomAndPan',
- ':svg:script^:svg:|type',
- ':svg:set^:svg:animation|',
- ':svg:stop^:svg:|',
- ':svg:style^:svg:|!disabled,media,title,type',
- ':svg:switch^:svg:graphics|',
- ':svg:symbol^:svg:|',
- ':svg:tspan^:svg:textPositioning|',
- ':svg:text^:svg:textPositioning|',
- ':svg:textPath^:svg:textContent|',
- ':svg:title^:svg:|',
- ':svg:use^:svg:graphics|',
- ':svg:view^:svg:|#zoomAndPan',
- 'data^[HTMLElement]|value',
- 'keygen^[HTMLElement]|!autofocus,challenge,!disabled,form,keytype,name',
- 'menuitem^[HTMLElement]|type,label,icon,!disabled,!checked,radiogroup,!default',
- 'summary^[HTMLElement]|',
- 'time^[HTMLElement]|dateTime',
- ':svg:cursor^:svg:|',
- ];
- var _ATTR_TO_PROP = {
- 'class': 'className',
- 'for': 'htmlFor',
- 'formaction': 'formAction',
- 'innerHtml': 'innerHTML',
- 'readonly': 'readOnly',
- 'tabindex': 'tabIndex',
- };
- var DomElementSchemaRegistry = /** @class */ (function (_super) {
- __extends(DomElementSchemaRegistry, _super);
- function DomElementSchemaRegistry() {
- var _this = _super.call(this) || this;
- _this._schema = {};
- SCHEMA.forEach(function (encodedType) {
- var /** @type {?} */ type = {};
- var _a = encodedType.split('|'), strType = _a[0], strProperties = _a[1];
- var /** @type {?} */ properties = strProperties.split(',');
- var _b = strType.split('^'), typeNames = _b[0], superName = _b[1];
- typeNames.split(',').forEach(function (tag) { return _this._schema[tag.toLowerCase()] = type; });
- var /** @type {?} */ superType = superName && _this._schema[superName.toLowerCase()];
- if (superType) {
- Object.keys(superType).forEach(function (prop) { type[prop] = superType[prop]; });
- }
- properties.forEach(function (property) {
- if (property.length > 0) {
- switch (property[0]) {
- case '*':
- // We don't yet support events.
- // If ever allowing to bind to events, GO THROUGH A SECURITY REVIEW, allowing events
- // will
- // almost certainly introduce bad XSS vulnerabilities.
- // type[property.substring(1)] = EVENT;
- break;
- case '!':
- type[property.substring(1)] = BOOLEAN;
- break;
- case '#':
- type[property.substring(1)] = NUMBER;
- break;
- case '%':
- type[property.substring(1)] = OBJECT;
- break;
- default:
- type[property] = STRING;
- }
- }
- });
- });
- return _this;
- }
- /**
- * @param {?} tagName
- * @param {?} propName
- * @param {?} schemaMetas
- * @return {?}
- */
- DomElementSchemaRegistry.prototype.hasProperty = /**
- * @param {?} tagName
- * @param {?} propName
- * @param {?} schemaMetas
- * @return {?}
- */
- function (tagName, propName, schemaMetas) {
- if (schemaMetas.some(function (schema) { return schema.name === NO_ERRORS_SCHEMA.name; })) {
- return true;
- }
- if (tagName.indexOf('-') > -1) {
- if (isNgContainer(tagName) || isNgContent(tagName)) {
- return false;
- }
- if (schemaMetas.some(function (schema) { return schema.name === CUSTOM_ELEMENTS_SCHEMA.name; })) {
- // Can't tell now as we don't know which properties a custom element will get
- // once it is instantiated
- return true;
- }
- }
- var /** @type {?} */ elementProperties = this._schema[tagName.toLowerCase()] || this._schema['unknown'];
- return !!elementProperties[propName];
- };
- /**
- * @param {?} tagName
- * @param {?} schemaMetas
- * @return {?}
- */
- DomElementSchemaRegistry.prototype.hasElement = /**
- * @param {?} tagName
- * @param {?} schemaMetas
- * @return {?}
- */
- function (tagName, schemaMetas) {
- if (schemaMetas.some(function (schema) { return schema.name === NO_ERRORS_SCHEMA.name; })) {
- return true;
- }
- if (tagName.indexOf('-') > -1) {
- if (isNgContainer(tagName) || isNgContent(tagName)) {
- return true;
- }
- if (schemaMetas.some(function (schema) { return schema.name === CUSTOM_ELEMENTS_SCHEMA.name; })) {
- // Allow any custom elements
- return true;
- }
- }
- return !!this._schema[tagName.toLowerCase()];
- };
- /**
- * securityContext returns the security context for the given property on the given DOM tag.
- *
- * Tag and property name are statically known and cannot change at runtime, i.e. it is not
- * possible to bind a value into a changing attribute or tag name.
- *
- * The filtering is white list based. All attributes in the schema above are assumed to have the
- * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known
- * attack vectors are assigned their appropriate context.
- */
- /**
- * securityContext returns the security context for the given property on the given DOM tag.
- *
- * Tag and property name are statically known and cannot change at runtime, i.e. it is not
- * possible to bind a value into a changing attribute or tag name.
- *
- * The filtering is white list based. All attributes in the schema above are assumed to have the
- * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known
- * attack vectors are assigned their appropriate context.
- * @param {?} tagName
- * @param {?} propName
- * @param {?} isAttribute
- * @return {?}
- */
- DomElementSchemaRegistry.prototype.securityContext = /**
- * securityContext returns the security context for the given property on the given DOM tag.
- *
- * Tag and property name are statically known and cannot change at runtime, i.e. it is not
- * possible to bind a value into a changing attribute or tag name.
- *
- * The filtering is white list based. All attributes in the schema above are assumed to have the
- * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known
- * attack vectors are assigned their appropriate context.
- * @param {?} tagName
- * @param {?} propName
- * @param {?} isAttribute
- * @return {?}
- */
- function (tagName, propName, isAttribute) {
- if (isAttribute) {
- // NB: For security purposes, use the mapped property name, not the attribute name.
- propName = this.getMappedPropName(propName);
- }
- // Make sure comparisons are case insensitive, so that case differences between attribute and
- // property names do not have a security impact.
- tagName = tagName.toLowerCase();
- propName = propName.toLowerCase();
- var /** @type {?} */ ctx = SECURITY_SCHEMA[tagName + '|' + propName];
- if (ctx) {
- return ctx;
- }
- ctx = SECURITY_SCHEMA['*|' + propName];
- return ctx ? ctx : SecurityContext.NONE;
- };
- /**
- * @param {?} propName
- * @return {?}
- */
- DomElementSchemaRegistry.prototype.getMappedPropName = /**
- * @param {?} propName
- * @return {?}
- */
- function (propName) { return _ATTR_TO_PROP[propName] || propName; };
- /**
- * @return {?}
- */
- DomElementSchemaRegistry.prototype.getDefaultComponentElementName = /**
- * @return {?}
- */
- function () { return 'ng-component'; };
- /**
- * @param {?} name
- * @return {?}
- */
- DomElementSchemaRegistry.prototype.validateProperty = /**
- * @param {?} name
- * @return {?}
- */
- function (name) {
- if (name.toLowerCase().startsWith('on')) {
- var /** @type {?} */ msg = "Binding to event property '" + name + "' is disallowed for security reasons, " +
- ("please use (" + name.slice(2) + ")=...") +
- ("\nIf '" + name + "' is a directive input, make sure the directive is imported by the") +
- " current module.";
- return { error: true, msg: msg };
- }
- else {
- return { error: false };
- }
- };
- /**
- * @param {?} name
- * @return {?}
- */
- DomElementSchemaRegistry.prototype.validateAttribute = /**
- * @param {?} name
- * @return {?}
- */
- function (name) {
- if (name.toLowerCase().startsWith('on')) {
- var /** @type {?} */ msg = "Binding to event attribute '" + name + "' is disallowed for security reasons, " +
- ("please use (" + name.slice(2) + ")=...");
- return { error: true, msg: msg };
- }
- else {
- return { error: false };
- }
- };
- /**
- * @return {?}
- */
- DomElementSchemaRegistry.prototype.allKnownElementNames = /**
- * @return {?}
- */
- function () { return Object.keys(this._schema); };
- /**
- * @param {?} propName
- * @return {?}
- */
- DomElementSchemaRegistry.prototype.normalizeAnimationStyleProperty = /**
- * @param {?} propName
- * @return {?}
- */
- function (propName) {
- return dashCaseToCamelCase(propName);
- };
- /**
- * @param {?} camelCaseProp
- * @param {?} userProvidedProp
- * @param {?} val
- * @return {?}
- */
- DomElementSchemaRegistry.prototype.normalizeAnimationStyleValue = /**
- * @param {?} camelCaseProp
- * @param {?} userProvidedProp
- * @param {?} val
- * @return {?}
- */
- function (camelCaseProp, userProvidedProp, val) {
- var /** @type {?} */ unit = '';
- var /** @type {?} */ strVal = val.toString().trim();
- var /** @type {?} */ errorMsg = /** @type {?} */ ((null));
- if (_isPixelDimensionStyle(camelCaseProp) && val !== 0 && val !== '0') {
- if (typeof val === 'number') {
- unit = 'px';
- }
- else {
- var /** @type {?} */ valAndSuffixMatch = val.match(/^[+-]?[\d\.]+([a-z]*)$/);
- if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {
- errorMsg = "Please provide a CSS unit value for " + userProvidedProp + ":" + val;
- }
- }
- }
- return { error: errorMsg, value: strVal + unit };
- };
- return DomElementSchemaRegistry;
- }(ElementSchemaRegistry));
- /**
- * @param {?} prop
- * @return {?}
- */
- function _isPixelDimensionStyle(prop) {
- switch (prop) {
- case 'width':
- case 'height':
- case 'minWidth':
- case 'minHeight':
- case 'maxWidth':
- case 'maxHeight':
- case 'left':
- case 'top':
- case 'bottom':
- case 'right':
- case 'fontSize':
- case 'outlineWidth':
- case 'outlineOffset':
- case 'paddingTop':
- case 'paddingLeft':
- case 'paddingBottom':
- case 'paddingRight':
- case 'marginTop':
- case 'marginLeft':
- case 'marginBottom':
- case 'marginRight':
- case 'borderRadius':
- case 'borderWidth':
- case 'borderTopWidth':
- case 'borderLeftWidth':
- case 'borderRightWidth':
- case 'borderBottomWidth':
- case 'textIndent':
- return true;
- default:
- return false;
- }
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * This file is a port of shadowCSS from webcomponents.js to TypeScript.
- *
- * Please make sure to keep to edits in sync with the source file.
- *
- * Source:
- * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
- *
- * The original file level comment is reproduced below
- */
- /*
- This is a limited shim for ShadowDOM css styling.
- https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles
-
- The intention here is to support only the styling features which can be
- relatively simply implemented. The goal is to allow users to avoid the
- most obvious pitfalls and do so without compromising performance significantly.
- For ShadowDOM styling that's not covered here, a set of best practices
- can be provided that should allow users to accomplish more complex styling.
-
- The following is a list of specific ShadowDOM styling features and a brief
- discussion of the approach used to shim.
-
- Shimmed features:
-
- * :host, :host-context: ShadowDOM allows styling of the shadowRoot's host
- element using the :host rule. To shim this feature, the :host styles are
- reformatted and prefixed with a given scope name and promoted to a
- document level stylesheet.
- For example, given a scope name of .foo, a rule like this:
-
- :host {
- background: red;
- }
- }
-
- becomes:
-
- .foo {
- background: red;
- }
-
- * encapsulation: Styles defined within ShadowDOM, apply only to
- dom inside the ShadowDOM. Polymer uses one of two techniques to implement
- this feature.
-
- By default, rules are prefixed with the host element tag name
- as a descendant selector. This ensures styling does not leak out of the 'top'
- of the element's ShadowDOM. For example,
-
- div {
- font-weight: bold;
- }
-
- becomes:
-
- x-foo div {
- font-weight: bold;
- }
-
- becomes:
-
-
- Alternatively, if WebComponents.ShadowCSS.strictStyling is set to true then
- selectors are scoped by adding an attribute selector suffix to each
- simple selector that contains the host element tag name. Each element
- in the element's ShadowDOM template is also given the scope attribute.
- Thus, these rules match only elements that have the scope attribute.
- For example, given a scope name of x-foo, a rule like this:
-
- div {
- font-weight: bold;
- }
-
- becomes:
-
- div[x-foo] {
- font-weight: bold;
- }
-
- Note that elements that are dynamically added to a scope must have the scope
- selector added to them manually.
-
- * upper/lower bound encapsulation: Styles which are defined outside a
- shadowRoot should not cross the ShadowDOM boundary and should not apply
- inside a shadowRoot.
-
- This styling behavior is not emulated. Some possible ways to do this that
- were rejected due to complexity and/or performance concerns include: (1) reset
- every possible property for every possible selector for a given scope name;
- (2) re-implement css in javascript.
-
- As an alternative, users should make sure to use selectors
- specific to the scope in which they are working.
-
- * ::distributed: This behavior is not emulated. It's often not necessary
- to style the contents of a specific insertion point and instead, descendants
- of the host element can be styled selectively. Users can also create an
- extra node around an insertion point and style that node's contents
- via descendent selectors. For example, with a shadowRoot like this:
-
- <style>
- ::content(div) {
- background: red;
- }
- </style>
- <content></content>
-
- could become:
-
- <style>
- / *@polyfill .content-container div * /
- ::content(div) {
- background: red;
- }
- </style>
- <div class="content-container">
- <content></content>
- </div>
-
- Note the use of @polyfill in the comment above a ShadowDOM specific style
- declaration. This is a directive to the styling shim to use the selector
- in comments in lieu of the next selector when running under polyfill.
- */
- var ShadowCss = /** @class */ (function () {
- function ShadowCss() {
- this.strictStyling = true;
- }
- /*
- * Shim some cssText with the given selector. Returns cssText that can
- * be included in the document via WebComponents.ShadowCSS.addCssToDocument(css).
- *
- * When strictStyling is true:
- * - selector is the attribute added to all elements inside the host,
- * - hostSelector is the attribute added to the host itself.
- */
- /**
- * @param {?} cssText
- * @param {?} selector
- * @param {?=} hostSelector
- * @return {?}
- */
- ShadowCss.prototype.shimCssText = /**
- * @param {?} cssText
- * @param {?} selector
- * @param {?=} hostSelector
- * @return {?}
- */
- function (cssText, selector, hostSelector) {
- if (hostSelector === void 0) { hostSelector = ''; }
- var /** @type {?} */ commentsWithHash = extractCommentsWithHash(cssText);
- cssText = stripComments(cssText);
- cssText = this._insertDirectives(cssText);
- var /** @type {?} */ scopedCssText = this._scopeCssText(cssText, selector, hostSelector);
- return [scopedCssText].concat(commentsWithHash).join('\n');
- };
- /**
- * @param {?} cssText
- * @return {?}
- */
- ShadowCss.prototype._insertDirectives = /**
- * @param {?} cssText
- * @return {?}
- */
- function (cssText) {
- cssText = this._insertPolyfillDirectivesInCssText(cssText);
- return this._insertPolyfillRulesInCssText(cssText);
- };
- /**
- * @param {?} cssText
- * @return {?}
- */
- ShadowCss.prototype._insertPolyfillDirectivesInCssText = /**
- * @param {?} cssText
- * @return {?}
- */
- function (cssText) {
- // Difference with webcomponents.js: does not handle comments
- return cssText.replace(_cssContentNextSelectorRe, function () {
- var m = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- m[_i] = arguments[_i];
- }
- return m[2] + '{';
- });
- };
- /**
- * @param {?} cssText
- * @return {?}
- */
- ShadowCss.prototype._insertPolyfillRulesInCssText = /**
- * @param {?} cssText
- * @return {?}
- */
- function (cssText) {
- // Difference with webcomponents.js: does not handle comments
- return cssText.replace(_cssContentRuleRe, function () {
- var m = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- m[_i] = arguments[_i];
- }
- var /** @type {?} */ rule = m[0].replace(m[1], '').replace(m[2], '');
- return m[4] + rule;
- });
- };
- /**
- * @param {?} cssText
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @return {?}
- */
- ShadowCss.prototype._scopeCssText = /**
- * @param {?} cssText
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @return {?}
- */
- function (cssText, scopeSelector, hostSelector) {
- var /** @type {?} */ unscopedRules = this._extractUnscopedRulesFromCssText(cssText);
- // replace :host and :host-context -shadowcsshost and -shadowcsshost respectively
- cssText = this._insertPolyfillHostInCssText(cssText);
- cssText = this._convertColonHost(cssText);
- cssText = this._convertColonHostContext(cssText);
- cssText = this._convertShadowDOMSelectors(cssText);
- if (scopeSelector) {
- cssText = this._scopeSelectors(cssText, scopeSelector, hostSelector);
- }
- cssText = cssText + '\n' + unscopedRules;
- return cssText.trim();
- };
- /**
- * @param {?} cssText
- * @return {?}
- */
- ShadowCss.prototype._extractUnscopedRulesFromCssText = /**
- * @param {?} cssText
- * @return {?}
- */
- function (cssText) {
- // Difference with webcomponents.js: does not handle comments
- var /** @type {?} */ r = '';
- var /** @type {?} */ m;
- _cssContentUnscopedRuleRe.lastIndex = 0;
- while ((m = _cssContentUnscopedRuleRe.exec(cssText)) !== null) {
- var /** @type {?} */ rule = m[0].replace(m[2], '').replace(m[1], m[4]);
- r += rule + '\n\n';
- }
- return r;
- };
- /**
- * @param {?} cssText
- * @return {?}
- */
- ShadowCss.prototype._convertColonHost = /**
- * @param {?} cssText
- * @return {?}
- */
- function (cssText) {
- return this._convertColonRule(cssText, _cssColonHostRe, this._colonHostPartReplacer);
- };
- /**
- * @param {?} cssText
- * @return {?}
- */
- ShadowCss.prototype._convertColonHostContext = /**
- * @param {?} cssText
- * @return {?}
- */
- function (cssText) {
- return this._convertColonRule(cssText, _cssColonHostContextRe, this._colonHostContextPartReplacer);
- };
- /**
- * @param {?} cssText
- * @param {?} regExp
- * @param {?} partReplacer
- * @return {?}
- */
- ShadowCss.prototype._convertColonRule = /**
- * @param {?} cssText
- * @param {?} regExp
- * @param {?} partReplacer
- * @return {?}
- */
- function (cssText, regExp, partReplacer) {
- // m[1] = :host(-context), m[2] = contents of (), m[3] rest of rule
- return cssText.replace(regExp, function () {
- var m = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- m[_i] = arguments[_i];
- }
- if (m[2]) {
- var /** @type {?} */ parts = m[2].split(',');
- var /** @type {?} */ r = [];
- for (var /** @type {?} */ i = 0; i < parts.length; i++) {
- var /** @type {?} */ p = parts[i].trim();
- if (!p)
- break;
- r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
- }
- return r.join(',');
- }
- else {
- return _polyfillHostNoCombinator + m[3];
- }
- });
- };
- /**
- * @param {?} host
- * @param {?} part
- * @param {?} suffix
- * @return {?}
- */
- ShadowCss.prototype._colonHostContextPartReplacer = /**
- * @param {?} host
- * @param {?} part
- * @param {?} suffix
- * @return {?}
- */
- function (host, part, suffix) {
- if (part.indexOf(_polyfillHost) > -1) {
- return this._colonHostPartReplacer(host, part, suffix);
- }
- else {
- return host + part + suffix + ', ' + part + ' ' + host + suffix;
- }
- };
- /**
- * @param {?} host
- * @param {?} part
- * @param {?} suffix
- * @return {?}
- */
- ShadowCss.prototype._colonHostPartReplacer = /**
- * @param {?} host
- * @param {?} part
- * @param {?} suffix
- * @return {?}
- */
- function (host, part, suffix) {
- return host + part.replace(_polyfillHost, '') + suffix;
- };
- /**
- * @param {?} cssText
- * @return {?}
- */
- ShadowCss.prototype._convertShadowDOMSelectors = /**
- * @param {?} cssText
- * @return {?}
- */
- function (cssText) {
- return _shadowDOMSelectorsRe.reduce(function (result, pattern) { return result.replace(pattern, ' '); }, cssText);
- };
- /**
- * @param {?} cssText
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @return {?}
- */
- ShadowCss.prototype._scopeSelectors = /**
- * @param {?} cssText
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @return {?}
- */
- function (cssText, scopeSelector, hostSelector) {
- var _this = this;
- return processRules(cssText, function (rule) {
- var /** @type {?} */ selector = rule.selector;
- var /** @type {?} */ content = rule.content;
- if (rule.selector[0] != '@') {
- selector =
- _this._scopeSelector(rule.selector, scopeSelector, hostSelector, _this.strictStyling);
- }
- else if (rule.selector.startsWith('@media') || rule.selector.startsWith('@supports') ||
- rule.selector.startsWith('@page') || rule.selector.startsWith('@document')) {
- content = _this._scopeSelectors(rule.content, scopeSelector, hostSelector);
- }
- return new CssRule(selector, content);
- });
- };
- /**
- * @param {?} selector
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @param {?} strict
- * @return {?}
- */
- ShadowCss.prototype._scopeSelector = /**
- * @param {?} selector
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @param {?} strict
- * @return {?}
- */
- function (selector, scopeSelector, hostSelector, strict) {
- var _this = this;
- return selector.split(',')
- .map(function (part) { return part.trim().split(_shadowDeepSelectors); })
- .map(function (deepParts) {
- var shallowPart = deepParts[0], otherParts = deepParts.slice(1);
- var /** @type {?} */ applyScope = function (shallowPart) {
- if (_this._selectorNeedsScoping(shallowPart, scopeSelector)) {
- return strict ?
- _this._applyStrictSelectorScope(shallowPart, scopeSelector, hostSelector) :
- _this._applySelectorScope(shallowPart, scopeSelector, hostSelector);
- }
- else {
- return shallowPart;
- }
- };
- return [applyScope(shallowPart)].concat(otherParts).join(' ');
- })
- .join(', ');
- };
- /**
- * @param {?} selector
- * @param {?} scopeSelector
- * @return {?}
- */
- ShadowCss.prototype._selectorNeedsScoping = /**
- * @param {?} selector
- * @param {?} scopeSelector
- * @return {?}
- */
- function (selector, scopeSelector) {
- var /** @type {?} */ re = this._makeScopeMatcher(scopeSelector);
- return !re.test(selector);
- };
- /**
- * @param {?} scopeSelector
- * @return {?}
- */
- ShadowCss.prototype._makeScopeMatcher = /**
- * @param {?} scopeSelector
- * @return {?}
- */
- function (scopeSelector) {
- var /** @type {?} */ lre = /\[/g;
- var /** @type {?} */ rre = /\]/g;
- scopeSelector = scopeSelector.replace(lre, '\\[').replace(rre, '\\]');
- return new RegExp('^(' + scopeSelector + ')' + _selectorReSuffix, 'm');
- };
- /**
- * @param {?} selector
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @return {?}
- */
- ShadowCss.prototype._applySelectorScope = /**
- * @param {?} selector
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @return {?}
- */
- function (selector, scopeSelector, hostSelector) {
- // Difference from webcomponents.js: scopeSelector could not be an array
- return this._applySimpleSelectorScope(selector, scopeSelector, hostSelector);
- };
- /**
- * @param {?} selector
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @return {?}
- */
- ShadowCss.prototype._applySimpleSelectorScope = /**
- * @param {?} selector
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @return {?}
- */
- function (selector, scopeSelector, hostSelector) {
- // In Android browser, the lastIndex is not reset when the regex is used in String.replace()
- _polyfillHostRe.lastIndex = 0;
- if (_polyfillHostRe.test(selector)) {
- var /** @type {?} */ replaceBy_1 = this.strictStyling ? "[" + hostSelector + "]" : scopeSelector;
- return selector
- .replace(_polyfillHostNoCombinatorRe, function (hnc, selector) {
- return selector.replace(/([^:]*)(:*)(.*)/, function (_, before, colon, after) {
- return before + replaceBy_1 + colon + after;
- });
- })
- .replace(_polyfillHostRe, replaceBy_1 + ' ');
- }
- return scopeSelector + ' ' + selector;
- };
- /**
- * @param {?} selector
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @return {?}
- */
- ShadowCss.prototype._applyStrictSelectorScope = /**
- * @param {?} selector
- * @param {?} scopeSelector
- * @param {?} hostSelector
- * @return {?}
- */
- function (selector, scopeSelector, hostSelector) {
- var _this = this;
- var /** @type {?} */ isRe = /\[is=([^\]]*)\]/g;
- scopeSelector = scopeSelector.replace(isRe, function (_) {
- var parts = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- parts[_i - 1] = arguments[_i];
- }
- return parts[0];
- });
- var /** @type {?} */ attrName = '[' + scopeSelector + ']';
- var /** @type {?} */ _scopeSelectorPart = function (p) {
- var /** @type {?} */ scopedP = p.trim();
- if (!scopedP) {
- return '';
- }
- if (p.indexOf(_polyfillHostNoCombinator) > -1) {
- scopedP = _this._applySimpleSelectorScope(p, scopeSelector, hostSelector);
- }
- else {
- // remove :host since it should be unnecessary
- var /** @type {?} */ t = p.replace(_polyfillHostRe, '');
- if (t.length > 0) {
- var /** @type {?} */ matches = t.match(/([^:]*)(:*)(.*)/);
- if (matches) {
- scopedP = matches[1] + attrName + matches[2] + matches[3];
- }
- }
- }
- return scopedP;
- };
- var /** @type {?} */ safeContent = new SafeSelector(selector);
- selector = safeContent.content();
- var /** @type {?} */ scopedSelector = '';
- var /** @type {?} */ startIndex = 0;
- var /** @type {?} */ res;
- var /** @type {?} */ sep = /( |>|\+|~(?!=))\s*/g;
- // If a selector appears before :host it should not be shimmed as it
- // matches on ancestor elements and not on elements in the host's shadow
- // `:host-context(div)` is transformed to
- // `-shadowcsshost-no-combinatordiv, div -shadowcsshost-no-combinator`
- // the `div` is not part of the component in the 2nd selectors and should not be scoped.
- // Historically `component-tag:host` was matching the component so we also want to preserve
- // this behavior to avoid breaking legacy apps (it should not match).
- // The behavior should be:
- // - `tag:host` -> `tag[h]` (this is to avoid breaking legacy apps, should not match anything)
- // - `tag :host` -> `tag [h]` (`tag` is not scoped because it's considered part of a
- // `:host-context(tag)`)
- var /** @type {?} */ hasHost = selector.indexOf(_polyfillHostNoCombinator) > -1;
- // Only scope parts after the first `-shadowcsshost-no-combinator` when it is present
- var /** @type {?} */ shouldScope = !hasHost;
- while ((res = sep.exec(selector)) !== null) {
- var /** @type {?} */ separator = res[1];
- var /** @type {?} */ part_1 = selector.slice(startIndex, res.index).trim();
- shouldScope = shouldScope || part_1.indexOf(_polyfillHostNoCombinator) > -1;
- var /** @type {?} */ scopedPart = shouldScope ? _scopeSelectorPart(part_1) : part_1;
- scopedSelector += scopedPart + " " + separator + " ";
- startIndex = sep.lastIndex;
- }
- var /** @type {?} */ part = selector.substring(startIndex);
- shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1;
- scopedSelector += shouldScope ? _scopeSelectorPart(part) : part;
- // replace the placeholders with their original values
- return safeContent.restore(scopedSelector);
- };
- /**
- * @param {?} selector
- * @return {?}
- */
- ShadowCss.prototype._insertPolyfillHostInCssText = /**
- * @param {?} selector
- * @return {?}
- */
- function (selector) {
- return selector.replace(_colonHostContextRe, _polyfillHostContext)
- .replace(_colonHostRe, _polyfillHost);
- };
- return ShadowCss;
- }());
- var SafeSelector = /** @class */ (function () {
- function SafeSelector(selector) {
- var _this = this;
- this.placeholders = [];
- this.index = 0;
- // Replaces attribute selectors with placeholders.
- // The WS in [attr="va lue"] would otherwise be interpreted as a selector separator.
- selector = selector.replace(/(\[[^\]]*\])/g, function (_, keep) {
- var /** @type {?} */ replaceBy = "__ph-" + _this.index + "__";
- _this.placeholders.push(keep);
- _this.index++;
- return replaceBy;
- });
- // Replaces the expression in `:nth-child(2n + 1)` with a placeholder.
- // WS and "+" would otherwise be interpreted as selector separators.
- this._content = selector.replace(/(:nth-[-\w]+)(\([^)]+\))/g, function (_, pseudo, exp) {
- var /** @type {?} */ replaceBy = "__ph-" + _this.index + "__";
- _this.placeholders.push(exp);
- _this.index++;
- return pseudo + replaceBy;
- });
- }
- /**
- * @param {?} content
- * @return {?}
- */
- SafeSelector.prototype.restore = /**
- * @param {?} content
- * @return {?}
- */
- function (content) {
- var _this = this;
- return content.replace(/__ph-(\d+)__/g, function (ph, index) { return _this.placeholders[+index]; });
- };
- /**
- * @return {?}
- */
- SafeSelector.prototype.content = /**
- * @return {?}
- */
- function () { return this._content; };
- return SafeSelector;
- }());
- var _cssContentNextSelectorRe = /polyfill-next-selector[^}]*content:[\s]*?(['"])(.*?)\1[;\s]*}([^{]*?){/gim;
- var _cssContentRuleRe = /(polyfill-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim;
- var _cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim;
- var _polyfillHost = '-shadowcsshost';
- // note: :host-context pre-processed to -shadowcsshostcontext.
- var _polyfillHostContext = '-shadowcsscontext';
- var _parenSuffix = ')(?:\\((' +
- '(?:\\([^)(]*\\)|[^)(]*)+?' +
- ')\\))?([^,{]*)';
- var _cssColonHostRe = new RegExp('(' + _polyfillHost + _parenSuffix, 'gim');
- var _cssColonHostContextRe = new RegExp('(' + _polyfillHostContext + _parenSuffix, 'gim');
- var _polyfillHostNoCombinator = _polyfillHost + '-no-combinator';
- var _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
- var _shadowDOMSelectorsRe = [
- /::shadow/g,
- /::content/g,
- /\/shadow-deep\//g,
- /\/shadow\//g,
- ];
- // The deep combinator is deprecated in the CSS spec
- // Support for `>>>`, `deep`, `::ng-deep` is then also deprecated and will be removed in the future.
- // see https://github.com/angular/angular/pull/17677
- var _shadowDeepSelectors = /(?:>>>)|(?:\/deep\/)|(?:::ng-deep)/g;
- var _selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$';
- var _polyfillHostRe = /-shadowcsshost/gim;
- var _colonHostRe = /:host/gim;
- var _colonHostContextRe = /:host-context/gim;
- var _commentRe = /\/\*\s*[\s\S]*?\*\//g;
- /**
- * @param {?} input
- * @return {?}
- */
- function stripComments(input) {
- return input.replace(_commentRe, '');
- }
- var _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g;
- /**
- * @param {?} input
- * @return {?}
- */
- function extractCommentsWithHash(input) {
- return input.match(_commentWithHashRe) || [];
- }
- var _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
- var _curlyRe = /([{}])/g;
- var OPEN_CURLY = '{';
- var CLOSE_CURLY = '}';
- var BLOCK_PLACEHOLDER = '%BLOCK%';
- var CssRule = /** @class */ (function () {
- function CssRule(selector, content) {
- this.selector = selector;
- this.content = content;
- }
- return CssRule;
- }());
- /**
- * @param {?} input
- * @param {?} ruleCallback
- * @return {?}
- */
- function processRules(input, ruleCallback) {
- var /** @type {?} */ inputWithEscapedBlocks = escapeBlocks(input);
- var /** @type {?} */ nextBlockIndex = 0;
- return inputWithEscapedBlocks.escapedString.replace(_ruleRe, function () {
- var m = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- m[_i] = arguments[_i];
- }
- var /** @type {?} */ selector = m[2];
- var /** @type {?} */ content = '';
- var /** @type {?} */ suffix = m[4];
- var /** @type {?} */ contentPrefix = '';
- if (suffix && suffix.startsWith('{' + BLOCK_PLACEHOLDER)) {
- content = inputWithEscapedBlocks.blocks[nextBlockIndex++];
- suffix = suffix.substring(BLOCK_PLACEHOLDER.length + 1);
- contentPrefix = '{';
- }
- var /** @type {?} */ rule = ruleCallback(new CssRule(selector, content));
- return "" + m[1] + rule.selector + m[3] + contentPrefix + rule.content + suffix;
- });
- }
- var StringWithEscapedBlocks = /** @class */ (function () {
- function StringWithEscapedBlocks(escapedString, blocks) {
- this.escapedString = escapedString;
- this.blocks = blocks;
- }
- return StringWithEscapedBlocks;
- }());
- /**
- * @param {?} input
- * @return {?}
- */
- function escapeBlocks(input) {
- var /** @type {?} */ inputParts = input.split(_curlyRe);
- var /** @type {?} */ resultParts = [];
- var /** @type {?} */ escapedBlocks = [];
- var /** @type {?} */ bracketCount = 0;
- var /** @type {?} */ currentBlockParts = [];
- for (var /** @type {?} */ partIndex = 0; partIndex < inputParts.length; partIndex++) {
- var /** @type {?} */ part = inputParts[partIndex];
- if (part == CLOSE_CURLY) {
- bracketCount--;
- }
- if (bracketCount > 0) {
- currentBlockParts.push(part);
- }
- else {
- if (currentBlockParts.length > 0) {
- escapedBlocks.push(currentBlockParts.join(''));
- resultParts.push(BLOCK_PLACEHOLDER);
- currentBlockParts = [];
- }
- resultParts.push(part);
- }
- if (part == OPEN_CURLY) {
- bracketCount++;
- }
- }
- if (currentBlockParts.length > 0) {
- escapedBlocks.push(currentBlockParts.join(''));
- resultParts.push(BLOCK_PLACEHOLDER);
- }
- return new StringWithEscapedBlocks(resultParts.join(''), escapedBlocks);
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var COMPONENT_VARIABLE = '%COMP%';
- var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE;
- var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE;
- var StylesCompileDependency = /** @class */ (function () {
- function StylesCompileDependency(name, moduleUrl, setValue) {
- this.name = name;
- this.moduleUrl = moduleUrl;
- this.setValue = setValue;
- }
- return StylesCompileDependency;
- }());
- var CompiledStylesheet = /** @class */ (function () {
- function CompiledStylesheet(outputCtx, stylesVar, dependencies, isShimmed, meta) {
- this.outputCtx = outputCtx;
- this.stylesVar = stylesVar;
- this.dependencies = dependencies;
- this.isShimmed = isShimmed;
- this.meta = meta;
- }
- return CompiledStylesheet;
- }());
- var StyleCompiler = /** @class */ (function () {
- function StyleCompiler(_urlResolver) {
- this._urlResolver = _urlResolver;
- this._shadowCss = new ShadowCss();
- }
- /**
- * @param {?} outputCtx
- * @param {?} comp
- * @return {?}
- */
- StyleCompiler.prototype.compileComponent = /**
- * @param {?} outputCtx
- * @param {?} comp
- * @return {?}
- */
- function (outputCtx, comp) {
- var /** @type {?} */ template = /** @type {?} */ ((comp.template));
- return this._compileStyles(outputCtx, comp, new CompileStylesheetMetadata({
- styles: template.styles,
- styleUrls: template.styleUrls,
- moduleUrl: identifierModuleUrl(comp.type)
- }), this.needsStyleShim(comp), true);
- };
- /**
- * @param {?} outputCtx
- * @param {?} comp
- * @param {?} stylesheet
- * @param {?=} shim
- * @return {?}
- */
- StyleCompiler.prototype.compileStyles = /**
- * @param {?} outputCtx
- * @param {?} comp
- * @param {?} stylesheet
- * @param {?=} shim
- * @return {?}
- */
- function (outputCtx, comp, stylesheet, shim) {
- if (shim === void 0) { shim = this.needsStyleShim(comp); }
- return this._compileStyles(outputCtx, comp, stylesheet, shim, false);
- };
- /**
- * @param {?} comp
- * @return {?}
- */
- StyleCompiler.prototype.needsStyleShim = /**
- * @param {?} comp
- * @return {?}
- */
- function (comp) {
- return /** @type {?} */ ((comp.template)).encapsulation === ViewEncapsulation.Emulated;
- };
- /**
- * @param {?} outputCtx
- * @param {?} comp
- * @param {?} stylesheet
- * @param {?} shim
- * @param {?} isComponentStylesheet
- * @return {?}
- */
- StyleCompiler.prototype._compileStyles = /**
- * @param {?} outputCtx
- * @param {?} comp
- * @param {?} stylesheet
- * @param {?} shim
- * @param {?} isComponentStylesheet
- * @return {?}
- */
- function (outputCtx, comp, stylesheet, shim, isComponentStylesheet) {
- var _this = this;
- var /** @type {?} */ styleExpressions = stylesheet.styles.map(function (plainStyle) { return literal(_this._shimIfNeeded(plainStyle, shim)); });
- var /** @type {?} */ dependencies = [];
- stylesheet.styleUrls.forEach(function (styleUrl) {
- var /** @type {?} */ exprIndex = styleExpressions.length;
- // Note: This placeholder will be filled later.
- styleExpressions.push(/** @type {?} */ ((null)));
- dependencies.push(new StylesCompileDependency(getStylesVarName(null), styleUrl, function (value) { return styleExpressions[exprIndex] = outputCtx.importExpr(value); }));
- });
- // styles variable contains plain strings and arrays of other styles arrays (recursive),
- // so we set its type to dynamic.
- var /** @type {?} */ stylesVar = getStylesVarName(isComponentStylesheet ? comp : null);
- var /** @type {?} */ stmt = variable(stylesVar)
- .set(literalArr(styleExpressions, new ArrayType(DYNAMIC_TYPE, [TypeModifier.Const])))
- .toDeclStmt(null, isComponentStylesheet ? [StmtModifier.Final] : [
- StmtModifier.Final, StmtModifier.Exported
- ]);
- outputCtx.statements.push(stmt);
- return new CompiledStylesheet(outputCtx, stylesVar, dependencies, shim, stylesheet);
- };
- /**
- * @param {?} style
- * @param {?} shim
- * @return {?}
- */
- StyleCompiler.prototype._shimIfNeeded = /**
- * @param {?} style
- * @param {?} shim
- * @return {?}
- */
- function (style, shim) {
- return shim ? this._shadowCss.shimCssText(style, CONTENT_ATTR, HOST_ATTR) : style;
- };
- return StyleCompiler;
- }());
- /**
- * @param {?} component
- * @return {?}
- */
- function getStylesVarName(component) {
- var /** @type {?} */ result = "styles";
- if (component) {
- result += "_" + identifierName(component.type);
- }
- return result;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var PRESERVE_WS_ATTR_NAME = 'ngPreserveWhitespaces';
- var SKIP_WS_TRIM_TAGS = new Set(['pre', 'template', 'textarea', 'script', 'style']);
- // Equivalent to \s with \u00a0 (non-breaking space) excluded.
- // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
- var WS_CHARS = ' \f\n\r\t\v\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff';
- var NO_WS_REGEXP = new RegExp("[^" + WS_CHARS + "]");
- var WS_REPLACE_REGEXP = new RegExp("[" + WS_CHARS + "]{2,}", 'g');
- /**
- * @param {?} attrs
- * @return {?}
- */
- function hasPreserveWhitespacesAttr(attrs) {
- return attrs.some(function (attr) { return attr.name === PRESERVE_WS_ATTR_NAME; });
- }
- /**
- * Angular Dart introduced &ngsp; as a placeholder for non-removable space, see:
- * https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart#L25-L32
- * In Angular Dart &ngsp; is converted to the 0xE500 PUA (Private Use Areas) unicode character
- * and later on replaced by a space. We are re-implementing the same idea here.
- * @param {?} value
- * @return {?}
- */
- function replaceNgsp(value) {
- // lexer is replacing the &ngsp; pseudo-entity with NGSP_UNICODE
- return value.replace(new RegExp(NGSP_UNICODE, 'g'), ' ');
- }
- /**
- * This visitor can walk HTML parse tree and remove / trim text nodes using the following rules:
- * - consider spaces, tabs and new lines as whitespace characters;
- * - drop text nodes consisting of whitespace characters only;
- * - for all other text nodes replace consecutive whitespace characters with one space;
- * - convert &ngsp; pseudo-entity to a single space;
- *
- * Removal and trimming of whitespaces have positive performance impact (less code to generate
- * while compiling templates, faster view creation). At the same time it can be "destructive"
- * in some cases (whitespaces can influence layout). Because of the potential of breaking layout
- * this visitor is not activated by default in Angular 5 and people need to explicitly opt-in for
- * whitespace removal. The default option for whitespace removal will be revisited in Angular 6
- * and might be changed to "on" by default.
- */
- var WhitespaceVisitor = /** @class */ (function () {
- function WhitespaceVisitor() {
- }
- /**
- * @param {?} element
- * @param {?} context
- * @return {?}
- */
- WhitespaceVisitor.prototype.visitElement = /**
- * @param {?} element
- * @param {?} context
- * @return {?}
- */
- function (element, context) {
- if (SKIP_WS_TRIM_TAGS.has(element.name) || hasPreserveWhitespacesAttr(element.attrs)) {
- // don't descent into elements where we need to preserve whitespaces
- // but still visit all attributes to eliminate one used as a market to preserve WS
- return new Element(element.name, visitAll(this, element.attrs), element.children, element.sourceSpan, element.startSourceSpan, element.endSourceSpan);
- }
- return new Element(element.name, element.attrs, visitAll(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan);
- };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- WhitespaceVisitor.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) {
- return attribute.name !== PRESERVE_WS_ATTR_NAME ? attribute : null;
- };
- /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- WhitespaceVisitor.prototype.visitText = /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- function (text, context) {
- var /** @type {?} */ isNotBlank = text.value.match(NO_WS_REGEXP);
- if (isNotBlank) {
- return new Text(replaceNgsp(text.value).replace(WS_REPLACE_REGEXP, ' '), text.sourceSpan);
- }
- return null;
- };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- WhitespaceVisitor.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) { return comment; };
- /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- WhitespaceVisitor.prototype.visitExpansion = /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- function (expansion, context) { return expansion; };
- /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- WhitespaceVisitor.prototype.visitExpansionCase = /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- function (expansionCase, context) { return expansionCase; };
- return WhitespaceVisitor;
- }());
- /**
- * @param {?} htmlAstWithErrors
- * @return {?}
- */
- function removeWhitespaces(htmlAstWithErrors) {
- return new ParseTreeResult(visitAll(new WhitespaceVisitor(), htmlAstWithErrors.rootNodes), htmlAstWithErrors.errors);
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- // http://cldr.unicode.org/index/cldr-spec/plural-rules
- var PLURAL_CASES = ['zero', 'one', 'two', 'few', 'many', 'other'];
- /**
- * Expands special forms into elements.
- *
- * For example,
- *
- * ```
- * { messages.length, plural,
- * =0 {zero}
- * =1 {one}
- * other {more than one}
- * }
- * ```
- *
- * will be expanded into
- *
- * ```
- * <ng-container [ngPlural]="messages.length">
- * <ng-template ngPluralCase="=0">zero</ng-template>
- * <ng-template ngPluralCase="=1">one</ng-template>
- * <ng-template ngPluralCase="other">more than one</ng-template>
- * </ng-container>
- * ```
- * @param {?} nodes
- * @return {?}
- */
- function expandNodes(nodes) {
- var /** @type {?} */ expander = new _Expander();
- return new ExpansionResult(visitAll(expander, nodes), expander.isExpanded, expander.errors);
- }
- var ExpansionResult = /** @class */ (function () {
- function ExpansionResult(nodes, expanded, errors) {
- this.nodes = nodes;
- this.expanded = expanded;
- this.errors = errors;
- }
- return ExpansionResult;
- }());
- var ExpansionError = /** @class */ (function (_super) {
- __extends(ExpansionError, _super);
- function ExpansionError(span, errorMsg) {
- return _super.call(this, span, errorMsg) || this;
- }
- return ExpansionError;
- }(ParseError));
- /**
- * Expand expansion forms (plural, select) to directives
- *
- * \@internal
- */
- var _Expander = /** @class */ (function () {
- function _Expander() {
- this.isExpanded = false;
- this.errors = [];
- }
- /**
- * @param {?} element
- * @param {?} context
- * @return {?}
- */
- _Expander.prototype.visitElement = /**
- * @param {?} element
- * @param {?} context
- * @return {?}
- */
- function (element, context) {
- return new Element(element.name, element.attrs, visitAll(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan);
- };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- _Expander.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) { return attribute; };
- /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- _Expander.prototype.visitText = /**
- * @param {?} text
- * @param {?} context
- * @return {?}
- */
- function (text, context) { return text; };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- _Expander.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) { return comment; };
- /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- _Expander.prototype.visitExpansion = /**
- * @param {?} icu
- * @param {?} context
- * @return {?}
- */
- function (icu, context) {
- this.isExpanded = true;
- return icu.type == 'plural' ? _expandPluralForm(icu, this.errors) :
- _expandDefaultForm(icu, this.errors);
- };
- /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- _Expander.prototype.visitExpansionCase = /**
- * @param {?} icuCase
- * @param {?} context
- * @return {?}
- */
- function (icuCase, context) {
- throw new Error('Should not be reached');
- };
- return _Expander;
- }());
- /**
- * @param {?} ast
- * @param {?} errors
- * @return {?}
- */
- function _expandPluralForm(ast, errors) {
- var /** @type {?} */ children = ast.cases.map(function (c) {
- if (PLURAL_CASES.indexOf(c.value) == -1 && !c.value.match(/^=\d+$/)) {
- errors.push(new ExpansionError(c.valueSourceSpan, "Plural cases should be \"=<number>\" or one of " + PLURAL_CASES.join(", ")));
- }
- var /** @type {?} */ expansionResult = expandNodes(c.expression);
- errors.push.apply(errors, expansionResult.errors);
- return new Element("ng-template", [new Attribute$1('ngPluralCase', "" + c.value, c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
- });
- var /** @type {?} */ switchAttr = new Attribute$1('[ngPlural]', ast.switchValue, ast.switchValueSourceSpan);
- return new Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan);
- }
- /**
- * @param {?} ast
- * @param {?} errors
- * @return {?}
- */
- function _expandDefaultForm(ast, errors) {
- var /** @type {?} */ children = ast.cases.map(function (c) {
- var /** @type {?} */ expansionResult = expandNodes(c.expression);
- errors.push.apply(errors, expansionResult.errors);
- if (c.value === 'other') {
- // other is the default case when no values match
- return new Element("ng-template", [new Attribute$1('ngSwitchDefault', '', c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
- }
- return new Element("ng-template", [new Attribute$1('ngSwitchCase', "" + c.value, c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
- });
- var /** @type {?} */ switchAttr = new Attribute$1('[ngSwitch]', ast.switchValue, ast.switchValueSourceSpan);
- return new Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan);
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var PROPERTY_PARTS_SEPARATOR = '.';
- var ATTRIBUTE_PREFIX = 'attr';
- var CLASS_PREFIX = 'class';
- var STYLE_PREFIX = 'style';
- var ANIMATE_PROP_PREFIX = 'animate-';
- /** @enum {number} */
- var BoundPropertyType = {
- DEFAULT: 0,
- LITERAL_ATTR: 1,
- ANIMATION: 2,
- };
- BoundPropertyType[BoundPropertyType.DEFAULT] = "DEFAULT";
- BoundPropertyType[BoundPropertyType.LITERAL_ATTR] = "LITERAL_ATTR";
- BoundPropertyType[BoundPropertyType.ANIMATION] = "ANIMATION";
- /**
- * Represents a parsed property.
- */
- var BoundProperty = /** @class */ (function () {
- function BoundProperty(name, expression, type, sourceSpan) {
- this.name = name;
- this.expression = expression;
- this.type = type;
- this.sourceSpan = sourceSpan;
- this.isLiteral = this.type === BoundPropertyType.LITERAL_ATTR;
- this.isAnimation = this.type === BoundPropertyType.ANIMATION;
- }
- return BoundProperty;
- }());
- /**
- * Parses bindings in templates and in the directive host area.
- */
- var BindingParser = /** @class */ (function () {
- function BindingParser(_exprParser, _interpolationConfig, _schemaRegistry, pipes, _targetErrors) {
- var _this = this;
- this._exprParser = _exprParser;
- this._interpolationConfig = _interpolationConfig;
- this._schemaRegistry = _schemaRegistry;
- this._targetErrors = _targetErrors;
- this.pipesByName = new Map();
- this._usedPipes = new Map();
- pipes.forEach(function (pipe) { return _this.pipesByName.set(pipe.name, pipe); });
- }
- /**
- * @return {?}
- */
- BindingParser.prototype.getUsedPipes = /**
- * @return {?}
- */
- function () { return Array.from(this._usedPipes.values()); };
- /**
- * @param {?} dirMeta
- * @param {?} elementSelector
- * @param {?} sourceSpan
- * @return {?}
- */
- BindingParser.prototype.createDirectiveHostPropertyAsts = /**
- * @param {?} dirMeta
- * @param {?} elementSelector
- * @param {?} sourceSpan
- * @return {?}
- */
- function (dirMeta, elementSelector, sourceSpan) {
- var _this = this;
- if (dirMeta.hostProperties) {
- var /** @type {?} */ boundProps_1 = [];
- Object.keys(dirMeta.hostProperties).forEach(function (propName) {
- var /** @type {?} */ expression = dirMeta.hostProperties[propName];
- if (typeof expression === 'string') {
- _this.parsePropertyBinding(propName, expression, true, sourceSpan, [], boundProps_1);
- }
- else {
- _this._reportError("Value of the host property binding \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan);
- }
- });
- return boundProps_1.map(function (prop) { return _this.createElementPropertyAst(elementSelector, prop); });
- }
- return null;
- };
- /**
- * @param {?} dirMeta
- * @param {?} sourceSpan
- * @return {?}
- */
- BindingParser.prototype.createDirectiveHostEventAsts = /**
- * @param {?} dirMeta
- * @param {?} sourceSpan
- * @return {?}
- */
- function (dirMeta, sourceSpan) {
- var _this = this;
- if (dirMeta.hostListeners) {
- var /** @type {?} */ targetEventAsts_1 = [];
- Object.keys(dirMeta.hostListeners).forEach(function (propName) {
- var /** @type {?} */ expression = dirMeta.hostListeners[propName];
- if (typeof expression === 'string') {
- _this.parseEvent(propName, expression, sourceSpan, [], targetEventAsts_1);
- }
- else {
- _this._reportError("Value of the host listener \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan);
- }
- });
- return targetEventAsts_1;
- }
- return null;
- };
- /**
- * @param {?} value
- * @param {?} sourceSpan
- * @return {?}
- */
- BindingParser.prototype.parseInterpolation = /**
- * @param {?} value
- * @param {?} sourceSpan
- * @return {?}
- */
- function (value, sourceSpan) {
- var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
- try {
- var /** @type {?} */ ast = /** @type {?} */ ((this._exprParser.parseInterpolation(value, sourceInfo, this._interpolationConfig)));
- if (ast)
- this._reportExpressionParserErrors(ast.errors, sourceSpan);
- this._checkPipes(ast, sourceSpan);
- return ast;
- }
- catch (/** @type {?} */ e) {
- this._reportError("" + e, sourceSpan);
- return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
- }
- };
- /**
- * @param {?} prefixToken
- * @param {?} value
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @param {?} targetVars
- * @return {?}
- */
- BindingParser.prototype.parseInlineTemplateBinding = /**
- * @param {?} prefixToken
- * @param {?} value
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @param {?} targetVars
- * @return {?}
- */
- function (prefixToken, value, sourceSpan, targetMatchableAttrs, targetProps, targetVars) {
- var /** @type {?} */ bindings = this._parseTemplateBindings(prefixToken, value, sourceSpan);
- for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
- var /** @type {?} */ binding = bindings[i];
- if (binding.keyIsVar) {
- targetVars.push(new VariableAst(binding.key, binding.name, sourceSpan));
- }
- else if (binding.expression) {
- this._parsePropertyAst(binding.key, binding.expression, sourceSpan, targetMatchableAttrs, targetProps);
- }
- else {
- targetMatchableAttrs.push([binding.key, '']);
- this.parseLiteralAttr(binding.key, null, sourceSpan, targetMatchableAttrs, targetProps);
- }
- }
- };
- /**
- * @param {?} prefixToken
- * @param {?} value
- * @param {?} sourceSpan
- * @return {?}
- */
- BindingParser.prototype._parseTemplateBindings = /**
- * @param {?} prefixToken
- * @param {?} value
- * @param {?} sourceSpan
- * @return {?}
- */
- function (prefixToken, value, sourceSpan) {
- var _this = this;
- var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
- try {
- var /** @type {?} */ bindingsResult = this._exprParser.parseTemplateBindings(prefixToken, value, sourceInfo);
- this._reportExpressionParserErrors(bindingsResult.errors, sourceSpan);
- bindingsResult.templateBindings.forEach(function (binding) {
- if (binding.expression) {
- _this._checkPipes(binding.expression, sourceSpan);
- }
- });
- bindingsResult.warnings.forEach(function (warning) { _this._reportError(warning, sourceSpan, ParseErrorLevel.WARNING); });
- return bindingsResult.templateBindings;
- }
- catch (/** @type {?} */ e) {
- this._reportError("" + e, sourceSpan);
- return [];
- }
- };
- /**
- * @param {?} name
- * @param {?} value
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @return {?}
- */
- BindingParser.prototype.parseLiteralAttr = /**
- * @param {?} name
- * @param {?} value
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @return {?}
- */
- function (name, value, sourceSpan, targetMatchableAttrs, targetProps) {
- if (_isAnimationLabel(name)) {
- name = name.substring(1);
- if (value) {
- this._reportError("Assigning animation triggers via @prop=\"exp\" attributes with an expression is invalid." +
- " Use property bindings (e.g. [@prop]=\"exp\") or use an attribute without a value (e.g. @prop) instead.", sourceSpan, ParseErrorLevel.ERROR);
- }
- this._parseAnimation(name, value, sourceSpan, targetMatchableAttrs, targetProps);
- }
- else {
- targetProps.push(new BoundProperty(name, this._exprParser.wrapLiteralPrimitive(value, ''), BoundPropertyType.LITERAL_ATTR, sourceSpan));
- }
- };
- /**
- * @param {?} name
- * @param {?} expression
- * @param {?} isHost
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @return {?}
- */
- BindingParser.prototype.parsePropertyBinding = /**
- * @param {?} name
- * @param {?} expression
- * @param {?} isHost
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @return {?}
- */
- function (name, expression, isHost, sourceSpan, targetMatchableAttrs, targetProps) {
- var /** @type {?} */ isAnimationProp = false;
- if (name.startsWith(ANIMATE_PROP_PREFIX)) {
- isAnimationProp = true;
- name = name.substring(ANIMATE_PROP_PREFIX.length);
- }
- else if (_isAnimationLabel(name)) {
- isAnimationProp = true;
- name = name.substring(1);
- }
- if (isAnimationProp) {
- this._parseAnimation(name, expression, sourceSpan, targetMatchableAttrs, targetProps);
- }
- else {
- this._parsePropertyAst(name, this._parseBinding(expression, isHost, sourceSpan), sourceSpan, targetMatchableAttrs, targetProps);
- }
- };
- /**
- * @param {?} name
- * @param {?} value
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @return {?}
- */
- BindingParser.prototype.parsePropertyInterpolation = /**
- * @param {?} name
- * @param {?} value
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @return {?}
- */
- function (name, value, sourceSpan, targetMatchableAttrs, targetProps) {
- var /** @type {?} */ expr = this.parseInterpolation(value, sourceSpan);
- if (expr) {
- this._parsePropertyAst(name, expr, sourceSpan, targetMatchableAttrs, targetProps);
- return true;
- }
- return false;
- };
- /**
- * @param {?} name
- * @param {?} ast
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @return {?}
- */
- BindingParser.prototype._parsePropertyAst = /**
- * @param {?} name
- * @param {?} ast
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @return {?}
- */
- function (name, ast, sourceSpan, targetMatchableAttrs, targetProps) {
- targetMatchableAttrs.push([name, /** @type {?} */ ((ast.source))]);
- targetProps.push(new BoundProperty(name, ast, BoundPropertyType.DEFAULT, sourceSpan));
- };
- /**
- * @param {?} name
- * @param {?} expression
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @return {?}
- */
- BindingParser.prototype._parseAnimation = /**
- * @param {?} name
- * @param {?} expression
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @return {?}
- */
- function (name, expression, sourceSpan, targetMatchableAttrs, targetProps) {
- // This will occur when a @trigger is not paired with an expression.
- // For animations it is valid to not have an expression since */void
- // states will be applied by angular when the element is attached/detached
- var /** @type {?} */ ast = this._parseBinding(expression || 'undefined', false, sourceSpan);
- targetMatchableAttrs.push([name, /** @type {?} */ ((ast.source))]);
- targetProps.push(new BoundProperty(name, ast, BoundPropertyType.ANIMATION, sourceSpan));
- };
- /**
- * @param {?} value
- * @param {?} isHostBinding
- * @param {?} sourceSpan
- * @return {?}
- */
- BindingParser.prototype._parseBinding = /**
- * @param {?} value
- * @param {?} isHostBinding
- * @param {?} sourceSpan
- * @return {?}
- */
- function (value, isHostBinding, sourceSpan) {
- var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
- try {
- var /** @type {?} */ ast = isHostBinding ?
- this._exprParser.parseSimpleBinding(value, sourceInfo, this._interpolationConfig) :
- this._exprParser.parseBinding(value, sourceInfo, this._interpolationConfig);
- if (ast)
- this._reportExpressionParserErrors(ast.errors, sourceSpan);
- this._checkPipes(ast, sourceSpan);
- return ast;
- }
- catch (/** @type {?} */ e) {
- this._reportError("" + e, sourceSpan);
- return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
- }
- };
- /**
- * @param {?} elementSelector
- * @param {?} boundProp
- * @return {?}
- */
- BindingParser.prototype.createElementPropertyAst = /**
- * @param {?} elementSelector
- * @param {?} boundProp
- * @return {?}
- */
- function (elementSelector, boundProp) {
- if (boundProp.isAnimation) {
- return new BoundElementPropertyAst(boundProp.name, PropertyBindingType.Animation, SecurityContext.NONE, boundProp.expression, null, boundProp.sourceSpan);
- }
- var /** @type {?} */ unit = null;
- var /** @type {?} */ bindingType = /** @type {?} */ ((undefined));
- var /** @type {?} */ boundPropertyName = null;
- var /** @type {?} */ parts = boundProp.name.split(PROPERTY_PARTS_SEPARATOR);
- var /** @type {?} */ securityContexts = /** @type {?} */ ((undefined));
- // Check check for special cases (prefix style, attr, class)
- if (parts.length > 1) {
- if (parts[0] == ATTRIBUTE_PREFIX) {
- boundPropertyName = parts[1];
- this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, true);
- securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, true);
- var /** @type {?} */ nsSeparatorIdx = boundPropertyName.indexOf(':');
- if (nsSeparatorIdx > -1) {
- var /** @type {?} */ ns = boundPropertyName.substring(0, nsSeparatorIdx);
- var /** @type {?} */ name_1 = boundPropertyName.substring(nsSeparatorIdx + 1);
- boundPropertyName = mergeNsAndName(ns, name_1);
- }
- bindingType = PropertyBindingType.Attribute;
- }
- else if (parts[0] == CLASS_PREFIX) {
- boundPropertyName = parts[1];
- bindingType = PropertyBindingType.Class;
- securityContexts = [SecurityContext.NONE];
- }
- else if (parts[0] == STYLE_PREFIX) {
- unit = parts.length > 2 ? parts[2] : null;
- boundPropertyName = parts[1];
- bindingType = PropertyBindingType.Style;
- securityContexts = [SecurityContext.STYLE];
- }
- }
- // If not a special case, use the full property name
- if (boundPropertyName === null) {
- boundPropertyName = this._schemaRegistry.getMappedPropName(boundProp.name);
- securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, false);
- bindingType = PropertyBindingType.Property;
- this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, false);
- }
- return new BoundElementPropertyAst(boundPropertyName, bindingType, securityContexts[0], boundProp.expression, unit, boundProp.sourceSpan);
- };
- /**
- * @param {?} name
- * @param {?} expression
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetEvents
- * @return {?}
- */
- BindingParser.prototype.parseEvent = /**
- * @param {?} name
- * @param {?} expression
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetEvents
- * @return {?}
- */
- function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
- if (_isAnimationLabel(name)) {
- name = name.substr(1);
- this._parseAnimationEvent(name, expression, sourceSpan, targetEvents);
- }
- else {
- this._parseEvent(name, expression, sourceSpan, targetMatchableAttrs, targetEvents);
- }
- };
- /**
- * @param {?} name
- * @param {?} expression
- * @param {?} sourceSpan
- * @param {?} targetEvents
- * @return {?}
- */
- BindingParser.prototype._parseAnimationEvent = /**
- * @param {?} name
- * @param {?} expression
- * @param {?} sourceSpan
- * @param {?} targetEvents
- * @return {?}
- */
- function (name, expression, sourceSpan, targetEvents) {
- var /** @type {?} */ matches = splitAtPeriod(name, [name, '']);
- var /** @type {?} */ eventName = matches[0];
- var /** @type {?} */ phase = matches[1].toLowerCase();
- if (phase) {
- switch (phase) {
- case 'start':
- case 'done':
- var /** @type {?} */ ast = this._parseAction(expression, sourceSpan);
- targetEvents.push(new BoundEventAst(eventName, null, phase, ast, sourceSpan));
- break;
- default:
- this._reportError("The provided animation output phase value \"" + phase + "\" for \"@" + eventName + "\" is not supported (use start or done)", sourceSpan);
- break;
- }
- }
- else {
- this._reportError("The animation trigger output event (@" + eventName + ") is missing its phase value name (start or done are currently supported)", sourceSpan);
- }
- };
- /**
- * @param {?} name
- * @param {?} expression
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetEvents
- * @return {?}
- */
- BindingParser.prototype._parseEvent = /**
- * @param {?} name
- * @param {?} expression
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetEvents
- * @return {?}
- */
- function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
- // long format: 'target: eventName'
- var _a = splitAtColon(name, [/** @type {?} */ ((null)), name]), target = _a[0], eventName = _a[1];
- var /** @type {?} */ ast = this._parseAction(expression, sourceSpan);
- targetMatchableAttrs.push([/** @type {?} */ ((name)), /** @type {?} */ ((ast.source))]);
- targetEvents.push(new BoundEventAst(eventName, target, null, ast, sourceSpan));
- // Don't detect directives for event names for now,
- // so don't add the event name to the matchableAttrs
- };
- /**
- * @param {?} value
- * @param {?} sourceSpan
- * @return {?}
- */
- BindingParser.prototype._parseAction = /**
- * @param {?} value
- * @param {?} sourceSpan
- * @return {?}
- */
- function (value, sourceSpan) {
- var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
- try {
- var /** @type {?} */ ast = this._exprParser.parseAction(value, sourceInfo, this._interpolationConfig);
- if (ast) {
- this._reportExpressionParserErrors(ast.errors, sourceSpan);
- }
- if (!ast || ast.ast instanceof EmptyExpr) {
- this._reportError("Empty expressions are not allowed", sourceSpan);
- return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
- }
- this._checkPipes(ast, sourceSpan);
- return ast;
- }
- catch (/** @type {?} */ e) {
- this._reportError("" + e, sourceSpan);
- return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
- }
- };
- /**
- * @param {?} message
- * @param {?} sourceSpan
- * @param {?=} level
- * @return {?}
- */
- BindingParser.prototype._reportError = /**
- * @param {?} message
- * @param {?} sourceSpan
- * @param {?=} level
- * @return {?}
- */
- function (message, sourceSpan, level) {
- if (level === void 0) { level = ParseErrorLevel.ERROR; }
- this._targetErrors.push(new ParseError(sourceSpan, message, level));
- };
- /**
- * @param {?} errors
- * @param {?} sourceSpan
- * @return {?}
- */
- BindingParser.prototype._reportExpressionParserErrors = /**
- * @param {?} errors
- * @param {?} sourceSpan
- * @return {?}
- */
- function (errors, sourceSpan) {
- for (var _i = 0, errors_1 = errors; _i < errors_1.length; _i++) {
- var error = errors_1[_i];
- this._reportError(error.message, sourceSpan);
- }
- };
- /**
- * @param {?} ast
- * @param {?} sourceSpan
- * @return {?}
- */
- BindingParser.prototype._checkPipes = /**
- * @param {?} ast
- * @param {?} sourceSpan
- * @return {?}
- */
- function (ast, sourceSpan) {
- var _this = this;
- if (ast) {
- var /** @type {?} */ collector = new PipeCollector();
- ast.visit(collector);
- collector.pipes.forEach(function (ast, pipeName) {
- var /** @type {?} */ pipeMeta = _this.pipesByName.get(pipeName);
- if (!pipeMeta) {
- _this._reportError("The pipe '" + pipeName + "' could not be found", new ParseSourceSpan(sourceSpan.start.moveBy(ast.span.start), sourceSpan.start.moveBy(ast.span.end)));
- }
- else {
- _this._usedPipes.set(pipeName, pipeMeta);
- }
- });
- }
- };
- /**
- * @param {?} propName the name of the property / attribute
- * @param {?} sourceSpan
- * @param {?} isAttr true when binding to an attribute
- * @return {?}
- */
- BindingParser.prototype._validatePropertyOrAttributeName = /**
- * @param {?} propName the name of the property / attribute
- * @param {?} sourceSpan
- * @param {?} isAttr true when binding to an attribute
- * @return {?}
- */
- function (propName, sourceSpan, isAttr) {
- var /** @type {?} */ report = isAttr ? this._schemaRegistry.validateAttribute(propName) :
- this._schemaRegistry.validateProperty(propName);
- if (report.error) {
- this._reportError(/** @type {?} */ ((report.msg)), sourceSpan, ParseErrorLevel.ERROR);
- }
- };
- return BindingParser;
- }());
- var PipeCollector = /** @class */ (function (_super) {
- __extends(PipeCollector, _super);
- function PipeCollector() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.pipes = new Map();
- return _this;
- }
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- PipeCollector.prototype.visitPipe = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- this.pipes.set(ast.name, ast);
- ast.exp.visit(this);
- this.visitAll(ast.args, context);
- return null;
- };
- return PipeCollector;
- }(RecursiveAstVisitor));
- /**
- * @param {?} name
- * @return {?}
- */
- function _isAnimationLabel(name) {
- return name[0] == '@';
- }
- /**
- * @param {?} registry
- * @param {?} selector
- * @param {?} propName
- * @param {?} isAttribute
- * @return {?}
- */
- function calcPossibleSecurityContexts(registry, selector, propName, isAttribute) {
- var /** @type {?} */ ctxs = [];
- CssSelector.parse(selector).forEach(function (selector) {
- var /** @type {?} */ elementNames = selector.element ? [selector.element] : registry.allKnownElementNames();
- var /** @type {?} */ notElementNames = new Set(selector.notSelectors.filter(function (selector) { return selector.isElementSelector(); })
- .map(function (selector) { return selector.element; }));
- var /** @type {?} */ possibleElementNames = elementNames.filter(function (elementName) { return !notElementNames.has(elementName); });
- ctxs.push.apply(ctxs, possibleElementNames.map(function (elementName) { return registry.securityContext(elementName, propName, isAttribute); }));
- });
- return ctxs.length === 0 ? [SecurityContext.NONE] : Array.from(new Set(ctxs)).sort();
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(let-)|(ref-|#)|(on-)|(bindon-)|(@))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/;
- // Group 1 = "bind-"
- var KW_BIND_IDX = 1;
- // Group 2 = "let-"
- var KW_LET_IDX = 2;
- // Group 3 = "ref-/#"
- var KW_REF_IDX = 3;
- // Group 4 = "on-"
- var KW_ON_IDX = 4;
- // Group 5 = "bindon-"
- var KW_BINDON_IDX = 5;
- // Group 6 = "@"
- var KW_AT_IDX = 6;
- // Group 7 = the identifier after "bind-", "let-", "ref-/#", "on-", "bindon-" or "@"
- var IDENT_KW_IDX = 7;
- // Group 8 = identifier inside [()]
- var IDENT_BANANA_BOX_IDX = 8;
- // Group 9 = identifier inside []
- var IDENT_PROPERTY_IDX = 9;
- // Group 10 = identifier inside ()
- var IDENT_EVENT_IDX = 10;
- // deprecated in 4.x
- var TEMPLATE_ELEMENT = 'template';
- // deprecated in 4.x
- var TEMPLATE_ATTR = 'template';
- var TEMPLATE_ATTR_PREFIX = '*';
- var CLASS_ATTR = 'class';
- var TEXT_CSS_SELECTOR = CssSelector.parse('*')[0];
- var TEMPLATE_ELEMENT_DEPRECATION_WARNING = 'The <template> element is deprecated. Use <ng-template> instead';
- var TEMPLATE_ATTR_DEPRECATION_WARNING = 'The template attribute is deprecated. Use an ng-template element instead.';
- var warningCounts = {};
- /**
- * @param {?} warnings
- * @return {?}
- */
- function warnOnlyOnce(warnings) {
- return function (error) {
- if (warnings.indexOf(error.msg) !== -1) {
- warningCounts[error.msg] = (warningCounts[error.msg] || 0) + 1;
- return warningCounts[error.msg] <= 1;
- }
- return true;
- };
- }
- var TemplateParseError = /** @class */ (function (_super) {
- __extends(TemplateParseError, _super);
- function TemplateParseError(message, span, level) {
- return _super.call(this, span, message, level) || this;
- }
- return TemplateParseError;
- }(ParseError));
- var TemplateParseResult = /** @class */ (function () {
- function TemplateParseResult(templateAst, usedPipes, errors) {
- this.templateAst = templateAst;
- this.usedPipes = usedPipes;
- this.errors = errors;
- }
- return TemplateParseResult;
- }());
- var TemplateParser = /** @class */ (function () {
- function TemplateParser(_config, _reflector, _exprParser, _schemaRegistry, _htmlParser, _console, transforms) {
- this._config = _config;
- this._reflector = _reflector;
- this._exprParser = _exprParser;
- this._schemaRegistry = _schemaRegistry;
- this._htmlParser = _htmlParser;
- this._console = _console;
- this.transforms = transforms;
- }
- /**
- * @param {?} component
- * @param {?} template
- * @param {?} directives
- * @param {?} pipes
- * @param {?} schemas
- * @param {?} templateUrl
- * @param {?} preserveWhitespaces
- * @return {?}
- */
- TemplateParser.prototype.parse = /**
- * @param {?} component
- * @param {?} template
- * @param {?} directives
- * @param {?} pipes
- * @param {?} schemas
- * @param {?} templateUrl
- * @param {?} preserveWhitespaces
- * @return {?}
- */
- function (component, template, directives, pipes, schemas, templateUrl, preserveWhitespaces) {
- var /** @type {?} */ result = this.tryParse(component, template, directives, pipes, schemas, templateUrl, preserveWhitespaces);
- var /** @type {?} */ warnings = /** @type {?} */ ((result.errors)).filter(function (error) { return error.level === ParseErrorLevel.WARNING; }).filter(warnOnlyOnce([TEMPLATE_ATTR_DEPRECATION_WARNING, TEMPLATE_ELEMENT_DEPRECATION_WARNING]));
- var /** @type {?} */ errors = /** @type {?} */ ((result.errors)).filter(function (error) { return error.level === ParseErrorLevel.ERROR; });
- if (warnings.length > 0) {
- this._console.warn("Template parse warnings:\n" + warnings.join('\n'));
- }
- if (errors.length > 0) {
- var /** @type {?} */ errorString = errors.join('\n');
- throw syntaxError("Template parse errors:\n" + errorString, errors);
- }
- return { template: /** @type {?} */ ((result.templateAst)), pipes: /** @type {?} */ ((result.usedPipes)) };
- };
- /**
- * @param {?} component
- * @param {?} template
- * @param {?} directives
- * @param {?} pipes
- * @param {?} schemas
- * @param {?} templateUrl
- * @param {?} preserveWhitespaces
- * @return {?}
- */
- TemplateParser.prototype.tryParse = /**
- * @param {?} component
- * @param {?} template
- * @param {?} directives
- * @param {?} pipes
- * @param {?} schemas
- * @param {?} templateUrl
- * @param {?} preserveWhitespaces
- * @return {?}
- */
- function (component, template, directives, pipes, schemas, templateUrl, preserveWhitespaces) {
- var /** @type {?} */ htmlParseResult = typeof template === 'string' ? /** @type {?} */ ((this._htmlParser)).parse(template, templateUrl, true, this.getInterpolationConfig(component)) :
- template;
- if (!preserveWhitespaces) {
- htmlParseResult = removeWhitespaces(htmlParseResult);
- }
- return this.tryParseHtml(this.expandHtml(htmlParseResult), component, directives, pipes, schemas);
- };
- /**
- * @param {?} htmlAstWithErrors
- * @param {?} component
- * @param {?} directives
- * @param {?} pipes
- * @param {?} schemas
- * @return {?}
- */
- TemplateParser.prototype.tryParseHtml = /**
- * @param {?} htmlAstWithErrors
- * @param {?} component
- * @param {?} directives
- * @param {?} pipes
- * @param {?} schemas
- * @return {?}
- */
- function (htmlAstWithErrors, component, directives, pipes, schemas) {
- var /** @type {?} */ result;
- var /** @type {?} */ errors = htmlAstWithErrors.errors;
- var /** @type {?} */ usedPipes = [];
- if (htmlAstWithErrors.rootNodes.length > 0) {
- var /** @type {?} */ uniqDirectives = removeSummaryDuplicates(directives);
- var /** @type {?} */ uniqPipes = removeSummaryDuplicates(pipes);
- var /** @type {?} */ providerViewContext = new ProviderViewContext(this._reflector, component);
- var /** @type {?} */ interpolationConfig = /** @type {?} */ ((undefined));
- if (component.template && component.template.interpolation) {
- interpolationConfig = {
- start: component.template.interpolation[0],
- end: component.template.interpolation[1]
- };
- }
- var /** @type {?} */ bindingParser = new BindingParser(this._exprParser, /** @type {?} */ ((interpolationConfig)), this._schemaRegistry, uniqPipes, errors);
- var /** @type {?} */ parseVisitor = new TemplateParseVisitor(this._reflector, this._config, providerViewContext, uniqDirectives, bindingParser, this._schemaRegistry, schemas, errors);
- result = visitAll(parseVisitor, htmlAstWithErrors.rootNodes, EMPTY_ELEMENT_CONTEXT);
- errors.push.apply(errors, providerViewContext.errors);
- usedPipes.push.apply(usedPipes, bindingParser.getUsedPipes());
- }
- else {
- result = [];
- }
- this._assertNoReferenceDuplicationOnTemplate(result, errors);
- if (errors.length > 0) {
- return new TemplateParseResult(result, usedPipes, errors);
- }
- if (this.transforms) {
- this.transforms.forEach(function (transform) { result = templateVisitAll(transform, result); });
- }
- return new TemplateParseResult(result, usedPipes, errors);
- };
- /**
- * @param {?} htmlAstWithErrors
- * @param {?=} forced
- * @return {?}
- */
- TemplateParser.prototype.expandHtml = /**
- * @param {?} htmlAstWithErrors
- * @param {?=} forced
- * @return {?}
- */
- function (htmlAstWithErrors, forced) {
- if (forced === void 0) { forced = false; }
- var /** @type {?} */ errors = htmlAstWithErrors.errors;
- if (errors.length == 0 || forced) {
- // Transform ICU messages to angular directives
- var /** @type {?} */ expandedHtmlAst = expandNodes(htmlAstWithErrors.rootNodes);
- errors.push.apply(errors, expandedHtmlAst.errors);
- htmlAstWithErrors = new ParseTreeResult(expandedHtmlAst.nodes, errors);
- }
- return htmlAstWithErrors;
- };
- /**
- * @param {?} component
- * @return {?}
- */
- TemplateParser.prototype.getInterpolationConfig = /**
- * @param {?} component
- * @return {?}
- */
- function (component) {
- if (component.template) {
- return InterpolationConfig.fromArray(component.template.interpolation);
- }
- return undefined;
- };
- /** @internal */
- /**
- * \@internal
- * @param {?} result
- * @param {?} errors
- * @return {?}
- */
- TemplateParser.prototype._assertNoReferenceDuplicationOnTemplate = /**
- * \@internal
- * @param {?} result
- * @param {?} errors
- * @return {?}
- */
- function (result, errors) {
- var /** @type {?} */ existingReferences = [];
- result.filter(function (element) { return !!(/** @type {?} */ (element)).references; })
- .forEach(function (element) {
- return (/** @type {?} */ (element)).references.forEach(function (reference) {
- var /** @type {?} */ name = reference.name;
- if (existingReferences.indexOf(name) < 0) {
- existingReferences.push(name);
- }
- else {
- var /** @type {?} */ error = new TemplateParseError("Reference \"#" + name + "\" is defined several times", reference.sourceSpan, ParseErrorLevel.ERROR);
- errors.push(error);
- }
- });
- });
- };
- return TemplateParser;
- }());
- var TemplateParseVisitor = /** @class */ (function () {
- function TemplateParseVisitor(reflector, config, providerViewContext, directives, _bindingParser, _schemaRegistry, _schemas, _targetErrors) {
- var _this = this;
- this.reflector = reflector;
- this.config = config;
- this.providerViewContext = providerViewContext;
- this._bindingParser = _bindingParser;
- this._schemaRegistry = _schemaRegistry;
- this._schemas = _schemas;
- this._targetErrors = _targetErrors;
- this.selectorMatcher = new SelectorMatcher();
- this.directivesIndex = new Map();
- this.ngContentCount = 0;
- // Note: queries start with id 1 so we can use the number in a Bloom filter!
- this.contentQueryStartId = providerViewContext.component.viewQueries.length + 1;
- directives.forEach(function (directive, index) {
- var /** @type {?} */ selector = CssSelector.parse(/** @type {?} */ ((directive.selector)));
- _this.selectorMatcher.addSelectables(selector, directive);
- _this.directivesIndex.set(directive, index);
- });
- }
- /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- TemplateParseVisitor.prototype.visitExpansion = /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- function (expansion, context) { return null; };
- /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- TemplateParseVisitor.prototype.visitExpansionCase = /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- function (expansionCase, context) { return null; };
- /**
- * @param {?} text
- * @param {?} parent
- * @return {?}
- */
- TemplateParseVisitor.prototype.visitText = /**
- * @param {?} text
- * @param {?} parent
- * @return {?}
- */
- function (text, parent) {
- var /** @type {?} */ ngContentIndex = /** @type {?} */ ((parent.findNgContentIndex(TEXT_CSS_SELECTOR)));
- var /** @type {?} */ valueNoNgsp = replaceNgsp(text.value);
- var /** @type {?} */ expr = this._bindingParser.parseInterpolation(valueNoNgsp, /** @type {?} */ ((text.sourceSpan)));
- return expr ? new BoundTextAst(expr, ngContentIndex, /** @type {?} */ ((text.sourceSpan))) :
- new TextAst(valueNoNgsp, ngContentIndex, /** @type {?} */ ((text.sourceSpan)));
- };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- TemplateParseVisitor.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) {
- return new AttrAst(attribute.name, attribute.value, attribute.sourceSpan);
- };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- TemplateParseVisitor.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) { return null; };
- /**
- * @param {?} element
- * @param {?} parent
- * @return {?}
- */
- TemplateParseVisitor.prototype.visitElement = /**
- * @param {?} element
- * @param {?} parent
- * @return {?}
- */
- function (element, parent) {
- var _this = this;
- var /** @type {?} */ queryStartIndex = this.contentQueryStartId;
- var /** @type {?} */ nodeName = element.name;
- var /** @type {?} */ preparsedElement = preparseElement(element);
- if (preparsedElement.type === PreparsedElementType.SCRIPT ||
- preparsedElement.type === PreparsedElementType.STYLE) {
- // Skipping <script> for security reasons
- // Skipping <style> as we already processed them
- // in the StyleCompiler
- return null;
- }
- if (preparsedElement.type === PreparsedElementType.STYLESHEET &&
- isStyleUrlResolvable(preparsedElement.hrefAttr)) {
- // Skipping stylesheets with either relative urls or package scheme as we already processed
- // them in the StyleCompiler
- return null;
- }
- var /** @type {?} */ matchableAttrs = [];
- var /** @type {?} */ elementOrDirectiveProps = [];
- var /** @type {?} */ elementOrDirectiveRefs = [];
- var /** @type {?} */ elementVars = [];
- var /** @type {?} */ events = [];
- var /** @type {?} */ templateElementOrDirectiveProps = [];
- var /** @type {?} */ templateMatchableAttrs = [];
- var /** @type {?} */ templateElementVars = [];
- var /** @type {?} */ hasInlineTemplates = false;
- var /** @type {?} */ attrs = [];
- var /** @type {?} */ isTemplateElement = isTemplate(element, this.config.enableLegacyTemplate, function (m, span) { return _this._reportError(m, span, ParseErrorLevel.WARNING); });
- element.attrs.forEach(function (attr) {
- var /** @type {?} */ hasBinding = _this._parseAttr(isTemplateElement, attr, matchableAttrs, elementOrDirectiveProps, events, elementOrDirectiveRefs, elementVars);
- var /** @type {?} */ templateBindingsSource;
- var /** @type {?} */ prefixToken;
- var /** @type {?} */ normalizedName = _this._normalizeAttributeName(attr.name);
- if (_this.config.enableLegacyTemplate && normalizedName == TEMPLATE_ATTR) {
- _this._reportError(TEMPLATE_ATTR_DEPRECATION_WARNING, attr.sourceSpan, ParseErrorLevel.WARNING);
- templateBindingsSource = attr.value;
- }
- else if (normalizedName.startsWith(TEMPLATE_ATTR_PREFIX)) {
- templateBindingsSource = attr.value;
- prefixToken = normalizedName.substring(TEMPLATE_ATTR_PREFIX.length) + ':';
- }
- var /** @type {?} */ hasTemplateBinding = templateBindingsSource != null;
- if (hasTemplateBinding) {
- if (hasInlineTemplates) {
- _this._reportError("Can't have multiple template bindings on one element. Use only one attribute named 'template' or prefixed with *", attr.sourceSpan);
- }
- hasInlineTemplates = true;
- _this._bindingParser.parseInlineTemplateBinding(/** @type {?} */ ((prefixToken)), /** @type {?} */ ((templateBindingsSource)), attr.sourceSpan, templateMatchableAttrs, templateElementOrDirectiveProps, templateElementVars);
- }
- if (!hasBinding && !hasTemplateBinding) {
- // don't include the bindings as attributes as well in the AST
- attrs.push(_this.visitAttribute(attr, null));
- matchableAttrs.push([attr.name, attr.value]);
- }
- });
- var /** @type {?} */ elementCssSelector = createElementCssSelector(nodeName, matchableAttrs);
- var _a = this._parseDirectives(this.selectorMatcher, elementCssSelector), directiveMetas = _a.directives, matchElement = _a.matchElement;
- var /** @type {?} */ references = [];
- var /** @type {?} */ boundDirectivePropNames = new Set();
- var /** @type {?} */ directiveAsts = this._createDirectiveAsts(isTemplateElement, element.name, directiveMetas, elementOrDirectiveProps, elementOrDirectiveRefs, /** @type {?} */ ((element.sourceSpan)), references, boundDirectivePropNames);
- var /** @type {?} */ elementProps = this._createElementPropertyAsts(element.name, elementOrDirectiveProps, boundDirectivePropNames);
- var /** @type {?} */ isViewRoot = parent.isTemplateElement || hasInlineTemplates;
- var /** @type {?} */ providerContext = new ProviderElementContext(this.providerViewContext, /** @type {?} */ ((parent.providerContext)), isViewRoot, directiveAsts, attrs, references, isTemplateElement, queryStartIndex, /** @type {?} */ ((element.sourceSpan)));
- var /** @type {?} */ children = visitAll(preparsedElement.nonBindable ? NON_BINDABLE_VISITOR : this, element.children, ElementContext.create(isTemplateElement, directiveAsts, isTemplateElement ? /** @type {?} */ ((parent.providerContext)) : providerContext));
- providerContext.afterElement();
- // Override the actual selector when the `ngProjectAs` attribute is provided
- var /** @type {?} */ projectionSelector = preparsedElement.projectAs != null ?
- CssSelector.parse(preparsedElement.projectAs)[0] :
- elementCssSelector;
- var /** @type {?} */ ngContentIndex = /** @type {?} */ ((parent.findNgContentIndex(projectionSelector)));
- var /** @type {?} */ parsedElement;
- if (preparsedElement.type === PreparsedElementType.NG_CONTENT) {
- if (element.children && !element.children.every(_isEmptyTextNode)) {
- this._reportError("<ng-content> element cannot have content.", /** @type {?} */ ((element.sourceSpan)));
- }
- parsedElement = new NgContentAst(this.ngContentCount++, hasInlineTemplates ? /** @type {?} */ ((null)) : ngContentIndex, /** @type {?} */ ((element.sourceSpan)));
- }
- else if (isTemplateElement) {
- this._assertAllEventsPublishedByDirectives(directiveAsts, events);
- this._assertNoComponentsNorElementBindingsOnTemplate(directiveAsts, elementProps, /** @type {?} */ ((element.sourceSpan)));
- parsedElement = new EmbeddedTemplateAst(attrs, events, references, elementVars, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, providerContext.queryMatches, children, hasInlineTemplates ? /** @type {?} */ ((null)) : ngContentIndex, /** @type {?} */ ((element.sourceSpan)));
- }
- else {
- this._assertElementExists(matchElement, element);
- this._assertOnlyOneComponent(directiveAsts, /** @type {?} */ ((element.sourceSpan)));
- var /** @type {?} */ ngContentIndex_1 = hasInlineTemplates ? null : parent.findNgContentIndex(projectionSelector);
- parsedElement = new ElementAst(nodeName, attrs, elementProps, events, references, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, providerContext.queryMatches, children, hasInlineTemplates ? null : ngContentIndex_1, element.sourceSpan, element.endSourceSpan || null);
- }
- if (hasInlineTemplates) {
- var /** @type {?} */ templateQueryStartIndex = this.contentQueryStartId;
- var /** @type {?} */ templateSelector = createElementCssSelector(TEMPLATE_ELEMENT, templateMatchableAttrs);
- var templateDirectiveMetas = this._parseDirectives(this.selectorMatcher, templateSelector).directives;
- var /** @type {?} */ templateBoundDirectivePropNames = new Set();
- var /** @type {?} */ templateDirectiveAsts = this._createDirectiveAsts(true, element.name, templateDirectiveMetas, templateElementOrDirectiveProps, [], /** @type {?} */ ((element.sourceSpan)), [], templateBoundDirectivePropNames);
- var /** @type {?} */ templateElementProps = this._createElementPropertyAsts(element.name, templateElementOrDirectiveProps, templateBoundDirectivePropNames);
- this._assertNoComponentsNorElementBindingsOnTemplate(templateDirectiveAsts, templateElementProps, /** @type {?} */ ((element.sourceSpan)));
- var /** @type {?} */ templateProviderContext = new ProviderElementContext(this.providerViewContext, /** @type {?} */ ((parent.providerContext)), parent.isTemplateElement, templateDirectiveAsts, [], [], true, templateQueryStartIndex, /** @type {?} */ ((element.sourceSpan)));
- templateProviderContext.afterElement();
- parsedElement = new EmbeddedTemplateAst([], [], [], templateElementVars, templateProviderContext.transformedDirectiveAsts, templateProviderContext.transformProviders, templateProviderContext.transformedHasViewContainer, templateProviderContext.queryMatches, [parsedElement], ngContentIndex, /** @type {?} */ ((element.sourceSpan)));
- }
- return parsedElement;
- };
- /**
- * @param {?} isTemplateElement
- * @param {?} attr
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @param {?} targetEvents
- * @param {?} targetRefs
- * @param {?} targetVars
- * @return {?}
- */
- TemplateParseVisitor.prototype._parseAttr = /**
- * @param {?} isTemplateElement
- * @param {?} attr
- * @param {?} targetMatchableAttrs
- * @param {?} targetProps
- * @param {?} targetEvents
- * @param {?} targetRefs
- * @param {?} targetVars
- * @return {?}
- */
- function (isTemplateElement, attr, targetMatchableAttrs, targetProps, targetEvents, targetRefs, targetVars) {
- var /** @type {?} */ name = this._normalizeAttributeName(attr.name);
- var /** @type {?} */ value = attr.value;
- var /** @type {?} */ srcSpan = attr.sourceSpan;
- var /** @type {?} */ bindParts = name.match(BIND_NAME_REGEXP);
- var /** @type {?} */ hasBinding = false;
- if (bindParts !== null) {
- hasBinding = true;
- if (bindParts[KW_BIND_IDX] != null) {
- this._bindingParser.parsePropertyBinding(bindParts[IDENT_KW_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
- }
- else if (bindParts[KW_LET_IDX]) {
- if (isTemplateElement) {
- var /** @type {?} */ identifier = bindParts[IDENT_KW_IDX];
- this._parseVariable(identifier, value, srcSpan, targetVars);
- }
- else {
- this._reportError("\"let-\" is only supported on ng-template elements.", srcSpan);
- }
- }
- else if (bindParts[KW_REF_IDX]) {
- var /** @type {?} */ identifier = bindParts[IDENT_KW_IDX];
- this._parseReference(identifier, value, srcSpan, targetRefs);
- }
- else if (bindParts[KW_ON_IDX]) {
- this._bindingParser.parseEvent(bindParts[IDENT_KW_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
- }
- else if (bindParts[KW_BINDON_IDX]) {
- this._bindingParser.parsePropertyBinding(bindParts[IDENT_KW_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
- this._parseAssignmentEvent(bindParts[IDENT_KW_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
- }
- else if (bindParts[KW_AT_IDX]) {
- this._bindingParser.parseLiteralAttr(name, value, srcSpan, targetMatchableAttrs, targetProps);
- }
- else if (bindParts[IDENT_BANANA_BOX_IDX]) {
- this._bindingParser.parsePropertyBinding(bindParts[IDENT_BANANA_BOX_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
- this._parseAssignmentEvent(bindParts[IDENT_BANANA_BOX_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
- }
- else if (bindParts[IDENT_PROPERTY_IDX]) {
- this._bindingParser.parsePropertyBinding(bindParts[IDENT_PROPERTY_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
- }
- else if (bindParts[IDENT_EVENT_IDX]) {
- this._bindingParser.parseEvent(bindParts[IDENT_EVENT_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
- }
- }
- else {
- hasBinding = this._bindingParser.parsePropertyInterpolation(name, value, srcSpan, targetMatchableAttrs, targetProps);
- }
- if (!hasBinding) {
- this._bindingParser.parseLiteralAttr(name, value, srcSpan, targetMatchableAttrs, targetProps);
- }
- return hasBinding;
- };
- /**
- * @param {?} attrName
- * @return {?}
- */
- TemplateParseVisitor.prototype._normalizeAttributeName = /**
- * @param {?} attrName
- * @return {?}
- */
- function (attrName) {
- return /^data-/i.test(attrName) ? attrName.substring(5) : attrName;
- };
- /**
- * @param {?} identifier
- * @param {?} value
- * @param {?} sourceSpan
- * @param {?} targetVars
- * @return {?}
- */
- TemplateParseVisitor.prototype._parseVariable = /**
- * @param {?} identifier
- * @param {?} value
- * @param {?} sourceSpan
- * @param {?} targetVars
- * @return {?}
- */
- function (identifier, value, sourceSpan, targetVars) {
- if (identifier.indexOf('-') > -1) {
- this._reportError("\"-\" is not allowed in variable names", sourceSpan);
- }
- targetVars.push(new VariableAst(identifier, value, sourceSpan));
- };
- /**
- * @param {?} identifier
- * @param {?} value
- * @param {?} sourceSpan
- * @param {?} targetRefs
- * @return {?}
- */
- TemplateParseVisitor.prototype._parseReference = /**
- * @param {?} identifier
- * @param {?} value
- * @param {?} sourceSpan
- * @param {?} targetRefs
- * @return {?}
- */
- function (identifier, value, sourceSpan, targetRefs) {
- if (identifier.indexOf('-') > -1) {
- this._reportError("\"-\" is not allowed in reference names", sourceSpan);
- }
- targetRefs.push(new ElementOrDirectiveRef(identifier, value, sourceSpan));
- };
- /**
- * @param {?} name
- * @param {?} expression
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetEvents
- * @return {?}
- */
- TemplateParseVisitor.prototype._parseAssignmentEvent = /**
- * @param {?} name
- * @param {?} expression
- * @param {?} sourceSpan
- * @param {?} targetMatchableAttrs
- * @param {?} targetEvents
- * @return {?}
- */
- function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
- this._bindingParser.parseEvent(name + "Change", expression + "=$event", sourceSpan, targetMatchableAttrs, targetEvents);
- };
- /**
- * @param {?} selectorMatcher
- * @param {?} elementCssSelector
- * @return {?}
- */
- TemplateParseVisitor.prototype._parseDirectives = /**
- * @param {?} selectorMatcher
- * @param {?} elementCssSelector
- * @return {?}
- */
- function (selectorMatcher, elementCssSelector) {
- var _this = this;
- // Need to sort the directives so that we get consistent results throughout,
- // as selectorMatcher uses Maps inside.
- // Also deduplicate directives as they might match more than one time!
- var /** @type {?} */ directives = new Array(this.directivesIndex.size);
- // Whether any directive selector matches on the element name
- var /** @type {?} */ matchElement = false;
- selectorMatcher.match(elementCssSelector, function (selector, directive) {
- directives[/** @type {?} */ ((_this.directivesIndex.get(directive)))] = directive;
- matchElement = matchElement || selector.hasElementSelector();
- });
- return {
- directives: directives.filter(function (dir) { return !!dir; }),
- matchElement: matchElement,
- };
- };
- /**
- * @param {?} isTemplateElement
- * @param {?} elementName
- * @param {?} directives
- * @param {?} props
- * @param {?} elementOrDirectiveRefs
- * @param {?} elementSourceSpan
- * @param {?} targetReferences
- * @param {?} targetBoundDirectivePropNames
- * @return {?}
- */
- TemplateParseVisitor.prototype._createDirectiveAsts = /**
- * @param {?} isTemplateElement
- * @param {?} elementName
- * @param {?} directives
- * @param {?} props
- * @param {?} elementOrDirectiveRefs
- * @param {?} elementSourceSpan
- * @param {?} targetReferences
- * @param {?} targetBoundDirectivePropNames
- * @return {?}
- */
- function (isTemplateElement, elementName, directives, props, elementOrDirectiveRefs, elementSourceSpan, targetReferences, targetBoundDirectivePropNames) {
- var _this = this;
- var /** @type {?} */ matchedReferences = new Set();
- var /** @type {?} */ component = /** @type {?} */ ((null));
- var /** @type {?} */ directiveAsts = directives.map(function (directive) {
- var /** @type {?} */ sourceSpan = new ParseSourceSpan(elementSourceSpan.start, elementSourceSpan.end, "Directive " + identifierName(directive.type));
- if (directive.isComponent) {
- component = directive;
- }
- var /** @type {?} */ directiveProperties = [];
- var /** @type {?} */ hostProperties = /** @type {?} */ ((_this._bindingParser.createDirectiveHostPropertyAsts(directive, elementName, sourceSpan)));
- // Note: We need to check the host properties here as well,
- // as we don't know the element name in the DirectiveWrapperCompiler yet.
- hostProperties = _this._checkPropertiesInSchema(elementName, hostProperties);
- var /** @type {?} */ hostEvents = /** @type {?} */ ((_this._bindingParser.createDirectiveHostEventAsts(directive, sourceSpan)));
- _this._createDirectivePropertyAsts(directive.inputs, props, directiveProperties, targetBoundDirectivePropNames);
- elementOrDirectiveRefs.forEach(function (elOrDirRef) {
- if ((elOrDirRef.value.length === 0 && directive.isComponent) ||
- (elOrDirRef.isReferenceToDirective(directive))) {
- targetReferences.push(new ReferenceAst(elOrDirRef.name, createTokenForReference(directive.type.reference), elOrDirRef.sourceSpan));
- matchedReferences.add(elOrDirRef.name);
- }
- });
- var /** @type {?} */ contentQueryStartId = _this.contentQueryStartId;
- _this.contentQueryStartId += directive.queries.length;
- return new DirectiveAst(directive, directiveProperties, hostProperties, hostEvents, contentQueryStartId, sourceSpan);
- });
- elementOrDirectiveRefs.forEach(function (elOrDirRef) {
- if (elOrDirRef.value.length > 0) {
- if (!matchedReferences.has(elOrDirRef.name)) {
- _this._reportError("There is no directive with \"exportAs\" set to \"" + elOrDirRef.value + "\"", elOrDirRef.sourceSpan);
- }
- }
- else if (!component) {
- var /** @type {?} */ refToken = /** @type {?} */ ((null));
- if (isTemplateElement) {
- refToken = createTokenForExternalReference(_this.reflector, Identifiers.TemplateRef);
- }
- targetReferences.push(new ReferenceAst(elOrDirRef.name, refToken, elOrDirRef.sourceSpan));
- }
- });
- return directiveAsts;
- };
- /**
- * @param {?} directiveProperties
- * @param {?} boundProps
- * @param {?} targetBoundDirectiveProps
- * @param {?} targetBoundDirectivePropNames
- * @return {?}
- */
- TemplateParseVisitor.prototype._createDirectivePropertyAsts = /**
- * @param {?} directiveProperties
- * @param {?} boundProps
- * @param {?} targetBoundDirectiveProps
- * @param {?} targetBoundDirectivePropNames
- * @return {?}
- */
- function (directiveProperties, boundProps, targetBoundDirectiveProps, targetBoundDirectivePropNames) {
- if (directiveProperties) {
- var /** @type {?} */ boundPropsByName_1 = new Map();
- boundProps.forEach(function (boundProp) {
- var /** @type {?} */ prevValue = boundPropsByName_1.get(boundProp.name);
- if (!prevValue || prevValue.isLiteral) {
- // give [a]="b" a higher precedence than a="b" on the same element
- // give [a]="b" a higher precedence than a="b" on the same element
- boundPropsByName_1.set(boundProp.name, boundProp);
- }
- });
- Object.keys(directiveProperties).forEach(function (dirProp) {
- var /** @type {?} */ elProp = directiveProperties[dirProp];
- var /** @type {?} */ boundProp = boundPropsByName_1.get(elProp);
- // Bindings are optional, so this binding only needs to be set up if an expression is given.
- if (boundProp) {
- targetBoundDirectivePropNames.add(boundProp.name);
- if (!isEmptyExpression(boundProp.expression)) {
- targetBoundDirectiveProps.push(new BoundDirectivePropertyAst(dirProp, boundProp.name, boundProp.expression, boundProp.sourceSpan));
- }
- }
- });
- }
- };
- /**
- * @param {?} elementName
- * @param {?} props
- * @param {?} boundDirectivePropNames
- * @return {?}
- */
- TemplateParseVisitor.prototype._createElementPropertyAsts = /**
- * @param {?} elementName
- * @param {?} props
- * @param {?} boundDirectivePropNames
- * @return {?}
- */
- function (elementName, props, boundDirectivePropNames) {
- var _this = this;
- var /** @type {?} */ boundElementProps = [];
- props.forEach(function (prop) {
- if (!prop.isLiteral && !boundDirectivePropNames.has(prop.name)) {
- boundElementProps.push(_this._bindingParser.createElementPropertyAst(elementName, prop));
- }
- });
- return this._checkPropertiesInSchema(elementName, boundElementProps);
- };
- /**
- * @param {?} directives
- * @return {?}
- */
- TemplateParseVisitor.prototype._findComponentDirectives = /**
- * @param {?} directives
- * @return {?}
- */
- function (directives) {
- return directives.filter(function (directive) { return directive.directive.isComponent; });
- };
- /**
- * @param {?} directives
- * @return {?}
- */
- TemplateParseVisitor.prototype._findComponentDirectiveNames = /**
- * @param {?} directives
- * @return {?}
- */
- function (directives) {
- return this._findComponentDirectives(directives)
- .map(function (directive) { return ((identifierName(directive.directive.type))); });
- };
- /**
- * @param {?} directives
- * @param {?} sourceSpan
- * @return {?}
- */
- TemplateParseVisitor.prototype._assertOnlyOneComponent = /**
- * @param {?} directives
- * @param {?} sourceSpan
- * @return {?}
- */
- function (directives, sourceSpan) {
- var /** @type {?} */ componentTypeNames = this._findComponentDirectiveNames(directives);
- if (componentTypeNames.length > 1) {
- this._reportError("More than one component matched on this element.\n" +
- "Make sure that only one component's selector can match a given element.\n" +
- ("Conflicting components: " + componentTypeNames.join(',')), sourceSpan);
- }
- };
- /**
- * Make sure that non-angular tags conform to the schemas.
- *
- * Note: An element is considered an angular tag when at least one directive selector matches the
- * tag name.
- *
- * @param {?} matchElement Whether any directive has matched on the tag name
- * @param {?} element the html element
- * @return {?}
- */
- TemplateParseVisitor.prototype._assertElementExists = /**
- * Make sure that non-angular tags conform to the schemas.
- *
- * Note: An element is considered an angular tag when at least one directive selector matches the
- * tag name.
- *
- * @param {?} matchElement Whether any directive has matched on the tag name
- * @param {?} element the html element
- * @return {?}
- */
- function (matchElement, element) {
- var /** @type {?} */ elName = element.name.replace(/^:xhtml:/, '');
- if (!matchElement && !this._schemaRegistry.hasElement(elName, this._schemas)) {
- var /** @type {?} */ errorMsg = "'" + elName + "' is not a known element:\n";
- errorMsg +=
- "1. If '" + elName + "' is an Angular component, then verify that it is part of this module.\n";
- if (elName.indexOf('-') > -1) {
- errorMsg +=
- "2. If '" + elName + "' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.";
- }
- else {
- errorMsg +=
- "2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.";
- }
- this._reportError(errorMsg, /** @type {?} */ ((element.sourceSpan)));
- }
- };
- /**
- * @param {?} directives
- * @param {?} elementProps
- * @param {?} sourceSpan
- * @return {?}
- */
- TemplateParseVisitor.prototype._assertNoComponentsNorElementBindingsOnTemplate = /**
- * @param {?} directives
- * @param {?} elementProps
- * @param {?} sourceSpan
- * @return {?}
- */
- function (directives, elementProps, sourceSpan) {
- var _this = this;
- var /** @type {?} */ componentTypeNames = this._findComponentDirectiveNames(directives);
- if (componentTypeNames.length > 0) {
- this._reportError("Components on an embedded template: " + componentTypeNames.join(','), sourceSpan);
- }
- elementProps.forEach(function (prop) {
- _this._reportError("Property binding " + prop.name + " not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the \"@NgModule.declarations\".", sourceSpan);
- });
- };
- /**
- * @param {?} directives
- * @param {?} events
- * @return {?}
- */
- TemplateParseVisitor.prototype._assertAllEventsPublishedByDirectives = /**
- * @param {?} directives
- * @param {?} events
- * @return {?}
- */
- function (directives, events) {
- var _this = this;
- var /** @type {?} */ allDirectiveEvents = new Set();
- directives.forEach(function (directive) {
- Object.keys(directive.directive.outputs).forEach(function (k) {
- var /** @type {?} */ eventName = directive.directive.outputs[k];
- allDirectiveEvents.add(eventName);
- });
- });
- events.forEach(function (event) {
- if (event.target != null || !allDirectiveEvents.has(event.name)) {
- _this._reportError("Event binding " + event.fullName + " not emitted by any directive on an embedded template. Make sure that the event name is spelled correctly and all directives are listed in the \"@NgModule.declarations\".", event.sourceSpan);
- }
- });
- };
- /**
- * @param {?} elementName
- * @param {?} boundProps
- * @return {?}
- */
- TemplateParseVisitor.prototype._checkPropertiesInSchema = /**
- * @param {?} elementName
- * @param {?} boundProps
- * @return {?}
- */
- function (elementName, boundProps) {
- var _this = this;
- // Note: We can't filter out empty expressions before this method,
- // as we still want to validate them!
- return boundProps.filter(function (boundProp) {
- if (boundProp.type === PropertyBindingType.Property &&
- !_this._schemaRegistry.hasProperty(elementName, boundProp.name, _this._schemas)) {
- var /** @type {?} */ errorMsg = "Can't bind to '" + boundProp.name + "' since it isn't a known property of '" + elementName + "'.";
- if (elementName.startsWith('ng-')) {
- errorMsg +=
- "\n1. If '" + boundProp.name + "' is an Angular directive, then add 'CommonModule' to the '@NgModule.imports' of this component." +
- "\n2. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.";
- }
- else if (elementName.indexOf('-') > -1) {
- errorMsg +=
- "\n1. If '" + elementName + "' is an Angular component and it has '" + boundProp.name + "' input, then verify that it is part of this module." +
- ("\n2. If '" + elementName + "' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.") +
- "\n3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.";
- }
- _this._reportError(errorMsg, boundProp.sourceSpan);
- }
- return !isEmptyExpression(boundProp.value);
- });
- };
- /**
- * @param {?} message
- * @param {?} sourceSpan
- * @param {?=} level
- * @return {?}
- */
- TemplateParseVisitor.prototype._reportError = /**
- * @param {?} message
- * @param {?} sourceSpan
- * @param {?=} level
- * @return {?}
- */
- function (message, sourceSpan, level) {
- if (level === void 0) { level = ParseErrorLevel.ERROR; }
- this._targetErrors.push(new ParseError(sourceSpan, message, level));
- };
- return TemplateParseVisitor;
- }());
- var NonBindableVisitor = /** @class */ (function () {
- function NonBindableVisitor() {
- }
- /**
- * @param {?} ast
- * @param {?} parent
- * @return {?}
- */
- NonBindableVisitor.prototype.visitElement = /**
- * @param {?} ast
- * @param {?} parent
- * @return {?}
- */
- function (ast, parent) {
- var /** @type {?} */ preparsedElement = preparseElement(ast);
- if (preparsedElement.type === PreparsedElementType.SCRIPT ||
- preparsedElement.type === PreparsedElementType.STYLE ||
- preparsedElement.type === PreparsedElementType.STYLESHEET) {
- // Skipping <script> for security reasons
- // Skipping <style> and stylesheets as we already processed them
- // in the StyleCompiler
- return null;
- }
- var /** @type {?} */ attrNameAndValues = ast.attrs.map(function (attr) { return [attr.name, attr.value]; });
- var /** @type {?} */ selector = createElementCssSelector(ast.name, attrNameAndValues);
- var /** @type {?} */ ngContentIndex = parent.findNgContentIndex(selector);
- var /** @type {?} */ children = visitAll(this, ast.children, EMPTY_ELEMENT_CONTEXT);
- return new ElementAst(ast.name, visitAll(this, ast.attrs), [], [], [], [], [], false, [], children, ngContentIndex, ast.sourceSpan, ast.endSourceSpan);
- };
- /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- NonBindableVisitor.prototype.visitComment = /**
- * @param {?} comment
- * @param {?} context
- * @return {?}
- */
- function (comment, context) { return null; };
- /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- NonBindableVisitor.prototype.visitAttribute = /**
- * @param {?} attribute
- * @param {?} context
- * @return {?}
- */
- function (attribute, context) {
- return new AttrAst(attribute.name, attribute.value, attribute.sourceSpan);
- };
- /**
- * @param {?} text
- * @param {?} parent
- * @return {?}
- */
- NonBindableVisitor.prototype.visitText = /**
- * @param {?} text
- * @param {?} parent
- * @return {?}
- */
- function (text, parent) {
- var /** @type {?} */ ngContentIndex = /** @type {?} */ ((parent.findNgContentIndex(TEXT_CSS_SELECTOR)));
- return new TextAst(text.value, ngContentIndex, /** @type {?} */ ((text.sourceSpan)));
- };
- /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- NonBindableVisitor.prototype.visitExpansion = /**
- * @param {?} expansion
- * @param {?} context
- * @return {?}
- */
- function (expansion, context) { return expansion; };
- /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- NonBindableVisitor.prototype.visitExpansionCase = /**
- * @param {?} expansionCase
- * @param {?} context
- * @return {?}
- */
- function (expansionCase, context) { return expansionCase; };
- return NonBindableVisitor;
- }());
- /**
- * A reference to an element or directive in a template. E.g., the reference in this template:
- *
- * <div #myMenu="coolMenu">
- *
- * would be {name: 'myMenu', value: 'coolMenu', sourceSpan: ...}
- */
- var ElementOrDirectiveRef = /** @class */ (function () {
- function ElementOrDirectiveRef(name, value, sourceSpan) {
- this.name = name;
- this.value = value;
- this.sourceSpan = sourceSpan;
- }
- /** Gets whether this is a reference to the given directive. */
- /**
- * Gets whether this is a reference to the given directive.
- * @param {?} directive
- * @return {?}
- */
- ElementOrDirectiveRef.prototype.isReferenceToDirective = /**
- * Gets whether this is a reference to the given directive.
- * @param {?} directive
- * @return {?}
- */
- function (directive) {
- return splitExportAs(directive.exportAs).indexOf(this.value) !== -1;
- };
- return ElementOrDirectiveRef;
- }());
- /**
- * Splits a raw, potentially comma-delimted `exportAs` value into an array of names.
- * @param {?} exportAs
- * @return {?}
- */
- function splitExportAs(exportAs) {
- return exportAs ? exportAs.split(',').map(function (e) { return e.trim(); }) : [];
- }
- /**
- * @param {?} classAttrValue
- * @return {?}
- */
- function splitClasses(classAttrValue) {
- return classAttrValue.trim().split(/\s+/g);
- }
- var ElementContext = /** @class */ (function () {
- function ElementContext(isTemplateElement, _ngContentIndexMatcher, _wildcardNgContentIndex, providerContext) {
- this.isTemplateElement = isTemplateElement;
- this._ngContentIndexMatcher = _ngContentIndexMatcher;
- this._wildcardNgContentIndex = _wildcardNgContentIndex;
- this.providerContext = providerContext;
- }
- /**
- * @param {?} isTemplateElement
- * @param {?} directives
- * @param {?} providerContext
- * @return {?}
- */
- ElementContext.create = /**
- * @param {?} isTemplateElement
- * @param {?} directives
- * @param {?} providerContext
- * @return {?}
- */
- function (isTemplateElement, directives, providerContext) {
- var /** @type {?} */ matcher = new SelectorMatcher();
- var /** @type {?} */ wildcardNgContentIndex = /** @type {?} */ ((null));
- var /** @type {?} */ component = directives.find(function (directive) { return directive.directive.isComponent; });
- if (component) {
- var /** @type {?} */ ngContentSelectors = /** @type {?} */ ((component.directive.template)).ngContentSelectors;
- for (var /** @type {?} */ i = 0; i < ngContentSelectors.length; i++) {
- var /** @type {?} */ selector = ngContentSelectors[i];
- if (selector === '*') {
- wildcardNgContentIndex = i;
- }
- else {
- matcher.addSelectables(CssSelector.parse(ngContentSelectors[i]), i);
- }
- }
- }
- return new ElementContext(isTemplateElement, matcher, wildcardNgContentIndex, providerContext);
- };
- /**
- * @param {?} selector
- * @return {?}
- */
- ElementContext.prototype.findNgContentIndex = /**
- * @param {?} selector
- * @return {?}
- */
- function (selector) {
- var /** @type {?} */ ngContentIndices = [];
- this._ngContentIndexMatcher.match(selector, function (selector, ngContentIndex) { ngContentIndices.push(ngContentIndex); });
- ngContentIndices.sort();
- if (this._wildcardNgContentIndex != null) {
- ngContentIndices.push(this._wildcardNgContentIndex);
- }
- return ngContentIndices.length > 0 ? ngContentIndices[0] : null;
- };
- return ElementContext;
- }());
- /**
- * @param {?} elementName
- * @param {?} attributes
- * @return {?}
- */
- function createElementCssSelector(elementName, attributes) {
- var /** @type {?} */ cssSelector = new CssSelector();
- var /** @type {?} */ elNameNoNs = splitNsName(elementName)[1];
- cssSelector.setElement(elNameNoNs);
- for (var /** @type {?} */ i = 0; i < attributes.length; i++) {
- var /** @type {?} */ attrName = attributes[i][0];
- var /** @type {?} */ attrNameNoNs = splitNsName(attrName)[1];
- var /** @type {?} */ attrValue = attributes[i][1];
- cssSelector.addAttribute(attrNameNoNs, attrValue);
- if (attrName.toLowerCase() == CLASS_ATTR) {
- var /** @type {?} */ classes = splitClasses(attrValue);
- classes.forEach(function (className) { return cssSelector.addClassName(className); });
- }
- }
- return cssSelector;
- }
- var EMPTY_ELEMENT_CONTEXT = new ElementContext(true, new SelectorMatcher(), null, null);
- var NON_BINDABLE_VISITOR = new NonBindableVisitor();
- /**
- * @param {?} node
- * @return {?}
- */
- function _isEmptyTextNode(node) {
- return node instanceof Text && node.value.trim().length == 0;
- }
- /**
- * @template T
- * @param {?} items
- * @return {?}
- */
- function removeSummaryDuplicates(items) {
- var /** @type {?} */ map = new Map();
- items.forEach(function (item) {
- if (!map.get(item.type.reference)) {
- map.set(item.type.reference, item);
- }
- });
- return Array.from(map.values());
- }
- /**
- * @param {?} ast
- * @return {?}
- */
- function isEmptyExpression(ast) {
- if (ast instanceof ASTWithSource) {
- ast = ast.ast;
- }
- return ast instanceof EmptyExpr;
- }
- /**
- * @param {?} el
- * @param {?} enableLegacyTemplate
- * @param {?} reportDeprecation
- * @return {?}
- */
- function isTemplate(el, enableLegacyTemplate, reportDeprecation) {
- if (isNgTemplate(el.name))
- return true;
- var /** @type {?} */ tagNoNs = splitNsName(el.name)[1];
- // `<template>` is HTML and case insensitive
- if (tagNoNs.toLowerCase() === TEMPLATE_ELEMENT) {
- if (enableLegacyTemplate && tagNoNs.toLowerCase() === TEMPLATE_ELEMENT) {
- reportDeprecation(TEMPLATE_ELEMENT_DEPRECATION_WARNING, /** @type {?} */ ((el.sourceSpan)));
- return true;
- }
- }
- return false;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var EventHandlerVars = /** @class */ (function () {
- function EventHandlerVars() {
- }
- EventHandlerVars.event = variable('$event');
- return EventHandlerVars;
- }());
- /**
- * @record
- */
-
- var ConvertActionBindingResult = /** @class */ (function () {
- function ConvertActionBindingResult(stmts, allowDefault) {
- this.stmts = stmts;
- this.allowDefault = allowDefault;
- }
- return ConvertActionBindingResult;
- }());
- /**
- * Converts the given expression AST into an executable output AST, assuming the expression is
- * used in an action binding (e.g. an event handler).
- * @param {?} localResolver
- * @param {?} implicitReceiver
- * @param {?} action
- * @param {?} bindingId
- * @return {?}
- */
- function convertActionBinding(localResolver, implicitReceiver, action, bindingId) {
- if (!localResolver) {
- localResolver = new DefaultLocalResolver();
- }
- var /** @type {?} */ actionWithoutBuiltins = convertPropertyBindingBuiltins({
- createLiteralArrayConverter: function (argCount) {
- // Note: no caching for literal arrays in actions.
- return function (args) { return literalArr(args); };
- },
- createLiteralMapConverter: function (keys) {
- // Note: no caching for literal maps in actions.
- return function (values) {
- var /** @type {?} */ entries = keys.map(function (k, i) {
- return ({
- key: k.key,
- value: values[i],
- quoted: k.quoted,
- });
- });
- return literalMap(entries);
- };
- },
- createPipeConverter: function (name) {
- throw new Error("Illegal State: Actions are not allowed to contain pipes. Pipe: " + name);
- }
- }, action);
- var /** @type {?} */ visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId);
- var /** @type {?} */ actionStmts = [];
- flattenStatements(actionWithoutBuiltins.visit(visitor, _Mode.Statement), actionStmts);
- prependTemporaryDecls(visitor.temporaryCount, bindingId, actionStmts);
- var /** @type {?} */ lastIndex = actionStmts.length - 1;
- var /** @type {?} */ preventDefaultVar = /** @type {?} */ ((null));
- if (lastIndex >= 0) {
- var /** @type {?} */ lastStatement = actionStmts[lastIndex];
- var /** @type {?} */ returnExpr = convertStmtIntoExpression(lastStatement);
- if (returnExpr) {
- // Note: We need to cast the result of the method call to dynamic,
- // as it might be a void method!
- preventDefaultVar = createPreventDefaultVar(bindingId);
- actionStmts[lastIndex] =
- preventDefaultVar.set(returnExpr.cast(DYNAMIC_TYPE).notIdentical(literal(false)))
- .toDeclStmt(null, [StmtModifier.Final]);
- }
- }
- return new ConvertActionBindingResult(actionStmts, preventDefaultVar);
- }
- /**
- * @record
- */
-
- /**
- * @record
- */
-
- /**
- * @param {?} converterFactory
- * @param {?} ast
- * @return {?}
- */
- function convertPropertyBindingBuiltins(converterFactory, ast) {
- return convertBuiltins(converterFactory, ast);
- }
- var ConvertPropertyBindingResult = /** @class */ (function () {
- function ConvertPropertyBindingResult(stmts, currValExpr) {
- this.stmts = stmts;
- this.currValExpr = currValExpr;
- }
- return ConvertPropertyBindingResult;
- }());
- /** @enum {number} */
- var BindingForm = {
- // The general form of binding expression, supports all expressions.
- General: 0,
- // Try to generate a simple binding (no temporaries or statements)
- // otherise generate a general binding
- TrySimple: 1,
- };
- BindingForm[BindingForm.General] = "General";
- BindingForm[BindingForm.TrySimple] = "TrySimple";
- /**
- * Converts the given expression AST into an executable output AST, assuming the expression
- * is used in property binding. The expression has to be preprocessed via
- * `convertPropertyBindingBuiltins`.
- * @param {?} localResolver
- * @param {?} implicitReceiver
- * @param {?} expressionWithoutBuiltins
- * @param {?} bindingId
- * @param {?} form
- * @return {?}
- */
- function convertPropertyBinding(localResolver, implicitReceiver, expressionWithoutBuiltins, bindingId, form) {
- if (!localResolver) {
- localResolver = new DefaultLocalResolver();
- }
- var /** @type {?} */ currValExpr = createCurrValueExpr(bindingId);
- var /** @type {?} */ stmts = [];
- var /** @type {?} */ visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId);
- var /** @type {?} */ outputExpr = expressionWithoutBuiltins.visit(visitor, _Mode.Expression);
- if (visitor.temporaryCount) {
- for (var /** @type {?} */ i = 0; i < visitor.temporaryCount; i++) {
- stmts.push(temporaryDeclaration(bindingId, i));
- }
- }
- else if (form == BindingForm.TrySimple) {
- return new ConvertPropertyBindingResult([], outputExpr);
- }
- stmts.push(currValExpr.set(outputExpr).toDeclStmt(DYNAMIC_TYPE, [StmtModifier.Final]));
- return new ConvertPropertyBindingResult(stmts, currValExpr);
- }
- /**
- * @param {?} converterFactory
- * @param {?} ast
- * @return {?}
- */
- function convertBuiltins(converterFactory, ast) {
- var /** @type {?} */ visitor = new _BuiltinAstConverter(converterFactory);
- return ast.visit(visitor);
- }
- /**
- * @param {?} bindingId
- * @param {?} temporaryNumber
- * @return {?}
- */
- function temporaryName(bindingId, temporaryNumber) {
- return "tmp_" + bindingId + "_" + temporaryNumber;
- }
- /**
- * @param {?} bindingId
- * @param {?} temporaryNumber
- * @return {?}
- */
- function temporaryDeclaration(bindingId, temporaryNumber) {
- return new DeclareVarStmt(temporaryName(bindingId, temporaryNumber), NULL_EXPR);
- }
- /**
- * @param {?} temporaryCount
- * @param {?} bindingId
- * @param {?} statements
- * @return {?}
- */
- function prependTemporaryDecls(temporaryCount, bindingId, statements) {
- for (var /** @type {?} */ i = temporaryCount - 1; i >= 0; i--) {
- statements.unshift(temporaryDeclaration(bindingId, i));
- }
- }
- /** @enum {number} */
- var _Mode = {
- Statement: 0,
- Expression: 1,
- };
- _Mode[_Mode.Statement] = "Statement";
- _Mode[_Mode.Expression] = "Expression";
- /**
- * @param {?} mode
- * @param {?} ast
- * @return {?}
- */
- function ensureStatementMode(mode, ast) {
- if (mode !== _Mode.Statement) {
- throw new Error("Expected a statement, but saw " + ast);
- }
- }
- /**
- * @param {?} mode
- * @param {?} ast
- * @return {?}
- */
- function ensureExpressionMode(mode, ast) {
- if (mode !== _Mode.Expression) {
- throw new Error("Expected an expression, but saw " + ast);
- }
- }
- /**
- * @param {?} mode
- * @param {?} expr
- * @return {?}
- */
- function convertToStatementIfNeeded(mode, expr) {
- if (mode === _Mode.Statement) {
- return expr.toStmt();
- }
- else {
- return expr;
- }
- }
- var _BuiltinAstConverter = /** @class */ (function (_super) {
- __extends(_BuiltinAstConverter, _super);
- function _BuiltinAstConverter(_converterFactory) {
- var _this = _super.call(this) || this;
- _this._converterFactory = _converterFactory;
- return _this;
- }
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- _BuiltinAstConverter.prototype.visitPipe = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var _this = this;
- var /** @type {?} */ args = [ast.exp].concat(ast.args).map(function (ast) { return ast.visit(_this, context); });
- return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createPipeConverter(ast.name, args.length));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- _BuiltinAstConverter.prototype.visitLiteralArray = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var _this = this;
- var /** @type {?} */ args = ast.expressions.map(function (ast) { return ast.visit(_this, context); });
- return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createLiteralArrayConverter(ast.expressions.length));
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- _BuiltinAstConverter.prototype.visitLiteralMap = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var _this = this;
- var /** @type {?} */ args = ast.values.map(function (ast) { return ast.visit(_this, context); });
- return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createLiteralMapConverter(ast.keys));
- };
- return _BuiltinAstConverter;
- }(AstTransformer));
- var _AstToIrVisitor = /** @class */ (function () {
- function _AstToIrVisitor(_localResolver, _implicitReceiver, bindingId) {
- this._localResolver = _localResolver;
- this._implicitReceiver = _implicitReceiver;
- this.bindingId = bindingId;
- this._nodeMap = new Map();
- this._resultMap = new Map();
- this._currentTemporary = 0;
- this.temporaryCount = 0;
- }
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitBinary = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- var /** @type {?} */ op;
- switch (ast.operation) {
- case '+':
- op = BinaryOperator.Plus;
- break;
- case '-':
- op = BinaryOperator.Minus;
- break;
- case '*':
- op = BinaryOperator.Multiply;
- break;
- case '/':
- op = BinaryOperator.Divide;
- break;
- case '%':
- op = BinaryOperator.Modulo;
- break;
- case '&&':
- op = BinaryOperator.And;
- break;
- case '||':
- op = BinaryOperator.Or;
- break;
- case '==':
- op = BinaryOperator.Equals;
- break;
- case '!=':
- op = BinaryOperator.NotEquals;
- break;
- case '===':
- op = BinaryOperator.Identical;
- break;
- case '!==':
- op = BinaryOperator.NotIdentical;
- break;
- case '<':
- op = BinaryOperator.Lower;
- break;
- case '>':
- op = BinaryOperator.Bigger;
- break;
- case '<=':
- op = BinaryOperator.LowerEquals;
- break;
- case '>=':
- op = BinaryOperator.BiggerEquals;
- break;
- default:
- throw new Error("Unsupported operation " + ast.operation);
- }
- return convertToStatementIfNeeded(mode, new BinaryOperatorExpr(op, this._visit(ast.left, _Mode.Expression), this._visit(ast.right, _Mode.Expression)));
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitChain = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- ensureStatementMode(mode, ast);
- return this.visitAll(ast.expressions, mode);
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitConditional = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- var /** @type {?} */ value = this._visit(ast.condition, _Mode.Expression);
- return convertToStatementIfNeeded(mode, value.conditional(this._visit(ast.trueExp, _Mode.Expression), this._visit(ast.falseExp, _Mode.Expression)));
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitPipe = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- throw new Error("Illegal state: Pipes should have been converted into functions. Pipe: " + ast.name);
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitFunctionCall = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- var /** @type {?} */ convertedArgs = this.visitAll(ast.args, _Mode.Expression);
- var /** @type {?} */ fnResult;
- if (ast instanceof BuiltinFunctionCall) {
- fnResult = ast.converter(convertedArgs);
- }
- else {
- fnResult = this._visit(/** @type {?} */ ((ast.target)), _Mode.Expression).callFn(convertedArgs);
- }
- return convertToStatementIfNeeded(mode, fnResult);
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitImplicitReceiver = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- ensureExpressionMode(mode, ast);
- return this._implicitReceiver;
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitInterpolation = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- ensureExpressionMode(mode, ast);
- var /** @type {?} */ args = [literal(ast.expressions.length)];
- for (var /** @type {?} */ i = 0; i < ast.strings.length - 1; i++) {
- args.push(literal(ast.strings[i]));
- args.push(this._visit(ast.expressions[i], _Mode.Expression));
- }
- args.push(literal(ast.strings[ast.strings.length - 1]));
- return ast.expressions.length <= 9 ?
- importExpr(Identifiers.inlineInterpolate).callFn(args) :
- importExpr(Identifiers.interpolate).callFn([args[0], literalArr(args.slice(1))]);
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitKeyedRead = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- var /** @type {?} */ leftMostSafe = this.leftMostSafeNode(ast);
- if (leftMostSafe) {
- return this.convertSafeAccess(ast, leftMostSafe, mode);
- }
- else {
- return convertToStatementIfNeeded(mode, this._visit(ast.obj, _Mode.Expression).key(this._visit(ast.key, _Mode.Expression)));
- }
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitKeyedWrite = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- var /** @type {?} */ obj = this._visit(ast.obj, _Mode.Expression);
- var /** @type {?} */ key = this._visit(ast.key, _Mode.Expression);
- var /** @type {?} */ value = this._visit(ast.value, _Mode.Expression);
- return convertToStatementIfNeeded(mode, obj.key(key).set(value));
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitLiteralArray = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- throw new Error("Illegal State: literal arrays should have been converted into functions");
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitLiteralMap = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- throw new Error("Illegal State: literal maps should have been converted into functions");
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitLiteralPrimitive = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- // For literal values of null, undefined, true, or false allow type inteference
- // to infer the type.
- var /** @type {?} */ type = ast.value === null || ast.value === undefined || ast.value === true || ast.value === true ?
- INFERRED_TYPE :
- undefined;
- return convertToStatementIfNeeded(mode, literal(ast.value, type));
- };
- /**
- * @param {?} name
- * @return {?}
- */
- _AstToIrVisitor.prototype._getLocal = /**
- * @param {?} name
- * @return {?}
- */
- function (name) { return this._localResolver.getLocal(name); };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitMethodCall = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- if (ast.receiver instanceof ImplicitReceiver && ast.name == '$any') {
- var /** @type {?} */ args = /** @type {?} */ (this.visitAll(ast.args, _Mode.Expression));
- if (args.length != 1) {
- throw new Error("Invalid call to $any, expected 1 argument but received " + (args.length || 'none'));
- }
- return (/** @type {?} */ (args[0])).cast(DYNAMIC_TYPE);
- }
- var /** @type {?} */ leftMostSafe = this.leftMostSafeNode(ast);
- if (leftMostSafe) {
- return this.convertSafeAccess(ast, leftMostSafe, mode);
- }
- else {
- var /** @type {?} */ args = this.visitAll(ast.args, _Mode.Expression);
- var /** @type {?} */ result = null;
- var /** @type {?} */ receiver = this._visit(ast.receiver, _Mode.Expression);
- if (receiver === this._implicitReceiver) {
- var /** @type {?} */ varExpr = this._getLocal(ast.name);
- if (varExpr) {
- result = varExpr.callFn(args);
- }
- }
- if (result == null) {
- result = receiver.callMethod(ast.name, args);
- }
- return convertToStatementIfNeeded(mode, result);
- }
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitPrefixNot = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- return convertToStatementIfNeeded(mode, not(this._visit(ast.expression, _Mode.Expression)));
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitNonNullAssert = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- return convertToStatementIfNeeded(mode, assertNotNull(this._visit(ast.expression, _Mode.Expression)));
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitPropertyRead = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- var /** @type {?} */ leftMostSafe = this.leftMostSafeNode(ast);
- if (leftMostSafe) {
- return this.convertSafeAccess(ast, leftMostSafe, mode);
- }
- else {
- var /** @type {?} */ result = null;
- var /** @type {?} */ receiver = this._visit(ast.receiver, _Mode.Expression);
- if (receiver === this._implicitReceiver) {
- result = this._getLocal(ast.name);
- }
- if (result == null) {
- result = receiver.prop(ast.name);
- }
- return convertToStatementIfNeeded(mode, result);
- }
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitPropertyWrite = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- var /** @type {?} */ receiver = this._visit(ast.receiver, _Mode.Expression);
- if (receiver === this._implicitReceiver) {
- var /** @type {?} */ varExpr = this._getLocal(ast.name);
- if (varExpr) {
- throw new Error('Cannot assign to a reference or variable!');
- }
- }
- return convertToStatementIfNeeded(mode, receiver.prop(ast.name).set(this._visit(ast.value, _Mode.Expression)));
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitSafePropertyRead = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- return this.convertSafeAccess(ast, this.leftMostSafeNode(ast), mode);
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitSafeMethodCall = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- return this.convertSafeAccess(ast, this.leftMostSafeNode(ast), mode);
- };
- /**
- * @param {?} asts
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitAll = /**
- * @param {?} asts
- * @param {?} mode
- * @return {?}
- */
- function (asts, mode) {
- var _this = this;
- return asts.map(function (ast) { return _this._visit(ast, mode); });
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.visitQuote = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- throw new Error("Quotes are not supported for evaluation!\n Statement: " + ast.uninterpretedExpression + " located at " + ast.location);
- };
- /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype._visit = /**
- * @param {?} ast
- * @param {?} mode
- * @return {?}
- */
- function (ast, mode) {
- var /** @type {?} */ result = this._resultMap.get(ast);
- if (result)
- return result;
- return (this._nodeMap.get(ast) || ast).visit(this, mode);
- };
- /**
- * @param {?} ast
- * @param {?} leftMostSafe
- * @param {?} mode
- * @return {?}
- */
- _AstToIrVisitor.prototype.convertSafeAccess = /**
- * @param {?} ast
- * @param {?} leftMostSafe
- * @param {?} mode
- * @return {?}
- */
- function (ast, leftMostSafe, mode) {
- // If the expression contains a safe access node on the left it needs to be converted to
- // an expression that guards the access to the member by checking the receiver for blank. As
- // execution proceeds from left to right, the left most part of the expression must be guarded
- // first but, because member access is left associative, the right side of the expression is at
- // the top of the AST. The desired result requires lifting a copy of the the left part of the
- // expression up to test it for blank before generating the unguarded version.
- // Consider, for example the following expression: a?.b.c?.d.e
- // This results in the ast:
- // .
- // / \
- // ?. e
- // / \
- // . d
- // / \
- // ?. c
- // / \
- // a b
- // The following tree should be generated:
- //
- // /---- ? ----\
- // / | \
- // a /--- ? ---\ null
- // / | \
- // . . null
- // / \ / \
- // . c . e
- // / \ / \
- // a b , d
- // / \
- // . c
- // / \
- // a b
- //
- // Notice that the first guard condition is the left hand of the left most safe access node
- // which comes in as leftMostSafe to this routine.
- var /** @type {?} */ guardedExpression = this._visit(leftMostSafe.receiver, _Mode.Expression);
- var /** @type {?} */ temporary = /** @type {?} */ ((undefined));
- if (this.needsTemporary(leftMostSafe.receiver)) {
- // If the expression has method calls or pipes then we need to save the result into a
- // temporary variable to avoid calling stateful or impure code more than once.
- temporary = this.allocateTemporary();
- // Preserve the result in the temporary variable
- guardedExpression = temporary.set(guardedExpression);
- // Ensure all further references to the guarded expression refer to the temporary instead.
- this._resultMap.set(leftMostSafe.receiver, temporary);
- }
- var /** @type {?} */ condition = guardedExpression.isBlank();
- // Convert the ast to an unguarded access to the receiver's member. The map will substitute
- // leftMostNode with its unguarded version in the call to `this.visit()`.
- if (leftMostSafe instanceof SafeMethodCall) {
- this._nodeMap.set(leftMostSafe, new MethodCall(leftMostSafe.span, leftMostSafe.receiver, leftMostSafe.name, leftMostSafe.args));
- }
- else {
- this._nodeMap.set(leftMostSafe, new PropertyRead(leftMostSafe.span, leftMostSafe.receiver, leftMostSafe.name));
- }
- // Recursively convert the node now without the guarded member access.
- var /** @type {?} */ access = this._visit(ast, _Mode.Expression);
- // Remove the mapping. This is not strictly required as the converter only traverses each node
- // once but is safer if the conversion is changed to traverse the nodes more than once.
- this._nodeMap.delete(leftMostSafe);
- // If we allocated a temporary, release it.
- if (temporary) {
- this.releaseTemporary(temporary);
- }
- // Produce the conditional
- return convertToStatementIfNeeded(mode, condition.conditional(literal(null), access));
- };
- /**
- * @param {?} ast
- * @return {?}
- */
- _AstToIrVisitor.prototype.leftMostSafeNode = /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- var _this = this;
- var /** @type {?} */ visit = function (visitor, ast) {
- return (_this._nodeMap.get(ast) || ast).visit(visitor);
- };
- return ast.visit({
- visitBinary: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitChain: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitConditional: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitFunctionCall: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitImplicitReceiver: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitInterpolation: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitKeyedRead: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return visit(this, ast.obj); },
- visitKeyedWrite: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitLiteralArray: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitLiteralMap: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitLiteralPrimitive: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitMethodCall: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return visit(this, ast.receiver); },
- visitPipe: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitPrefixNot: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitNonNullAssert: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitPropertyRead: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return visit(this, ast.receiver); },
- visitPropertyWrite: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitQuote: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return null; },
- visitSafeMethodCall: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return visit(this, ast.receiver) || ast; },
- visitSafePropertyRead: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- return visit(this, ast.receiver) || ast;
- }
- });
- };
- /**
- * @param {?} ast
- * @return {?}
- */
- _AstToIrVisitor.prototype.needsTemporary = /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- var _this = this;
- var /** @type {?} */ visit = function (visitor, ast) {
- return ast && (_this._nodeMap.get(ast) || ast).visit(visitor);
- };
- var /** @type {?} */ visitSome = function (visitor, ast) {
- return ast.some(function (ast) { return visit(visitor, ast); });
- };
- return ast.visit({
- visitBinary: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return visit(this, ast.left) || visit(this, ast.right); },
- visitChain: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return false; },
- visitConditional: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- return visit(this, ast.condition) || visit(this, ast.trueExp) ||
- visit(this, ast.falseExp);
- },
- visitFunctionCall: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return true; },
- visitImplicitReceiver: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return false; },
- visitInterpolation: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return visitSome(this, ast.expressions); },
- visitKeyedRead: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return false; },
- visitKeyedWrite: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return false; },
- visitLiteralArray: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return true; },
- visitLiteralMap: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return true; },
- visitLiteralPrimitive: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return false; },
- visitMethodCall: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return true; },
- visitPipe: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return true; },
- visitPrefixNot: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return visit(this, ast.expression); },
- visitNonNullAssert: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return visit(this, ast.expression); },
- visitPropertyRead: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return false; },
- visitPropertyWrite: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return false; },
- visitQuote: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return false; },
- visitSafeMethodCall: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return true; },
- visitSafePropertyRead: /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return false; }
- });
- };
- /**
- * @return {?}
- */
- _AstToIrVisitor.prototype.allocateTemporary = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ tempNumber = this._currentTemporary++;
- this.temporaryCount = Math.max(this._currentTemporary, this.temporaryCount);
- return new ReadVarExpr(temporaryName(this.bindingId, tempNumber));
- };
- /**
- * @param {?} temporary
- * @return {?}
- */
- _AstToIrVisitor.prototype.releaseTemporary = /**
- * @param {?} temporary
- * @return {?}
- */
- function (temporary) {
- this._currentTemporary--;
- if (temporary.name != temporaryName(this.bindingId, this._currentTemporary)) {
- throw new Error("Temporary " + temporary.name + " released out of order");
- }
- };
- return _AstToIrVisitor;
- }());
- /**
- * @param {?} arg
- * @param {?} output
- * @return {?}
- */
- function flattenStatements(arg, output) {
- if (Array.isArray(arg)) {
- (/** @type {?} */ (arg)).forEach(function (entry) { return flattenStatements(entry, output); });
- }
- else {
- output.push(arg);
- }
- }
- var DefaultLocalResolver = /** @class */ (function () {
- function DefaultLocalResolver() {
- }
- /**
- * @param {?} name
- * @return {?}
- */
- DefaultLocalResolver.prototype.getLocal = /**
- * @param {?} name
- * @return {?}
- */
- function (name) {
- if (name === EventHandlerVars.event.name) {
- return EventHandlerVars.event;
- }
- return null;
- };
- return DefaultLocalResolver;
- }());
- /**
- * @param {?} bindingId
- * @return {?}
- */
- function createCurrValueExpr(bindingId) {
- return variable("currVal_" + bindingId); // fix syntax highlighting: `
- }
- /**
- * @param {?} bindingId
- * @return {?}
- */
- function createPreventDefaultVar(bindingId) {
- return variable("pd_" + bindingId);
- }
- /**
- * @param {?} stmt
- * @return {?}
- */
- function convertStmtIntoExpression(stmt) {
- if (stmt instanceof ExpressionStatement) {
- return stmt.expr;
- }
- else if (stmt instanceof ReturnStatement) {
- return stmt.value;
- }
- return null;
- }
- var BuiltinFunctionCall = /** @class */ (function (_super) {
- __extends(BuiltinFunctionCall, _super);
- function BuiltinFunctionCall(span, args, converter) {
- var _this = _super.call(this, span, null, args) || this;
- _this.args = args;
- _this.converter = converter;
- return _this;
- }
- return BuiltinFunctionCall;
- }(FunctionCall));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Generates code that is used to type check templates.
- */
- var TypeCheckCompiler = /** @class */ (function () {
- function TypeCheckCompiler(options, reflector) {
- this.options = options;
- this.reflector = reflector;
- }
- /**
- * Important notes:
- * - This must not produce new `import` statements, but only refer to types outside
- * of the file via the variables provided via externalReferenceVars.
- * This allows Typescript to reuse the old program's structure as no imports have changed.
- * - This must not produce any exports, as this would pollute the .d.ts file
- * and also violate the point above.
- */
- /**
- * Important notes:
- * - This must not produce new `import` statements, but only refer to types outside
- * of the file via the variables provided via externalReferenceVars.
- * This allows Typescript to reuse the old program's structure as no imports have changed.
- * - This must not produce any exports, as this would pollute the .d.ts file
- * and also violate the point above.
- * @param {?} componentId
- * @param {?} component
- * @param {?} template
- * @param {?} usedPipes
- * @param {?} externalReferenceVars
- * @param {?} ctx
- * @return {?}
- */
- TypeCheckCompiler.prototype.compileComponent = /**
- * Important notes:
- * - This must not produce new `import` statements, but only refer to types outside
- * of the file via the variables provided via externalReferenceVars.
- * This allows Typescript to reuse the old program's structure as no imports have changed.
- * - This must not produce any exports, as this would pollute the .d.ts file
- * and also violate the point above.
- * @param {?} componentId
- * @param {?} component
- * @param {?} template
- * @param {?} usedPipes
- * @param {?} externalReferenceVars
- * @param {?} ctx
- * @return {?}
- */
- function (componentId, component, template, usedPipes, externalReferenceVars, ctx) {
- var _this = this;
- var /** @type {?} */ pipes = new Map();
- usedPipes.forEach(function (p) { return pipes.set(p.name, p.type.reference); });
- var /** @type {?} */ embeddedViewCount = 0;
- var /** @type {?} */ viewBuilderFactory = function (parent, guards) {
- var /** @type {?} */ embeddedViewIndex = embeddedViewCount++;
- return new ViewBuilder(_this.options, _this.reflector, externalReferenceVars, parent, component.type.reference, component.isHost, embeddedViewIndex, pipes, guards, ctx, viewBuilderFactory);
- };
- var /** @type {?} */ visitor = viewBuilderFactory(null, []);
- visitor.visitAll([], template);
- return visitor.build(componentId);
- };
- return TypeCheckCompiler;
- }());
- var DYNAMIC_VAR_NAME = '_any';
- var TypeCheckLocalResolver = /** @class */ (function () {
- function TypeCheckLocalResolver() {
- }
- /**
- * @param {?} name
- * @return {?}
- */
- TypeCheckLocalResolver.prototype.getLocal = /**
- * @param {?} name
- * @return {?}
- */
- function (name) {
- if (name === EventHandlerVars.event.name) {
- // References to the event should not be type-checked.
- // TODO(chuckj): determine a better type for the event.
- return variable(DYNAMIC_VAR_NAME);
- }
- return null;
- };
- return TypeCheckLocalResolver;
- }());
- var defaultResolver = new TypeCheckLocalResolver();
- var ViewBuilder = /** @class */ (function () {
- function ViewBuilder(options, reflector, externalReferenceVars, parent, component, isHostComponent, embeddedViewIndex, pipes, guards, ctx, viewBuilderFactory) {
- this.options = options;
- this.reflector = reflector;
- this.externalReferenceVars = externalReferenceVars;
- this.parent = parent;
- this.component = component;
- this.isHostComponent = isHostComponent;
- this.embeddedViewIndex = embeddedViewIndex;
- this.pipes = pipes;
- this.guards = guards;
- this.ctx = ctx;
- this.viewBuilderFactory = viewBuilderFactory;
- this.refOutputVars = new Map();
- this.variables = [];
- this.children = [];
- this.updates = [];
- this.actions = [];
- }
- /**
- * @param {?} type
- * @return {?}
- */
- ViewBuilder.prototype.getOutputVar = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- var /** @type {?} */ varName;
- if (type === this.component && this.isHostComponent) {
- varName = DYNAMIC_VAR_NAME;
- }
- else if (type instanceof StaticSymbol) {
- varName = this.externalReferenceVars.get(type);
- }
- else {
- varName = DYNAMIC_VAR_NAME;
- }
- if (!varName) {
- throw new Error("Illegal State: referring to a type without a variable " + JSON.stringify(type));
- }
- return varName;
- };
- /**
- * @param {?} ast
- * @return {?}
- */
- ViewBuilder.prototype.getTypeGuardExpressions = /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- var /** @type {?} */ result = this.guards.slice();
- for (var _i = 0, _a = ast.directives; _i < _a.length; _i++) {
- var directive = _a[_i];
- for (var _b = 0, _c = directive.inputs; _b < _c.length; _b++) {
- var input = _c[_b];
- var /** @type {?} */ guard = directive.directive.guards[input.directiveName];
- if (guard) {
- var /** @type {?} */ useIf = guard === 'UseIf';
- result.push({
- guard: guard,
- useIf: useIf,
- expression: /** @type {?} */ ({ context: this.component, value: input.value })
- });
- }
- }
- }
- return result;
- };
- /**
- * @param {?} variables
- * @param {?} astNodes
- * @return {?}
- */
- ViewBuilder.prototype.visitAll = /**
- * @param {?} variables
- * @param {?} astNodes
- * @return {?}
- */
- function (variables, astNodes) {
- this.variables = variables;
- templateVisitAll(this, astNodes);
- };
- /**
- * @param {?} componentId
- * @param {?=} targetStatements
- * @return {?}
- */
- ViewBuilder.prototype.build = /**
- * @param {?} componentId
- * @param {?=} targetStatements
- * @return {?}
- */
- function (componentId, targetStatements) {
- var _this = this;
- if (targetStatements === void 0) { targetStatements = []; }
- this.children.forEach(function (child) { return child.build(componentId, targetStatements); });
- var /** @type {?} */ viewStmts = [variable(DYNAMIC_VAR_NAME).set(NULL_EXPR).toDeclStmt(DYNAMIC_TYPE)];
- var /** @type {?} */ bindingCount = 0;
- this.updates.forEach(function (expression) {
- var _a = _this.preprocessUpdateExpression(expression), sourceSpan = _a.sourceSpan, context = _a.context, value = _a.value;
- var /** @type {?} */ bindingId = "" + bindingCount++;
- var /** @type {?} */ nameResolver = context === _this.component ? _this : defaultResolver;
- var _b = convertPropertyBinding(nameResolver, variable(_this.getOutputVar(context)), value, bindingId, BindingForm.General), stmts = _b.stmts, currValExpr = _b.currValExpr;
- stmts.push(new ExpressionStatement(currValExpr));
- viewStmts.push.apply(viewStmts, stmts.map(function (stmt) { return applySourceSpanToStatementIfNeeded(stmt, sourceSpan); }));
- });
- this.actions.forEach(function (_a) {
- var sourceSpan = _a.sourceSpan, context = _a.context, value = _a.value;
- var /** @type {?} */ bindingId = "" + bindingCount++;
- var /** @type {?} */ nameResolver = context === _this.component ? _this : defaultResolver;
- var stmts = convertActionBinding(nameResolver, variable(_this.getOutputVar(context)), value, bindingId).stmts;
- viewStmts.push.apply(viewStmts, stmts.map(function (stmt) { return applySourceSpanToStatementIfNeeded(stmt, sourceSpan); }));
- });
- if (this.guards.length) {
- var /** @type {?} */ guardExpression = undefined;
- for (var _i = 0, _a = this.guards; _i < _a.length; _i++) {
- var guard = _a[_i];
- var _b = this.preprocessUpdateExpression(guard.expression), context = _b.context, value = _b.value;
- var /** @type {?} */ bindingId = "" + bindingCount++;
- var /** @type {?} */ nameResolver = context === this.component ? this : defaultResolver;
- // We only support support simple expressions and ignore others as they
- // are unlikely to affect type narrowing.
- var _c = convertPropertyBinding(nameResolver, variable(this.getOutputVar(context)), value, bindingId, BindingForm.TrySimple), stmts = _c.stmts, currValExpr = _c.currValExpr;
- if (stmts.length == 0) {
- var /** @type {?} */ guardClause = guard.useIf ? currValExpr : this.ctx.importExpr(guard.guard).callFn([currValExpr]);
- guardExpression = guardExpression ? guardExpression.and(guardClause) : guardClause;
- }
- }
- if (guardExpression) {
- viewStmts = [new IfStmt(guardExpression, viewStmts)];
- }
- }
- var /** @type {?} */ viewName = "_View_" + componentId + "_" + this.embeddedViewIndex;
- var /** @type {?} */ viewFactory = new DeclareFunctionStmt(viewName, [], viewStmts);
- targetStatements.push(viewFactory);
- return targetStatements;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitBoundText = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var _this = this;
- var /** @type {?} */ astWithSource = /** @type {?} */ (ast.value);
- var /** @type {?} */ inter = /** @type {?} */ (astWithSource.ast);
- inter.expressions.forEach(function (expr) {
- return _this.updates.push({ context: _this.component, value: expr, sourceSpan: ast.sourceSpan });
- });
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitEmbeddedTemplate = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- this.visitElementOrTemplate(ast);
- // Note: The old view compiler used to use an `any` type
- // for the context in any embedded view.
- // We keep this behaivor behind a flag for now.
- if (this.options.fullTemplateTypeCheck) {
- // Find any applicable type guards. For example, NgIf has a type guard on ngIf
- // (see NgIf.ngIfTypeGuard) that can be used to indicate that a template is only
- // stamped out if ngIf is truthy so any bindings in the template can assume that,
- // if a nullable type is used for ngIf, that expression is not null or undefined.
- var /** @type {?} */ guards = this.getTypeGuardExpressions(ast);
- var /** @type {?} */ childVisitor = this.viewBuilderFactory(this, guards);
- this.children.push(childVisitor);
- childVisitor.visitAll(ast.variables, ast.children);
- }
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitElement = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var _this = this;
- this.visitElementOrTemplate(ast);
- var /** @type {?} */ inputDefs = [];
- var /** @type {?} */ updateRendererExpressions = [];
- var /** @type {?} */ outputDefs = [];
- ast.inputs.forEach(function (inputAst) {
- _this.updates.push({ context: _this.component, value: inputAst.value, sourceSpan: inputAst.sourceSpan });
- });
- templateVisitAll(this, ast.children);
- };
- /**
- * @param {?} ast
- * @return {?}
- */
- ViewBuilder.prototype.visitElementOrTemplate = /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) {
- var _this = this;
- ast.directives.forEach(function (dirAst) { _this.visitDirective(dirAst); });
- ast.references.forEach(function (ref) {
- var /** @type {?} */ outputVarType = /** @type {?} */ ((null));
- // Note: The old view compiler used to use an `any` type
- // for directives exposed via `exportAs`.
- // We keep this behaivor behind a flag for now.
- if (ref.value && ref.value.identifier && _this.options.fullTemplateTypeCheck) {
- outputVarType = ref.value.identifier.reference;
- }
- else {
- outputVarType = BuiltinTypeName.Dynamic;
- }
- _this.refOutputVars.set(ref.name, outputVarType);
- });
- ast.outputs.forEach(function (outputAst) {
- _this.actions.push({ context: _this.component, value: outputAst.handler, sourceSpan: outputAst.sourceSpan });
- });
- };
- /**
- * @param {?} dirAst
- * @return {?}
- */
- ViewBuilder.prototype.visitDirective = /**
- * @param {?} dirAst
- * @return {?}
- */
- function (dirAst) {
- var _this = this;
- var /** @type {?} */ dirType = dirAst.directive.type.reference;
- dirAst.inputs.forEach(function (input) {
- return _this.updates.push({ context: _this.component, value: input.value, sourceSpan: input.sourceSpan });
- });
- // Note: The old view compiler used to use an `any` type
- // for expressions in host properties / events.
- // We keep this behaivor behind a flag for now.
- if (this.options.fullTemplateTypeCheck) {
- dirAst.hostProperties.forEach(function (inputAst) {
- return _this.updates.push({ context: dirType, value: inputAst.value, sourceSpan: inputAst.sourceSpan });
- });
- dirAst.hostEvents.forEach(function (hostEventAst) {
- return _this.actions.push({
- context: dirType,
- value: hostEventAst.handler,
- sourceSpan: hostEventAst.sourceSpan
- });
- });
- }
- };
- /**
- * @param {?} name
- * @return {?}
- */
- ViewBuilder.prototype.getLocal = /**
- * @param {?} name
- * @return {?}
- */
- function (name) {
- if (name == EventHandlerVars.event.name) {
- return variable(this.getOutputVar(BuiltinTypeName.Dynamic));
- }
- for (var /** @type {?} */ currBuilder = this; currBuilder; currBuilder = currBuilder.parent) {
- var /** @type {?} */ outputVarType = void 0;
- // check references
- outputVarType = currBuilder.refOutputVars.get(name);
- if (outputVarType == null) {
- // check variables
- var /** @type {?} */ varAst = currBuilder.variables.find(function (varAst) { return varAst.name === name; });
- if (varAst) {
- outputVarType = BuiltinTypeName.Dynamic;
- }
- }
- if (outputVarType != null) {
- return variable(this.getOutputVar(outputVarType));
- }
- }
- return null;
- };
- /**
- * @param {?} name
- * @return {?}
- */
- ViewBuilder.prototype.pipeOutputVar = /**
- * @param {?} name
- * @return {?}
- */
- function (name) {
- var /** @type {?} */ pipe = this.pipes.get(name);
- if (!pipe) {
- throw new Error("Illegal State: Could not find pipe " + name + " in template of " + this.component);
- }
- return this.getOutputVar(pipe);
- };
- /**
- * @param {?} expression
- * @return {?}
- */
- ViewBuilder.prototype.preprocessUpdateExpression = /**
- * @param {?} expression
- * @return {?}
- */
- function (expression) {
- var _this = this;
- return {
- sourceSpan: expression.sourceSpan,
- context: expression.context,
- value: convertPropertyBindingBuiltins({
- createLiteralArrayConverter: function (argCount) {
- return function (args) {
- var /** @type {?} */ arr = literalArr(args);
- // Note: The old view compiler used to use an `any` type
- // for arrays.
- return _this.options.fullTemplateTypeCheck ? arr : arr.cast(DYNAMIC_TYPE);
- };
- },
- createLiteralMapConverter: function (keys) {
- return function (values) {
- var /** @type {?} */ entries = keys.map(function (k, i) {
- return ({
- key: k.key,
- value: values[i],
- quoted: k.quoted,
- });
- });
- var /** @type {?} */ map = literalMap(entries);
- // Note: The old view compiler used to use an `any` type
- // for maps.
- return _this.options.fullTemplateTypeCheck ? map : map.cast(DYNAMIC_TYPE);
- };
- },
- createPipeConverter: function (name, argCount) {
- return function (args) {
- // Note: The old view compiler used to use an `any` type
- // for pipes.
- var /** @type {?} */ pipeExpr = _this.options.fullTemplateTypeCheck ?
- variable(_this.pipeOutputVar(name)) :
- variable(_this.getOutputVar(BuiltinTypeName.Dynamic));
- return pipeExpr.callMethod('transform', args);
- };
- },
- }, expression.value)
- };
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitNgContent = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitText = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitDirectiveProperty = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitReference = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitVariable = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitEvent = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitElementProperty = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitAttr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- return ViewBuilder;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var CLASS_ATTR$1 = 'class';
- var STYLE_ATTR = 'style';
- var IMPLICIT_TEMPLATE_VAR = '\$implicit';
- var ViewCompileResult = /** @class */ (function () {
- function ViewCompileResult(viewClassVar, rendererTypeVar) {
- this.viewClassVar = viewClassVar;
- this.rendererTypeVar = rendererTypeVar;
- }
- return ViewCompileResult;
- }());
- var ViewCompiler = /** @class */ (function () {
- function ViewCompiler(_reflector) {
- this._reflector = _reflector;
- }
- /**
- * @param {?} outputCtx
- * @param {?} component
- * @param {?} template
- * @param {?} styles
- * @param {?} usedPipes
- * @return {?}
- */
- ViewCompiler.prototype.compileComponent = /**
- * @param {?} outputCtx
- * @param {?} component
- * @param {?} template
- * @param {?} styles
- * @param {?} usedPipes
- * @return {?}
- */
- function (outputCtx, component, template, styles, usedPipes) {
- var _this = this;
- var /** @type {?} */ embeddedViewCount = 0;
- var /** @type {?} */ staticQueryIds = findStaticQueryIds(template);
- var /** @type {?} */ renderComponentVarName = /** @type {?} */ ((undefined));
- if (!component.isHost) {
- var /** @type {?} */ template_1 = /** @type {?} */ ((component.template));
- var /** @type {?} */ customRenderData = [];
- if (template_1.animations && template_1.animations.length) {
- customRenderData.push(new LiteralMapEntry('animation', convertValueToOutputAst(outputCtx, template_1.animations), true));
- }
- var /** @type {?} */ renderComponentVar = variable(rendererTypeName(component.type.reference));
- renderComponentVarName = /** @type {?} */ ((renderComponentVar.name));
- outputCtx.statements.push(renderComponentVar
- .set(importExpr(Identifiers.createRendererType2).callFn([new LiteralMapExpr([
- new LiteralMapEntry('encapsulation', literal(template_1.encapsulation), false),
- new LiteralMapEntry('styles', styles, false),
- new LiteralMapEntry('data', new LiteralMapExpr(customRenderData), false)
- ])]))
- .toDeclStmt(importType(Identifiers.RendererType2), [StmtModifier.Final, StmtModifier.Exported]));
- }
- var /** @type {?} */ viewBuilderFactory = function (parent) {
- var /** @type {?} */ embeddedViewIndex = embeddedViewCount++;
- return new ViewBuilder$1(_this._reflector, outputCtx, parent, component, embeddedViewIndex, usedPipes, staticQueryIds, viewBuilderFactory);
- };
- var /** @type {?} */ visitor = viewBuilderFactory(null);
- visitor.visitAll([], template);
- (_a = outputCtx.statements).push.apply(_a, visitor.build());
- return new ViewCompileResult(visitor.viewName, renderComponentVarName);
- var _a;
- };
- return ViewCompiler;
- }());
- var LOG_VAR$1 = variable('_l');
- var VIEW_VAR = variable('_v');
- var CHECK_VAR = variable('_ck');
- var COMP_VAR = variable('_co');
- var EVENT_NAME_VAR = variable('en');
- var ALLOW_DEFAULT_VAR = variable("ad");
- var ViewBuilder$1 = /** @class */ (function () {
- function ViewBuilder(reflector, outputCtx, parent, component, embeddedViewIndex, usedPipes, staticQueryIds, viewBuilderFactory) {
- this.reflector = reflector;
- this.outputCtx = outputCtx;
- this.parent = parent;
- this.component = component;
- this.embeddedViewIndex = embeddedViewIndex;
- this.usedPipes = usedPipes;
- this.staticQueryIds = staticQueryIds;
- this.viewBuilderFactory = viewBuilderFactory;
- this.nodes = [];
- this.purePipeNodeIndices = Object.create(null);
- this.refNodeIndices = Object.create(null);
- this.variables = [];
- this.children = [];
- // TODO(tbosch): The old view compiler used to use an `any` type
- // for the context in any embedded view. We keep this behaivor for now
- // to be able to introduce the new view compiler without too many errors.
- this.compType = this.embeddedViewIndex > 0 ?
- DYNAMIC_TYPE : /** @type {?} */
- ((expressionType(outputCtx.importExpr(this.component.type.reference))));
- this.viewName = viewClassName(this.component.type.reference, this.embeddedViewIndex);
- }
- /**
- * @param {?} variables
- * @param {?} astNodes
- * @return {?}
- */
- ViewBuilder.prototype.visitAll = /**
- * @param {?} variables
- * @param {?} astNodes
- * @return {?}
- */
- function (variables, astNodes) {
- var _this = this;
- this.variables = variables;
- // create the pipes for the pure pipes immediately, so that we know their indices.
- if (!this.parent) {
- this.usedPipes.forEach(function (pipe) {
- if (pipe.pure) {
- _this.purePipeNodeIndices[pipe.name] = _this._createPipe(null, pipe);
- }
- });
- }
- if (!this.parent) {
- var /** @type {?} */ queryIds_1 = staticViewQueryIds(this.staticQueryIds);
- this.component.viewQueries.forEach(function (query, queryIndex) {
- // Note: queries start with id 1 so we can use the number in a Bloom filter!
- var /** @type {?} */ queryId = queryIndex + 1;
- var /** @type {?} */ bindingType = query.first ? 0 /* First */ : 1;
- var /** @type {?} */ flags = 134217728 /* TypeViewQuery */ | calcStaticDynamicQueryFlags(queryIds_1, queryId, query.first);
- _this.nodes.push(function () {
- return ({
- sourceSpan: null,
- nodeFlags: flags,
- nodeDef: importExpr(Identifiers.queryDef).callFn([
- literal(flags), literal(queryId),
- new LiteralMapExpr([new LiteralMapEntry(query.propertyName, literal(bindingType), false)])
- ])
- });
- });
- });
- }
- templateVisitAll(this, astNodes);
- if (this.parent && (astNodes.length === 0 || needsAdditionalRootNode(astNodes))) {
- // if the view is an embedded view, then we need to add an additional root node in some cases
- this.nodes.push(function () {
- return ({
- sourceSpan: null,
- nodeFlags: 1 /* TypeElement */,
- nodeDef: importExpr(Identifiers.anchorDef).callFn([
- literal(0 /* None */), NULL_EXPR, NULL_EXPR, literal(0)
- ])
- });
- });
- }
- };
- /**
- * @param {?=} targetStatements
- * @return {?}
- */
- ViewBuilder.prototype.build = /**
- * @param {?=} targetStatements
- * @return {?}
- */
- function (targetStatements) {
- if (targetStatements === void 0) { targetStatements = []; }
- this.children.forEach(function (child) { return child.build(targetStatements); });
- var _a = this._createNodeExpressions(), updateRendererStmts = _a.updateRendererStmts, updateDirectivesStmts = _a.updateDirectivesStmts, nodeDefExprs = _a.nodeDefExprs;
- var /** @type {?} */ updateRendererFn = this._createUpdateFn(updateRendererStmts);
- var /** @type {?} */ updateDirectivesFn = this._createUpdateFn(updateDirectivesStmts);
- var /** @type {?} */ viewFlags = 0;
- if (!this.parent && this.component.changeDetection === ChangeDetectionStrategy.OnPush) {
- viewFlags |= 2 /* OnPush */;
- }
- var /** @type {?} */ viewFactory = new DeclareFunctionStmt(this.viewName, [new FnParam(/** @type {?} */ ((LOG_VAR$1.name)))], [new ReturnStatement(importExpr(Identifiers.viewDef).callFn([
- literal(viewFlags),
- literalArr(nodeDefExprs),
- updateDirectivesFn,
- updateRendererFn,
- ]))], importType(Identifiers.ViewDefinition), this.embeddedViewIndex === 0 ? [StmtModifier.Exported] : []);
- targetStatements.push(viewFactory);
- return targetStatements;
- };
- /**
- * @param {?} updateStmts
- * @return {?}
- */
- ViewBuilder.prototype._createUpdateFn = /**
- * @param {?} updateStmts
- * @return {?}
- */
- function (updateStmts) {
- var /** @type {?} */ updateFn;
- if (updateStmts.length > 0) {
- var /** @type {?} */ preStmts = [];
- if (!this.component.isHost && findReadVarNames(updateStmts).has(/** @type {?} */ ((COMP_VAR.name)))) {
- preStmts.push(COMP_VAR.set(VIEW_VAR.prop('component')).toDeclStmt(this.compType));
- }
- updateFn = fn([
- new FnParam(/** @type {?} */ ((CHECK_VAR.name)), INFERRED_TYPE),
- new FnParam(/** @type {?} */ ((VIEW_VAR.name)), INFERRED_TYPE)
- ], preStmts.concat(updateStmts), INFERRED_TYPE);
- }
- else {
- updateFn = NULL_EXPR;
- }
- return updateFn;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitNgContent = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- // ngContentDef(ngContentIndex: number, index: number): NodeDef;
- this.nodes.push(function () {
- return ({
- sourceSpan: ast.sourceSpan,
- nodeFlags: 8 /* TypeNgContent */,
- nodeDef: importExpr(Identifiers.ngContentDef).callFn([
- literal(ast.ngContentIndex), literal(ast.index)
- ])
- });
- });
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitText = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- // Static text nodes have no check function
- var /** @type {?} */ checkIndex = -1;
- this.nodes.push(function () {
- return ({
- sourceSpan: ast.sourceSpan,
- nodeFlags: 2 /* TypeText */,
- nodeDef: importExpr(Identifiers.textDef).callFn([
- literal(checkIndex),
- literal(ast.ngContentIndex),
- literalArr([literal(ast.value)]),
- ])
- });
- });
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitBoundText = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var _this = this;
- var /** @type {?} */ nodeIndex = this.nodes.length;
- // reserve the space in the nodeDefs array
- this.nodes.push(/** @type {?} */ ((null)));
- var /** @type {?} */ astWithSource = /** @type {?} */ (ast.value);
- var /** @type {?} */ inter = /** @type {?} */ (astWithSource.ast);
- var /** @type {?} */ updateRendererExpressions = inter.expressions.map(function (expr, bindingIndex) {
- return _this._preprocessUpdateExpression({ nodeIndex: nodeIndex, bindingIndex: bindingIndex, sourceSpan: ast.sourceSpan, context: COMP_VAR, value: expr });
- });
- // Check index is the same as the node index during compilation
- // They might only differ at runtime
- var /** @type {?} */ checkIndex = nodeIndex;
- this.nodes[nodeIndex] = function () {
- return ({
- sourceSpan: ast.sourceSpan,
- nodeFlags: 2 /* TypeText */,
- nodeDef: importExpr(Identifiers.textDef).callFn([
- literal(checkIndex),
- literal(ast.ngContentIndex),
- literalArr(inter.strings.map(function (s) { return literal(s); })),
- ]),
- updateRenderer: updateRendererExpressions
- });
- };
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitEmbeddedTemplate = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var _this = this;
- var /** @type {?} */ nodeIndex = this.nodes.length;
- // reserve the space in the nodeDefs array
- this.nodes.push(/** @type {?} */ ((null)));
- var _a = this._visitElementOrTemplate(nodeIndex, ast), flags = _a.flags, queryMatchesExpr = _a.queryMatchesExpr, hostEvents = _a.hostEvents;
- var /** @type {?} */ childVisitor = this.viewBuilderFactory(this);
- this.children.push(childVisitor);
- childVisitor.visitAll(ast.variables, ast.children);
- var /** @type {?} */ childCount = this.nodes.length - nodeIndex - 1;
- // anchorDef(
- // flags: NodeFlags, matchedQueries: [string, QueryValueType][], ngContentIndex: number,
- // childCount: number, handleEventFn?: ElementHandleEventFn, templateFactory?:
- // ViewDefinitionFactory): NodeDef;
- this.nodes[nodeIndex] = function () {
- return ({
- sourceSpan: ast.sourceSpan,
- nodeFlags: 1 /* TypeElement */ | flags,
- nodeDef: importExpr(Identifiers.anchorDef).callFn([
- literal(flags),
- queryMatchesExpr,
- literal(ast.ngContentIndex),
- literal(childCount),
- _this._createElementHandleEventFn(nodeIndex, hostEvents),
- variable(childVisitor.viewName),
- ])
- });
- };
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitElement = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var _this = this;
- var /** @type {?} */ nodeIndex = this.nodes.length;
- // reserve the space in the nodeDefs array so we can add children
- this.nodes.push(/** @type {?} */ ((null)));
- // Using a null element name creates an anchor.
- var /** @type {?} */ elName = isNgContainer(ast.name) ? null : ast.name;
- var _a = this._visitElementOrTemplate(nodeIndex, ast), flags = _a.flags, usedEvents = _a.usedEvents, queryMatchesExpr = _a.queryMatchesExpr, dirHostBindings = _a.hostBindings, hostEvents = _a.hostEvents;
- var /** @type {?} */ inputDefs = [];
- var /** @type {?} */ updateRendererExpressions = [];
- var /** @type {?} */ outputDefs = [];
- if (elName) {
- var /** @type {?} */ hostBindings = ast.inputs
- .map(function (inputAst) {
- return ({
- context: /** @type {?} */ (COMP_VAR),
- inputAst: inputAst,
- dirAst: /** @type {?} */ (null),
- });
- })
- .concat(dirHostBindings);
- if (hostBindings.length) {
- updateRendererExpressions =
- hostBindings.map(function (hostBinding, bindingIndex) {
- return _this._preprocessUpdateExpression({
- context: hostBinding.context,
- nodeIndex: nodeIndex,
- bindingIndex: bindingIndex,
- sourceSpan: hostBinding.inputAst.sourceSpan,
- value: hostBinding.inputAst.value
- });
- });
- inputDefs = hostBindings.map(function (hostBinding) { return elementBindingDef(hostBinding.inputAst, hostBinding.dirAst); });
- }
- outputDefs = usedEvents.map(function (_a) {
- var target = _a[0], eventName = _a[1];
- return literalArr([literal(target), literal(eventName)]);
- });
- }
- templateVisitAll(this, ast.children);
- var /** @type {?} */ childCount = this.nodes.length - nodeIndex - 1;
- var /** @type {?} */ compAst = ast.directives.find(function (dirAst) { return dirAst.directive.isComponent; });
- var /** @type {?} */ compRendererType = /** @type {?} */ (NULL_EXPR);
- var /** @type {?} */ compView = /** @type {?} */ (NULL_EXPR);
- if (compAst) {
- compView = this.outputCtx.importExpr(compAst.directive.componentViewType);
- compRendererType = this.outputCtx.importExpr(compAst.directive.rendererType);
- }
- // Check index is the same as the node index during compilation
- // They might only differ at runtime
- var /** @type {?} */ checkIndex = nodeIndex;
- this.nodes[nodeIndex] = function () {
- return ({
- sourceSpan: ast.sourceSpan,
- nodeFlags: 1 /* TypeElement */ | flags,
- nodeDef: importExpr(Identifiers.elementDef).callFn([
- literal(checkIndex),
- literal(flags),
- queryMatchesExpr,
- literal(ast.ngContentIndex),
- literal(childCount),
- literal(elName),
- elName ? fixedAttrsDef(ast) : NULL_EXPR,
- inputDefs.length ? literalArr(inputDefs) : NULL_EXPR,
- outputDefs.length ? literalArr(outputDefs) : NULL_EXPR,
- _this._createElementHandleEventFn(nodeIndex, hostEvents),
- compView,
- compRendererType,
- ]),
- updateRenderer: updateRendererExpressions
- });
- };
- };
- /**
- * @param {?} nodeIndex
- * @param {?} ast
- * @return {?}
- */
- ViewBuilder.prototype._visitElementOrTemplate = /**
- * @param {?} nodeIndex
- * @param {?} ast
- * @return {?}
- */
- function (nodeIndex, ast) {
- var _this = this;
- var /** @type {?} */ flags = 0;
- if (ast.hasViewContainer) {
- flags |= 16777216 /* EmbeddedViews */;
- }
- var /** @type {?} */ usedEvents = new Map();
- ast.outputs.forEach(function (event) {
- var _a = elementEventNameAndTarget(event, null), name = _a.name, target = _a.target;
- usedEvents.set(elementEventFullName(target, name), [target, name]);
- });
- ast.directives.forEach(function (dirAst) {
- dirAst.hostEvents.forEach(function (event) {
- var _a = elementEventNameAndTarget(event, dirAst), name = _a.name, target = _a.target;
- usedEvents.set(elementEventFullName(target, name), [target, name]);
- });
- });
- var /** @type {?} */ hostBindings = [];
- var /** @type {?} */ hostEvents = [];
- this._visitComponentFactoryResolverProvider(ast.directives);
- ast.providers.forEach(function (providerAst, providerIndex) {
- var /** @type {?} */ dirAst = /** @type {?} */ ((undefined));
- var /** @type {?} */ dirIndex = /** @type {?} */ ((undefined));
- ast.directives.forEach(function (localDirAst, i) {
- if (localDirAst.directive.type.reference === tokenReference(providerAst.token)) {
- dirAst = localDirAst;
- dirIndex = i;
- }
- });
- if (dirAst) {
- var _a = _this._visitDirective(providerAst, dirAst, dirIndex, nodeIndex, ast.references, ast.queryMatches, usedEvents, /** @type {?} */ ((_this.staticQueryIds.get(/** @type {?} */ (ast))))), dirHostBindings = _a.hostBindings, dirHostEvents = _a.hostEvents;
- hostBindings.push.apply(hostBindings, dirHostBindings);
- hostEvents.push.apply(hostEvents, dirHostEvents);
- }
- else {
- _this._visitProvider(providerAst, ast.queryMatches);
- }
- });
- var /** @type {?} */ queryMatchExprs = [];
- ast.queryMatches.forEach(function (match) {
- var /** @type {?} */ valueType = /** @type {?} */ ((undefined));
- if (tokenReference(match.value) ===
- _this.reflector.resolveExternalReference(Identifiers.ElementRef)) {
- valueType = 0 /* ElementRef */;
- }
- else if (tokenReference(match.value) ===
- _this.reflector.resolveExternalReference(Identifiers.ViewContainerRef)) {
- valueType = 3 /* ViewContainerRef */;
- }
- else if (tokenReference(match.value) ===
- _this.reflector.resolveExternalReference(Identifiers.TemplateRef)) {
- valueType = 2 /* TemplateRef */;
- }
- if (valueType != null) {
- queryMatchExprs.push(literalArr([literal(match.queryId), literal(valueType)]));
- }
- });
- ast.references.forEach(function (ref) {
- var /** @type {?} */ valueType = /** @type {?} */ ((undefined));
- if (!ref.value) {
- valueType = 1 /* RenderElement */;
- }
- else if (tokenReference(ref.value) ===
- _this.reflector.resolveExternalReference(Identifiers.TemplateRef)) {
- valueType = 2 /* TemplateRef */;
- }
- if (valueType != null) {
- _this.refNodeIndices[ref.name] = nodeIndex;
- queryMatchExprs.push(literalArr([literal(ref.name), literal(valueType)]));
- }
- });
- ast.outputs.forEach(function (outputAst) {
- hostEvents.push({ context: COMP_VAR, eventAst: outputAst, dirAst: /** @type {?} */ ((null)) });
- });
- return {
- flags: flags,
- usedEvents: Array.from(usedEvents.values()),
- queryMatchesExpr: queryMatchExprs.length ? literalArr(queryMatchExprs) : NULL_EXPR,
- hostBindings: hostBindings,
- hostEvents: hostEvents
- };
- };
- /**
- * @param {?} providerAst
- * @param {?} dirAst
- * @param {?} directiveIndex
- * @param {?} elementNodeIndex
- * @param {?} refs
- * @param {?} queryMatches
- * @param {?} usedEvents
- * @param {?} queryIds
- * @return {?}
- */
- ViewBuilder.prototype._visitDirective = /**
- * @param {?} providerAst
- * @param {?} dirAst
- * @param {?} directiveIndex
- * @param {?} elementNodeIndex
- * @param {?} refs
- * @param {?} queryMatches
- * @param {?} usedEvents
- * @param {?} queryIds
- * @return {?}
- */
- function (providerAst, dirAst, directiveIndex, elementNodeIndex, refs, queryMatches, usedEvents, queryIds) {
- var _this = this;
- var /** @type {?} */ nodeIndex = this.nodes.length;
- // reserve the space in the nodeDefs array so we can add children
- this.nodes.push(/** @type {?} */ ((null)));
- dirAst.directive.queries.forEach(function (query, queryIndex) {
- var /** @type {?} */ queryId = dirAst.contentQueryStartId + queryIndex;
- var /** @type {?} */ flags = 67108864 /* TypeContentQuery */ | calcStaticDynamicQueryFlags(queryIds, queryId, query.first);
- var /** @type {?} */ bindingType = query.first ? 0 /* First */ : 1;
- _this.nodes.push(function () {
- return ({
- sourceSpan: dirAst.sourceSpan,
- nodeFlags: flags,
- nodeDef: importExpr(Identifiers.queryDef).callFn([
- literal(flags), literal(queryId),
- new LiteralMapExpr([new LiteralMapEntry(query.propertyName, literal(bindingType), false)])
- ]),
- });
- });
- });
- // Note: the operation below might also create new nodeDefs,
- // but we don't want them to be a child of a directive,
- // as they might be a provider/pipe on their own.
- // I.e. we only allow queries as children of directives nodes.
- var /** @type {?} */ childCount = this.nodes.length - nodeIndex - 1;
- var _a = this._visitProviderOrDirective(providerAst, queryMatches), flags = _a.flags, queryMatchExprs = _a.queryMatchExprs, providerExpr = _a.providerExpr, depsExpr = _a.depsExpr;
- refs.forEach(function (ref) {
- if (ref.value && tokenReference(ref.value) === tokenReference(providerAst.token)) {
- _this.refNodeIndices[ref.name] = nodeIndex;
- queryMatchExprs.push(literalArr([literal(ref.name), literal(4 /* Provider */)]));
- }
- });
- if (dirAst.directive.isComponent) {
- flags |= 32768 /* Component */;
- }
- var /** @type {?} */ inputDefs = dirAst.inputs.map(function (inputAst, inputIndex) {
- var /** @type {?} */ mapValue = literalArr([literal(inputIndex), literal(inputAst.directiveName)]);
- // Note: it's important to not quote the key so that we can capture renames by minifiers!
- return new LiteralMapEntry(inputAst.directiveName, mapValue, false);
- });
- var /** @type {?} */ outputDefs = [];
- var /** @type {?} */ dirMeta = dirAst.directive;
- Object.keys(dirMeta.outputs).forEach(function (propName) {
- var /** @type {?} */ eventName = dirMeta.outputs[propName];
- if (usedEvents.has(eventName)) {
- // Note: it's important to not quote the key so that we can capture renames by minifiers!
- outputDefs.push(new LiteralMapEntry(propName, literal(eventName), false));
- }
- });
- var /** @type {?} */ updateDirectiveExpressions = [];
- if (dirAst.inputs.length || (flags & (262144 /* DoCheck */ | 65536 /* OnInit */)) > 0) {
- updateDirectiveExpressions =
- dirAst.inputs.map(function (input, bindingIndex) {
- return _this._preprocessUpdateExpression({
- nodeIndex: nodeIndex,
- bindingIndex: bindingIndex,
- sourceSpan: input.sourceSpan,
- context: COMP_VAR,
- value: input.value
- });
- });
- }
- var /** @type {?} */ dirContextExpr = importExpr(Identifiers.nodeValue).callFn([VIEW_VAR, literal(nodeIndex)]);
- var /** @type {?} */ hostBindings = dirAst.hostProperties.map(function (inputAst) {
- return ({
- context: dirContextExpr,
- dirAst: dirAst,
- inputAst: inputAst,
- });
- });
- var /** @type {?} */ hostEvents = dirAst.hostEvents.map(function (hostEventAst) {
- return ({
- context: dirContextExpr,
- eventAst: hostEventAst, dirAst: dirAst,
- });
- });
- // Check index is the same as the node index during compilation
- // They might only differ at runtime
- var /** @type {?} */ checkIndex = nodeIndex;
- this.nodes[nodeIndex] = function () {
- return ({
- sourceSpan: dirAst.sourceSpan,
- nodeFlags: 16384 /* TypeDirective */ | flags,
- nodeDef: importExpr(Identifiers.directiveDef).callFn([
- literal(checkIndex),
- literal(flags),
- queryMatchExprs.length ? literalArr(queryMatchExprs) : NULL_EXPR,
- literal(childCount),
- providerExpr,
- depsExpr,
- inputDefs.length ? new LiteralMapExpr(inputDefs) : NULL_EXPR,
- outputDefs.length ? new LiteralMapExpr(outputDefs) : NULL_EXPR,
- ]),
- updateDirectives: updateDirectiveExpressions,
- directive: dirAst.directive.type,
- });
- };
- return { hostBindings: hostBindings, hostEvents: hostEvents };
- };
- /**
- * @param {?} providerAst
- * @param {?} queryMatches
- * @return {?}
- */
- ViewBuilder.prototype._visitProvider = /**
- * @param {?} providerAst
- * @param {?} queryMatches
- * @return {?}
- */
- function (providerAst, queryMatches) {
- this._addProviderNode(this._visitProviderOrDirective(providerAst, queryMatches));
- };
- /**
- * @param {?} directives
- * @return {?}
- */
- ViewBuilder.prototype._visitComponentFactoryResolverProvider = /**
- * @param {?} directives
- * @return {?}
- */
- function (directives) {
- var /** @type {?} */ componentDirMeta = directives.find(function (dirAst) { return dirAst.directive.isComponent; });
- if (componentDirMeta && componentDirMeta.directive.entryComponents.length) {
- var _a = componentFactoryResolverProviderDef(this.reflector, this.outputCtx, 8192 /* PrivateProvider */, componentDirMeta.directive.entryComponents), providerExpr = _a.providerExpr, depsExpr = _a.depsExpr, flags = _a.flags, tokenExpr = _a.tokenExpr;
- this._addProviderNode({
- providerExpr: providerExpr,
- depsExpr: depsExpr,
- flags: flags,
- tokenExpr: tokenExpr,
- queryMatchExprs: [],
- sourceSpan: componentDirMeta.sourceSpan
- });
- }
- };
- /**
- * @param {?} data
- * @return {?}
- */
- ViewBuilder.prototype._addProviderNode = /**
- * @param {?} data
- * @return {?}
- */
- function (data) {
- var /** @type {?} */ nodeIndex = this.nodes.length;
- // providerDef(
- // flags: NodeFlags, matchedQueries: [string, QueryValueType][], token:any,
- // value: any, deps: ([DepFlags, any] | any)[]): NodeDef;
- this.nodes.push(function () {
- return ({
- sourceSpan: data.sourceSpan,
- nodeFlags: data.flags,
- nodeDef: importExpr(Identifiers.providerDef).callFn([
- literal(data.flags),
- data.queryMatchExprs.length ? literalArr(data.queryMatchExprs) : NULL_EXPR,
- data.tokenExpr, data.providerExpr, data.depsExpr
- ])
- });
- });
- };
- /**
- * @param {?} providerAst
- * @param {?} queryMatches
- * @return {?}
- */
- ViewBuilder.prototype._visitProviderOrDirective = /**
- * @param {?} providerAst
- * @param {?} queryMatches
- * @return {?}
- */
- function (providerAst, queryMatches) {
- var /** @type {?} */ flags = 0;
- var /** @type {?} */ queryMatchExprs = [];
- queryMatches.forEach(function (match) {
- if (tokenReference(match.value) === tokenReference(providerAst.token)) {
- queryMatchExprs.push(literalArr([literal(match.queryId), literal(4 /* Provider */)]));
- }
- });
- var _a = providerDef(this.outputCtx, providerAst), providerExpr = _a.providerExpr, depsExpr = _a.depsExpr, providerFlags = _a.flags, tokenExpr = _a.tokenExpr;
- return {
- flags: flags | providerFlags,
- queryMatchExprs: queryMatchExprs,
- providerExpr: providerExpr,
- depsExpr: depsExpr,
- tokenExpr: tokenExpr,
- sourceSpan: providerAst.sourceSpan
- };
- };
- /**
- * @param {?} name
- * @return {?}
- */
- ViewBuilder.prototype.getLocal = /**
- * @param {?} name
- * @return {?}
- */
- function (name) {
- if (name == EventHandlerVars.event.name) {
- return EventHandlerVars.event;
- }
- var /** @type {?} */ currViewExpr = VIEW_VAR;
- for (var /** @type {?} */ currBuilder = this; currBuilder; currBuilder = currBuilder.parent,
- currViewExpr = currViewExpr.prop('parent').cast(DYNAMIC_TYPE)) {
- // check references
- var /** @type {?} */ refNodeIndex = currBuilder.refNodeIndices[name];
- if (refNodeIndex != null) {
- return importExpr(Identifiers.nodeValue).callFn([currViewExpr, literal(refNodeIndex)]);
- }
- // check variables
- var /** @type {?} */ varAst = currBuilder.variables.find(function (varAst) { return varAst.name === name; });
- if (varAst) {
- var /** @type {?} */ varValue = varAst.value || IMPLICIT_TEMPLATE_VAR;
- return currViewExpr.prop('context').prop(varValue);
- }
- }
- return null;
- };
- /**
- * @param {?} sourceSpan
- * @param {?} argCount
- * @return {?}
- */
- ViewBuilder.prototype._createLiteralArrayConverter = /**
- * @param {?} sourceSpan
- * @param {?} argCount
- * @return {?}
- */
- function (sourceSpan, argCount) {
- if (argCount === 0) {
- var /** @type {?} */ valueExpr_1 = importExpr(Identifiers.EMPTY_ARRAY);
- return function () { return valueExpr_1; };
- }
- var /** @type {?} */ checkIndex = this.nodes.length;
- this.nodes.push(function () {
- return ({
- sourceSpan: sourceSpan,
- nodeFlags: 32 /* TypePureArray */,
- nodeDef: importExpr(Identifiers.pureArrayDef).callFn([
- literal(checkIndex),
- literal(argCount),
- ])
- });
- });
- return function (args) { return callCheckStmt(checkIndex, args); };
- };
- /**
- * @param {?} sourceSpan
- * @param {?} keys
- * @return {?}
- */
- ViewBuilder.prototype._createLiteralMapConverter = /**
- * @param {?} sourceSpan
- * @param {?} keys
- * @return {?}
- */
- function (sourceSpan, keys) {
- if (keys.length === 0) {
- var /** @type {?} */ valueExpr_2 = importExpr(Identifiers.EMPTY_MAP);
- return function () { return valueExpr_2; };
- }
- var /** @type {?} */ map = literalMap(keys.map(function (e, i) { return (__assign({}, e, { value: literal(i) })); }));
- var /** @type {?} */ checkIndex = this.nodes.length;
- this.nodes.push(function () {
- return ({
- sourceSpan: sourceSpan,
- nodeFlags: 64 /* TypePureObject */,
- nodeDef: importExpr(Identifiers.pureObjectDef).callFn([
- literal(checkIndex),
- map,
- ])
- });
- });
- return function (args) { return callCheckStmt(checkIndex, args); };
- };
- /**
- * @param {?} expression
- * @param {?} name
- * @param {?} argCount
- * @return {?}
- */
- ViewBuilder.prototype._createPipeConverter = /**
- * @param {?} expression
- * @param {?} name
- * @param {?} argCount
- * @return {?}
- */
- function (expression, name, argCount) {
- var /** @type {?} */ pipe = /** @type {?} */ ((this.usedPipes.find(function (pipeSummary) { return pipeSummary.name === name; })));
- if (pipe.pure) {
- var /** @type {?} */ checkIndex_1 = this.nodes.length;
- this.nodes.push(function () {
- return ({
- sourceSpan: expression.sourceSpan,
- nodeFlags: 128 /* TypePurePipe */,
- nodeDef: importExpr(Identifiers.purePipeDef).callFn([
- literal(checkIndex_1),
- literal(argCount),
- ])
- });
- });
- // find underlying pipe in the component view
- var /** @type {?} */ compViewExpr = VIEW_VAR;
- var /** @type {?} */ compBuilder = this;
- while (compBuilder.parent) {
- compBuilder = compBuilder.parent;
- compViewExpr = compViewExpr.prop('parent').cast(DYNAMIC_TYPE);
- }
- var /** @type {?} */ pipeNodeIndex = compBuilder.purePipeNodeIndices[name];
- var /** @type {?} */ pipeValueExpr_1 = importExpr(Identifiers.nodeValue).callFn([compViewExpr, literal(pipeNodeIndex)]);
- return function (args) {
- return callUnwrapValue(expression.nodeIndex, expression.bindingIndex, callCheckStmt(checkIndex_1, [pipeValueExpr_1].concat(args)));
- };
- }
- else {
- var /** @type {?} */ nodeIndex = this._createPipe(expression.sourceSpan, pipe);
- var /** @type {?} */ nodeValueExpr_1 = importExpr(Identifiers.nodeValue).callFn([VIEW_VAR, literal(nodeIndex)]);
- return function (args) {
- return callUnwrapValue(expression.nodeIndex, expression.bindingIndex, nodeValueExpr_1.callMethod('transform', args));
- };
- }
- };
- /**
- * @param {?} sourceSpan
- * @param {?} pipe
- * @return {?}
- */
- ViewBuilder.prototype._createPipe = /**
- * @param {?} sourceSpan
- * @param {?} pipe
- * @return {?}
- */
- function (sourceSpan, pipe) {
- var _this = this;
- var /** @type {?} */ nodeIndex = this.nodes.length;
- var /** @type {?} */ flags = 0;
- pipe.type.lifecycleHooks.forEach(function (lifecycleHook) {
- // for pipes, we only support ngOnDestroy
- if (lifecycleHook === LifecycleHooks.OnDestroy) {
- flags |= lifecycleHookToNodeFlag(lifecycleHook);
- }
- });
- var /** @type {?} */ depExprs = pipe.type.diDeps.map(function (diDep) { return depDef(_this.outputCtx, diDep); });
- // function pipeDef(
- // flags: NodeFlags, ctor: any, deps: ([DepFlags, any] | any)[]): NodeDef
- this.nodes.push(function () {
- return ({
- sourceSpan: sourceSpan,
- nodeFlags: 16 /* TypePipe */,
- nodeDef: importExpr(Identifiers.pipeDef).callFn([
- literal(flags), _this.outputCtx.importExpr(pipe.type.reference), literalArr(depExprs)
- ])
- });
- });
- return nodeIndex;
- };
- /**
- * For the AST in `UpdateExpression.value`:
- * - create nodes for pipes, literal arrays and, literal maps,
- * - update the AST to replace pipes, literal arrays and, literal maps with calls to check fn.
- *
- * WARNING: This might create new nodeDefs (for pipes and literal arrays and literal maps)!
- * @param {?} expression
- * @return {?}
- */
- ViewBuilder.prototype._preprocessUpdateExpression = /**
- * For the AST in `UpdateExpression.value`:
- * - create nodes for pipes, literal arrays and, literal maps,
- * - update the AST to replace pipes, literal arrays and, literal maps with calls to check fn.
- *
- * WARNING: This might create new nodeDefs (for pipes and literal arrays and literal maps)!
- * @param {?} expression
- * @return {?}
- */
- function (expression) {
- var _this = this;
- return {
- nodeIndex: expression.nodeIndex,
- bindingIndex: expression.bindingIndex,
- sourceSpan: expression.sourceSpan,
- context: expression.context,
- value: convertPropertyBindingBuiltins({
- createLiteralArrayConverter: function (argCount) {
- return _this._createLiteralArrayConverter(expression.sourceSpan, argCount);
- },
- createLiteralMapConverter: function (keys) {
- return _this._createLiteralMapConverter(expression.sourceSpan, keys);
- },
- createPipeConverter: function (name, argCount) {
- return _this._createPipeConverter(expression, name, argCount);
- }
- }, expression.value)
- };
- };
- /**
- * @return {?}
- */
- ViewBuilder.prototype._createNodeExpressions = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ self = this;
- var /** @type {?} */ updateBindingCount = 0;
- var /** @type {?} */ updateRendererStmts = [];
- var /** @type {?} */ updateDirectivesStmts = [];
- var /** @type {?} */ nodeDefExprs = this.nodes.map(function (factory, nodeIndex) {
- var _a = factory(), nodeDef = _a.nodeDef, nodeFlags = _a.nodeFlags, updateDirectives = _a.updateDirectives, updateRenderer = _a.updateRenderer, sourceSpan = _a.sourceSpan;
- if (updateRenderer) {
- updateRendererStmts.push.apply(updateRendererStmts, createUpdateStatements(nodeIndex, sourceSpan, updateRenderer, false));
- }
- if (updateDirectives) {
- updateDirectivesStmts.push.apply(updateDirectivesStmts, createUpdateStatements(nodeIndex, sourceSpan, updateDirectives, (nodeFlags & (262144 /* DoCheck */ | 65536 /* OnInit */)) > 0));
- }
- // We use a comma expression to call the log function before
- // the nodeDef function, but still use the result of the nodeDef function
- // as the value.
- // Note: We only add the logger to elements / text nodes,
- // so we don't generate too much code.
- var /** @type {?} */ logWithNodeDef = nodeFlags & 3 /* CatRenderNode */ ?
- new CommaExpr([LOG_VAR$1.callFn([]).callFn([]), nodeDef]) :
- nodeDef;
- return applySourceSpanToExpressionIfNeeded(logWithNodeDef, sourceSpan);
- });
- return { updateRendererStmts: updateRendererStmts, updateDirectivesStmts: updateDirectivesStmts, nodeDefExprs: nodeDefExprs };
- /**
- * @param {?} nodeIndex
- * @param {?} sourceSpan
- * @param {?} expressions
- * @param {?} allowEmptyExprs
- * @return {?}
- */
- function createUpdateStatements(nodeIndex, sourceSpan, expressions, allowEmptyExprs) {
- var /** @type {?} */ updateStmts = [];
- var /** @type {?} */ exprs = expressions.map(function (_a) {
- var sourceSpan = _a.sourceSpan, context = _a.context, value = _a.value;
- var /** @type {?} */ bindingId = "" + updateBindingCount++;
- var /** @type {?} */ nameResolver = context === COMP_VAR ? self : null;
- var _b = convertPropertyBinding(nameResolver, context, value, bindingId, BindingForm.General), stmts = _b.stmts, currValExpr = _b.currValExpr;
- updateStmts.push.apply(updateStmts, stmts.map(function (stmt) { return applySourceSpanToStatementIfNeeded(stmt, sourceSpan); }));
- return applySourceSpanToExpressionIfNeeded(currValExpr, sourceSpan);
- });
- if (expressions.length || allowEmptyExprs) {
- updateStmts.push(applySourceSpanToStatementIfNeeded(callCheckStmt(nodeIndex, exprs).toStmt(), sourceSpan));
- }
- return updateStmts;
- }
- };
- /**
- * @param {?} nodeIndex
- * @param {?} handlers
- * @return {?}
- */
- ViewBuilder.prototype._createElementHandleEventFn = /**
- * @param {?} nodeIndex
- * @param {?} handlers
- * @return {?}
- */
- function (nodeIndex, handlers) {
- var _this = this;
- var /** @type {?} */ handleEventStmts = [];
- var /** @type {?} */ handleEventBindingCount = 0;
- handlers.forEach(function (_a) {
- var context = _a.context, eventAst = _a.eventAst, dirAst = _a.dirAst;
- var /** @type {?} */ bindingId = "" + handleEventBindingCount++;
- var /** @type {?} */ nameResolver = context === COMP_VAR ? _this : null;
- var _b = convertActionBinding(nameResolver, context, eventAst.handler, bindingId), stmts = _b.stmts, allowDefault = _b.allowDefault;
- var /** @type {?} */ trueStmts = stmts;
- if (allowDefault) {
- trueStmts.push(ALLOW_DEFAULT_VAR.set(allowDefault.and(ALLOW_DEFAULT_VAR)).toStmt());
- }
- var _c = elementEventNameAndTarget(eventAst, dirAst), eventTarget = _c.target, eventName = _c.name;
- var /** @type {?} */ fullEventName = elementEventFullName(eventTarget, eventName);
- handleEventStmts.push(applySourceSpanToStatementIfNeeded(new IfStmt(literal(fullEventName).identical(EVENT_NAME_VAR), trueStmts), eventAst.sourceSpan));
- });
- var /** @type {?} */ handleEventFn;
- if (handleEventStmts.length > 0) {
- var /** @type {?} */ preStmts = [ALLOW_DEFAULT_VAR.set(literal(true)).toDeclStmt(BOOL_TYPE)];
- if (!this.component.isHost && findReadVarNames(handleEventStmts).has(/** @type {?} */ ((COMP_VAR.name)))) {
- preStmts.push(COMP_VAR.set(VIEW_VAR.prop('component')).toDeclStmt(this.compType));
- }
- handleEventFn = fn([
- new FnParam(/** @type {?} */ ((VIEW_VAR.name)), INFERRED_TYPE),
- new FnParam(/** @type {?} */ ((EVENT_NAME_VAR.name)), INFERRED_TYPE),
- new FnParam(/** @type {?} */ ((EventHandlerVars.event.name)), INFERRED_TYPE)
- ], preStmts.concat(handleEventStmts, [new ReturnStatement(ALLOW_DEFAULT_VAR)]), INFERRED_TYPE);
- }
- else {
- handleEventFn = NULL_EXPR;
- }
- return handleEventFn;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitDirective = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitDirectiveProperty = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitReference = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitVariable = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitEvent = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitElementProperty = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- ViewBuilder.prototype.visitAttr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) { };
- return ViewBuilder;
- }());
- /**
- * @param {?} astNodes
- * @return {?}
- */
- function needsAdditionalRootNode(astNodes) {
- var /** @type {?} */ lastAstNode = astNodes[astNodes.length - 1];
- if (lastAstNode instanceof EmbeddedTemplateAst) {
- return lastAstNode.hasViewContainer;
- }
- if (lastAstNode instanceof ElementAst) {
- if (isNgContainer(lastAstNode.name) && lastAstNode.children.length) {
- return needsAdditionalRootNode(lastAstNode.children);
- }
- return lastAstNode.hasViewContainer;
- }
- return lastAstNode instanceof NgContentAst;
- }
- /**
- * @param {?} inputAst
- * @param {?} dirAst
- * @return {?}
- */
- function elementBindingDef(inputAst, dirAst) {
- switch (inputAst.type) {
- case PropertyBindingType.Attribute:
- return literalArr([
- literal(1 /* TypeElementAttribute */), literal(inputAst.name),
- literal(inputAst.securityContext)
- ]);
- case PropertyBindingType.Property:
- return literalArr([
- literal(8 /* TypeProperty */), literal(inputAst.name),
- literal(inputAst.securityContext)
- ]);
- case PropertyBindingType.Animation:
- var /** @type {?} */ bindingType = 8 /* TypeProperty */ |
- (dirAst && dirAst.directive.isComponent ? 32 /* SyntheticHostProperty */ :
- 16 /* SyntheticProperty */);
- return literalArr([
- literal(bindingType), literal('@' + inputAst.name), literal(inputAst.securityContext)
- ]);
- case PropertyBindingType.Class:
- return literalArr([literal(2 /* TypeElementClass */), literal(inputAst.name), NULL_EXPR]);
- case PropertyBindingType.Style:
- return literalArr([
- literal(4 /* TypeElementStyle */), literal(inputAst.name), literal(inputAst.unit)
- ]);
- }
- }
- /**
- * @param {?} elementAst
- * @return {?}
- */
- function fixedAttrsDef(elementAst) {
- var /** @type {?} */ mapResult = Object.create(null);
- elementAst.attrs.forEach(function (attrAst) { mapResult[attrAst.name] = attrAst.value; });
- elementAst.directives.forEach(function (dirAst) {
- Object.keys(dirAst.directive.hostAttributes).forEach(function (name) {
- var /** @type {?} */ value = dirAst.directive.hostAttributes[name];
- var /** @type {?} */ prevValue = mapResult[name];
- mapResult[name] = prevValue != null ? mergeAttributeValue(name, prevValue, value) : value;
- });
- });
- // Note: We need to sort to get a defined output order
- // for tests and for caching generated artifacts...
- return literalArr(Object.keys(mapResult).sort().map(function (attrName) { return literalArr([literal(attrName), literal(mapResult[attrName])]); }));
- }
- /**
- * @param {?} attrName
- * @param {?} attrValue1
- * @param {?} attrValue2
- * @return {?}
- */
- function mergeAttributeValue(attrName, attrValue1, attrValue2) {
- if (attrName == CLASS_ATTR$1 || attrName == STYLE_ATTR) {
- return attrValue1 + " " + attrValue2;
- }
- else {
- return attrValue2;
- }
- }
- /**
- * @param {?} nodeIndex
- * @param {?} exprs
- * @return {?}
- */
- function callCheckStmt(nodeIndex, exprs) {
- if (exprs.length > 10) {
- return CHECK_VAR.callFn([VIEW_VAR, literal(nodeIndex), literal(1 /* Dynamic */), literalArr(exprs)]);
- }
- else {
- return CHECK_VAR.callFn([VIEW_VAR, literal(nodeIndex), literal(0 /* Inline */)].concat(exprs));
- }
- }
- /**
- * @param {?} nodeIndex
- * @param {?} bindingIdx
- * @param {?} expr
- * @return {?}
- */
- function callUnwrapValue(nodeIndex, bindingIdx, expr) {
- return importExpr(Identifiers.unwrapValue).callFn([
- VIEW_VAR, literal(nodeIndex), literal(bindingIdx), expr
- ]);
- }
- /**
- * @param {?} nodes
- * @param {?=} result
- * @return {?}
- */
- function findStaticQueryIds(nodes, result) {
- if (result === void 0) { result = new Map(); }
- nodes.forEach(function (node) {
- var /** @type {?} */ staticQueryIds = new Set();
- var /** @type {?} */ dynamicQueryIds = new Set();
- var /** @type {?} */ queryMatches = /** @type {?} */ ((undefined));
- if (node instanceof ElementAst) {
- findStaticQueryIds(node.children, result);
- node.children.forEach(function (child) {
- var /** @type {?} */ childData = /** @type {?} */ ((result.get(child)));
- childData.staticQueryIds.forEach(function (queryId) { return staticQueryIds.add(queryId); });
- childData.dynamicQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
- });
- queryMatches = node.queryMatches;
- }
- else if (node instanceof EmbeddedTemplateAst) {
- findStaticQueryIds(node.children, result);
- node.children.forEach(function (child) {
- var /** @type {?} */ childData = /** @type {?} */ ((result.get(child)));
- childData.staticQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
- childData.dynamicQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
- });
- queryMatches = node.queryMatches;
- }
- if (queryMatches) {
- queryMatches.forEach(function (match) { return staticQueryIds.add(match.queryId); });
- }
- dynamicQueryIds.forEach(function (queryId) { return staticQueryIds.delete(queryId); });
- result.set(node, { staticQueryIds: staticQueryIds, dynamicQueryIds: dynamicQueryIds });
- });
- return result;
- }
- /**
- * @param {?} nodeStaticQueryIds
- * @return {?}
- */
- function staticViewQueryIds(nodeStaticQueryIds) {
- var /** @type {?} */ staticQueryIds = new Set();
- var /** @type {?} */ dynamicQueryIds = new Set();
- Array.from(nodeStaticQueryIds.values()).forEach(function (entry) {
- entry.staticQueryIds.forEach(function (queryId) { return staticQueryIds.add(queryId); });
- entry.dynamicQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
- });
- dynamicQueryIds.forEach(function (queryId) { return staticQueryIds.delete(queryId); });
- return { staticQueryIds: staticQueryIds, dynamicQueryIds: dynamicQueryIds };
- }
- /**
- * @param {?} eventAst
- * @param {?} dirAst
- * @return {?}
- */
- function elementEventNameAndTarget(eventAst, dirAst) {
- if (eventAst.isAnimation) {
- return {
- name: "@" + eventAst.name + "." + eventAst.phase,
- target: dirAst && dirAst.directive.isComponent ? 'component' : null
- };
- }
- else {
- return eventAst;
- }
- }
- /**
- * @param {?} queryIds
- * @param {?} queryId
- * @param {?} isFirst
- * @return {?}
- */
- function calcStaticDynamicQueryFlags(queryIds, queryId, isFirst) {
- var /** @type {?} */ flags = 0;
- // Note: We only make queries static that query for a single item.
- // This is because of backwards compatibility with the old view compiler...
- if (isFirst && (queryIds.staticQueryIds.has(queryId) || !queryIds.dynamicQueryIds.has(queryId))) {
- flags |= 268435456 /* StaticQuery */;
- }
- else {
- flags |= 536870912 /* DynamicQuery */;
- }
- return flags;
- }
- /**
- * @param {?} target
- * @param {?} name
- * @return {?}
- */
- function elementEventFullName(target, name) {
- return target ? target + ":" + name : name;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A container for message extracted from the templates.
- */
- var MessageBundle = /** @class */ (function () {
- function MessageBundle(_htmlParser, _implicitTags, _implicitAttrs, _locale) {
- if (_locale === void 0) { _locale = null; }
- this._htmlParser = _htmlParser;
- this._implicitTags = _implicitTags;
- this._implicitAttrs = _implicitAttrs;
- this._locale = _locale;
- this._messages = [];
- }
- /**
- * @param {?} html
- * @param {?} url
- * @param {?} interpolationConfig
- * @return {?}
- */
- MessageBundle.prototype.updateFromTemplate = /**
- * @param {?} html
- * @param {?} url
- * @param {?} interpolationConfig
- * @return {?}
- */
- function (html, url, interpolationConfig) {
- var /** @type {?} */ htmlParserResult = this._htmlParser.parse(html, url, true, interpolationConfig);
- if (htmlParserResult.errors.length) {
- return htmlParserResult.errors;
- }
- var /** @type {?} */ i18nParserResult = extractMessages(htmlParserResult.rootNodes, interpolationConfig, this._implicitTags, this._implicitAttrs);
- if (i18nParserResult.errors.length) {
- return i18nParserResult.errors;
- }
- (_a = this._messages).push.apply(_a, i18nParserResult.messages);
- return [];
- var _a;
- };
- // Return the message in the internal format
- // The public (serialized) format might be different, see the `write` method.
- /**
- * @return {?}
- */
- MessageBundle.prototype.getMessages = /**
- * @return {?}
- */
- function () { return this._messages; };
- /**
- * @param {?} serializer
- * @param {?=} filterSources
- * @return {?}
- */
- MessageBundle.prototype.write = /**
- * @param {?} serializer
- * @param {?=} filterSources
- * @return {?}
- */
- function (serializer, filterSources) {
- var /** @type {?} */ messages = {};
- var /** @type {?} */ mapperVisitor = new MapPlaceholderNames();
- // Deduplicate messages based on their ID
- this._messages.forEach(function (message) {
- var /** @type {?} */ id = serializer.digest(message);
- if (!messages.hasOwnProperty(id)) {
- messages[id] = message;
- }
- else {
- (_a = messages[id].sources).push.apply(_a, message.sources);
- }
- var _a;
- });
- // Transform placeholder names using the serializer mapping
- var /** @type {?} */ msgList = Object.keys(messages).map(function (id) {
- var /** @type {?} */ mapper = serializer.createNameMapper(messages[id]);
- var /** @type {?} */ src = messages[id];
- var /** @type {?} */ nodes = mapper ? mapperVisitor.convert(src.nodes, mapper) : src.nodes;
- var /** @type {?} */ transformedMessage = new Message(nodes, {}, {}, src.meaning, src.description, id);
- transformedMessage.sources = src.sources;
- if (filterSources) {
- transformedMessage.sources.forEach(function (source) { return source.filePath = filterSources(source.filePath); });
- }
- return transformedMessage;
- });
- return serializer.write(msgList, this._locale);
- };
- return MessageBundle;
- }());
- var MapPlaceholderNames = /** @class */ (function (_super) {
- __extends(MapPlaceholderNames, _super);
- function MapPlaceholderNames() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} nodes
- * @param {?} mapper
- * @return {?}
- */
- MapPlaceholderNames.prototype.convert = /**
- * @param {?} nodes
- * @param {?} mapper
- * @return {?}
- */
- function (nodes, mapper) {
- var _this = this;
- return mapper ? nodes.map(function (n) { return n.visit(_this, mapper); }) : nodes;
- };
- /**
- * @param {?} ph
- * @param {?} mapper
- * @return {?}
- */
- MapPlaceholderNames.prototype.visitTagPlaceholder = /**
- * @param {?} ph
- * @param {?} mapper
- * @return {?}
- */
- function (ph, mapper) {
- var _this = this;
- var /** @type {?} */ startName = /** @type {?} */ ((mapper.toPublicName(ph.startName)));
- var /** @type {?} */ closeName = ph.closeName ? /** @type {?} */ ((mapper.toPublicName(ph.closeName))) : ph.closeName;
- var /** @type {?} */ children = ph.children.map(function (n) { return n.visit(_this, mapper); });
- return new TagPlaceholder(ph.tag, ph.attrs, startName, closeName, children, ph.isVoid, ph.sourceSpan);
- };
- /**
- * @param {?} ph
- * @param {?} mapper
- * @return {?}
- */
- MapPlaceholderNames.prototype.visitPlaceholder = /**
- * @param {?} ph
- * @param {?} mapper
- * @return {?}
- */
- function (ph, mapper) {
- return new Placeholder(ph.value, /** @type {?} */ ((mapper.toPublicName(ph.name))), ph.sourceSpan);
- };
- /**
- * @param {?} ph
- * @param {?} mapper
- * @return {?}
- */
- MapPlaceholderNames.prototype.visitIcuPlaceholder = /**
- * @param {?} ph
- * @param {?} mapper
- * @return {?}
- */
- function (ph, mapper) {
- return new IcuPlaceholder(ph.value, /** @type {?} */ ((mapper.toPublicName(ph.name))), ph.sourceSpan);
- };
- return MapPlaceholderNames;
- }(CloneVisitor));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var GeneratedFile = /** @class */ (function () {
- function GeneratedFile(srcFileUrl, genFileUrl, sourceOrStmts) {
- this.srcFileUrl = srcFileUrl;
- this.genFileUrl = genFileUrl;
- if (typeof sourceOrStmts === 'string') {
- this.source = sourceOrStmts;
- this.stmts = null;
- }
- else {
- this.source = null;
- this.stmts = sourceOrStmts;
- }
- }
- /**
- * @param {?} other
- * @return {?}
- */
- GeneratedFile.prototype.isEquivalent = /**
- * @param {?} other
- * @return {?}
- */
- function (other) {
- if (this.genFileUrl !== other.genFileUrl) {
- return false;
- }
- if (this.source) {
- return this.source === other.source;
- }
- if (other.stmts == null) {
- return false;
- }
- // Note: the constructor guarantees that if this.source is not filled,
- // then this.stmts is.
- return areAllEquivalent(/** @type {?} */ ((this.stmts)), /** @type {?} */ ((other.stmts)));
- };
- return GeneratedFile;
- }());
- /**
- * @param {?} file
- * @param {?=} preamble
- * @return {?}
- */
- function toTypeScript(file, preamble) {
- if (preamble === void 0) { preamble = ''; }
- if (!file.stmts) {
- throw new Error("Illegal state: No stmts present on GeneratedFile " + file.genFileUrl);
- }
- return new TypeScriptEmitter().emitStatements(file.genFileUrl, file.stmts, preamble);
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @record
- */
-
- /**
- * @param {?} moduleMeta
- * @param {?} reflector
- * @return {?}
- */
- function listLazyRoutes(moduleMeta, reflector) {
- var /** @type {?} */ allLazyRoutes = [];
- for (var _i = 0, _a = moduleMeta.transitiveModule.providers; _i < _a.length; _i++) {
- var _b = _a[_i], provider = _b.provider, module = _b.module;
- if (tokenReference(provider.token) === reflector.ROUTES) {
- var /** @type {?} */ loadChildren = _collectLoadChildren(provider.useValue);
- for (var _c = 0, loadChildren_1 = loadChildren; _c < loadChildren_1.length; _c++) {
- var route = loadChildren_1[_c];
- allLazyRoutes.push(parseLazyRoute(route, reflector, module.reference));
- }
- }
- }
- return allLazyRoutes;
- }
- /**
- * @param {?} routes
- * @param {?=} target
- * @return {?}
- */
- function _collectLoadChildren(routes, target) {
- if (target === void 0) { target = []; }
- if (typeof routes === 'string') {
- target.push(routes);
- }
- else if (Array.isArray(routes)) {
- for (var _i = 0, routes_1 = routes; _i < routes_1.length; _i++) {
- var route = routes_1[_i];
- _collectLoadChildren(route, target);
- }
- }
- else if (routes.loadChildren) {
- _collectLoadChildren(routes.loadChildren, target);
- }
- else if (routes.children) {
- _collectLoadChildren(routes.children, target);
- }
- return target;
- }
- /**
- * @param {?} route
- * @param {?} reflector
- * @param {?=} module
- * @return {?}
- */
- function parseLazyRoute(route, reflector, module) {
- var _a = route.split('#'), routePath = _a[0], routeName = _a[1];
- var /** @type {?} */ referencedModule = reflector.resolveExternalReference({
- moduleName: routePath,
- name: routeName,
- }, module ? module.filePath : undefined);
- return { route: route, module: module || referencedModule, referencedModule: referencedModule };
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var ResolvedStaticSymbol = /** @class */ (function () {
- function ResolvedStaticSymbol(symbol, metadata) {
- this.symbol = symbol;
- this.metadata = metadata;
- }
- return ResolvedStaticSymbol;
- }());
- /**
- * The host of the SymbolResolverHost disconnects the implementation from TypeScript / other
- * language
- * services and from underlying file systems.
- * @record
- */
-
- var SUPPORTED_SCHEMA_VERSION = 4;
- /**
- * This class is responsible for loading metadata per symbol,
- * and normalizing references between symbols.
- *
- * Internally, it only uses symbols without members,
- * and deduces the values for symbols with members based
- * on these symbols.
- */
- var StaticSymbolResolver = /** @class */ (function () {
- function StaticSymbolResolver(host, staticSymbolCache, summaryResolver, errorRecorder) {
- this.host = host;
- this.staticSymbolCache = staticSymbolCache;
- this.summaryResolver = summaryResolver;
- this.errorRecorder = errorRecorder;
- this.metadataCache = new Map();
- this.resolvedSymbols = new Map();
- this.resolvedFilePaths = new Set();
- this.importAs = new Map();
- this.symbolResourcePaths = new Map();
- this.symbolFromFile = new Map();
- this.knownFileNameToModuleNames = new Map();
- }
- /**
- * @param {?} staticSymbol
- * @return {?}
- */
- StaticSymbolResolver.prototype.resolveSymbol = /**
- * @param {?} staticSymbol
- * @return {?}
- */
- function (staticSymbol) {
- if (staticSymbol.members.length > 0) {
- return /** @type {?} */ ((this._resolveSymbolMembers(staticSymbol)));
- }
- // Note: always ask for a summary first,
- // as we might have read shallow metadata via a .d.ts file
- // for the symbol.
- var /** @type {?} */ resultFromSummary = /** @type {?} */ ((this._resolveSymbolFromSummary(staticSymbol)));
- if (resultFromSummary) {
- return resultFromSummary;
- }
- var /** @type {?} */ resultFromCache = this.resolvedSymbols.get(staticSymbol);
- if (resultFromCache) {
- return resultFromCache;
- }
- // Note: Some users use libraries that were not compiled with ngc, i.e. they don't
- // have summaries, only .d.ts files. So we always need to check both, the summary
- // and metadata.
- this._createSymbolsOf(staticSymbol.filePath);
- return /** @type {?} */ ((this.resolvedSymbols.get(staticSymbol)));
- };
- /**
- * getImportAs produces a symbol that can be used to import the given symbol.
- * The import might be different than the symbol if the symbol is exported from
- * a library with a summary; in which case we want to import the symbol from the
- * ngfactory re-export instead of directly to avoid introducing a direct dependency
- * on an otherwise indirect dependency.
- *
- * @param staticSymbol the symbol for which to generate a import symbol
- */
- /**
- * getImportAs produces a symbol that can be used to import the given symbol.
- * The import might be different than the symbol if the symbol is exported from
- * a library with a summary; in which case we want to import the symbol from the
- * ngfactory re-export instead of directly to avoid introducing a direct dependency
- * on an otherwise indirect dependency.
- *
- * @param {?} staticSymbol the symbol for which to generate a import symbol
- * @param {?=} useSummaries
- * @return {?}
- */
- StaticSymbolResolver.prototype.getImportAs = /**
- * getImportAs produces a symbol that can be used to import the given symbol.
- * The import might be different than the symbol if the symbol is exported from
- * a library with a summary; in which case we want to import the symbol from the
- * ngfactory re-export instead of directly to avoid introducing a direct dependency
- * on an otherwise indirect dependency.
- *
- * @param {?} staticSymbol the symbol for which to generate a import symbol
- * @param {?=} useSummaries
- * @return {?}
- */
- function (staticSymbol, useSummaries) {
- if (useSummaries === void 0) { useSummaries = true; }
- if (staticSymbol.members.length) {
- var /** @type {?} */ baseSymbol = this.getStaticSymbol(staticSymbol.filePath, staticSymbol.name);
- var /** @type {?} */ baseImportAs = this.getImportAs(baseSymbol, useSummaries);
- return baseImportAs ?
- this.getStaticSymbol(baseImportAs.filePath, baseImportAs.name, staticSymbol.members) :
- null;
- }
- var /** @type {?} */ summarizedFileName = stripSummaryForJitFileSuffix(staticSymbol.filePath);
- if (summarizedFileName !== staticSymbol.filePath) {
- var /** @type {?} */ summarizedName = stripSummaryForJitNameSuffix(staticSymbol.name);
- var /** @type {?} */ baseSymbol = this.getStaticSymbol(summarizedFileName, summarizedName, staticSymbol.members);
- var /** @type {?} */ baseImportAs = this.getImportAs(baseSymbol, useSummaries);
- return baseImportAs ?
- this.getStaticSymbol(summaryForJitFileName(baseImportAs.filePath), summaryForJitName(baseImportAs.name), baseSymbol.members) :
- null;
- }
- var /** @type {?} */ result = (useSummaries && this.summaryResolver.getImportAs(staticSymbol)) || null;
- if (!result) {
- result = /** @type {?} */ ((this.importAs.get(staticSymbol)));
- }
- return result;
- };
- /**
- * getResourcePath produces the path to the original location of the symbol and should
- * be used to determine the relative location of resource references recorded in
- * symbol metadata.
- */
- /**
- * getResourcePath produces the path to the original location of the symbol and should
- * be used to determine the relative location of resource references recorded in
- * symbol metadata.
- * @param {?} staticSymbol
- * @return {?}
- */
- StaticSymbolResolver.prototype.getResourcePath = /**
- * getResourcePath produces the path to the original location of the symbol and should
- * be used to determine the relative location of resource references recorded in
- * symbol metadata.
- * @param {?} staticSymbol
- * @return {?}
- */
- function (staticSymbol) {
- return this.symbolResourcePaths.get(staticSymbol) || staticSymbol.filePath;
- };
- /**
- * getTypeArity returns the number of generic type parameters the given symbol
- * has. If the symbol is not a type the result is null.
- */
- /**
- * getTypeArity returns the number of generic type parameters the given symbol
- * has. If the symbol is not a type the result is null.
- * @param {?} staticSymbol
- * @return {?}
- */
- StaticSymbolResolver.prototype.getTypeArity = /**
- * getTypeArity returns the number of generic type parameters the given symbol
- * has. If the symbol is not a type the result is null.
- * @param {?} staticSymbol
- * @return {?}
- */
- function (staticSymbol) {
- // If the file is a factory/ngsummary file, don't resolve the symbol as doing so would
- // cause the metadata for an factory/ngsummary file to be loaded which doesn't exist.
- // All references to generated classes must include the correct arity whenever
- // generating code.
- if (isGeneratedFile(staticSymbol.filePath)) {
- return null;
- }
- var /** @type {?} */ resolvedSymbol = unwrapResolvedMetadata(this.resolveSymbol(staticSymbol));
- while (resolvedSymbol && resolvedSymbol.metadata instanceof StaticSymbol) {
- resolvedSymbol = unwrapResolvedMetadata(this.resolveSymbol(resolvedSymbol.metadata));
- }
- return (resolvedSymbol && resolvedSymbol.metadata && resolvedSymbol.metadata.arity) || null;
- };
- /**
- * @param {?} filePath
- * @return {?}
- */
- StaticSymbolResolver.prototype.getKnownModuleName = /**
- * @param {?} filePath
- * @return {?}
- */
- function (filePath) {
- return this.knownFileNameToModuleNames.get(filePath) || null;
- };
- /**
- * @param {?} sourceSymbol
- * @param {?} targetSymbol
- * @return {?}
- */
- StaticSymbolResolver.prototype.recordImportAs = /**
- * @param {?} sourceSymbol
- * @param {?} targetSymbol
- * @return {?}
- */
- function (sourceSymbol, targetSymbol) {
- sourceSymbol.assertNoMembers();
- targetSymbol.assertNoMembers();
- this.importAs.set(sourceSymbol, targetSymbol);
- };
- /**
- * @param {?} fileName
- * @param {?} moduleName
- * @return {?}
- */
- StaticSymbolResolver.prototype.recordModuleNameForFileName = /**
- * @param {?} fileName
- * @param {?} moduleName
- * @return {?}
- */
- function (fileName, moduleName) {
- this.knownFileNameToModuleNames.set(fileName, moduleName);
- };
- /**
- * Invalidate all information derived from the given file.
- *
- * @param fileName the file to invalidate
- */
- /**
- * Invalidate all information derived from the given file.
- *
- * @param {?} fileName the file to invalidate
- * @return {?}
- */
- StaticSymbolResolver.prototype.invalidateFile = /**
- * Invalidate all information derived from the given file.
- *
- * @param {?} fileName the file to invalidate
- * @return {?}
- */
- function (fileName) {
- this.metadataCache.delete(fileName);
- this.resolvedFilePaths.delete(fileName);
- var /** @type {?} */ symbols = this.symbolFromFile.get(fileName);
- if (symbols) {
- this.symbolFromFile.delete(fileName);
- for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
- var symbol = symbols_1[_i];
- this.resolvedSymbols.delete(symbol);
- this.importAs.delete(symbol);
- this.symbolResourcePaths.delete(symbol);
- }
- }
- };
- /* @internal */
- /**
- * @template T
- * @param {?} cb
- * @return {?}
- */
- StaticSymbolResolver.prototype.ignoreErrorsFor = /**
- * @template T
- * @param {?} cb
- * @return {?}
- */
- function (cb) {
- var /** @type {?} */ recorder = this.errorRecorder;
- this.errorRecorder = function () { };
- try {
- return cb();
- }
- finally {
- this.errorRecorder = recorder;
- }
- };
- /**
- * @param {?} staticSymbol
- * @return {?}
- */
- StaticSymbolResolver.prototype._resolveSymbolMembers = /**
- * @param {?} staticSymbol
- * @return {?}
- */
- function (staticSymbol) {
- var /** @type {?} */ members = staticSymbol.members;
- var /** @type {?} */ baseResolvedSymbol = this.resolveSymbol(this.getStaticSymbol(staticSymbol.filePath, staticSymbol.name));
- if (!baseResolvedSymbol) {
- return null;
- }
- var /** @type {?} */ baseMetadata = unwrapResolvedMetadata(baseResolvedSymbol.metadata);
- if (baseMetadata instanceof StaticSymbol) {
- return new ResolvedStaticSymbol(staticSymbol, this.getStaticSymbol(baseMetadata.filePath, baseMetadata.name, members));
- }
- else if (baseMetadata && baseMetadata.__symbolic === 'class') {
- if (baseMetadata.statics && members.length === 1) {
- return new ResolvedStaticSymbol(staticSymbol, baseMetadata.statics[members[0]]);
- }
- }
- else {
- var /** @type {?} */ value = baseMetadata;
- for (var /** @type {?} */ i = 0; i < members.length && value; i++) {
- value = value[members[i]];
- }
- return new ResolvedStaticSymbol(staticSymbol, value);
- }
- return null;
- };
- /**
- * @param {?} staticSymbol
- * @return {?}
- */
- StaticSymbolResolver.prototype._resolveSymbolFromSummary = /**
- * @param {?} staticSymbol
- * @return {?}
- */
- function (staticSymbol) {
- var /** @type {?} */ summary = this.summaryResolver.resolveSummary(staticSymbol);
- return summary ? new ResolvedStaticSymbol(staticSymbol, summary.metadata) : null;
- };
- /**
- * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
- * All types passed to the StaticResolver should be pseudo-types returned by this method.
- *
- * @param declarationFile the absolute path of the file where the symbol is declared
- * @param name the name of the type.
- * @param members a symbol for a static member of the named type
- */
- /**
- * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
- * All types passed to the StaticResolver should be pseudo-types returned by this method.
- *
- * @param {?} declarationFile the absolute path of the file where the symbol is declared
- * @param {?} name the name of the type.
- * @param {?=} members a symbol for a static member of the named type
- * @return {?}
- */
- StaticSymbolResolver.prototype.getStaticSymbol = /**
- * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
- * All types passed to the StaticResolver should be pseudo-types returned by this method.
- *
- * @param {?} declarationFile the absolute path of the file where the symbol is declared
- * @param {?} name the name of the type.
- * @param {?=} members a symbol for a static member of the named type
- * @return {?}
- */
- function (declarationFile, name, members) {
- return this.staticSymbolCache.get(declarationFile, name, members);
- };
- /**
- * hasDecorators checks a file's metadata for the presense of decorators without evalutating the
- * metadata.
- *
- * @param filePath the absolute path to examine for decorators.
- * @returns true if any class in the file has a decorator.
- */
- /**
- * hasDecorators checks a file's metadata for the presense of decorators without evalutating the
- * metadata.
- *
- * @param {?} filePath the absolute path to examine for decorators.
- * @return {?} true if any class in the file has a decorator.
- */
- StaticSymbolResolver.prototype.hasDecorators = /**
- * hasDecorators checks a file's metadata for the presense of decorators without evalutating the
- * metadata.
- *
- * @param {?} filePath the absolute path to examine for decorators.
- * @return {?} true if any class in the file has a decorator.
- */
- function (filePath) {
- var /** @type {?} */ metadata = this.getModuleMetadata(filePath);
- if (metadata['metadata']) {
- return Object.keys(metadata['metadata']).some(function (metadataKey) {
- var /** @type {?} */ entry = metadata['metadata'][metadataKey];
- return entry && entry.__symbolic === 'class' && entry.decorators;
- });
- }
- return false;
- };
- /**
- * @param {?} filePath
- * @return {?}
- */
- StaticSymbolResolver.prototype.getSymbolsOf = /**
- * @param {?} filePath
- * @return {?}
- */
- function (filePath) {
- var /** @type {?} */ summarySymbols = this.summaryResolver.getSymbolsOf(filePath);
- if (summarySymbols) {
- return summarySymbols;
- }
- // Note: Some users use libraries that were not compiled with ngc, i.e. they don't
- // have summaries, only .d.ts files, but `summaryResolver.isLibraryFile` returns true.
- this._createSymbolsOf(filePath);
- var /** @type {?} */ metadataSymbols = [];
- this.resolvedSymbols.forEach(function (resolvedSymbol) {
- if (resolvedSymbol.symbol.filePath === filePath) {
- metadataSymbols.push(resolvedSymbol.symbol);
- }
- });
- return metadataSymbols;
- };
- /**
- * @param {?} filePath
- * @return {?}
- */
- StaticSymbolResolver.prototype._createSymbolsOf = /**
- * @param {?} filePath
- * @return {?}
- */
- function (filePath) {
- var _this = this;
- if (this.resolvedFilePaths.has(filePath)) {
- return;
- }
- this.resolvedFilePaths.add(filePath);
- var /** @type {?} */ resolvedSymbols = [];
- var /** @type {?} */ metadata = this.getModuleMetadata(filePath);
- if (metadata['importAs']) {
- // Index bundle indices should use the importAs module name defined
- // in the bundle.
- this.knownFileNameToModuleNames.set(filePath, metadata['importAs']);
- }
- // handle the symbols in one of the re-export location
- if (metadata['exports']) {
- var _loop_1 = function (moduleExport) {
- // handle the symbols in the list of explicitly re-exported symbols.
- if (moduleExport.export) {
- moduleExport.export.forEach(function (exportSymbol) {
- var /** @type {?} */ symbolName;
- if (typeof exportSymbol === 'string') {
- symbolName = exportSymbol;
- }
- else {
- symbolName = exportSymbol.as;
- }
- symbolName = unescapeIdentifier(symbolName);
- var /** @type {?} */ symName = symbolName;
- if (typeof exportSymbol !== 'string') {
- symName = unescapeIdentifier(exportSymbol.name);
- }
- var /** @type {?} */ resolvedModule = _this.resolveModule(moduleExport.from, filePath);
- if (resolvedModule) {
- var /** @type {?} */ targetSymbol = _this.getStaticSymbol(resolvedModule, symName);
- var /** @type {?} */ sourceSymbol = _this.getStaticSymbol(filePath, symbolName);
- resolvedSymbols.push(_this.createExport(sourceSymbol, targetSymbol));
- }
- });
- }
- else {
- // handle the symbols via export * directives.
- var /** @type {?} */ resolvedModule = this_1.resolveModule(moduleExport.from, filePath);
- if (resolvedModule) {
- var /** @type {?} */ nestedExports = this_1.getSymbolsOf(resolvedModule);
- nestedExports.forEach(function (targetSymbol) {
- var /** @type {?} */ sourceSymbol = _this.getStaticSymbol(filePath, targetSymbol.name);
- resolvedSymbols.push(_this.createExport(sourceSymbol, targetSymbol));
- });
- }
- }
- };
- var this_1 = this;
- for (var _i = 0, _a = metadata['exports']; _i < _a.length; _i++) {
- var moduleExport = _a[_i];
- _loop_1(moduleExport);
- }
- }
- // handle the actual metadata. Has to be after the exports
- // as there migth be collisions in the names, and we want the symbols
- // of the current module to win ofter reexports.
- if (metadata['metadata']) {
- // handle direct declarations of the symbol
- var /** @type {?} */ topLevelSymbolNames_1 = new Set(Object.keys(metadata['metadata']).map(unescapeIdentifier));
- var /** @type {?} */ origins_1 = metadata['origins'] || {};
- Object.keys(metadata['metadata']).forEach(function (metadataKey) {
- var /** @type {?} */ symbolMeta = metadata['metadata'][metadataKey];
- var /** @type {?} */ name = unescapeIdentifier(metadataKey);
- var /** @type {?} */ symbol = _this.getStaticSymbol(filePath, name);
- var /** @type {?} */ origin = origins_1.hasOwnProperty(metadataKey) && origins_1[metadataKey];
- if (origin) {
- // If the symbol is from a bundled index, use the declaration location of the
- // symbol so relative references (such as './my.html') will be calculated
- // correctly.
- var /** @type {?} */ originFilePath = _this.resolveModule(origin, filePath);
- if (!originFilePath) {
- _this.reportError(new Error("Couldn't resolve original symbol for " + origin + " from " + filePath));
- }
- else {
- _this.symbolResourcePaths.set(symbol, originFilePath);
- }
- }
- resolvedSymbols.push(_this.createResolvedSymbol(symbol, filePath, topLevelSymbolNames_1, symbolMeta));
- });
- }
- resolvedSymbols.forEach(function (resolvedSymbol) { return _this.resolvedSymbols.set(resolvedSymbol.symbol, resolvedSymbol); });
- this.symbolFromFile.set(filePath, resolvedSymbols.map(function (resolvedSymbol) { return resolvedSymbol.symbol; }));
- };
- /**
- * @param {?} sourceSymbol
- * @param {?} topLevelPath
- * @param {?} topLevelSymbolNames
- * @param {?} metadata
- * @return {?}
- */
- StaticSymbolResolver.prototype.createResolvedSymbol = /**
- * @param {?} sourceSymbol
- * @param {?} topLevelPath
- * @param {?} topLevelSymbolNames
- * @param {?} metadata
- * @return {?}
- */
- function (sourceSymbol, topLevelPath, topLevelSymbolNames, metadata) {
- var _this = this;
- // For classes that don't have Angular summaries / metadata,
- // we only keep their arity, but nothing else
- // (e.g. their constructor parameters).
- // We do this to prevent introducing deep imports
- // as we didn't generate .ngfactory.ts files with proper reexports.
- if (this.summaryResolver.isLibraryFile(sourceSymbol.filePath) && metadata &&
- metadata['__symbolic'] === 'class') {
- var /** @type {?} */ transformedMeta_1 = { __symbolic: 'class', arity: metadata.arity };
- return new ResolvedStaticSymbol(sourceSymbol, transformedMeta_1);
- }
- var /** @type {?} */ _originalFileMemo;
- var /** @type {?} */ getOriginalName = function () {
- if (!_originalFileMemo) {
- // Guess what hte original file name is from the reference. If it has a `.d.ts` extension
- // replace it with `.ts`. If it already has `.ts` just leave it in place. If it doesn't have
- // .ts or .d.ts, append `.ts'. Also, if it is in `node_modules`, trim the `node_module`
- // location as it is not important to finding the file.
- _originalFileMemo =
- _this.host.getOutputName(topLevelPath.replace(/((\.ts)|(\.d\.ts)|)$/, '.ts')
- .replace(/^.*node_modules[/\\]/, ''));
- }
- return _originalFileMemo;
- };
- var /** @type {?} */ self = this;
- var ReferenceTransformer = /** @class */ (function (_super) {
- __extends(ReferenceTransformer, _super);
- function ReferenceTransformer() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} map
- * @param {?} functionParams
- * @return {?}
- */
- ReferenceTransformer.prototype.visitStringMap = /**
- * @param {?} map
- * @param {?} functionParams
- * @return {?}
- */
- function (map, functionParams) {
- var /** @type {?} */ symbolic = map['__symbolic'];
- if (symbolic === 'function') {
- var /** @type {?} */ oldLen = functionParams.length;
- functionParams.push.apply(functionParams, (map['parameters'] || []));
- var /** @type {?} */ result = _super.prototype.visitStringMap.call(this, map, functionParams);
- functionParams.length = oldLen;
- return result;
- }
- else if (symbolic === 'reference') {
- var /** @type {?} */ module = map['module'];
- var /** @type {?} */ name_1 = map['name'] ? unescapeIdentifier(map['name']) : map['name'];
- if (!name_1) {
- return null;
- }
- var /** @type {?} */ filePath = void 0;
- if (module) {
- filePath = /** @type {?} */ ((self.resolveModule(module, sourceSymbol.filePath)));
- if (!filePath) {
- return {
- __symbolic: 'error',
- message: "Could not resolve " + module + " relative to " + sourceSymbol.filePath + ".",
- line: map["line"],
- character: map["character"],
- fileName: getOriginalName()
- };
- }
- return {
- __symbolic: 'resolved',
- symbol: self.getStaticSymbol(filePath, name_1),
- line: map["line"],
- character: map["character"],
- fileName: getOriginalName()
- };
- }
- else if (functionParams.indexOf(name_1) >= 0) {
- // reference to a function parameter
- return { __symbolic: 'reference', name: name_1 };
- }
- else {
- if (topLevelSymbolNames.has(name_1)) {
- return self.getStaticSymbol(topLevelPath, name_1);
- }
- // ambient value
- null;
- }
- }
- else if (symbolic === 'error') {
- return __assign({}, map, { fileName: getOriginalName() });
- }
- else {
- return _super.prototype.visitStringMap.call(this, map, functionParams);
- }
- };
- return ReferenceTransformer;
- }(ValueTransformer));
- var /** @type {?} */ transformedMeta = visitValue(metadata, new ReferenceTransformer(), []);
- var /** @type {?} */ unwrappedTransformedMeta = unwrapResolvedMetadata(transformedMeta);
- if (unwrappedTransformedMeta instanceof StaticSymbol) {
- return this.createExport(sourceSymbol, unwrappedTransformedMeta);
- }
- return new ResolvedStaticSymbol(sourceSymbol, transformedMeta);
- };
- /**
- * @param {?} sourceSymbol
- * @param {?} targetSymbol
- * @return {?}
- */
- StaticSymbolResolver.prototype.createExport = /**
- * @param {?} sourceSymbol
- * @param {?} targetSymbol
- * @return {?}
- */
- function (sourceSymbol, targetSymbol) {
- sourceSymbol.assertNoMembers();
- targetSymbol.assertNoMembers();
- if (this.summaryResolver.isLibraryFile(sourceSymbol.filePath) &&
- this.summaryResolver.isLibraryFile(targetSymbol.filePath)) {
- // This case is for an ng library importing symbols from a plain ts library
- // transitively.
- // Note: We rely on the fact that we discover symbols in the direction
- // from source files to library files
- this.importAs.set(targetSymbol, this.getImportAs(sourceSymbol) || sourceSymbol);
- }
- return new ResolvedStaticSymbol(sourceSymbol, targetSymbol);
- };
- /**
- * @param {?} error
- * @param {?=} context
- * @param {?=} path
- * @return {?}
- */
- StaticSymbolResolver.prototype.reportError = /**
- * @param {?} error
- * @param {?=} context
- * @param {?=} path
- * @return {?}
- */
- function (error, context, path) {
- if (this.errorRecorder) {
- this.errorRecorder(error, (context && context.filePath) || path);
- }
- else {
- throw error;
- }
- };
- /**
- * @param {?} module an absolute path to a module file.
- * @return {?}
- */
- StaticSymbolResolver.prototype.getModuleMetadata = /**
- * @param {?} module an absolute path to a module file.
- * @return {?}
- */
- function (module) {
- var /** @type {?} */ moduleMetadata = this.metadataCache.get(module);
- if (!moduleMetadata) {
- var /** @type {?} */ moduleMetadatas = this.host.getMetadataFor(module);
- if (moduleMetadatas) {
- var /** @type {?} */ maxVersion_1 = -1;
- moduleMetadatas.forEach(function (md) {
- if (md && md['version'] > maxVersion_1) {
- maxVersion_1 = md['version'];
- moduleMetadata = md;
- }
- });
- }
- if (!moduleMetadata) {
- moduleMetadata =
- { __symbolic: 'module', version: SUPPORTED_SCHEMA_VERSION, module: module, metadata: {} };
- }
- if (moduleMetadata['version'] != SUPPORTED_SCHEMA_VERSION) {
- var /** @type {?} */ errorMessage = moduleMetadata['version'] == 2 ?
- "Unsupported metadata version " + moduleMetadata['version'] + " for module " + module + ". This module should be compiled with a newer version of ngc" :
- "Metadata version mismatch for module " + module + ", found version " + moduleMetadata['version'] + ", expected " + SUPPORTED_SCHEMA_VERSION;
- this.reportError(new Error(errorMessage));
- }
- this.metadataCache.set(module, moduleMetadata);
- }
- return moduleMetadata;
- };
- /**
- * @param {?} module
- * @param {?} symbolName
- * @param {?=} containingFile
- * @return {?}
- */
- StaticSymbolResolver.prototype.getSymbolByModule = /**
- * @param {?} module
- * @param {?} symbolName
- * @param {?=} containingFile
- * @return {?}
- */
- function (module, symbolName, containingFile) {
- var /** @type {?} */ filePath = this.resolveModule(module, containingFile);
- if (!filePath) {
- this.reportError(new Error("Could not resolve module " + module + (containingFile ? ' relative to ' +
- containingFile : '')));
- return this.getStaticSymbol("ERROR:" + module, symbolName);
- }
- return this.getStaticSymbol(filePath, symbolName);
- };
- /**
- * @param {?} module
- * @param {?=} containingFile
- * @return {?}
- */
- StaticSymbolResolver.prototype.resolveModule = /**
- * @param {?} module
- * @param {?=} containingFile
- * @return {?}
- */
- function (module, containingFile) {
- try {
- return this.host.moduleNameToFileName(module, containingFile);
- }
- catch (/** @type {?} */ e) {
- console.error("Could not resolve module '" + module + "' relative to file " + containingFile);
- this.reportError(e, undefined, containingFile);
- }
- return null;
- };
- return StaticSymbolResolver;
- }());
- /**
- * @param {?} identifier
- * @return {?}
- */
- function unescapeIdentifier(identifier) {
- return identifier.startsWith('___') ? identifier.substr(1) : identifier;
- }
- /**
- * @param {?} metadata
- * @return {?}
- */
- function unwrapResolvedMetadata(metadata) {
- if (metadata && metadata.__symbolic === 'resolved') {
- return metadata.symbol;
- }
- return metadata;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @param {?} srcFileName
- * @param {?} forJitCtx
- * @param {?} summaryResolver
- * @param {?} symbolResolver
- * @param {?} symbols
- * @param {?} types
- * @return {?}
- */
- function serializeSummaries(srcFileName, forJitCtx, summaryResolver, symbolResolver, symbols, types) {
- var /** @type {?} */ toJsonSerializer = new ToJsonSerializer(symbolResolver, summaryResolver, srcFileName);
- // for symbols, we use everything except for the class metadata itself
- // (we keep the statics though), as the class metadata is contained in the
- // CompileTypeSummary.
- symbols.forEach(function (resolvedSymbol) {
- return toJsonSerializer.addSummary({ symbol: resolvedSymbol.symbol, metadata: resolvedSymbol.metadata });
- });
- // Add type summaries.
- types.forEach(function (_a) {
- var summary = _a.summary, metadata = _a.metadata;
- toJsonSerializer.addSummary({ symbol: summary.type.reference, metadata: undefined, type: summary });
- });
- var _a = toJsonSerializer.serialize(), json = _a.json, exportAs = _a.exportAs;
- if (forJitCtx) {
- var /** @type {?} */ forJitSerializer_1 = new ForJitSerializer(forJitCtx, symbolResolver, summaryResolver);
- types.forEach(function (_a) {
- var summary = _a.summary, metadata = _a.metadata;
- forJitSerializer_1.addSourceType(summary, metadata);
- });
- toJsonSerializer.unprocessedSymbolSummariesBySymbol.forEach(function (summary) {
- if (summaryResolver.isLibraryFile(summary.symbol.filePath) && summary.type) {
- forJitSerializer_1.addLibType(summary.type);
- }
- });
- forJitSerializer_1.serialize(exportAs);
- }
- return { json: json, exportAs: exportAs };
- }
- /**
- * @param {?} symbolCache
- * @param {?} summaryResolver
- * @param {?} libraryFileName
- * @param {?} json
- * @return {?}
- */
- function deserializeSummaries(symbolCache, summaryResolver, libraryFileName, json) {
- var /** @type {?} */ deserializer = new FromJsonDeserializer(symbolCache, summaryResolver);
- return deserializer.deserialize(libraryFileName, json);
- }
- /**
- * @param {?} outputCtx
- * @param {?} reference
- * @return {?}
- */
- function createForJitStub(outputCtx, reference) {
- return createSummaryForJitFunction(outputCtx, reference, NULL_EXPR);
- }
- /**
- * @param {?} outputCtx
- * @param {?} reference
- * @param {?} value
- * @return {?}
- */
- function createSummaryForJitFunction(outputCtx, reference, value) {
- var /** @type {?} */ fnName = summaryForJitName(reference.name);
- outputCtx.statements.push(fn([], [new ReturnStatement(value)], new ArrayType(DYNAMIC_TYPE)).toDeclStmt(fnName, [
- StmtModifier.Final, StmtModifier.Exported
- ]));
- }
- var ToJsonSerializer = /** @class */ (function (_super) {
- __extends(ToJsonSerializer, _super);
- function ToJsonSerializer(symbolResolver, summaryResolver, srcFileName) {
- var _this = _super.call(this) || this;
- _this.symbolResolver = symbolResolver;
- _this.summaryResolver = summaryResolver;
- _this.srcFileName = srcFileName;
- _this.symbols = [];
- _this.indexBySymbol = new Map();
- _this.reexportedBy = new Map();
- _this.processedSummaryBySymbol = new Map();
- _this.processedSummaries = [];
- _this.unprocessedSymbolSummariesBySymbol = new Map();
- _this.moduleName = symbolResolver.getKnownModuleName(srcFileName);
- return _this;
- }
- /**
- * @param {?} summary
- * @return {?}
- */
- ToJsonSerializer.prototype.addSummary = /**
- * @param {?} summary
- * @return {?}
- */
- function (summary) {
- var _this = this;
- var /** @type {?} */ unprocessedSummary = this.unprocessedSymbolSummariesBySymbol.get(summary.symbol);
- var /** @type {?} */ processedSummary = this.processedSummaryBySymbol.get(summary.symbol);
- if (!unprocessedSummary) {
- unprocessedSummary = { symbol: summary.symbol, metadata: undefined };
- this.unprocessedSymbolSummariesBySymbol.set(summary.symbol, unprocessedSummary);
- processedSummary = { symbol: this.processValue(summary.symbol, 0 /* None */) };
- this.processedSummaries.push(processedSummary);
- this.processedSummaryBySymbol.set(summary.symbol, processedSummary);
- }
- if (!unprocessedSummary.metadata && summary.metadata) {
- var /** @type {?} */ metadata_1 = summary.metadata || {};
- if (metadata_1.__symbolic === 'class') {
- // For classes, we keep everything except their class decorators.
- // We need to keep e.g. the ctor args, method names, method decorators
- // so that the class can be extended in another compilation unit.
- // We don't keep the class decorators as
- // 1) they refer to data
- // that should not cause a rebuild of downstream compilation units
- // (e.g. inline templates of @Component, or @NgModule.declarations)
- // 2) their data is already captured in TypeSummaries, e.g. DirectiveSummary.
- var /** @type {?} */ clone_1 = {};
- Object.keys(metadata_1).forEach(function (propName) {
- if (propName !== 'decorators') {
- clone_1[propName] = metadata_1[propName];
- }
- });
- metadata_1 = clone_1;
- }
- else if (isCall(metadata_1)) {
- if (!isFunctionCall(metadata_1) && !isMethodCallOnVariable(metadata_1)) {
- // Don't store complex calls as we won't be able to simplify them anyways later on.
- // Don't store complex calls as we won't be able to simplify them anyways later on.
- metadata_1 = {
- __symbolic: 'error',
- message: 'Complex function calls are not supported.',
- };
- }
- }
- // Note: We need to keep storing ctor calls for e.g.
- // `export const x = new InjectionToken(...)`
- unprocessedSummary.metadata = metadata_1;
- processedSummary.metadata = this.processValue(metadata_1, 1 /* ResolveValue */);
- if (metadata_1 instanceof StaticSymbol &&
- this.summaryResolver.isLibraryFile(metadata_1.filePath)) {
- var /** @type {?} */ declarationSymbol = this.symbols[/** @type {?} */ ((this.indexBySymbol.get(metadata_1)))];
- if (!isLoweredSymbol(declarationSymbol.name)) {
- // Note: symbols that were introduced during codegen in the user file can have a reexport
- // if a user used `export *`. However, we can't rely on this as tsickle will change
- // `export *` into named exports, using only the information from the typechecker.
- // As we introduce the new symbols after typecheck, Tsickle does not know about them,
- // and omits them when expanding `export *`.
- // So we have to keep reexporting these symbols manually via .ngfactory files.
- this.reexportedBy.set(declarationSymbol, summary.symbol);
- }
- }
- }
- if (!unprocessedSummary.type && summary.type) {
- unprocessedSummary.type = summary.type;
- // Note: We don't add the summaries of all referenced symbols as for the ResolvedSymbols,
- // as the type summaries already contain the transitive data that they require
- // (in a minimal way).
- processedSummary.type = this.processValue(summary.type, 0 /* None */);
- // except for reexported directives / pipes, so we need to store
- // their summaries explicitly.
- if (summary.type.summaryKind === CompileSummaryKind.NgModule) {
- var /** @type {?} */ ngModuleSummary = /** @type {?} */ (summary.type);
- ngModuleSummary.exportedDirectives.concat(ngModuleSummary.exportedPipes).forEach(function (id) {
- var /** @type {?} */ symbol = id.reference;
- if (_this.summaryResolver.isLibraryFile(symbol.filePath) &&
- !_this.unprocessedSymbolSummariesBySymbol.has(symbol)) {
- var /** @type {?} */ summary_1 = _this.summaryResolver.resolveSummary(symbol);
- if (summary_1) {
- _this.addSummary(summary_1);
- }
- }
- });
- }
- }
- };
- /**
- * @return {?}
- */
- ToJsonSerializer.prototype.serialize = /**
- * @return {?}
- */
- function () {
- var _this = this;
- var /** @type {?} */ exportAs = [];
- var /** @type {?} */ json = JSON.stringify({
- moduleName: this.moduleName,
- summaries: this.processedSummaries,
- symbols: this.symbols.map(function (symbol, index) {
- symbol.assertNoMembers();
- var /** @type {?} */ importAs = /** @type {?} */ ((undefined));
- if (_this.summaryResolver.isLibraryFile(symbol.filePath)) {
- var /** @type {?} */ reexportSymbol = _this.reexportedBy.get(symbol);
- if (reexportSymbol) {
- importAs = /** @type {?} */ ((_this.indexBySymbol.get(reexportSymbol)));
- }
- else {
- var /** @type {?} */ summary = _this.unprocessedSymbolSummariesBySymbol.get(symbol);
- if (!summary || !summary.metadata || summary.metadata.__symbolic !== 'interface') {
- importAs = symbol.name + "_" + index;
- exportAs.push({ symbol: symbol, exportAs: importAs });
- }
- }
- }
- return {
- __symbol: index,
- name: symbol.name,
- filePath: _this.summaryResolver.toSummaryFileName(symbol.filePath, _this.srcFileName),
- importAs: importAs
- };
- })
- });
- return { json: json, exportAs: exportAs };
- };
- /**
- * @param {?} value
- * @param {?} flags
- * @return {?}
- */
- ToJsonSerializer.prototype.processValue = /**
- * @param {?} value
- * @param {?} flags
- * @return {?}
- */
- function (value, flags) {
- return visitValue(value, this, flags);
- };
- /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- ToJsonSerializer.prototype.visitOther = /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- function (value, context) {
- if (value instanceof StaticSymbol) {
- var /** @type {?} */ baseSymbol = this.symbolResolver.getStaticSymbol(value.filePath, value.name);
- var /** @type {?} */ index = this.visitStaticSymbol(baseSymbol, context);
- return { __symbol: index, members: value.members };
- }
- };
- /**
- * Returns null if the options.resolveValue is true, and the summary for the symbol
- * resolved to a type or could not be resolved.
- * @param {?} baseSymbol
- * @param {?} flags
- * @return {?}
- */
- ToJsonSerializer.prototype.visitStaticSymbol = /**
- * Returns null if the options.resolveValue is true, and the summary for the symbol
- * resolved to a type or could not be resolved.
- * @param {?} baseSymbol
- * @param {?} flags
- * @return {?}
- */
- function (baseSymbol, flags) {
- var /** @type {?} */ index = this.indexBySymbol.get(baseSymbol);
- var /** @type {?} */ summary = null;
- if (flags & 1 /* ResolveValue */ &&
- this.summaryResolver.isLibraryFile(baseSymbol.filePath)) {
- if (this.unprocessedSymbolSummariesBySymbol.has(baseSymbol)) {
- // the summary for this symbol was already added
- // -> nothing to do.
- return /** @type {?} */ ((index));
- }
- summary = this.loadSummary(baseSymbol);
- if (summary && summary.metadata instanceof StaticSymbol) {
- // The summary is a reexport
- index = this.visitStaticSymbol(summary.metadata, flags);
- // reset the summary as it is just a reexport, so we don't want to store it.
- summary = null;
- }
- }
- else if (index != null) {
- // Note: == on purpose to compare with undefined!
- // No summary and the symbol is already added -> nothing to do.
- return index;
- }
- // Note: == on purpose to compare with undefined!
- if (index == null) {
- index = this.symbols.length;
- this.symbols.push(baseSymbol);
- }
- this.indexBySymbol.set(baseSymbol, index);
- if (summary) {
- this.addSummary(summary);
- }
- return index;
- };
- /**
- * @param {?} symbol
- * @return {?}
- */
- ToJsonSerializer.prototype.loadSummary = /**
- * @param {?} symbol
- * @return {?}
- */
- function (symbol) {
- var /** @type {?} */ summary = this.summaryResolver.resolveSummary(symbol);
- if (!summary) {
- // some symbols might originate from a plain typescript library
- // that just exported .d.ts and .metadata.json files, i.e. where no summary
- // files were created.
- var /** @type {?} */ resolvedSymbol = this.symbolResolver.resolveSymbol(symbol);
- if (resolvedSymbol) {
- summary = { symbol: resolvedSymbol.symbol, metadata: resolvedSymbol.metadata };
- }
- }
- return summary;
- };
- return ToJsonSerializer;
- }(ValueTransformer));
- var ForJitSerializer = /** @class */ (function () {
- function ForJitSerializer(outputCtx, symbolResolver, summaryResolver) {
- this.outputCtx = outputCtx;
- this.symbolResolver = symbolResolver;
- this.summaryResolver = summaryResolver;
- this.data = [];
- }
- /**
- * @param {?} summary
- * @param {?} metadata
- * @return {?}
- */
- ForJitSerializer.prototype.addSourceType = /**
- * @param {?} summary
- * @param {?} metadata
- * @return {?}
- */
- function (summary, metadata) {
- this.data.push({ summary: summary, metadata: metadata, isLibrary: false });
- };
- /**
- * @param {?} summary
- * @return {?}
- */
- ForJitSerializer.prototype.addLibType = /**
- * @param {?} summary
- * @return {?}
- */
- function (summary) {
- this.data.push({ summary: summary, metadata: null, isLibrary: true });
- };
- /**
- * @param {?} exportAsArr
- * @return {?}
- */
- ForJitSerializer.prototype.serialize = /**
- * @param {?} exportAsArr
- * @return {?}
- */
- function (exportAsArr) {
- var _this = this;
- var /** @type {?} */ exportAsBySymbol = new Map();
- for (var _i = 0, exportAsArr_1 = exportAsArr; _i < exportAsArr_1.length; _i++) {
- var _a = exportAsArr_1[_i], symbol = _a.symbol, exportAs = _a.exportAs;
- exportAsBySymbol.set(symbol, exportAs);
- }
- var /** @type {?} */ ngModuleSymbols = new Set();
- for (var _b = 0, _c = this.data; _b < _c.length; _b++) {
- var _d = _c[_b], summary = _d.summary, metadata = _d.metadata, isLibrary = _d.isLibrary;
- if (summary.summaryKind === CompileSummaryKind.NgModule) {
- // collect the symbols that refer to NgModule classes.
- // Note: we can't just rely on `summary.type.summaryKind` to determine this as
- // we don't add the summaries of all referenced symbols when we serialize type summaries.
- // See serializeSummaries for details.
- ngModuleSymbols.add(summary.type.reference);
- var /** @type {?} */ modSummary = /** @type {?} */ (summary);
- for (var _e = 0, _f = modSummary.modules; _e < _f.length; _e++) {
- var mod = _f[_e];
- ngModuleSymbols.add(mod.reference);
- }
- }
- if (!isLibrary) {
- var /** @type {?} */ fnName = summaryForJitName(summary.type.reference.name);
- createSummaryForJitFunction(this.outputCtx, summary.type.reference, this.serializeSummaryWithDeps(summary, /** @type {?} */ ((metadata))));
- }
- }
- ngModuleSymbols.forEach(function (ngModuleSymbol) {
- if (_this.summaryResolver.isLibraryFile(ngModuleSymbol.filePath)) {
- var /** @type {?} */ exportAs = exportAsBySymbol.get(ngModuleSymbol) || ngModuleSymbol.name;
- var /** @type {?} */ jitExportAsName = summaryForJitName(exportAs);
- _this.outputCtx.statements.push(variable(jitExportAsName)
- .set(_this.serializeSummaryRef(ngModuleSymbol))
- .toDeclStmt(null, [StmtModifier.Exported]));
- }
- });
- };
- /**
- * @param {?} summary
- * @param {?} metadata
- * @return {?}
- */
- ForJitSerializer.prototype.serializeSummaryWithDeps = /**
- * @param {?} summary
- * @param {?} metadata
- * @return {?}
- */
- function (summary, metadata) {
- var _this = this;
- var /** @type {?} */ expressions = [this.serializeSummary(summary)];
- var /** @type {?} */ providers = [];
- if (metadata instanceof CompileNgModuleMetadata) {
- expressions.push.apply(expressions,
- // For directives / pipes, we only add the declared ones,
- // and rely on transitively importing NgModules to get the transitive
- // summaries.
- metadata.declaredDirectives.concat(metadata.declaredPipes)
- .map(function (type) { return type.reference; })
- .concat(metadata.transitiveModule.modules.map(function (type) { return type.reference; })
- .filter(function (ref) { return ref !== metadata.type.reference; }))
- .map(function (ref) { return _this.serializeSummaryRef(ref); }));
- // Note: We don't use `NgModuleSummary.providers`, as that one is transitive,
- // and we already have transitive modules.
- providers = metadata.providers;
- }
- else if (summary.summaryKind === CompileSummaryKind.Directive) {
- var /** @type {?} */ dirSummary = /** @type {?} */ (summary);
- providers = dirSummary.providers.concat(dirSummary.viewProviders);
- }
- // Note: We can't just refer to the `ngsummary.ts` files for `useClass` providers (as we do for
- // declaredDirectives / declaredPipes), as we allow
- // providers without ctor arguments to skip the `@Injectable` decorator,
- // i.e. we didn't generate .ngsummary.ts files for these.
- expressions.push.apply(expressions, providers.filter(function (provider) { return !!provider.useClass; }).map(function (provider) {
- return _this.serializeSummary(/** @type {?} */ ({
- summaryKind: CompileSummaryKind.Injectable, type: provider.useClass
- }));
- }));
- return literalArr(expressions);
- };
- /**
- * @param {?} typeSymbol
- * @return {?}
- */
- ForJitSerializer.prototype.serializeSummaryRef = /**
- * @param {?} typeSymbol
- * @return {?}
- */
- function (typeSymbol) {
- var /** @type {?} */ jitImportedSymbol = this.symbolResolver.getStaticSymbol(summaryForJitFileName(typeSymbol.filePath), summaryForJitName(typeSymbol.name));
- return this.outputCtx.importExpr(jitImportedSymbol);
- };
- /**
- * @param {?} data
- * @return {?}
- */
- ForJitSerializer.prototype.serializeSummary = /**
- * @param {?} data
- * @return {?}
- */
- function (data) {
- var /** @type {?} */ outputCtx = this.outputCtx;
- var Transformer = /** @class */ (function () {
- function Transformer() {
- }
- /**
- * @param {?} arr
- * @param {?} context
- * @return {?}
- */
- Transformer.prototype.visitArray = /**
- * @param {?} arr
- * @param {?} context
- * @return {?}
- */
- function (arr, context) {
- var _this = this;
- return literalArr(arr.map(function (entry) { return visitValue(entry, _this, context); }));
- };
- /**
- * @param {?} map
- * @param {?} context
- * @return {?}
- */
- Transformer.prototype.visitStringMap = /**
- * @param {?} map
- * @param {?} context
- * @return {?}
- */
- function (map, context) {
- var _this = this;
- return new LiteralMapExpr(Object.keys(map).map(function (key) { return new LiteralMapEntry(key, visitValue(map[key], _this, context), false); }));
- };
- /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- Transformer.prototype.visitPrimitive = /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- function (value, context) { return literal(value); };
- /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- Transformer.prototype.visitOther = /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- function (value, context) {
- if (value instanceof StaticSymbol) {
- return outputCtx.importExpr(value);
- }
- else {
- throw new Error("Illegal State: Encountered value " + value);
- }
- };
- return Transformer;
- }());
- return visitValue(data, new Transformer(), null);
- };
- return ForJitSerializer;
- }());
- var FromJsonDeserializer = /** @class */ (function (_super) {
- __extends(FromJsonDeserializer, _super);
- function FromJsonDeserializer(symbolCache, summaryResolver) {
- var _this = _super.call(this) || this;
- _this.symbolCache = symbolCache;
- _this.summaryResolver = summaryResolver;
- return _this;
- }
- /**
- * @param {?} libraryFileName
- * @param {?} json
- * @return {?}
- */
- FromJsonDeserializer.prototype.deserialize = /**
- * @param {?} libraryFileName
- * @param {?} json
- * @return {?}
- */
- function (libraryFileName, json) {
- var _this = this;
- var /** @type {?} */ data = JSON.parse(json);
- var /** @type {?} */ allImportAs = [];
- this.symbols = data.symbols.map(function (serializedSymbol) {
- return _this.symbolCache.get(_this.summaryResolver.fromSummaryFileName(serializedSymbol.filePath, libraryFileName), serializedSymbol.name);
- });
- data.symbols.forEach(function (serializedSymbol, index) {
- var /** @type {?} */ symbol = _this.symbols[index];
- var /** @type {?} */ importAs = serializedSymbol.importAs;
- if (typeof importAs === 'number') {
- allImportAs.push({ symbol: symbol, importAs: _this.symbols[importAs] });
- }
- else if (typeof importAs === 'string') {
- allImportAs.push({ symbol: symbol, importAs: _this.symbolCache.get(ngfactoryFilePath(libraryFileName), importAs) });
- }
- });
- var /** @type {?} */ summaries = /** @type {?} */ (visitValue(data.summaries, this, null));
- return { moduleName: data.moduleName, summaries: summaries, importAs: allImportAs };
- };
- /**
- * @param {?} map
- * @param {?} context
- * @return {?}
- */
- FromJsonDeserializer.prototype.visitStringMap = /**
- * @param {?} map
- * @param {?} context
- * @return {?}
- */
- function (map, context) {
- if ('__symbol' in map) {
- var /** @type {?} */ baseSymbol = this.symbols[map['__symbol']];
- var /** @type {?} */ members = map['members'];
- return members.length ? this.symbolCache.get(baseSymbol.filePath, baseSymbol.name, members) :
- baseSymbol;
- }
- else {
- return _super.prototype.visitStringMap.call(this, map, context);
- }
- };
- return FromJsonDeserializer;
- }(ValueTransformer));
- /**
- * @param {?} metadata
- * @return {?}
- */
- function isCall(metadata) {
- return metadata && metadata.__symbolic === 'call';
- }
- /**
- * @param {?} metadata
- * @return {?}
- */
- function isFunctionCall(metadata) {
- return isCall(metadata) && unwrapResolvedMetadata(metadata.expression) instanceof StaticSymbol;
- }
- /**
- * @param {?} metadata
- * @return {?}
- */
- function isMethodCallOnVariable(metadata) {
- return isCall(metadata) && metadata.expression && metadata.expression.__symbolic === 'select' &&
- unwrapResolvedMetadata(metadata.expression.expression) instanceof StaticSymbol;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /** @enum {number} */
- var StubEmitFlags = {
- Basic: 1,
- TypeCheck: 2,
- All: 3,
- };
- StubEmitFlags[StubEmitFlags.Basic] = "Basic";
- StubEmitFlags[StubEmitFlags.TypeCheck] = "TypeCheck";
- StubEmitFlags[StubEmitFlags.All] = "All";
- var AotCompiler = /** @class */ (function () {
- function AotCompiler(_config, _options, _host, _reflector, _metadataResolver, _templateParser, _styleCompiler, _viewCompiler, _typeCheckCompiler, _ngModuleCompiler, _outputEmitter, _summaryResolver, _symbolResolver) {
- this._config = _config;
- this._options = _options;
- this._host = _host;
- this._reflector = _reflector;
- this._metadataResolver = _metadataResolver;
- this._templateParser = _templateParser;
- this._styleCompiler = _styleCompiler;
- this._viewCompiler = _viewCompiler;
- this._typeCheckCompiler = _typeCheckCompiler;
- this._ngModuleCompiler = _ngModuleCompiler;
- this._outputEmitter = _outputEmitter;
- this._summaryResolver = _summaryResolver;
- this._symbolResolver = _symbolResolver;
- this._templateAstCache = new Map();
- this._analyzedFiles = new Map();
- }
- /**
- * @return {?}
- */
- AotCompiler.prototype.clearCache = /**
- * @return {?}
- */
- function () { this._metadataResolver.clearCache(); };
- /**
- * @param {?} rootFiles
- * @return {?}
- */
- AotCompiler.prototype.analyzeModulesSync = /**
- * @param {?} rootFiles
- * @return {?}
- */
- function (rootFiles) {
- var _this = this;
- var /** @type {?} */ analyzeResult = analyzeAndValidateNgModules(rootFiles, this._host, this._symbolResolver, this._metadataResolver);
- analyzeResult.ngModules.forEach(function (ngModule) {
- return _this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, true);
- });
- return analyzeResult;
- };
- /**
- * @param {?} rootFiles
- * @return {?}
- */
- AotCompiler.prototype.analyzeModulesAsync = /**
- * @param {?} rootFiles
- * @return {?}
- */
- function (rootFiles) {
- var _this = this;
- var /** @type {?} */ analyzeResult = analyzeAndValidateNgModules(rootFiles, this._host, this._symbolResolver, this._metadataResolver);
- return Promise
- .all(analyzeResult.ngModules.map(function (ngModule) {
- return _this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, false);
- }))
- .then(function () { return analyzeResult; });
- };
- /**
- * @param {?} fileName
- * @return {?}
- */
- AotCompiler.prototype._analyzeFile = /**
- * @param {?} fileName
- * @return {?}
- */
- function (fileName) {
- var /** @type {?} */ analyzedFile = this._analyzedFiles.get(fileName);
- if (!analyzedFile) {
- analyzedFile =
- analyzeFile(this._host, this._symbolResolver, this._metadataResolver, fileName);
- this._analyzedFiles.set(fileName, analyzedFile);
- }
- return analyzedFile;
- };
- /**
- * @param {?} fileName
- * @return {?}
- */
- AotCompiler.prototype.findGeneratedFileNames = /**
- * @param {?} fileName
- * @return {?}
- */
- function (fileName) {
- var _this = this;
- var /** @type {?} */ genFileNames = [];
- var /** @type {?} */ file = this._analyzeFile(fileName);
- // Make sure we create a .ngfactory if we have a injectable/directive/pipe/NgModule
- // or a reference to a non source file.
- // Note: This is overestimating the required .ngfactory files as the real calculation is harder.
- // Only do this for StubEmitFlags.Basic, as adding a type check block
- // does not change this file (as we generate type check blocks based on NgModules).
- if (this._options.allowEmptyCodegenFiles || file.directives.length || file.pipes.length ||
- file.injectables.length || file.ngModules.length || file.exportsNonSourceFiles) {
- genFileNames.push(ngfactoryFilePath(file.fileName, true));
- if (this._options.enableSummariesForJit) {
- genFileNames.push(summaryForJitFileName(file.fileName, true));
- }
- }
- var /** @type {?} */ fileSuffix = normalizeGenFileSuffix(splitTypescriptSuffix(file.fileName, true)[1]);
- file.directives.forEach(function (dirSymbol) {
- var /** @type {?} */ compMeta = /** @type {?} */ ((_this._metadataResolver.getNonNormalizedDirectiveMetadata(dirSymbol))).metadata;
- if (!compMeta.isComponent) {
- return;
- } /** @type {?} */
- ((
- // Note: compMeta is a component and therefore template is non null.
- compMeta.template)).styleUrls.forEach(function (styleUrl) {
- var /** @type {?} */ normalizedUrl = _this._host.resourceNameToFileName(styleUrl, file.fileName);
- if (!normalizedUrl) {
- throw syntaxError("Couldn't resolve resource " + styleUrl + " relative to " + file.fileName);
- }
- var /** @type {?} */ needsShim = (/** @type {?} */ ((compMeta.template)).encapsulation || _this._config.defaultEncapsulation) === ViewEncapsulation.Emulated;
- genFileNames.push(_stylesModuleUrl(normalizedUrl, needsShim, fileSuffix));
- if (_this._options.allowEmptyCodegenFiles) {
- genFileNames.push(_stylesModuleUrl(normalizedUrl, !needsShim, fileSuffix));
- }
- });
- });
- return genFileNames;
- };
- /**
- * @param {?} genFileName
- * @param {?=} originalFileName
- * @return {?}
- */
- AotCompiler.prototype.emitBasicStub = /**
- * @param {?} genFileName
- * @param {?=} originalFileName
- * @return {?}
- */
- function (genFileName, originalFileName) {
- var /** @type {?} */ outputCtx = this._createOutputContext(genFileName);
- if (genFileName.endsWith('.ngfactory.ts')) {
- if (!originalFileName) {
- throw new Error("Assertion error: require the original file for .ngfactory.ts stubs. File: " + genFileName);
- }
- var /** @type {?} */ originalFile = this._analyzeFile(originalFileName);
- this._createNgFactoryStub(outputCtx, originalFile, StubEmitFlags.Basic);
- }
- else if (genFileName.endsWith('.ngsummary.ts')) {
- if (this._options.enableSummariesForJit) {
- if (!originalFileName) {
- throw new Error("Assertion error: require the original file for .ngsummary.ts stubs. File: " + genFileName);
- }
- var /** @type {?} */ originalFile = this._analyzeFile(originalFileName);
- _createEmptyStub(outputCtx);
- originalFile.ngModules.forEach(function (ngModule) {
- // create exports that user code can reference
- createForJitStub(outputCtx, ngModule.type.reference);
- });
- }
- }
- else if (genFileName.endsWith('.ngstyle.ts')) {
- _createEmptyStub(outputCtx);
- }
- // Note: for the stubs, we don't need a property srcFileUrl,
- // as lateron in emitAllImpls we will create the proper GeneratedFiles with the
- // correct srcFileUrl.
- // This is good as e.g. for .ngstyle.ts files we can't derive
- // the url of components based on the genFileUrl.
- return this._codegenSourceModule('unknown', outputCtx);
- };
- /**
- * @param {?} genFileName
- * @param {?} originalFileName
- * @return {?}
- */
- AotCompiler.prototype.emitTypeCheckStub = /**
- * @param {?} genFileName
- * @param {?} originalFileName
- * @return {?}
- */
- function (genFileName, originalFileName) {
- var /** @type {?} */ originalFile = this._analyzeFile(originalFileName);
- var /** @type {?} */ outputCtx = this._createOutputContext(genFileName);
- if (genFileName.endsWith('.ngfactory.ts')) {
- this._createNgFactoryStub(outputCtx, originalFile, StubEmitFlags.TypeCheck);
- }
- return outputCtx.statements.length > 0 ?
- this._codegenSourceModule(originalFile.fileName, outputCtx) :
- null;
- };
- /**
- * @param {?} fileNames
- * @return {?}
- */
- AotCompiler.prototype.loadFilesAsync = /**
- * @param {?} fileNames
- * @return {?}
- */
- function (fileNames) {
- var _this = this;
- var /** @type {?} */ files = fileNames.map(function (fileName) { return _this._analyzeFile(fileName); });
- var /** @type {?} */ loadingPromises = [];
- files.forEach(function (file) {
- return file.ngModules.forEach(function (ngModule) {
- return loadingPromises.push(_this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, false));
- });
- });
- return Promise.all(loadingPromises).then(function (_) { return mergeAndValidateNgFiles(files); });
- };
- /**
- * @param {?} fileNames
- * @return {?}
- */
- AotCompiler.prototype.loadFilesSync = /**
- * @param {?} fileNames
- * @return {?}
- */
- function (fileNames) {
- var _this = this;
- var /** @type {?} */ files = fileNames.map(function (fileName) { return _this._analyzeFile(fileName); });
- files.forEach(function (file) {
- return file.ngModules.forEach(function (ngModule) {
- return _this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, true);
- });
- });
- return mergeAndValidateNgFiles(files);
- };
- /**
- * @param {?} outputCtx
- * @param {?} file
- * @param {?} emitFlags
- * @return {?}
- */
- AotCompiler.prototype._createNgFactoryStub = /**
- * @param {?} outputCtx
- * @param {?} file
- * @param {?} emitFlags
- * @return {?}
- */
- function (outputCtx, file, emitFlags) {
- var _this = this;
- var /** @type {?} */ componentId = 0;
- file.ngModules.forEach(function (ngModuleMeta, ngModuleIndex) {
- // Note: the code below needs to executed for StubEmitFlags.Basic and StubEmitFlags.TypeCheck,
- // so we don't change the .ngfactory file too much when adding the typecheck block.
- // create exports that user code can reference
- // Note: the code below needs to executed for StubEmitFlags.Basic and StubEmitFlags.TypeCheck,
- // so we don't change the .ngfactory file too much when adding the typecheck block.
- // create exports that user code can reference
- _this._ngModuleCompiler.createStub(outputCtx, ngModuleMeta.type.reference);
- // add references to the symbols from the metadata.
- // These can be used by the type check block for components,
- // and they also cause TypeScript to include these files into the program too,
- // which will make them part of the analyzedFiles.
- var /** @type {?} */ externalReferences = ngModuleMeta.transitiveModule.directives.map(function (d) { return d.reference; }).concat(ngModuleMeta.transitiveModule.pipes.map(function (d) { return d.reference; }), ngModuleMeta.importedModules.map(function (m) { return m.type.reference; }), ngModuleMeta.exportedModules.map(function (m) { return m.type.reference; }), _this._externalIdentifierReferences([Identifiers.TemplateRef, Identifiers.ElementRef]));
- var /** @type {?} */ externalReferenceVars = new Map();
- externalReferences.forEach(function (ref, typeIndex) {
- externalReferenceVars.set(ref, "_decl" + ngModuleIndex + "_" + typeIndex);
- });
- externalReferenceVars.forEach(function (varName, reference) {
- outputCtx.statements.push(variable(varName)
- .set(NULL_EXPR.cast(DYNAMIC_TYPE))
- .toDeclStmt(expressionType(outputCtx.importExpr(reference, /* typeParams */ null, /* useSummaries */ /* useSummaries */ false))));
- });
- if (emitFlags & StubEmitFlags.TypeCheck) {
- // add the typecheck block for all components of the NgModule
- ngModuleMeta.declaredDirectives.forEach(function (dirId) {
- var /** @type {?} */ compMeta = _this._metadataResolver.getDirectiveMetadata(dirId.reference);
- if (!compMeta.isComponent) {
- return;
- }
- componentId++;
- _this._createTypeCheckBlock(outputCtx, compMeta.type.reference.name + "_Host_" + componentId, ngModuleMeta, _this._metadataResolver.getHostComponentMetadata(compMeta), [compMeta.type], externalReferenceVars);
- _this._createTypeCheckBlock(outputCtx, compMeta.type.reference.name + "_" + componentId, ngModuleMeta, compMeta, ngModuleMeta.transitiveModule.directives, externalReferenceVars);
- });
- }
- });
- if (outputCtx.statements.length === 0) {
- _createEmptyStub(outputCtx);
- }
- };
- /**
- * @param {?} references
- * @return {?}
- */
- AotCompiler.prototype._externalIdentifierReferences = /**
- * @param {?} references
- * @return {?}
- */
- function (references) {
- var /** @type {?} */ result = [];
- for (var _i = 0, references_1 = references; _i < references_1.length; _i++) {
- var reference = references_1[_i];
- var /** @type {?} */ token = createTokenForExternalReference(this._reflector, reference);
- if (token.identifier) {
- result.push(token.identifier.reference);
- }
- }
- return result;
- };
- /**
- * @param {?} ctx
- * @param {?} componentId
- * @param {?} moduleMeta
- * @param {?} compMeta
- * @param {?} directives
- * @param {?} externalReferenceVars
- * @return {?}
- */
- AotCompiler.prototype._createTypeCheckBlock = /**
- * @param {?} ctx
- * @param {?} componentId
- * @param {?} moduleMeta
- * @param {?} compMeta
- * @param {?} directives
- * @param {?} externalReferenceVars
- * @return {?}
- */
- function (ctx, componentId, moduleMeta, compMeta, directives, externalReferenceVars) {
- var _a = this._parseTemplate(compMeta, moduleMeta, directives), parsedTemplate = _a.template, usedPipes = _a.pipes;
- (_b = ctx.statements).push.apply(_b, this._typeCheckCompiler.compileComponent(componentId, compMeta, parsedTemplate, usedPipes, externalReferenceVars, ctx));
- var _b;
- };
- /**
- * @param {?} analyzeResult
- * @param {?} locale
- * @return {?}
- */
- AotCompiler.prototype.emitMessageBundle = /**
- * @param {?} analyzeResult
- * @param {?} locale
- * @return {?}
- */
- function (analyzeResult, locale) {
- var _this = this;
- var /** @type {?} */ errors = [];
- var /** @type {?} */ htmlParser = new HtmlParser();
- // TODO(vicb): implicit tags & attributes
- var /** @type {?} */ messageBundle = new MessageBundle(htmlParser, [], {}, locale);
- analyzeResult.files.forEach(function (file) {
- var /** @type {?} */ compMetas = [];
- file.directives.forEach(function (directiveType) {
- var /** @type {?} */ dirMeta = _this._metadataResolver.getDirectiveMetadata(directiveType);
- if (dirMeta && dirMeta.isComponent) {
- compMetas.push(dirMeta);
- }
- });
- compMetas.forEach(function (compMeta) {
- var /** @type {?} */ html = /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).template));
- var /** @type {?} */ interpolationConfig = InterpolationConfig.fromArray(/** @type {?} */ ((compMeta.template)).interpolation);
- errors.push.apply(errors, /** @type {?} */ ((messageBundle.updateFromTemplate(html, file.fileName, interpolationConfig))));
- });
- });
- if (errors.length) {
- throw new Error(errors.map(function (e) { return e.toString(); }).join('\n'));
- }
- return messageBundle;
- };
- /**
- * @param {?} analyzeResult
- * @return {?}
- */
- AotCompiler.prototype.emitAllImpls = /**
- * @param {?} analyzeResult
- * @return {?}
- */
- function (analyzeResult) {
- var _this = this;
- var ngModuleByPipeOrDirective = analyzeResult.ngModuleByPipeOrDirective, files = analyzeResult.files;
- var /** @type {?} */ sourceModules = files.map(function (file) {
- return _this._compileImplFile(file.fileName, ngModuleByPipeOrDirective, file.directives, file.pipes, file.ngModules, file.injectables);
- });
- return flatten(sourceModules);
- };
- /**
- * @param {?} srcFileUrl
- * @param {?} ngModuleByPipeOrDirective
- * @param {?} directives
- * @param {?} pipes
- * @param {?} ngModules
- * @param {?} injectables
- * @return {?}
- */
- AotCompiler.prototype._compileImplFile = /**
- * @param {?} srcFileUrl
- * @param {?} ngModuleByPipeOrDirective
- * @param {?} directives
- * @param {?} pipes
- * @param {?} ngModules
- * @param {?} injectables
- * @return {?}
- */
- function (srcFileUrl, ngModuleByPipeOrDirective, directives, pipes, ngModules, injectables) {
- var _this = this;
- var /** @type {?} */ fileSuffix = normalizeGenFileSuffix(splitTypescriptSuffix(srcFileUrl, true)[1]);
- var /** @type {?} */ generatedFiles = [];
- var /** @type {?} */ outputCtx = this._createOutputContext(ngfactoryFilePath(srcFileUrl, true));
- generatedFiles.push.apply(generatedFiles, this._createSummary(srcFileUrl, directives, pipes, ngModules, injectables, outputCtx));
- // compile all ng modules
- ngModules.forEach(function (ngModuleMeta) { return _this._compileModule(outputCtx, ngModuleMeta); });
- // compile components
- directives.forEach(function (dirType) {
- var /** @type {?} */ compMeta = _this._metadataResolver.getDirectiveMetadata(/** @type {?} */ (dirType));
- if (!compMeta.isComponent) {
- return;
- }
- var /** @type {?} */ ngModule = ngModuleByPipeOrDirective.get(dirType);
- if (!ngModule) {
- throw new Error("Internal Error: cannot determine the module for component " + identifierName(compMeta.type) + "!");
- }
- // compile styles
- var /** @type {?} */ componentStylesheet = _this._styleCompiler.compileComponent(outputCtx, compMeta); /** @type {?} */
- ((
- // Note: compMeta is a component and therefore template is non null.
- compMeta.template)).externalStylesheets.forEach(function (stylesheetMeta) {
- // Note: fill non shim and shim style files as they might
- // be shared by component with and without ViewEncapsulation.
- var /** @type {?} */ shim = _this._styleCompiler.needsStyleShim(compMeta);
- generatedFiles.push(_this._codegenStyles(srcFileUrl, compMeta, stylesheetMeta, shim, fileSuffix));
- if (_this._options.allowEmptyCodegenFiles) {
- generatedFiles.push(_this._codegenStyles(srcFileUrl, compMeta, stylesheetMeta, !shim, fileSuffix));
- }
- });
- // compile components
- var /** @type {?} */ compViewVars = _this._compileComponent(outputCtx, compMeta, ngModule, ngModule.transitiveModule.directives, componentStylesheet, fileSuffix);
- _this._compileComponentFactory(outputCtx, compMeta, ngModule, fileSuffix);
- });
- if (outputCtx.statements.length > 0 || this._options.allowEmptyCodegenFiles) {
- var /** @type {?} */ srcModule = this._codegenSourceModule(srcFileUrl, outputCtx);
- generatedFiles.unshift(srcModule);
- }
- return generatedFiles;
- };
- /**
- * @param {?} srcFileName
- * @param {?} directives
- * @param {?} pipes
- * @param {?} ngModules
- * @param {?} injectables
- * @param {?} ngFactoryCtx
- * @return {?}
- */
- AotCompiler.prototype._createSummary = /**
- * @param {?} srcFileName
- * @param {?} directives
- * @param {?} pipes
- * @param {?} ngModules
- * @param {?} injectables
- * @param {?} ngFactoryCtx
- * @return {?}
- */
- function (srcFileName, directives, pipes, ngModules, injectables, ngFactoryCtx) {
- var _this = this;
- var /** @type {?} */ symbolSummaries = this._symbolResolver.getSymbolsOf(srcFileName)
- .map(function (symbol) { return _this._symbolResolver.resolveSymbol(symbol); });
- var /** @type {?} */ typeData = ngModules.map(function (meta) {
- return ({
- summary: /** @type {?} */ ((_this._metadataResolver.getNgModuleSummary(meta.type.reference))),
- metadata: /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(meta.type.reference)))
- });
- }).concat(directives.map(function (ref) {
- return ({
- summary: /** @type {?} */ ((_this._metadataResolver.getDirectiveSummary(ref))),
- metadata: /** @type {?} */ ((_this._metadataResolver.getDirectiveMetadata(ref)))
- });
- }), pipes.map(function (ref) {
- return ({
- summary: /** @type {?} */ ((_this._metadataResolver.getPipeSummary(ref))),
- metadata: /** @type {?} */ ((_this._metadataResolver.getPipeMetadata(ref)))
- });
- }), injectables.map(function (ref) {
- return ({
- summary: /** @type {?} */ ((_this._metadataResolver.getInjectableSummary(ref))),
- metadata: /** @type {?} */ ((_this._metadataResolver.getInjectableSummary(ref))).type
- });
- }));
- var /** @type {?} */ forJitOutputCtx = this._options.enableSummariesForJit ?
- this._createOutputContext(summaryForJitFileName(srcFileName, true)) :
- null;
- var _a = serializeSummaries(srcFileName, forJitOutputCtx, this._summaryResolver, this._symbolResolver, symbolSummaries, typeData), json = _a.json, exportAs = _a.exportAs;
- exportAs.forEach(function (entry) {
- ngFactoryCtx.statements.push(variable(entry.exportAs).set(ngFactoryCtx.importExpr(entry.symbol)).toDeclStmt(null, [
- StmtModifier.Exported
- ]));
- });
- var /** @type {?} */ summaryJson = new GeneratedFile(srcFileName, summaryFileName(srcFileName), json);
- var /** @type {?} */ result = [summaryJson];
- if (forJitOutputCtx) {
- result.push(this._codegenSourceModule(srcFileName, forJitOutputCtx));
- }
- return result;
- };
- /**
- * @param {?} outputCtx
- * @param {?} ngModule
- * @return {?}
- */
- AotCompiler.prototype._compileModule = /**
- * @param {?} outputCtx
- * @param {?} ngModule
- * @return {?}
- */
- function (outputCtx, ngModule) {
- var /** @type {?} */ providers = [];
- if (this._options.locale) {
- var /** @type {?} */ normalizedLocale = this._options.locale.replace(/_/g, '-');
- providers.push({
- token: createTokenForExternalReference(this._reflector, Identifiers.LOCALE_ID),
- useValue: normalizedLocale,
- });
- }
- if (this._options.i18nFormat) {
- providers.push({
- token: createTokenForExternalReference(this._reflector, Identifiers.TRANSLATIONS_FORMAT),
- useValue: this._options.i18nFormat
- });
- }
- this._ngModuleCompiler.compile(outputCtx, ngModule, providers);
- };
- /**
- * @param {?} outputCtx
- * @param {?} compMeta
- * @param {?} ngModule
- * @param {?} fileSuffix
- * @return {?}
- */
- AotCompiler.prototype._compileComponentFactory = /**
- * @param {?} outputCtx
- * @param {?} compMeta
- * @param {?} ngModule
- * @param {?} fileSuffix
- * @return {?}
- */
- function (outputCtx, compMeta, ngModule, fileSuffix) {
- var /** @type {?} */ hostMeta = this._metadataResolver.getHostComponentMetadata(compMeta);
- var /** @type {?} */ hostViewFactoryVar = this._compileComponent(outputCtx, hostMeta, ngModule, [compMeta.type], null, fileSuffix)
- .viewClassVar;
- var /** @type {?} */ compFactoryVar = componentFactoryName(compMeta.type.reference);
- var /** @type {?} */ inputsExprs = [];
- for (var /** @type {?} */ propName in compMeta.inputs) {
- var /** @type {?} */ templateName = compMeta.inputs[propName];
- // Don't quote so that the key gets minified...
- inputsExprs.push(new LiteralMapEntry(propName, literal(templateName), false));
- }
- var /** @type {?} */ outputsExprs = [];
- for (var /** @type {?} */ propName in compMeta.outputs) {
- var /** @type {?} */ templateName = compMeta.outputs[propName];
- // Don't quote so that the key gets minified...
- outputsExprs.push(new LiteralMapEntry(propName, literal(templateName), false));
- }
- outputCtx.statements.push(variable(compFactoryVar)
- .set(importExpr(Identifiers.createComponentFactory).callFn([
- literal(compMeta.selector), outputCtx.importExpr(compMeta.type.reference),
- variable(hostViewFactoryVar), new LiteralMapExpr(inputsExprs),
- new LiteralMapExpr(outputsExprs),
- literalArr(/** @type {?} */ ((compMeta.template)).ngContentSelectors.map(function (selector) { return literal(selector); }))
- ]))
- .toDeclStmt(importType(Identifiers.ComponentFactory, [/** @type {?} */ ((expressionType(outputCtx.importExpr(compMeta.type.reference))))], [TypeModifier.Const]), [StmtModifier.Final, StmtModifier.Exported]));
- };
- /**
- * @param {?} outputCtx
- * @param {?} compMeta
- * @param {?} ngModule
- * @param {?} directiveIdentifiers
- * @param {?} componentStyles
- * @param {?} fileSuffix
- * @return {?}
- */
- AotCompiler.prototype._compileComponent = /**
- * @param {?} outputCtx
- * @param {?} compMeta
- * @param {?} ngModule
- * @param {?} directiveIdentifiers
- * @param {?} componentStyles
- * @param {?} fileSuffix
- * @return {?}
- */
- function (outputCtx, compMeta, ngModule, directiveIdentifiers, componentStyles, fileSuffix) {
- var _a = this._parseTemplate(compMeta, ngModule, directiveIdentifiers), parsedTemplate = _a.template, usedPipes = _a.pipes;
- var /** @type {?} */ stylesExpr = componentStyles ? variable(componentStyles.stylesVar) : literalArr([]);
- var /** @type {?} */ viewResult = this._viewCompiler.compileComponent(outputCtx, compMeta, parsedTemplate, stylesExpr, usedPipes);
- if (componentStyles) {
- _resolveStyleStatements(this._symbolResolver, componentStyles, this._styleCompiler.needsStyleShim(compMeta), fileSuffix);
- }
- return viewResult;
- };
- /**
- * @param {?} compMeta
- * @param {?} ngModule
- * @param {?} directiveIdentifiers
- * @return {?}
- */
- AotCompiler.prototype._parseTemplate = /**
- * @param {?} compMeta
- * @param {?} ngModule
- * @param {?} directiveIdentifiers
- * @return {?}
- */
- function (compMeta, ngModule, directiveIdentifiers) {
- var _this = this;
- if (this._templateAstCache.has(compMeta.type.reference)) {
- return /** @type {?} */ ((this._templateAstCache.get(compMeta.type.reference)));
- }
- var /** @type {?} */ preserveWhitespaces = /** @type {?} */ ((/** @type {?} */ ((compMeta)).template)).preserveWhitespaces;
- var /** @type {?} */ directives = directiveIdentifiers.map(function (dir) { return _this._metadataResolver.getDirectiveSummary(dir.reference); });
- var /** @type {?} */ pipes = ngModule.transitiveModule.pipes.map(function (pipe) { return _this._metadataResolver.getPipeSummary(pipe.reference); });
- var /** @type {?} */ result = this._templateParser.parse(compMeta, /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).htmlAst)), directives, pipes, ngModule.schemas, templateSourceUrl(ngModule.type, compMeta, /** @type {?} */ ((compMeta.template))), preserveWhitespaces);
- this._templateAstCache.set(compMeta.type.reference, result);
- return result;
- };
- /**
- * @param {?} genFilePath
- * @return {?}
- */
- AotCompiler.prototype._createOutputContext = /**
- * @param {?} genFilePath
- * @return {?}
- */
- function (genFilePath) {
- var _this = this;
- var /** @type {?} */ importExpr$$1 = function (symbol, typeParams, useSummaries) {
- if (typeParams === void 0) { typeParams = null; }
- if (useSummaries === void 0) { useSummaries = true; }
- if (!(symbol instanceof StaticSymbol)) {
- throw new Error("Internal error: unknown identifier " + JSON.stringify(symbol));
- }
- var /** @type {?} */ arity = _this._symbolResolver.getTypeArity(symbol) || 0;
- var _a = _this._symbolResolver.getImportAs(symbol, useSummaries) || symbol, filePath = _a.filePath, name = _a.name, members = _a.members;
- var /** @type {?} */ importModule = _this._fileNameToModuleName(filePath, genFilePath);
- // It should be good enough to compare filePath to genFilePath and if they are equal
- // there is a self reference. However, ngfactory files generate to .ts but their
- // symbols have .d.ts so a simple compare is insufficient. They should be canonical
- // and is tracked by #17705.
- var /** @type {?} */ selfReference = _this._fileNameToModuleName(genFilePath, genFilePath);
- var /** @type {?} */ moduleName = importModule === selfReference ? null : importModule;
- // If we are in a type expression that refers to a generic type then supply
- // the required type parameters. If there were not enough type parameters
- // supplied, supply any as the type. Outside a type expression the reference
- // should not supply type parameters and be treated as a simple value reference
- // to the constructor function itself.
- var /** @type {?} */ suppliedTypeParams = typeParams || [];
- var /** @type {?} */ missingTypeParamsCount = arity - suppliedTypeParams.length;
- var /** @type {?} */ allTypeParams = suppliedTypeParams.concat(new Array(missingTypeParamsCount).fill(DYNAMIC_TYPE));
- return members.reduce(function (expr, memberName) { return expr.prop(memberName); }, /** @type {?} */ (importExpr(new ExternalReference(moduleName, name, null), allTypeParams)));
- };
- return { statements: [], genFilePath: genFilePath, importExpr: importExpr$$1 };
- };
- /**
- * @param {?} importedFilePath
- * @param {?} containingFilePath
- * @return {?}
- */
- AotCompiler.prototype._fileNameToModuleName = /**
- * @param {?} importedFilePath
- * @param {?} containingFilePath
- * @return {?}
- */
- function (importedFilePath, containingFilePath) {
- return this._summaryResolver.getKnownModuleName(importedFilePath) ||
- this._symbolResolver.getKnownModuleName(importedFilePath) ||
- this._host.fileNameToModuleName(importedFilePath, containingFilePath);
- };
- /**
- * @param {?} srcFileUrl
- * @param {?} compMeta
- * @param {?} stylesheetMetadata
- * @param {?} isShimmed
- * @param {?} fileSuffix
- * @return {?}
- */
- AotCompiler.prototype._codegenStyles = /**
- * @param {?} srcFileUrl
- * @param {?} compMeta
- * @param {?} stylesheetMetadata
- * @param {?} isShimmed
- * @param {?} fileSuffix
- * @return {?}
- */
- function (srcFileUrl, compMeta, stylesheetMetadata, isShimmed, fileSuffix) {
- var /** @type {?} */ outputCtx = this._createOutputContext(_stylesModuleUrl(/** @type {?} */ ((stylesheetMetadata.moduleUrl)), isShimmed, fileSuffix));
- var /** @type {?} */ compiledStylesheet = this._styleCompiler.compileStyles(outputCtx, compMeta, stylesheetMetadata, isShimmed);
- _resolveStyleStatements(this._symbolResolver, compiledStylesheet, isShimmed, fileSuffix);
- return this._codegenSourceModule(srcFileUrl, outputCtx);
- };
- /**
- * @param {?} srcFileUrl
- * @param {?} ctx
- * @return {?}
- */
- AotCompiler.prototype._codegenSourceModule = /**
- * @param {?} srcFileUrl
- * @param {?} ctx
- * @return {?}
- */
- function (srcFileUrl, ctx) {
- return new GeneratedFile(srcFileUrl, ctx.genFilePath, ctx.statements);
- };
- /**
- * @param {?=} entryRoute
- * @param {?=} analyzedModules
- * @return {?}
- */
- AotCompiler.prototype.listLazyRoutes = /**
- * @param {?=} entryRoute
- * @param {?=} analyzedModules
- * @return {?}
- */
- function (entryRoute, analyzedModules) {
- var /** @type {?} */ self = this;
- if (entryRoute) {
- var /** @type {?} */ symbol = parseLazyRoute(entryRoute, this._reflector).referencedModule;
- return visitLazyRoute(symbol);
- }
- else if (analyzedModules) {
- var /** @type {?} */ allLazyRoutes = [];
- for (var _i = 0, _a = analyzedModules.ngModules; _i < _a.length; _i++) {
- var ngModule = _a[_i];
- var /** @type {?} */ lazyRoutes = listLazyRoutes(ngModule, this._reflector);
- for (var _b = 0, lazyRoutes_1 = lazyRoutes; _b < lazyRoutes_1.length; _b++) {
- var lazyRoute = lazyRoutes_1[_b];
- allLazyRoutes.push(lazyRoute);
- }
- }
- return allLazyRoutes;
- }
- else {
- throw new Error("Either route or analyzedModules has to be specified!");
- }
- /**
- * @param {?} symbol
- * @param {?=} seenRoutes
- * @param {?=} allLazyRoutes
- * @return {?}
- */
- function visitLazyRoute(symbol, seenRoutes, allLazyRoutes) {
- if (seenRoutes === void 0) { seenRoutes = new Set(); }
- if (allLazyRoutes === void 0) { allLazyRoutes = []; }
- // Support pointing to default exports, but stop recursing there,
- // as the StaticReflector does not yet support default exports.
- if (seenRoutes.has(symbol) || !symbol.name) {
- return allLazyRoutes;
- }
- seenRoutes.add(symbol);
- var /** @type {?} */ lazyRoutes = listLazyRoutes(/** @type {?} */ ((self._metadataResolver.getNgModuleMetadata(symbol, true))), self._reflector);
- for (var _i = 0, lazyRoutes_2 = lazyRoutes; _i < lazyRoutes_2.length; _i++) {
- var lazyRoute = lazyRoutes_2[_i];
- allLazyRoutes.push(lazyRoute);
- visitLazyRoute(lazyRoute.referencedModule, seenRoutes, allLazyRoutes);
- }
- return allLazyRoutes;
- }
- };
- return AotCompiler;
- }());
- /**
- * @param {?} outputCtx
- * @return {?}
- */
- function _createEmptyStub(outputCtx) {
- // Note: We need to produce at least one import statement so that
- // TypeScript knows that the file is an es6 module. Otherwise our generated
- // exports / imports won't be emitted properly by TypeScript.
- outputCtx.statements.push(importExpr(Identifiers.ComponentFactory).toStmt());
- }
- /**
- * @param {?} symbolResolver
- * @param {?} compileResult
- * @param {?} needsShim
- * @param {?} fileSuffix
- * @return {?}
- */
- function _resolveStyleStatements(symbolResolver, compileResult, needsShim, fileSuffix) {
- compileResult.dependencies.forEach(function (dep) {
- dep.setValue(symbolResolver.getStaticSymbol(_stylesModuleUrl(dep.moduleUrl, needsShim, fileSuffix), dep.name));
- });
- }
- /**
- * @param {?} stylesheetUrl
- * @param {?} shim
- * @param {?} suffix
- * @return {?}
- */
- function _stylesModuleUrl(stylesheetUrl, shim, suffix) {
- return "" + stylesheetUrl + (shim ? '.shim' : '') + ".ngstyle" + suffix;
- }
- /**
- * @record
- */
-
- /**
- * @record
- */
-
- /**
- * @record
- */
-
- /**
- * @param {?} fileNames
- * @param {?} host
- * @param {?} staticSymbolResolver
- * @param {?} metadataResolver
- * @return {?}
- */
- function analyzeNgModules(fileNames, host, staticSymbolResolver, metadataResolver) {
- var /** @type {?} */ files = _analyzeFilesIncludingNonProgramFiles(fileNames, host, staticSymbolResolver, metadataResolver);
- return mergeAnalyzedFiles(files);
- }
- /**
- * @param {?} fileNames
- * @param {?} host
- * @param {?} staticSymbolResolver
- * @param {?} metadataResolver
- * @return {?}
- */
- function analyzeAndValidateNgModules(fileNames, host, staticSymbolResolver, metadataResolver) {
- return validateAnalyzedModules(analyzeNgModules(fileNames, host, staticSymbolResolver, metadataResolver));
- }
- /**
- * @param {?} analyzedModules
- * @return {?}
- */
- function validateAnalyzedModules(analyzedModules) {
- if (analyzedModules.symbolsMissingModule && analyzedModules.symbolsMissingModule.length) {
- var /** @type {?} */ messages = analyzedModules.symbolsMissingModule.map(function (s) {
- return "Cannot determine the module for class " + s.name + " in " + s.filePath + "! Add " + s.name + " to the NgModule to fix it.";
- });
- throw syntaxError(messages.join('\n'));
- }
- return analyzedModules;
- }
- /**
- * @param {?} fileNames
- * @param {?} host
- * @param {?} staticSymbolResolver
- * @param {?} metadataResolver
- * @return {?}
- */
- function _analyzeFilesIncludingNonProgramFiles(fileNames, host, staticSymbolResolver, metadataResolver) {
- var /** @type {?} */ seenFiles = new Set();
- var /** @type {?} */ files = [];
- var /** @type {?} */ visitFile = function (fileName) {
- if (seenFiles.has(fileName) || !host.isSourceFile(fileName)) {
- return false;
- }
- seenFiles.add(fileName);
- var /** @type {?} */ analyzedFile = analyzeFile(host, staticSymbolResolver, metadataResolver, fileName);
- files.push(analyzedFile);
- analyzedFile.ngModules.forEach(function (ngModule) {
- ngModule.transitiveModule.modules.forEach(function (modMeta) { return visitFile(modMeta.reference.filePath); });
- });
- };
- fileNames.forEach(function (fileName) { return visitFile(fileName); });
- return files;
- }
- /**
- * @param {?} host
- * @param {?} staticSymbolResolver
- * @param {?} metadataResolver
- * @param {?} fileName
- * @return {?}
- */
- function analyzeFile(host, staticSymbolResolver, metadataResolver, fileName) {
- var /** @type {?} */ directives = [];
- var /** @type {?} */ pipes = [];
- var /** @type {?} */ injectables = [];
- var /** @type {?} */ ngModules = [];
- var /** @type {?} */ hasDecorators = staticSymbolResolver.hasDecorators(fileName);
- var /** @type {?} */ exportsNonSourceFiles = false;
- // Don't analyze .d.ts files that have no decorators as a shortcut
- // to speed up the analysis. This prevents us from
- // resolving the references in these files.
- // Note: exportsNonSourceFiles is only needed when compiling with summaries,
- // which is not the case when .d.ts files are treated as input files.
- if (!fileName.endsWith('.d.ts') || hasDecorators) {
- staticSymbolResolver.getSymbolsOf(fileName).forEach(function (symbol) {
- var /** @type {?} */ resolvedSymbol = staticSymbolResolver.resolveSymbol(symbol);
- var /** @type {?} */ symbolMeta = resolvedSymbol.metadata;
- if (!symbolMeta || symbolMeta.__symbolic === 'error') {
- return;
- }
- var /** @type {?} */ isNgSymbol = false;
- if (symbolMeta.__symbolic === 'class') {
- if (metadataResolver.isDirective(symbol)) {
- isNgSymbol = true;
- directives.push(symbol);
- }
- else if (metadataResolver.isPipe(symbol)) {
- isNgSymbol = true;
- pipes.push(symbol);
- }
- else if (metadataResolver.isNgModule(symbol)) {
- var /** @type {?} */ ngModule = metadataResolver.getNgModuleMetadata(symbol, false);
- if (ngModule) {
- isNgSymbol = true;
- ngModules.push(ngModule);
- }
- }
- else if (metadataResolver.isInjectable(symbol)) {
- isNgSymbol = true;
- injectables.push(symbol);
- }
- }
- if (!isNgSymbol) {
- exportsNonSourceFiles =
- exportsNonSourceFiles || isValueExportingNonSourceFile(host, symbolMeta);
- }
- });
- }
- return {
- fileName: fileName, directives: directives, pipes: pipes, ngModules: ngModules, injectables: injectables, exportsNonSourceFiles: exportsNonSourceFiles,
- };
- }
- /**
- * @param {?} host
- * @param {?} metadata
- * @return {?}
- */
- function isValueExportingNonSourceFile(host, metadata) {
- var /** @type {?} */ exportsNonSourceFiles = false;
- var Visitor = /** @class */ (function () {
- function Visitor() {
- }
- /**
- * @param {?} arr
- * @param {?} context
- * @return {?}
- */
- Visitor.prototype.visitArray = /**
- * @param {?} arr
- * @param {?} context
- * @return {?}
- */
- function (arr, context) {
- var _this = this;
- arr.forEach(function (v) { return visitValue(v, _this, context); });
- };
- /**
- * @param {?} map
- * @param {?} context
- * @return {?}
- */
- Visitor.prototype.visitStringMap = /**
- * @param {?} map
- * @param {?} context
- * @return {?}
- */
- function (map, context) {
- var _this = this;
- Object.keys(map).forEach(function (key) { return visitValue(map[key], _this, context); });
- };
- /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- Visitor.prototype.visitPrimitive = /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- function (value, context) { };
- /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- Visitor.prototype.visitOther = /**
- * @param {?} value
- * @param {?} context
- * @return {?}
- */
- function (value, context) {
- if (value instanceof StaticSymbol && !host.isSourceFile(value.filePath)) {
- exportsNonSourceFiles = true;
- }
- };
- return Visitor;
- }());
- visitValue(metadata, new Visitor(), null);
- return exportsNonSourceFiles;
- }
- /**
- * @param {?} analyzedFiles
- * @return {?}
- */
- function mergeAnalyzedFiles(analyzedFiles) {
- var /** @type {?} */ allNgModules = [];
- var /** @type {?} */ ngModuleByPipeOrDirective = new Map();
- var /** @type {?} */ allPipesAndDirectives = new Set();
- analyzedFiles.forEach(function (af) {
- af.ngModules.forEach(function (ngModule) {
- allNgModules.push(ngModule);
- ngModule.declaredDirectives.forEach(function (d) { return ngModuleByPipeOrDirective.set(d.reference, ngModule); });
- ngModule.declaredPipes.forEach(function (p) { return ngModuleByPipeOrDirective.set(p.reference, ngModule); });
- });
- af.directives.forEach(function (d) { return allPipesAndDirectives.add(d); });
- af.pipes.forEach(function (p) { return allPipesAndDirectives.add(p); });
- });
- var /** @type {?} */ symbolsMissingModule = [];
- allPipesAndDirectives.forEach(function (ref) {
- if (!ngModuleByPipeOrDirective.has(ref)) {
- symbolsMissingModule.push(ref);
- }
- });
- return {
- ngModules: allNgModules,
- ngModuleByPipeOrDirective: ngModuleByPipeOrDirective,
- symbolsMissingModule: symbolsMissingModule,
- files: analyzedFiles
- };
- }
- /**
- * @param {?} files
- * @return {?}
- */
- function mergeAndValidateNgFiles(files) {
- return validateAnalyzedModules(mergeAnalyzedFiles(files));
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @record
- */
-
- /**
- * @record
- */
-
- var FORMATTED_MESSAGE = 'ngFormattedMessage';
- /**
- * @param {?} level
- * @return {?}
- */
- function indentStr(level) {
- if (level <= 0)
- return '';
- if (level < 6)
- return ['', ' ', ' ', ' ', ' ', ' '][level];
- var /** @type {?} */ half = indentStr(Math.floor(level / 2));
- return half + half + (level % 2 === 1 ? ' ' : '');
- }
- /**
- * @param {?} chain
- * @param {?=} indent
- * @return {?}
- */
- function formatChain(chain, indent) {
- if (indent === void 0) { indent = 0; }
- if (!chain)
- return '';
- var /** @type {?} */ position = chain.position ?
- chain.position.fileName + "(" + (chain.position.line + 1) + "," + (chain.position.column + 1) + ")" :
- '';
- var /** @type {?} */ prefix = position && indent === 0 ? position + ": " : '';
- var /** @type {?} */ postfix = position && indent !== 0 ? " at " + position : '';
- var /** @type {?} */ message = "" + prefix + chain.message + postfix;
- return "" + indentStr(indent) + message + ((chain.next && ('\n' + formatChain(chain.next, indent + 2))) || '');
- }
- /**
- * @param {?} chain
- * @return {?}
- */
- function formattedError(chain) {
- var /** @type {?} */ message = formatChain(chain) + '.';
- var /** @type {?} */ error = /** @type {?} */ (syntaxError(message));
- (/** @type {?} */ (error))[FORMATTED_MESSAGE] = true;
- error.chain = chain;
- error.position = chain.position;
- return error;
- }
- /**
- * @param {?} error
- * @return {?}
- */
- function isFormattedError(error) {
- return !!(/** @type {?} */ (error))[FORMATTED_MESSAGE];
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var ANGULAR_CORE = '@angular/core';
- var ANGULAR_ROUTER = '@angular/router';
- var HIDDEN_KEY = /^\$.*\$$/;
- var IGNORE = {
- __symbolic: 'ignore'
- };
- var USE_VALUE = 'useValue';
- var PROVIDE = 'provide';
- var REFERENCE_SET = new Set([USE_VALUE, 'useFactory', 'data']);
- var TYPEGUARD_POSTFIX = 'TypeGuard';
- var USE_IF = 'UseIf';
- /**
- * @param {?} value
- * @return {?}
- */
- function shouldIgnore(value) {
- return value && value.__symbolic == 'ignore';
- }
- /**
- * A static reflector implements enough of the Reflector API that is necessary to compile
- * templates statically.
- */
- var StaticReflector = /** @class */ (function () {
- function StaticReflector(summaryResolver, symbolResolver, knownMetadataClasses, knownMetadataFunctions, errorRecorder) {
- if (knownMetadataClasses === void 0) { knownMetadataClasses = []; }
- if (knownMetadataFunctions === void 0) { knownMetadataFunctions = []; }
- var _this = this;
- this.summaryResolver = summaryResolver;
- this.symbolResolver = symbolResolver;
- this.errorRecorder = errorRecorder;
- this.annotationCache = new Map();
- this.propertyCache = new Map();
- this.parameterCache = new Map();
- this.methodCache = new Map();
- this.staticCache = new Map();
- this.conversionMap = new Map();
- this.resolvedExternalReferences = new Map();
- this.annotationForParentClassWithSummaryKind = new Map();
- this.initializeConversionMap();
- knownMetadataClasses.forEach(function (kc) {
- return _this._registerDecoratorOrConstructor(_this.getStaticSymbol(kc.filePath, kc.name), kc.ctor);
- });
- knownMetadataFunctions.forEach(function (kf) { return _this._registerFunction(_this.getStaticSymbol(kf.filePath, kf.name), kf.fn); });
- this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.Directive, [createDirective, createComponent]);
- this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.Pipe, [createPipe]);
- this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.NgModule, [createNgModule]);
- this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.Injectable, [createInjectable, createPipe, createDirective, createComponent, createNgModule]);
- }
- /**
- * @param {?} typeOrFunc
- * @return {?}
- */
- StaticReflector.prototype.componentModuleUrl = /**
- * @param {?} typeOrFunc
- * @return {?}
- */
- function (typeOrFunc) {
- var /** @type {?} */ staticSymbol = this.findSymbolDeclaration(typeOrFunc);
- return this.symbolResolver.getResourcePath(staticSymbol);
- };
- /**
- * @param {?} ref
- * @param {?=} containingFile
- * @return {?}
- */
- StaticReflector.prototype.resolveExternalReference = /**
- * @param {?} ref
- * @param {?=} containingFile
- * @return {?}
- */
- function (ref, containingFile) {
- var /** @type {?} */ key = undefined;
- if (!containingFile) {
- key = ref.moduleName + ":" + ref.name;
- var /** @type {?} */ declarationSymbol_1 = this.resolvedExternalReferences.get(key);
- if (declarationSymbol_1)
- return declarationSymbol_1;
- }
- var /** @type {?} */ refSymbol = this.symbolResolver.getSymbolByModule(/** @type {?} */ ((ref.moduleName)), /** @type {?} */ ((ref.name)), containingFile);
- var /** @type {?} */ declarationSymbol = this.findSymbolDeclaration(refSymbol);
- if (!containingFile) {
- this.symbolResolver.recordModuleNameForFileName(refSymbol.filePath, /** @type {?} */ ((ref.moduleName)));
- this.symbolResolver.recordImportAs(declarationSymbol, refSymbol);
- }
- if (key) {
- this.resolvedExternalReferences.set(key, declarationSymbol);
- }
- return declarationSymbol;
- };
- /**
- * @param {?} moduleUrl
- * @param {?} name
- * @param {?=} containingFile
- * @return {?}
- */
- StaticReflector.prototype.findDeclaration = /**
- * @param {?} moduleUrl
- * @param {?} name
- * @param {?=} containingFile
- * @return {?}
- */
- function (moduleUrl, name, containingFile) {
- return this.findSymbolDeclaration(this.symbolResolver.getSymbolByModule(moduleUrl, name, containingFile));
- };
- /**
- * @param {?} moduleUrl
- * @param {?} name
- * @return {?}
- */
- StaticReflector.prototype.tryFindDeclaration = /**
- * @param {?} moduleUrl
- * @param {?} name
- * @return {?}
- */
- function (moduleUrl, name) {
- var _this = this;
- return this.symbolResolver.ignoreErrorsFor(function () { return _this.findDeclaration(moduleUrl, name); });
- };
- /**
- * @param {?} symbol
- * @return {?}
- */
- StaticReflector.prototype.findSymbolDeclaration = /**
- * @param {?} symbol
- * @return {?}
- */
- function (symbol) {
- var /** @type {?} */ resolvedSymbol = this.symbolResolver.resolveSymbol(symbol);
- if (resolvedSymbol) {
- var /** @type {?} */ resolvedMetadata = resolvedSymbol.metadata;
- if (resolvedMetadata && resolvedMetadata.__symbolic === 'resolved') {
- resolvedMetadata = resolvedMetadata.symbol;
- }
- if (resolvedMetadata instanceof StaticSymbol) {
- return this.findSymbolDeclaration(resolvedSymbol.metadata);
- }
- }
- return symbol;
- };
- /**
- * @param {?} type
- * @return {?}
- */
- StaticReflector.prototype.annotations = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- var /** @type {?} */ annotations = this.annotationCache.get(type);
- if (!annotations) {
- annotations = [];
- var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
- var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
- if (parentType) {
- var /** @type {?} */ parentAnnotations = this.annotations(parentType);
- annotations.push.apply(annotations, parentAnnotations);
- }
- var /** @type {?} */ ownAnnotations_1 = [];
- if (classMetadata['decorators']) {
- ownAnnotations_1 = this.simplify(type, classMetadata['decorators']);
- annotations.push.apply(annotations, ownAnnotations_1);
- }
- if (parentType && !this.summaryResolver.isLibraryFile(type.filePath) &&
- this.summaryResolver.isLibraryFile(parentType.filePath)) {
- var /** @type {?} */ summary = this.summaryResolver.resolveSummary(parentType);
- if (summary && summary.type) {
- var /** @type {?} */ requiredAnnotationTypes = /** @type {?} */ ((this.annotationForParentClassWithSummaryKind.get(/** @type {?} */ ((summary.type.summaryKind)))));
- var /** @type {?} */ typeHasRequiredAnnotation = requiredAnnotationTypes.some(function (requiredType) { return ownAnnotations_1.some(function (ann) { return requiredType.isTypeOf(ann); }); });
- if (!typeHasRequiredAnnotation) {
- this.reportError(formatMetadataError(metadataError("Class " + type.name + " in " + type.filePath + " extends from a " + CompileSummaryKind[(/** @type {?} */ ((summary.type.summaryKind)))] + " in another compilation unit without duplicating the decorator", undefined, "Please add a " + requiredAnnotationTypes.map(function (type) { return type.ngMetadataName; }).join(' or ') + " decorator to the class"), type), type);
- }
- }
- }
- this.annotationCache.set(type, annotations.filter(function (ann) { return !!ann; }));
- }
- return annotations;
- };
- /**
- * @param {?} type
- * @return {?}
- */
- StaticReflector.prototype.propMetadata = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- var _this = this;
- var /** @type {?} */ propMetadata = this.propertyCache.get(type);
- if (!propMetadata) {
- var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
- propMetadata = {};
- var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
- if (parentType) {
- var /** @type {?} */ parentPropMetadata_1 = this.propMetadata(parentType);
- Object.keys(parentPropMetadata_1).forEach(function (parentProp) {
- /** @type {?} */ ((propMetadata))[parentProp] = parentPropMetadata_1[parentProp];
- });
- }
- var /** @type {?} */ members_1 = classMetadata['members'] || {};
- Object.keys(members_1).forEach(function (propName) {
- var /** @type {?} */ propData = members_1[propName];
- var /** @type {?} */ prop = (/** @type {?} */ (propData))
- .find(function (a) { return a['__symbolic'] == 'property' || a['__symbolic'] == 'method'; });
- var /** @type {?} */ decorators = [];
- if (/** @type {?} */ ((propMetadata))[propName]) {
- decorators.push.apply(decorators, /** @type {?} */ ((propMetadata))[propName]);
- } /** @type {?} */
- ((propMetadata))[propName] = decorators;
- if (prop && prop['decorators']) {
- decorators.push.apply(decorators, _this.simplify(type, prop['decorators']));
- }
- });
- this.propertyCache.set(type, propMetadata);
- }
- return propMetadata;
- };
- /**
- * @param {?} type
- * @return {?}
- */
- StaticReflector.prototype.parameters = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- var _this = this;
- if (!(type instanceof StaticSymbol)) {
- this.reportError(new Error("parameters received " + JSON.stringify(type) + " which is not a StaticSymbol"), type);
- return [];
- }
- try {
- var /** @type {?} */ parameters_1 = this.parameterCache.get(type);
- if (!parameters_1) {
- var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
- var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
- var /** @type {?} */ members = classMetadata ? classMetadata['members'] : null;
- var /** @type {?} */ ctorData = members ? members['__ctor__'] : null;
- if (ctorData) {
- var /** @type {?} */ ctor = (/** @type {?} */ (ctorData)).find(function (a) { return a['__symbolic'] == 'constructor'; });
- var /** @type {?} */ rawParameterTypes = /** @type {?} */ (ctor['parameters']) || [];
- var /** @type {?} */ parameterDecorators_1 = /** @type {?} */ (this.simplify(type, ctor['parameterDecorators'] || []));
- parameters_1 = [];
- rawParameterTypes.forEach(function (rawParamType, index) {
- var /** @type {?} */ nestedResult = [];
- var /** @type {?} */ paramType = _this.trySimplify(type, rawParamType);
- if (paramType)
- nestedResult.push(paramType);
- var /** @type {?} */ decorators = parameterDecorators_1 ? parameterDecorators_1[index] : null;
- if (decorators) {
- nestedResult.push.apply(nestedResult, decorators);
- } /** @type {?} */
- ((parameters_1)).push(nestedResult);
- });
- }
- else if (parentType) {
- parameters_1 = this.parameters(parentType);
- }
- if (!parameters_1) {
- parameters_1 = [];
- }
- this.parameterCache.set(type, parameters_1);
- }
- return parameters_1;
- }
- catch (/** @type {?} */ e) {
- console.error("Failed on type " + JSON.stringify(type) + " with error " + e);
- throw e;
- }
- };
- /**
- * @param {?} type
- * @return {?}
- */
- StaticReflector.prototype._methodNames = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- var /** @type {?} */ methodNames = this.methodCache.get(type);
- if (!methodNames) {
- var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
- methodNames = {};
- var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
- if (parentType) {
- var /** @type {?} */ parentMethodNames_1 = this._methodNames(parentType);
- Object.keys(parentMethodNames_1).forEach(function (parentProp) {
- /** @type {?} */ ((methodNames))[parentProp] = parentMethodNames_1[parentProp];
- });
- }
- var /** @type {?} */ members_2 = classMetadata['members'] || {};
- Object.keys(members_2).forEach(function (propName) {
- var /** @type {?} */ propData = members_2[propName];
- var /** @type {?} */ isMethod = (/** @type {?} */ (propData)).some(function (a) { return a['__symbolic'] == 'method'; }); /** @type {?} */
- ((methodNames))[propName] = /** @type {?} */ ((methodNames))[propName] || isMethod;
- });
- this.methodCache.set(type, methodNames);
- }
- return methodNames;
- };
- /**
- * @param {?} type
- * @return {?}
- */
- StaticReflector.prototype._staticMembers = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- var /** @type {?} */ staticMembers = this.staticCache.get(type);
- if (!staticMembers) {
- var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
- var /** @type {?} */ staticMemberData = classMetadata['statics'] || {};
- staticMembers = Object.keys(staticMemberData);
- this.staticCache.set(type, staticMembers);
- }
- return staticMembers;
- };
- /**
- * @param {?} type
- * @param {?} classMetadata
- * @return {?}
- */
- StaticReflector.prototype.findParentType = /**
- * @param {?} type
- * @param {?} classMetadata
- * @return {?}
- */
- function (type, classMetadata) {
- var /** @type {?} */ parentType = this.trySimplify(type, classMetadata['extends']);
- if (parentType instanceof StaticSymbol) {
- return parentType;
- }
- };
- /**
- * @param {?} type
- * @param {?} lcProperty
- * @return {?}
- */
- StaticReflector.prototype.hasLifecycleHook = /**
- * @param {?} type
- * @param {?} lcProperty
- * @return {?}
- */
- function (type, lcProperty) {
- if (!(type instanceof StaticSymbol)) {
- this.reportError(new Error("hasLifecycleHook received " + JSON.stringify(type) + " which is not a StaticSymbol"), type);
- }
- try {
- return !!this._methodNames(type)[lcProperty];
- }
- catch (/** @type {?} */ e) {
- console.error("Failed on type " + JSON.stringify(type) + " with error " + e);
- throw e;
- }
- };
- /**
- * @param {?} type
- * @return {?}
- */
- StaticReflector.prototype.guards = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- if (!(type instanceof StaticSymbol)) {
- this.reportError(new Error("guards received " + JSON.stringify(type) + " which is not a StaticSymbol"), type);
- return {};
- }
- var /** @type {?} */ staticMembers = this._staticMembers(type);
- var /** @type {?} */ result = {};
- for (var _i = 0, staticMembers_1 = staticMembers; _i < staticMembers_1.length; _i++) {
- var name_1 = staticMembers_1[_i];
- if (name_1.endsWith(TYPEGUARD_POSTFIX)) {
- var /** @type {?} */ property = name_1.substr(0, name_1.length - TYPEGUARD_POSTFIX.length);
- var /** @type {?} */ value = void 0;
- if (property.endsWith(USE_IF)) {
- property = name_1.substr(0, property.length - USE_IF.length);
- value = USE_IF;
- }
- else {
- value = this.getStaticSymbol(type.filePath, type.name, [name_1]);
- }
- result[property] = value;
- }
- }
- return result;
- };
- /**
- * @param {?} type
- * @param {?} ctor
- * @return {?}
- */
- StaticReflector.prototype._registerDecoratorOrConstructor = /**
- * @param {?} type
- * @param {?} ctor
- * @return {?}
- */
- function (type, ctor) {
- this.conversionMap.set(type, function (context, args) { return new (ctor.bind.apply(ctor, [void 0].concat(args)))(); });
- };
- /**
- * @param {?} type
- * @param {?} fn
- * @return {?}
- */
- StaticReflector.prototype._registerFunction = /**
- * @param {?} type
- * @param {?} fn
- * @return {?}
- */
- function (type, fn) {
- this.conversionMap.set(type, function (context, args) { return fn.apply(undefined, args); });
- };
- /**
- * @return {?}
- */
- StaticReflector.prototype.initializeConversionMap = /**
- * @return {?}
- */
- function () {
- this.injectionToken = this.findDeclaration(ANGULAR_CORE, 'InjectionToken');
- this.opaqueToken = this.findDeclaration(ANGULAR_CORE, 'OpaqueToken');
- this.ROUTES = this.tryFindDeclaration(ANGULAR_ROUTER, 'ROUTES');
- this.ANALYZE_FOR_ENTRY_COMPONENTS =
- this.findDeclaration(ANGULAR_CORE, 'ANALYZE_FOR_ENTRY_COMPONENTS');
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Host'), createHost);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Injectable'), createInjectable);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Self'), createSelf);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'SkipSelf'), createSkipSelf);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Inject'), createInject);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Optional'), createOptional);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Attribute'), createAttribute);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ContentChild'), createContentChild);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ContentChildren'), createContentChildren);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ViewChild'), createViewChild);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ViewChildren'), createViewChildren);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Input'), createInput);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Output'), createOutput);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Pipe'), createPipe);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'HostBinding'), createHostBinding);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'HostListener'), createHostListener);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Directive'), createDirective);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Component'), createComponent);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'NgModule'), createNgModule);
- // Note: Some metadata classes can be used directly with Provider.deps.
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Host'), createHost);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Self'), createSelf);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'SkipSelf'), createSkipSelf);
- this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Optional'), createOptional);
- };
- /**
- * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
- * All types passed to the StaticResolver should be pseudo-types returned by this method.
- *
- * @param declarationFile the absolute path of the file where the symbol is declared
- * @param name the name of the type.
- */
- /**
- * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
- * All types passed to the StaticResolver should be pseudo-types returned by this method.
- *
- * @param {?} declarationFile the absolute path of the file where the symbol is declared
- * @param {?} name the name of the type.
- * @param {?=} members
- * @return {?}
- */
- StaticReflector.prototype.getStaticSymbol = /**
- * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
- * All types passed to the StaticResolver should be pseudo-types returned by this method.
- *
- * @param {?} declarationFile the absolute path of the file where the symbol is declared
- * @param {?} name the name of the type.
- * @param {?=} members
- * @return {?}
- */
- function (declarationFile, name, members) {
- return this.symbolResolver.getStaticSymbol(declarationFile, name, members);
- };
- /**
- * Simplify but discard any errors
- * @param {?} context
- * @param {?} value
- * @return {?}
- */
- StaticReflector.prototype.trySimplify = /**
- * Simplify but discard any errors
- * @param {?} context
- * @param {?} value
- * @return {?}
- */
- function (context, value) {
- var /** @type {?} */ originalRecorder = this.errorRecorder;
- this.errorRecorder = function (error, fileName) { };
- var /** @type {?} */ result = this.simplify(context, value);
- this.errorRecorder = originalRecorder;
- return result;
- };
- /**
- * \@internal
- * @param {?} context
- * @param {?} value
- * @return {?}
- */
- StaticReflector.prototype.simplify = /**
- * \@internal
- * @param {?} context
- * @param {?} value
- * @return {?}
- */
- function (context, value) {
- var /** @type {?} */ self = this;
- var /** @type {?} */ scope = BindingScope.empty;
- var /** @type {?} */ calling = new Map();
- var /** @type {?} */ rootContext = context;
- /**
- * @param {?} context
- * @param {?} value
- * @param {?} depth
- * @param {?} references
- * @return {?}
- */
- function simplifyInContext(context, value, depth, references) {
- /**
- * @param {?} staticSymbol
- * @return {?}
- */
- function resolveReferenceValue(staticSymbol) {
- var /** @type {?} */ resolvedSymbol = self.symbolResolver.resolveSymbol(staticSymbol);
- return resolvedSymbol ? resolvedSymbol.metadata : null;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- function simplifyEagerly(value) {
- return simplifyInContext(context, value, depth, 0);
- }
- /**
- * @param {?} value
- * @return {?}
- */
- function simplifyLazily(value) {
- return simplifyInContext(context, value, depth, references + 1);
- }
- /**
- * @param {?} nestedContext
- * @param {?} value
- * @return {?}
- */
- function simplifyNested(nestedContext, value) {
- if (nestedContext === context) {
- // If the context hasn't changed let the exception propagate unmodified.
- return simplifyInContext(nestedContext, value, depth + 1, references);
- }
- try {
- return simplifyInContext(nestedContext, value, depth + 1, references);
- }
- catch (/** @type {?} */ e) {
- if (isMetadataError(e)) {
- // Propagate the message text up but add a message to the chain that explains how we got
- // here.
- // e.chain implies e.symbol
- var /** @type {?} */ summaryMsg = e.chain ? 'references \'' + /** @type {?} */ ((e.symbol)).name + '\'' : errorSummary(e);
- var /** @type {?} */ summary = "'" + nestedContext.name + "' " + summaryMsg;
- var /** @type {?} */ chain = { message: summary, position: e.position, next: e.chain };
- // TODO(chuckj): retrieve the position information indirectly from the collectors node
- // map if the metadata is from a .ts file.
- self.error({
- message: e.message,
- advise: e.advise,
- context: e.context, chain: chain,
- symbol: nestedContext
- }, context);
- }
- else {
- // It is probably an internal error.
- throw e;
- }
- }
- }
- /**
- * @param {?} functionSymbol
- * @param {?} targetFunction
- * @param {?} args
- * @param {?} targetExpression
- * @return {?}
- */
- function simplifyCall(functionSymbol, targetFunction, args, targetExpression) {
- if (targetFunction && targetFunction['__symbolic'] == 'function') {
- if (calling.get(functionSymbol)) {
- self.error({
- message: 'Recursion is not supported',
- summary: "called '" + functionSymbol.name + "' recursively",
- value: targetFunction
- }, functionSymbol);
- }
- try {
- var /** @type {?} */ value_1 = targetFunction['value'];
- if (value_1 && (depth != 0 || value_1.__symbolic != 'error')) {
- var /** @type {?} */ parameters = targetFunction['parameters'];
- var /** @type {?} */ defaults = targetFunction.defaults;
- args = args.map(function (arg) { return simplifyNested(context, arg); })
- .map(function (arg) { return shouldIgnore(arg) ? undefined : arg; });
- if (defaults && defaults.length > args.length) {
- args.push.apply(args, defaults.slice(args.length).map(function (value) { return simplify(value); }));
- }
- calling.set(functionSymbol, true);
- var /** @type {?} */ functionScope = BindingScope.build();
- for (var /** @type {?} */ i = 0; i < parameters.length; i++) {
- functionScope.define(parameters[i], args[i]);
- }
- var /** @type {?} */ oldScope = scope;
- var /** @type {?} */ result_1;
- try {
- scope = functionScope.done();
- result_1 = simplifyNested(functionSymbol, value_1);
- }
- finally {
- scope = oldScope;
- }
- return result_1;
- }
- }
- finally {
- calling.delete(functionSymbol);
- }
- }
- if (depth === 0) {
- // If depth is 0 we are evaluating the top level expression that is describing element
- // decorator. In this case, it is a decorator we don't understand, such as a custom
- // non-angular decorator, and we should just ignore it.
- return IGNORE;
- }
- var /** @type {?} */ position = undefined;
- if (targetExpression && targetExpression.__symbolic == 'resolved') {
- var /** @type {?} */ line = targetExpression.line;
- var /** @type {?} */ character = targetExpression.character;
- var /** @type {?} */ fileName = targetExpression.fileName;
- if (fileName != null && line != null && character != null) {
- position = { fileName: fileName, line: line, column: character };
- }
- }
- self.error({
- message: FUNCTION_CALL_NOT_SUPPORTED,
- context: functionSymbol,
- value: targetFunction, position: position
- }, context);
- }
- /**
- * @param {?} expression
- * @return {?}
- */
- function simplify(expression) {
- if (isPrimitive(expression)) {
- return expression;
- }
- if (expression instanceof Array) {
- var /** @type {?} */ result_2 = [];
- for (var _i = 0, _a = (/** @type {?} */ (expression)); _i < _a.length; _i++) {
- var item = _a[_i];
- // Check for a spread expression
- if (item && item.__symbolic === 'spread') {
- // We call with references as 0 because we require the actual value and cannot
- // tolerate a reference here.
- var /** @type {?} */ spreadArray = simplifyEagerly(item.expression);
- if (Array.isArray(spreadArray)) {
- for (var _b = 0, spreadArray_1 = spreadArray; _b < spreadArray_1.length; _b++) {
- var spreadItem = spreadArray_1[_b];
- result_2.push(spreadItem);
- }
- continue;
- }
- }
- var /** @type {?} */ value_2 = simplify(item);
- if (shouldIgnore(value_2)) {
- continue;
- }
- result_2.push(value_2);
- }
- return result_2;
- }
- if (expression instanceof StaticSymbol) {
- // Stop simplification at builtin symbols or if we are in a reference context and
- // the symbol doesn't have members.
- if (expression === self.injectionToken || self.conversionMap.has(expression) ||
- (references > 0 && !expression.members.length)) {
- return expression;
- }
- else {
- var /** @type {?} */ staticSymbol = expression;
- var /** @type {?} */ declarationValue = resolveReferenceValue(staticSymbol);
- if (declarationValue != null) {
- return simplifyNested(staticSymbol, declarationValue);
- }
- else {
- return staticSymbol;
- }
- }
- }
- if (expression) {
- if (expression['__symbolic']) {
- var /** @type {?} */ staticSymbol = void 0;
- switch (expression['__symbolic']) {
- case 'binop':
- var /** @type {?} */ left = simplify(expression['left']);
- if (shouldIgnore(left))
- return left;
- var /** @type {?} */ right = simplify(expression['right']);
- if (shouldIgnore(right))
- return right;
- switch (expression['operator']) {
- case '&&':
- return left && right;
- case '||':
- return left || right;
- case '|':
- return left | right;
- case '^':
- return left ^ right;
- case '&':
- return left & right;
- case '==':
- return left == right;
- case '!=':
- return left != right;
- case '===':
- return left === right;
- case '!==':
- return left !== right;
- case '<':
- return left < right;
- case '>':
- return left > right;
- case '<=':
- return left <= right;
- case '>=':
- return left >= right;
- case '<<':
- return left << right;
- case '>>':
- return left >> right;
- case '+':
- return left + right;
- case '-':
- return left - right;
- case '*':
- return left * right;
- case '/':
- return left / right;
- case '%':
- return left % right;
- }
- return null;
- case 'if':
- var /** @type {?} */ condition = simplify(expression['condition']);
- return condition ? simplify(expression['thenExpression']) :
- simplify(expression['elseExpression']);
- case 'pre':
- var /** @type {?} */ operand = simplify(expression['operand']);
- if (shouldIgnore(operand))
- return operand;
- switch (expression['operator']) {
- case '+':
- return operand;
- case '-':
- return -operand;
- case '!':
- return !operand;
- case '~':
- return ~operand;
- }
- return null;
- case 'index':
- var /** @type {?} */ indexTarget = simplifyEagerly(expression['expression']);
- var /** @type {?} */ index = simplifyEagerly(expression['index']);
- if (indexTarget && isPrimitive(index))
- return indexTarget[index];
- return null;
- case 'select':
- var /** @type {?} */ member = expression['member'];
- var /** @type {?} */ selectContext = context;
- var /** @type {?} */ selectTarget = simplify(expression['expression']);
- if (selectTarget instanceof StaticSymbol) {
- var /** @type {?} */ members = selectTarget.members.concat(member);
- selectContext =
- self.getStaticSymbol(selectTarget.filePath, selectTarget.name, members);
- var /** @type {?} */ declarationValue = resolveReferenceValue(selectContext);
- if (declarationValue != null) {
- return simplifyNested(selectContext, declarationValue);
- }
- else {
- return selectContext;
- }
- }
- if (selectTarget && isPrimitive(member))
- return simplifyNested(selectContext, selectTarget[member]);
- return null;
- case 'reference':
- // Note: This only has to deal with variable references, as symbol references have
- // been converted into 'resolved'
- // in the StaticSymbolResolver.
- var /** @type {?} */ name_2 = expression['name'];
- var /** @type {?} */ localValue = scope.resolve(name_2);
- if (localValue != BindingScope.missing) {
- return localValue;
- }
- break;
- case 'resolved':
- try {
- return simplify(expression.symbol);
- }
- catch (/** @type {?} */ e) {
- // If an error is reported evaluating the symbol record the position of the
- // reference in the error so it can
- // be reported in the error message generated from the exception.
- if (isMetadataError(e) && expression.fileName != null &&
- expression.line != null && expression.character != null) {
- e.position = {
- fileName: expression.fileName,
- line: expression.line,
- column: expression.character
- };
- }
- throw e;
- }
- case 'class':
- return context;
- case 'function':
- return context;
- case 'new':
- case 'call':
- // Determine if the function is a built-in conversion
- staticSymbol = simplifyInContext(context, expression['expression'], depth + 1, /* references */ 0);
- if (staticSymbol instanceof StaticSymbol) {
- if (staticSymbol === self.injectionToken || staticSymbol === self.opaqueToken) {
- // if somebody calls new InjectionToken, don't create an InjectionToken,
- // but rather return the symbol to which the InjectionToken is assigned to.
- // OpaqueToken is supported too as it is required by the language service to
- // support v4 and prior versions of Angular.
- return context;
- }
- var /** @type {?} */ argExpressions = expression['arguments'] || [];
- var /** @type {?} */ converter = self.conversionMap.get(staticSymbol);
- if (converter) {
- var /** @type {?} */ args = argExpressions.map(function (arg) { return simplifyNested(context, arg); })
- .map(function (arg) { return shouldIgnore(arg) ? undefined : arg; });
- return converter(context, args);
- }
- else {
- // Determine if the function is one we can simplify.
- var /** @type {?} */ targetFunction = resolveReferenceValue(staticSymbol);
- return simplifyCall(staticSymbol, targetFunction, argExpressions, expression['expression']);
- }
- }
- return IGNORE;
- case 'error':
- var /** @type {?} */ message = expression.message;
- if (expression['line'] != null) {
- self.error({
- message: message,
- context: expression.context,
- value: expression,
- position: {
- fileName: expression['fileName'],
- line: expression['line'],
- column: expression['character']
- }
- }, context);
- }
- else {
- self.error({ message: message, context: expression.context }, context);
- }
- return IGNORE;
- case 'ignore':
- return expression;
- }
- return null;
- }
- return mapStringMap(expression, function (value, name) {
- if (REFERENCE_SET.has(name)) {
- if (name === USE_VALUE && PROVIDE in expression) {
- // If this is a provider expression, check for special tokens that need the value
- // during analysis.
- var /** @type {?} */ provide = simplify(expression.provide);
- if (provide === self.ROUTES || provide == self.ANALYZE_FOR_ENTRY_COMPONENTS) {
- return simplify(value);
- }
- }
- return simplifyLazily(value);
- }
- return simplify(value);
- });
- }
- return IGNORE;
- }
- return simplify(value);
- }
- var /** @type {?} */ result;
- try {
- result = simplifyInContext(context, value, 0, 0);
- }
- catch (/** @type {?} */ e) {
- if (this.errorRecorder) {
- this.reportError(e, context);
- }
- else {
- throw formatMetadataError(e, context);
- }
- }
- if (shouldIgnore(result)) {
- return undefined;
- }
- return result;
- };
- /**
- * @param {?} type
- * @return {?}
- */
- StaticReflector.prototype.getTypeMetadata = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- var /** @type {?} */ resolvedSymbol = this.symbolResolver.resolveSymbol(type);
- return resolvedSymbol && resolvedSymbol.metadata ? resolvedSymbol.metadata :
- { __symbolic: 'class' };
- };
- /**
- * @param {?} error
- * @param {?} context
- * @param {?=} path
- * @return {?}
- */
- StaticReflector.prototype.reportError = /**
- * @param {?} error
- * @param {?} context
- * @param {?=} path
- * @return {?}
- */
- function (error, context, path) {
- if (this.errorRecorder) {
- this.errorRecorder(formatMetadataError(error, context), (context && context.filePath) || path);
- }
- else {
- throw error;
- }
- };
- /**
- * @param {?} __0
- * @param {?} reportingContext
- * @return {?}
- */
- StaticReflector.prototype.error = /**
- * @param {?} __0
- * @param {?} reportingContext
- * @return {?}
- */
- function (_a, reportingContext) {
- var message = _a.message, summary = _a.summary, advise = _a.advise, position = _a.position, context = _a.context, value = _a.value, symbol = _a.symbol, chain = _a.chain;
- this.reportError(metadataError(message, summary, advise, position, symbol, context, chain), reportingContext);
- };
- return StaticReflector;
- }());
- var METADATA_ERROR = 'ngMetadataError';
- /**
- * @param {?} message
- * @param {?=} summary
- * @param {?=} advise
- * @param {?=} position
- * @param {?=} symbol
- * @param {?=} context
- * @param {?=} chain
- * @return {?}
- */
- function metadataError(message, summary, advise, position, symbol, context, chain) {
- var /** @type {?} */ error = /** @type {?} */ (syntaxError(message));
- (/** @type {?} */ (error))[METADATA_ERROR] = true;
- if (advise)
- error.advise = advise;
- if (position)
- error.position = position;
- if (summary)
- error.summary = summary;
- if (context)
- error.context = context;
- if (chain)
- error.chain = chain;
- if (symbol)
- error.symbol = symbol;
- return error;
- }
- /**
- * @param {?} error
- * @return {?}
- */
- function isMetadataError(error) {
- return !!(/** @type {?} */ (error))[METADATA_ERROR];
- }
- var REFERENCE_TO_NONEXPORTED_CLASS = 'Reference to non-exported class';
- var VARIABLE_NOT_INITIALIZED = 'Variable not initialized';
- var DESTRUCTURE_NOT_SUPPORTED = 'Destructuring not supported';
- var COULD_NOT_RESOLVE_TYPE = 'Could not resolve type';
- var FUNCTION_CALL_NOT_SUPPORTED = 'Function call not supported';
- var REFERENCE_TO_LOCAL_SYMBOL = 'Reference to a local symbol';
- var LAMBDA_NOT_SUPPORTED = 'Lambda not supported';
- /**
- * @param {?} message
- * @param {?} context
- * @return {?}
- */
- function expandedMessage(message, context) {
- switch (message) {
- case REFERENCE_TO_NONEXPORTED_CLASS:
- if (context && context.className) {
- return "References to a non-exported class are not supported in decorators but " + context.className + " was referenced.";
- }
- break;
- case VARIABLE_NOT_INITIALIZED:
- return 'Only initialized variables and constants can be referenced in decorators because the value of this variable is needed by the template compiler';
- case DESTRUCTURE_NOT_SUPPORTED:
- return 'Referencing an exported destructured variable or constant is not supported in decorators and this value is needed by the template compiler';
- case COULD_NOT_RESOLVE_TYPE:
- if (context && context.typeName) {
- return "Could not resolve type " + context.typeName;
- }
- break;
- case FUNCTION_CALL_NOT_SUPPORTED:
- if (context && context.name) {
- return "Function calls are not supported in decorators but '" + context.name + "' was called";
- }
- return 'Function calls are not supported in decorators';
- case REFERENCE_TO_LOCAL_SYMBOL:
- if (context && context.name) {
- return "Reference to a local (non-exported) symbols are not supported in decorators but '" + context.name + "' was referenced";
- }
- break;
- case LAMBDA_NOT_SUPPORTED:
- return "Function expressions are not supported in decorators";
- }
- return message;
- }
- /**
- * @param {?} message
- * @param {?} context
- * @return {?}
- */
- function messageAdvise(message, context) {
- switch (message) {
- case REFERENCE_TO_NONEXPORTED_CLASS:
- if (context && context.className) {
- return "Consider exporting '" + context.className + "'";
- }
- break;
- case DESTRUCTURE_NOT_SUPPORTED:
- return 'Consider simplifying to avoid destructuring';
- case REFERENCE_TO_LOCAL_SYMBOL:
- if (context && context.name) {
- return "Consider exporting '" + context.name + "'";
- }
- break;
- case LAMBDA_NOT_SUPPORTED:
- return "Consider changing the function expression into an exported function";
- }
- return undefined;
- }
- /**
- * @param {?} error
- * @return {?}
- */
- function errorSummary(error) {
- if (error.summary) {
- return error.summary;
- }
- switch (error.message) {
- case REFERENCE_TO_NONEXPORTED_CLASS:
- if (error.context && error.context.className) {
- return "references non-exported class " + error.context.className;
- }
- break;
- case VARIABLE_NOT_INITIALIZED:
- return 'is not initialized';
- case DESTRUCTURE_NOT_SUPPORTED:
- return 'is a destructured variable';
- case COULD_NOT_RESOLVE_TYPE:
- return 'could not be resolved';
- case FUNCTION_CALL_NOT_SUPPORTED:
- if (error.context && error.context.name) {
- return "calls '" + error.context.name + "'";
- }
- return "calls a function";
- case REFERENCE_TO_LOCAL_SYMBOL:
- if (error.context && error.context.name) {
- return "references local variable " + error.context.name;
- }
- return "references a local variable";
- }
- return 'contains the error';
- }
- /**
- * @param {?} input
- * @param {?} transform
- * @return {?}
- */
- function mapStringMap(input, transform) {
- if (!input)
- return {};
- var /** @type {?} */ result = {};
- Object.keys(input).forEach(function (key) {
- var /** @type {?} */ value = transform(input[key], key);
- if (!shouldIgnore(value)) {
- if (HIDDEN_KEY.test(key)) {
- Object.defineProperty(result, key, { enumerable: false, configurable: true, value: value });
- }
- else {
- result[key] = value;
- }
- }
- });
- return result;
- }
- /**
- * @param {?} o
- * @return {?}
- */
- function isPrimitive(o) {
- return o === null || (typeof o !== 'function' && typeof o !== 'object');
- }
- /**
- * @abstract
- */
- var BindingScope = /** @class */ (function () {
- function BindingScope() {
- }
- /**
- * @return {?}
- */
- BindingScope.build = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ current = new Map();
- return {
- define: function (name, value) {
- current.set(name, value);
- return this;
- },
- done: function () {
- return current.size > 0 ? new PopulatedScope(current) : BindingScope.empty;
- }
- };
- };
- BindingScope.missing = {};
- BindingScope.empty = { resolve: function (name) { return BindingScope.missing; } };
- return BindingScope;
- }());
- var PopulatedScope = /** @class */ (function (_super) {
- __extends(PopulatedScope, _super);
- function PopulatedScope(bindings) {
- var _this = _super.call(this) || this;
- _this.bindings = bindings;
- return _this;
- }
- /**
- * @param {?} name
- * @return {?}
- */
- PopulatedScope.prototype.resolve = /**
- * @param {?} name
- * @return {?}
- */
- function (name) {
- return this.bindings.has(name) ? this.bindings.get(name) : BindingScope.missing;
- };
- return PopulatedScope;
- }(BindingScope));
- /**
- * @param {?} chain
- * @param {?} advise
- * @return {?}
- */
- function formatMetadataMessageChain(chain, advise) {
- var /** @type {?} */ expanded = expandedMessage(chain.message, chain.context);
- var /** @type {?} */ nesting = chain.symbol ? " in '" + chain.symbol.name + "'" : '';
- var /** @type {?} */ message = "" + expanded + nesting;
- var /** @type {?} */ position = chain.position;
- var /** @type {?} */ next = chain.next ?
- formatMetadataMessageChain(chain.next, advise) :
- advise ? { message: advise } : undefined;
- return { message: message, position: position, next: next };
- }
- /**
- * @param {?} e
- * @param {?} context
- * @return {?}
- */
- function formatMetadataError(e, context) {
- if (isMetadataError(e)) {
- // Produce a formatted version of the and leaving enough information in the original error
- // to recover the formatting information to eventually produce a diagnostic error message.
- var /** @type {?} */ position = e.position;
- var /** @type {?} */ chain = {
- message: "Error during template compile of '" + context.name + "'",
- position: position,
- next: { message: e.message, next: e.chain, context: e.context, symbol: e.symbol }
- };
- var /** @type {?} */ advise = e.advise || messageAdvise(e.message, e.context);
- return formattedError(formatMetadataMessageChain(chain, advise));
- }
- return e;
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @record
- */
-
- var AotSummaryResolver = /** @class */ (function () {
- function AotSummaryResolver(host, staticSymbolCache) {
- this.host = host;
- this.staticSymbolCache = staticSymbolCache;
- this.summaryCache = new Map();
- this.loadedFilePaths = new Map();
- this.importAs = new Map();
- this.knownFileNameToModuleNames = new Map();
- }
- /**
- * @param {?} filePath
- * @return {?}
- */
- AotSummaryResolver.prototype.isLibraryFile = /**
- * @param {?} filePath
- * @return {?}
- */
- function (filePath) {
- // Note: We need to strip the .ngfactory. file path,
- // so this method also works for generated files
- // (for which host.isSourceFile will always return false).
- return !this.host.isSourceFile(stripGeneratedFileSuffix(filePath));
- };
- /**
- * @param {?} filePath
- * @param {?} referringSrcFileName
- * @return {?}
- */
- AotSummaryResolver.prototype.toSummaryFileName = /**
- * @param {?} filePath
- * @param {?} referringSrcFileName
- * @return {?}
- */
- function (filePath, referringSrcFileName) {
- return this.host.toSummaryFileName(filePath, referringSrcFileName);
- };
- /**
- * @param {?} fileName
- * @param {?} referringLibFileName
- * @return {?}
- */
- AotSummaryResolver.prototype.fromSummaryFileName = /**
- * @param {?} fileName
- * @param {?} referringLibFileName
- * @return {?}
- */
- function (fileName, referringLibFileName) {
- return this.host.fromSummaryFileName(fileName, referringLibFileName);
- };
- /**
- * @param {?} staticSymbol
- * @return {?}
- */
- AotSummaryResolver.prototype.resolveSummary = /**
- * @param {?} staticSymbol
- * @return {?}
- */
- function (staticSymbol) {
- var /** @type {?} */ rootSymbol = staticSymbol.members.length ?
- this.staticSymbolCache.get(staticSymbol.filePath, staticSymbol.name) :
- staticSymbol;
- var /** @type {?} */ summary = this.summaryCache.get(rootSymbol);
- if (!summary) {
- this._loadSummaryFile(staticSymbol.filePath);
- summary = /** @type {?} */ ((this.summaryCache.get(staticSymbol)));
- }
- return (rootSymbol === staticSymbol && summary) || null;
- };
- /**
- * @param {?} filePath
- * @return {?}
- */
- AotSummaryResolver.prototype.getSymbolsOf = /**
- * @param {?} filePath
- * @return {?}
- */
- function (filePath) {
- if (this._loadSummaryFile(filePath)) {
- return Array.from(this.summaryCache.keys()).filter(function (symbol) { return symbol.filePath === filePath; });
- }
- return null;
- };
- /**
- * @param {?} staticSymbol
- * @return {?}
- */
- AotSummaryResolver.prototype.getImportAs = /**
- * @param {?} staticSymbol
- * @return {?}
- */
- function (staticSymbol) {
- staticSymbol.assertNoMembers();
- return /** @type {?} */ ((this.importAs.get(staticSymbol)));
- };
- /**
- * Converts a file path to a module name that can be used as an `import`.
- */
- /**
- * Converts a file path to a module name that can be used as an `import`.
- * @param {?} importedFilePath
- * @return {?}
- */
- AotSummaryResolver.prototype.getKnownModuleName = /**
- * Converts a file path to a module name that can be used as an `import`.
- * @param {?} importedFilePath
- * @return {?}
- */
- function (importedFilePath) {
- return this.knownFileNameToModuleNames.get(importedFilePath) || null;
- };
- /**
- * @param {?} summary
- * @return {?}
- */
- AotSummaryResolver.prototype.addSummary = /**
- * @param {?} summary
- * @return {?}
- */
- function (summary) { this.summaryCache.set(summary.symbol, summary); };
- /**
- * @param {?} filePath
- * @return {?}
- */
- AotSummaryResolver.prototype._loadSummaryFile = /**
- * @param {?} filePath
- * @return {?}
- */
- function (filePath) {
- var _this = this;
- var /** @type {?} */ hasSummary = this.loadedFilePaths.get(filePath);
- if (hasSummary != null) {
- return hasSummary;
- }
- var /** @type {?} */ json = null;
- if (this.isLibraryFile(filePath)) {
- var /** @type {?} */ summaryFilePath = summaryFileName(filePath);
- try {
- json = this.host.loadSummary(summaryFilePath);
- }
- catch (/** @type {?} */ e) {
- console.error("Error loading summary file " + summaryFilePath);
- throw e;
- }
- }
- hasSummary = json != null;
- this.loadedFilePaths.set(filePath, hasSummary);
- if (json) {
- var _a = deserializeSummaries(this.staticSymbolCache, this, filePath, json), moduleName = _a.moduleName, summaries = _a.summaries, importAs = _a.importAs;
- summaries.forEach(function (summary) { return _this.summaryCache.set(summary.symbol, summary); });
- if (moduleName) {
- this.knownFileNameToModuleNames.set(filePath, moduleName);
- }
- importAs.forEach(function (importAs) { _this.importAs.set(importAs.symbol, importAs.importAs); });
- }
- return hasSummary;
- };
- return AotSummaryResolver;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} host
- * @return {?}
- */
- function createAotUrlResolver(host) {
- return {
- resolve: function (basePath, url) {
- var /** @type {?} */ filePath = host.resourceNameToFileName(url, basePath);
- if (!filePath) {
- throw syntaxError("Couldn't resolve resource " + url + " from " + basePath);
- }
- return filePath;
- }
- };
- }
- /**
- * Creates a new AotCompiler based on options and a host.
- * @param {?} compilerHost
- * @param {?} options
- * @param {?=} errorCollector
- * @return {?}
- */
- function createAotCompiler(compilerHost, options, errorCollector) {
- var /** @type {?} */ translations = options.translations || '';
- var /** @type {?} */ urlResolver = createAotUrlResolver(compilerHost);
- var /** @type {?} */ symbolCache = new StaticSymbolCache();
- var /** @type {?} */ summaryResolver = new AotSummaryResolver(compilerHost, symbolCache);
- var /** @type {?} */ symbolResolver = new StaticSymbolResolver(compilerHost, symbolCache, summaryResolver);
- var /** @type {?} */ staticReflector = new StaticReflector(summaryResolver, symbolResolver, [], [], errorCollector);
- var /** @type {?} */ htmlParser = new I18NHtmlParser(new HtmlParser(), translations, options.i18nFormat, options.missingTranslation, console);
- var /** @type {?} */ config = new CompilerConfig({
- defaultEncapsulation: ViewEncapsulation.Emulated,
- useJit: false,
- enableLegacyTemplate: options.enableLegacyTemplate === true,
- missingTranslation: options.missingTranslation,
- preserveWhitespaces: options.preserveWhitespaces,
- strictInjectionParameters: options.strictInjectionParameters,
- });
- var /** @type {?} */ normalizer = new DirectiveNormalizer({ get: function (url) { return compilerHost.loadResource(url); } }, urlResolver, htmlParser, config);
- var /** @type {?} */ expressionParser = new Parser(new Lexer());
- var /** @type {?} */ elementSchemaRegistry = new DomElementSchemaRegistry();
- var /** @type {?} */ tmplParser = new TemplateParser(config, staticReflector, expressionParser, elementSchemaRegistry, htmlParser, console, []);
- var /** @type {?} */ resolver = new CompileMetadataResolver(config, htmlParser, new NgModuleResolver(staticReflector), new DirectiveResolver(staticReflector), new PipeResolver(staticReflector), summaryResolver, elementSchemaRegistry, normalizer, console, symbolCache, staticReflector, errorCollector);
- // TODO(vicb): do not pass options.i18nFormat here
- var /** @type {?} */ viewCompiler = new ViewCompiler(staticReflector);
- var /** @type {?} */ typeCheckCompiler = new TypeCheckCompiler(options, staticReflector);
- var /** @type {?} */ compiler = new AotCompiler(config, options, compilerHost, staticReflector, resolver, tmplParser, new StyleCompiler(urlResolver), viewCompiler, typeCheckCompiler, new NgModuleCompiler(staticReflector), new TypeScriptEmitter(), summaryResolver, symbolResolver);
- return { compiler: compiler, reflector: staticReflector };
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @record
- * @template T
- */
-
- /**
- * @abstract
- * @template T
- */
- var SummaryResolver = /** @class */ (function () {
- function SummaryResolver() {
- }
- return SummaryResolver;
- }());
- var JitSummaryResolver = /** @class */ (function () {
- function JitSummaryResolver() {
- this._summaries = new Map();
- }
- /**
- * @return {?}
- */
- JitSummaryResolver.prototype.isLibraryFile = /**
- * @return {?}
- */
- function () { return false; };
- /**
- * @param {?} fileName
- * @return {?}
- */
- JitSummaryResolver.prototype.toSummaryFileName = /**
- * @param {?} fileName
- * @return {?}
- */
- function (fileName) { return fileName; };
- /**
- * @param {?} fileName
- * @return {?}
- */
- JitSummaryResolver.prototype.fromSummaryFileName = /**
- * @param {?} fileName
- * @return {?}
- */
- function (fileName) { return fileName; };
- /**
- * @param {?} reference
- * @return {?}
- */
- JitSummaryResolver.prototype.resolveSummary = /**
- * @param {?} reference
- * @return {?}
- */
- function (reference) {
- return this._summaries.get(reference) || null;
- };
- /**
- * @return {?}
- */
- JitSummaryResolver.prototype.getSymbolsOf = /**
- * @return {?}
- */
- function () { return []; };
- /**
- * @param {?} reference
- * @return {?}
- */
- JitSummaryResolver.prototype.getImportAs = /**
- * @param {?} reference
- * @return {?}
- */
- function (reference) { return reference; };
- /**
- * @param {?} fileName
- * @return {?}
- */
- JitSummaryResolver.prototype.getKnownModuleName = /**
- * @param {?} fileName
- * @return {?}
- */
- function (fileName) { return null; };
- /**
- * @param {?} summary
- * @return {?}
- */
- JitSummaryResolver.prototype.addSummary = /**
- * @param {?} summary
- * @return {?}
- */
- function (summary) { this._summaries.set(summary.symbol, summary); };
- return JitSummaryResolver;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} statements
- * @param {?} reflector
- * @return {?}
- */
- function interpretStatements(statements, reflector) {
- var /** @type {?} */ ctx = new _ExecutionContext(null, null, null, new Map());
- var /** @type {?} */ visitor = new StatementInterpreter(reflector);
- visitor.visitAllStatements(statements, ctx);
- var /** @type {?} */ result = {};
- ctx.exports.forEach(function (exportName) { result[exportName] = ctx.vars.get(exportName); });
- return result;
- }
- /**
- * @param {?} varNames
- * @param {?} varValues
- * @param {?} statements
- * @param {?} ctx
- * @param {?} visitor
- * @return {?}
- */
- function _executeFunctionStatements(varNames, varValues, statements, ctx, visitor) {
- var /** @type {?} */ childCtx = ctx.createChildWihtLocalVars();
- for (var /** @type {?} */ i = 0; i < varNames.length; i++) {
- childCtx.vars.set(varNames[i], varValues[i]);
- }
- var /** @type {?} */ result = visitor.visitAllStatements(statements, childCtx);
- return result ? result.value : null;
- }
- var _ExecutionContext = /** @class */ (function () {
- function _ExecutionContext(parent, instance, className, vars) {
- this.parent = parent;
- this.instance = instance;
- this.className = className;
- this.vars = vars;
- this.exports = [];
- }
- /**
- * @return {?}
- */
- _ExecutionContext.prototype.createChildWihtLocalVars = /**
- * @return {?}
- */
- function () {
- return new _ExecutionContext(this, this.instance, this.className, new Map());
- };
- return _ExecutionContext;
- }());
- var ReturnValue = /** @class */ (function () {
- function ReturnValue(value) {
- this.value = value;
- }
- return ReturnValue;
- }());
- /**
- * @param {?} _classStmt
- * @param {?} _ctx
- * @param {?} _visitor
- * @return {?}
- */
- function createDynamicClass(_classStmt, _ctx, _visitor) {
- var /** @type {?} */ propertyDescriptors = {};
- _classStmt.getters.forEach(function (getter) {
- // Note: use `function` instead of arrow function to capture `this`
- propertyDescriptors[getter.name] = {
- configurable: false,
- get: function () {
- var /** @type {?} */ instanceCtx = new _ExecutionContext(_ctx, this, _classStmt.name, _ctx.vars);
- return _executeFunctionStatements([], [], getter.body, instanceCtx, _visitor);
- }
- };
- });
- _classStmt.methods.forEach(function (method) {
- var /** @type {?} */ paramNames = method.params.map(function (param) { return param.name; });
- // Note: use `function` instead of arrow function to capture `this`
- propertyDescriptors[/** @type {?} */ ((method.name))] = {
- writable: false,
- configurable: false,
- value: function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var /** @type {?} */ instanceCtx = new _ExecutionContext(_ctx, this, _classStmt.name, _ctx.vars);
- return _executeFunctionStatements(paramNames, args, method.body, instanceCtx, _visitor);
- }
- };
- });
- var /** @type {?} */ ctorParamNames = _classStmt.constructorMethod.params.map(function (param) { return param.name; });
- // Note: use `function` instead of arrow function to capture `this`
- var /** @type {?} */ ctor = function () {
- var _this = this;
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var /** @type {?} */ instanceCtx = new _ExecutionContext(_ctx, this, _classStmt.name, _ctx.vars);
- _classStmt.fields.forEach(function (field) { _this[field.name] = undefined; });
- _executeFunctionStatements(ctorParamNames, args, _classStmt.constructorMethod.body, instanceCtx, _visitor);
- };
- var /** @type {?} */ superClass = _classStmt.parent ? _classStmt.parent.visitExpression(_visitor, _ctx) : Object;
- ctor.prototype = Object.create(superClass.prototype, propertyDescriptors);
- return ctor;
- }
- var StatementInterpreter = /** @class */ (function () {
- function StatementInterpreter(reflector) {
- this.reflector = reflector;
- }
- /**
- * @param {?} ast
- * @return {?}
- */
- StatementInterpreter.prototype.debugAst = /**
- * @param {?} ast
- * @return {?}
- */
- function (ast) { return debugOutputAstAsTypeScript(ast); };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitDeclareVarStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- ctx.vars.set(stmt.name, stmt.value.visitExpression(this, ctx));
- if (stmt.hasModifier(StmtModifier.Exported)) {
- ctx.exports.push(stmt.name);
- }
- return null;
- };
- /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitWriteVarExpr = /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- function (expr, ctx) {
- var /** @type {?} */ value = expr.value.visitExpression(this, ctx);
- var /** @type {?} */ currCtx = ctx;
- while (currCtx != null) {
- if (currCtx.vars.has(expr.name)) {
- currCtx.vars.set(expr.name, value);
- return value;
- }
- currCtx = /** @type {?} */ ((currCtx.parent));
- }
- throw new Error("Not declared variable " + expr.name);
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitReadVarExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var /** @type {?} */ varName = /** @type {?} */ ((ast.name));
- if (ast.builtin != null) {
- switch (ast.builtin) {
- case BuiltinVar.Super:
- return ctx.instance.__proto__;
- case BuiltinVar.This:
- return ctx.instance;
- case BuiltinVar.CatchError:
- varName = CATCH_ERROR_VAR$2;
- break;
- case BuiltinVar.CatchStack:
- varName = CATCH_STACK_VAR$2;
- break;
- default:
- throw new Error("Unknown builtin variable " + ast.builtin);
- }
- }
- var /** @type {?} */ currCtx = ctx;
- while (currCtx != null) {
- if (currCtx.vars.has(varName)) {
- return currCtx.vars.get(varName);
- }
- currCtx = /** @type {?} */ ((currCtx.parent));
- }
- throw new Error("Not declared variable " + varName);
- };
- /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitWriteKeyExpr = /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- function (expr, ctx) {
- var /** @type {?} */ receiver = expr.receiver.visitExpression(this, ctx);
- var /** @type {?} */ index = expr.index.visitExpression(this, ctx);
- var /** @type {?} */ value = expr.value.visitExpression(this, ctx);
- receiver[index] = value;
- return value;
- };
- /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitWritePropExpr = /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- function (expr, ctx) {
- var /** @type {?} */ receiver = expr.receiver.visitExpression(this, ctx);
- var /** @type {?} */ value = expr.value.visitExpression(this, ctx);
- receiver[expr.name] = value;
- return value;
- };
- /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitInvokeMethodExpr = /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- function (expr, ctx) {
- var /** @type {?} */ receiver = expr.receiver.visitExpression(this, ctx);
- var /** @type {?} */ args = this.visitAllExpressions(expr.args, ctx);
- var /** @type {?} */ result;
- if (expr.builtin != null) {
- switch (expr.builtin) {
- case BuiltinMethod.ConcatArray:
- result = receiver.concat.apply(receiver, args);
- break;
- case BuiltinMethod.SubscribeObservable:
- result = receiver.subscribe({ next: args[0] });
- break;
- case BuiltinMethod.Bind:
- result = receiver.bind.apply(receiver, args);
- break;
- default:
- throw new Error("Unknown builtin method " + expr.builtin);
- }
- }
- else {
- result = receiver[/** @type {?} */ ((expr.name))].apply(receiver, args);
- }
- return result;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitInvokeFunctionExpr = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- var /** @type {?} */ args = this.visitAllExpressions(stmt.args, ctx);
- var /** @type {?} */ fnExpr = stmt.fn;
- if (fnExpr instanceof ReadVarExpr && fnExpr.builtin === BuiltinVar.Super) {
- ctx.instance.constructor.prototype.constructor.apply(ctx.instance, args);
- return null;
- }
- else {
- var /** @type {?} */ fn$$1 = stmt.fn.visitExpression(this, ctx);
- return fn$$1.apply(null, args);
- }
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitReturnStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- return new ReturnValue(stmt.value.visitExpression(this, ctx));
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitDeclareClassStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- var /** @type {?} */ clazz = createDynamicClass(stmt, ctx, this);
- ctx.vars.set(stmt.name, clazz);
- if (stmt.hasModifier(StmtModifier.Exported)) {
- ctx.exports.push(stmt.name);
- }
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitExpressionStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- return stmt.expr.visitExpression(this, ctx);
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitIfStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- var /** @type {?} */ condition = stmt.condition.visitExpression(this, ctx);
- if (condition) {
- return this.visitAllStatements(stmt.trueCase, ctx);
- }
- else if (stmt.falseCase != null) {
- return this.visitAllStatements(stmt.falseCase, ctx);
- }
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitTryCatchStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- try {
- return this.visitAllStatements(stmt.bodyStmts, ctx);
- }
- catch (/** @type {?} */ e) {
- var /** @type {?} */ childCtx = ctx.createChildWihtLocalVars();
- childCtx.vars.set(CATCH_ERROR_VAR$2, e);
- childCtx.vars.set(CATCH_STACK_VAR$2, e.stack);
- return this.visitAllStatements(stmt.catchStmts, childCtx);
- }
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitThrowStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- throw stmt.error.visitExpression(this, ctx);
- };
- /**
- * @param {?} stmt
- * @param {?=} context
- * @return {?}
- */
- StatementInterpreter.prototype.visitCommentStmt = /**
- * @param {?} stmt
- * @param {?=} context
- * @return {?}
- */
- function (stmt, context) { return null; };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitInstantiateExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var /** @type {?} */ args = this.visitAllExpressions(ast.args, ctx);
- var /** @type {?} */ clazz = ast.classExpr.visitExpression(this, ctx);
- return new (clazz.bind.apply(clazz, [void 0].concat(args)))();
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitLiteralExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) { return ast.value; };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitExternalExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- return this.reflector.resolveExternalReference(ast.value);
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitConditionalExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- if (ast.condition.visitExpression(this, ctx)) {
- return ast.trueCase.visitExpression(this, ctx);
- }
- else if (ast.falseCase != null) {
- return ast.falseCase.visitExpression(this, ctx);
- }
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitNotExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- return !ast.condition.visitExpression(this, ctx);
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitAssertNotNullExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- return ast.condition.visitExpression(this, ctx);
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitCastExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- return ast.value.visitExpression(this, ctx);
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitFunctionExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var /** @type {?} */ paramNames = ast.params.map(function (param) { return param.name; });
- return _declareFn(paramNames, ast.statements, ctx, this);
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitDeclareFunctionStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- var /** @type {?} */ paramNames = stmt.params.map(function (param) { return param.name; });
- ctx.vars.set(stmt.name, _declareFn(paramNames, stmt.statements, ctx, this));
- if (stmt.hasModifier(StmtModifier.Exported)) {
- ctx.exports.push(stmt.name);
- }
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitBinaryOperatorExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var _this = this;
- var /** @type {?} */ lhs = function () { return ast.lhs.visitExpression(_this, ctx); };
- var /** @type {?} */ rhs = function () { return ast.rhs.visitExpression(_this, ctx); };
- switch (ast.operator) {
- case BinaryOperator.Equals:
- return lhs() == rhs();
- case BinaryOperator.Identical:
- return lhs() === rhs();
- case BinaryOperator.NotEquals:
- return lhs() != rhs();
- case BinaryOperator.NotIdentical:
- return lhs() !== rhs();
- case BinaryOperator.And:
- return lhs() && rhs();
- case BinaryOperator.Or:
- return lhs() || rhs();
- case BinaryOperator.Plus:
- return lhs() + rhs();
- case BinaryOperator.Minus:
- return lhs() - rhs();
- case BinaryOperator.Divide:
- return lhs() / rhs();
- case BinaryOperator.Multiply:
- return lhs() * rhs();
- case BinaryOperator.Modulo:
- return lhs() % rhs();
- case BinaryOperator.Lower:
- return lhs() < rhs();
- case BinaryOperator.LowerEquals:
- return lhs() <= rhs();
- case BinaryOperator.Bigger:
- return lhs() > rhs();
- case BinaryOperator.BiggerEquals:
- return lhs() >= rhs();
- default:
- throw new Error("Unknown operator " + ast.operator);
- }
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitReadPropExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var /** @type {?} */ result;
- var /** @type {?} */ receiver = ast.receiver.visitExpression(this, ctx);
- result = receiver[ast.name];
- return result;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitReadKeyExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var /** @type {?} */ receiver = ast.receiver.visitExpression(this, ctx);
- var /** @type {?} */ prop = ast.index.visitExpression(this, ctx);
- return receiver[prop];
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitLiteralArrayExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- return this.visitAllExpressions(ast.entries, ctx);
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitLiteralMapExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var _this = this;
- var /** @type {?} */ result = {};
- ast.entries.forEach(function (entry) { return result[entry.key] = entry.value.visitExpression(_this, ctx); });
- return result;
- };
- /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- StatementInterpreter.prototype.visitCommaExpr = /**
- * @param {?} ast
- * @param {?} context
- * @return {?}
- */
- function (ast, context) {
- var /** @type {?} */ values = this.visitAllExpressions(ast.parts, context);
- return values[values.length - 1];
- };
- /**
- * @param {?} expressions
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitAllExpressions = /**
- * @param {?} expressions
- * @param {?} ctx
- * @return {?}
- */
- function (expressions, ctx) {
- var _this = this;
- return expressions.map(function (expr) { return expr.visitExpression(_this, ctx); });
- };
- /**
- * @param {?} statements
- * @param {?} ctx
- * @return {?}
- */
- StatementInterpreter.prototype.visitAllStatements = /**
- * @param {?} statements
- * @param {?} ctx
- * @return {?}
- */
- function (statements, ctx) {
- for (var /** @type {?} */ i = 0; i < statements.length; i++) {
- var /** @type {?} */ stmt = statements[i];
- var /** @type {?} */ val = stmt.visitStatement(this, ctx);
- if (val instanceof ReturnValue) {
- return val;
- }
- }
- return null;
- };
- return StatementInterpreter;
- }());
- /**
- * @param {?} varNames
- * @param {?} statements
- * @param {?} ctx
- * @param {?} visitor
- * @return {?}
- */
- function _declareFn(varNames, statements, ctx, visitor) {
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return _executeFunctionStatements(varNames, args, statements, ctx, visitor);
- };
- }
- var CATCH_ERROR_VAR$2 = 'error';
- var CATCH_STACK_VAR$2 = 'stack';
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @abstract
- */
- var AbstractJsEmitterVisitor = /** @class */ (function (_super) {
- __extends(AbstractJsEmitterVisitor, _super);
- function AbstractJsEmitterVisitor() {
- return _super.call(this, false) || this;
- }
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype.visitDeclareClassStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- var _this = this;
- ctx.pushClass(stmt);
- this._visitClassConstructor(stmt, ctx);
- if (stmt.parent != null) {
- ctx.print(stmt, stmt.name + ".prototype = Object.create(");
- stmt.parent.visitExpression(this, ctx);
- ctx.println(stmt, ".prototype);");
- }
- stmt.getters.forEach(function (getter) { return _this._visitClassGetter(stmt, getter, ctx); });
- stmt.methods.forEach(function (method) { return _this._visitClassMethod(stmt, method, ctx); });
- ctx.popClass();
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype._visitClassConstructor = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- ctx.print(stmt, "function " + stmt.name + "(");
- if (stmt.constructorMethod != null) {
- this._visitParams(stmt.constructorMethod.params, ctx);
- }
- ctx.println(stmt, ") {");
- ctx.incIndent();
- if (stmt.constructorMethod != null) {
- if (stmt.constructorMethod.body.length > 0) {
- ctx.println(stmt, "var self = this;");
- this.visitAllStatements(stmt.constructorMethod.body, ctx);
- }
- }
- ctx.decIndent();
- ctx.println(stmt, "}");
- };
- /**
- * @param {?} stmt
- * @param {?} getter
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype._visitClassGetter = /**
- * @param {?} stmt
- * @param {?} getter
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, getter, ctx) {
- ctx.println(stmt, "Object.defineProperty(" + stmt.name + ".prototype, '" + getter.name + "', { get: function() {");
- ctx.incIndent();
- if (getter.body.length > 0) {
- ctx.println(stmt, "var self = this;");
- this.visitAllStatements(getter.body, ctx);
- }
- ctx.decIndent();
- ctx.println(stmt, "}});");
- };
- /**
- * @param {?} stmt
- * @param {?} method
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype._visitClassMethod = /**
- * @param {?} stmt
- * @param {?} method
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, method, ctx) {
- ctx.print(stmt, stmt.name + ".prototype." + method.name + " = function(");
- this._visitParams(method.params, ctx);
- ctx.println(stmt, ") {");
- ctx.incIndent();
- if (method.body.length > 0) {
- ctx.println(stmt, "var self = this;");
- this.visitAllStatements(method.body, ctx);
- }
- ctx.decIndent();
- ctx.println(stmt, "};");
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype.visitReadVarExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- if (ast.builtin === BuiltinVar.This) {
- ctx.print(ast, 'self');
- }
- else if (ast.builtin === BuiltinVar.Super) {
- throw new Error("'super' needs to be handled at a parent ast node, not at the variable level!");
- }
- else {
- _super.prototype.visitReadVarExpr.call(this, ast, ctx);
- }
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype.visitDeclareVarStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- ctx.print(stmt, "var " + stmt.name + " = ");
- stmt.value.visitExpression(this, ctx);
- ctx.println(stmt, ";");
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype.visitCastExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ast.value.visitExpression(this, ctx);
- return null;
- };
- /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype.visitInvokeFunctionExpr = /**
- * @param {?} expr
- * @param {?} ctx
- * @return {?}
- */
- function (expr, ctx) {
- var /** @type {?} */ fnExpr = expr.fn;
- if (fnExpr instanceof ReadVarExpr && fnExpr.builtin === BuiltinVar.Super) {
- /** @type {?} */ ((/** @type {?} */ ((ctx.currentClass)).parent)).visitExpression(this, ctx);
- ctx.print(expr, ".call(this");
- if (expr.args.length > 0) {
- ctx.print(expr, ", ");
- this.visitAllExpressions(expr.args, ctx, ',');
- }
- ctx.print(expr, ")");
- }
- else {
- _super.prototype.visitInvokeFunctionExpr.call(this, expr, ctx);
- }
- return null;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype.visitFunctionExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- ctx.print(ast, "function(");
- this._visitParams(ast.params, ctx);
- ctx.println(ast, ") {");
- ctx.incIndent();
- this.visitAllStatements(ast.statements, ctx);
- ctx.decIndent();
- ctx.print(ast, "}");
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype.visitDeclareFunctionStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- ctx.print(stmt, "function " + stmt.name + "(");
- this._visitParams(stmt.params, ctx);
- ctx.println(stmt, ") {");
- ctx.incIndent();
- this.visitAllStatements(stmt.statements, ctx);
- ctx.decIndent();
- ctx.println(stmt, "}");
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype.visitTryCatchStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- ctx.println(stmt, "try {");
- ctx.incIndent();
- this.visitAllStatements(stmt.bodyStmts, ctx);
- ctx.decIndent();
- ctx.println(stmt, "} catch (" + CATCH_ERROR_VAR$1.name + ") {");
- ctx.incIndent();
- var /** @type {?} */ catchStmts = [/** @type {?} */ (CATCH_STACK_VAR$1.set(CATCH_ERROR_VAR$1.prop('stack')).toDeclStmt(null, [
- StmtModifier.Final
- ]))].concat(stmt.catchStmts);
- this.visitAllStatements(catchStmts, ctx);
- ctx.decIndent();
- ctx.println(stmt, "}");
- return null;
- };
- /**
- * @param {?} params
- * @param {?} ctx
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype._visitParams = /**
- * @param {?} params
- * @param {?} ctx
- * @return {?}
- */
- function (params, ctx) {
- this.visitAllObjects(function (param) { return ctx.print(null, param.name); }, params, ctx, ',');
- };
- /**
- * @param {?} method
- * @return {?}
- */
- AbstractJsEmitterVisitor.prototype.getBuiltinMethodName = /**
- * @param {?} method
- * @return {?}
- */
- function (method) {
- var /** @type {?} */ name;
- switch (method) {
- case BuiltinMethod.ConcatArray:
- name = 'concat';
- break;
- case BuiltinMethod.SubscribeObservable:
- name = 'subscribe';
- break;
- case BuiltinMethod.Bind:
- name = 'bind';
- break;
- default:
- throw new Error("Unknown builtin method: " + method);
- }
- return name;
- };
- return AbstractJsEmitterVisitor;
- }(AbstractEmitterVisitor));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} sourceUrl
- * @param {?} ctx
- * @param {?} vars
- * @param {?} createSourceMap
- * @return {?}
- */
- function evalExpression(sourceUrl, ctx, vars, createSourceMap) {
- var /** @type {?} */ fnBody = ctx.toSource() + "\n//# sourceURL=" + sourceUrl;
- var /** @type {?} */ fnArgNames = [];
- var /** @type {?} */ fnArgValues = [];
- for (var /** @type {?} */ argName in vars) {
- fnArgNames.push(argName);
- fnArgValues.push(vars[argName]);
- }
- if (createSourceMap) {
- // using `new Function(...)` generates a header, 1 line of no arguments, 2 lines otherwise
- // E.g. ```
- // function anonymous(a,b,c
- // /**/) { ... }```
- // We don't want to hard code this fact, so we auto detect it via an empty function first.
- var /** @type {?} */ emptyFn = new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat('return null;'))))().toString();
- var /** @type {?} */ headerLines = emptyFn.slice(0, emptyFn.indexOf('return null;')).split('\n').length - 1;
- fnBody += "\n" + ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment();
- }
- return new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat(fnBody))))().apply(void 0, fnArgValues);
- }
- /**
- * @param {?} sourceUrl
- * @param {?} statements
- * @param {?} reflector
- * @param {?} createSourceMaps
- * @return {?}
- */
- function jitStatements(sourceUrl, statements, reflector, createSourceMaps) {
- var /** @type {?} */ converter = new JitEmitterVisitor(reflector);
- var /** @type {?} */ ctx = EmitterVisitorContext.createRoot();
- converter.visitAllStatements(statements, ctx);
- converter.createReturnStmt(ctx);
- return evalExpression(sourceUrl, ctx, converter.getArgs(), createSourceMaps);
- }
- var JitEmitterVisitor = /** @class */ (function (_super) {
- __extends(JitEmitterVisitor, _super);
- function JitEmitterVisitor(reflector) {
- var _this = _super.call(this) || this;
- _this.reflector = reflector;
- _this._evalArgNames = [];
- _this._evalArgValues = [];
- _this._evalExportedVars = [];
- return _this;
- }
- /**
- * @param {?} ctx
- * @return {?}
- */
- JitEmitterVisitor.prototype.createReturnStmt = /**
- * @param {?} ctx
- * @return {?}
- */
- function (ctx) {
- var /** @type {?} */ stmt = new ReturnStatement(new LiteralMapExpr(this._evalExportedVars.map(function (resultVar) { return new LiteralMapEntry(resultVar, variable(resultVar), false); })));
- stmt.visitStatement(this, ctx);
- };
- /**
- * @return {?}
- */
- JitEmitterVisitor.prototype.getArgs = /**
- * @return {?}
- */
- function () {
- var /** @type {?} */ result = {};
- for (var /** @type {?} */ i = 0; i < this._evalArgNames.length; i++) {
- result[this._evalArgNames[i]] = this._evalArgValues[i];
- }
- return result;
- };
- /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- JitEmitterVisitor.prototype.visitExternalExpr = /**
- * @param {?} ast
- * @param {?} ctx
- * @return {?}
- */
- function (ast, ctx) {
- var /** @type {?} */ value = this.reflector.resolveExternalReference(ast.value);
- var /** @type {?} */ id = this._evalArgValues.indexOf(value);
- if (id === -1) {
- id = this._evalArgValues.length;
- this._evalArgValues.push(value);
- var /** @type {?} */ name_1 = identifierName({ reference: value }) || 'val';
- this._evalArgNames.push("jit_" + name_1 + "_" + id);
- }
- ctx.print(ast, this._evalArgNames[id]);
- return null;
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- JitEmitterVisitor.prototype.visitDeclareVarStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- if (stmt.hasModifier(StmtModifier.Exported)) {
- this._evalExportedVars.push(stmt.name);
- }
- return _super.prototype.visitDeclareVarStmt.call(this, stmt, ctx);
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- JitEmitterVisitor.prototype.visitDeclareFunctionStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- if (stmt.hasModifier(StmtModifier.Exported)) {
- this._evalExportedVars.push(stmt.name);
- }
- return _super.prototype.visitDeclareFunctionStmt.call(this, stmt, ctx);
- };
- /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- JitEmitterVisitor.prototype.visitDeclareClassStmt = /**
- * @param {?} stmt
- * @param {?} ctx
- * @return {?}
- */
- function (stmt, ctx) {
- if (stmt.hasModifier(StmtModifier.Exported)) {
- this._evalExportedVars.push(stmt.name);
- }
- return _super.prototype.visitDeclareClassStmt.call(this, stmt, ctx);
- };
- return JitEmitterVisitor;
- }(AbstractJsEmitterVisitor));
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @record
- */
-
- /**
- * An internal module of the Angular compiler that begins with component types,
- * extracts templates, and eventually produces a compiled version of the component
- * ready for linking into an application.
- *
- * \@security When compiling templates at runtime, you must ensure that the entire template comes
- * from a trusted source. Attacker-controlled data introduced by a template could expose your
- * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
- */
- var JitCompiler = /** @class */ (function () {
- function JitCompiler(_metadataResolver, _templateParser, _styleCompiler, _viewCompiler, _ngModuleCompiler, _summaryResolver, _reflector, _compilerConfig, _console, getExtraNgModuleProviders) {
- this._metadataResolver = _metadataResolver;
- this._templateParser = _templateParser;
- this._styleCompiler = _styleCompiler;
- this._viewCompiler = _viewCompiler;
- this._ngModuleCompiler = _ngModuleCompiler;
- this._summaryResolver = _summaryResolver;
- this._reflector = _reflector;
- this._compilerConfig = _compilerConfig;
- this._console = _console;
- this.getExtraNgModuleProviders = getExtraNgModuleProviders;
- this._compiledTemplateCache = new Map();
- this._compiledHostTemplateCache = new Map();
- this._compiledDirectiveWrapperCache = new Map();
- this._compiledNgModuleCache = new Map();
- this._sharedStylesheetCount = 0;
- this._addedAotSummaries = new Set();
- }
- /**
- * @param {?} moduleType
- * @return {?}
- */
- JitCompiler.prototype.compileModuleSync = /**
- * @param {?} moduleType
- * @return {?}
- */
- function (moduleType) {
- return SyncAsync.assertSync(this._compileModuleAndComponents(moduleType, true));
- };
- /**
- * @param {?} moduleType
- * @return {?}
- */
- JitCompiler.prototype.compileModuleAsync = /**
- * @param {?} moduleType
- * @return {?}
- */
- function (moduleType) {
- return Promise.resolve(this._compileModuleAndComponents(moduleType, false));
- };
- /**
- * @param {?} moduleType
- * @return {?}
- */
- JitCompiler.prototype.compileModuleAndAllComponentsSync = /**
- * @param {?} moduleType
- * @return {?}
- */
- function (moduleType) {
- return SyncAsync.assertSync(this._compileModuleAndAllComponents(moduleType, true));
- };
- /**
- * @param {?} moduleType
- * @return {?}
- */
- JitCompiler.prototype.compileModuleAndAllComponentsAsync = /**
- * @param {?} moduleType
- * @return {?}
- */
- function (moduleType) {
- return Promise.resolve(this._compileModuleAndAllComponents(moduleType, false));
- };
- /**
- * @param {?} component
- * @return {?}
- */
- JitCompiler.prototype.getComponentFactory = /**
- * @param {?} component
- * @return {?}
- */
- function (component) {
- var /** @type {?} */ summary = this._metadataResolver.getDirectiveSummary(component);
- return /** @type {?} */ (summary.componentFactory);
- };
- /**
- * @param {?} summaries
- * @return {?}
- */
- JitCompiler.prototype.loadAotSummaries = /**
- * @param {?} summaries
- * @return {?}
- */
- function (summaries) {
- this.clearCache();
- this._addAotSummaries(summaries);
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- JitCompiler.prototype._addAotSummaries = /**
- * @param {?} fn
- * @return {?}
- */
- function (fn$$1) {
- if (this._addedAotSummaries.has(fn$$1)) {
- return;
- }
- this._addedAotSummaries.add(fn$$1);
- var /** @type {?} */ summaries = fn$$1();
- for (var /** @type {?} */ i = 0; i < summaries.length; i++) {
- var /** @type {?} */ entry = summaries[i];
- if (typeof entry === 'function') {
- this._addAotSummaries(entry);
- }
- else {
- var /** @type {?} */ summary = /** @type {?} */ (entry);
- this._summaryResolver.addSummary({ symbol: summary.type.reference, metadata: null, type: summary });
- }
- }
- };
- /**
- * @param {?} ref
- * @return {?}
- */
- JitCompiler.prototype.hasAotSummary = /**
- * @param {?} ref
- * @return {?}
- */
- function (ref) { return !!this._summaryResolver.resolveSummary(ref); };
- /**
- * @param {?} ids
- * @return {?}
- */
- JitCompiler.prototype._filterJitIdentifiers = /**
- * @param {?} ids
- * @return {?}
- */
- function (ids) {
- var _this = this;
- return ids.map(function (mod) { return mod.reference; }).filter(function (ref) { return !_this.hasAotSummary(ref); });
- };
- /**
- * @param {?} moduleType
- * @param {?} isSync
- * @return {?}
- */
- JitCompiler.prototype._compileModuleAndComponents = /**
- * @param {?} moduleType
- * @param {?} isSync
- * @return {?}
- */
- function (moduleType, isSync) {
- var _this = this;
- return SyncAsync.then(this._loadModules(moduleType, isSync), function () {
- _this._compileComponents(moduleType, null);
- return _this._compileModule(moduleType);
- });
- };
- /**
- * @param {?} moduleType
- * @param {?} isSync
- * @return {?}
- */
- JitCompiler.prototype._compileModuleAndAllComponents = /**
- * @param {?} moduleType
- * @param {?} isSync
- * @return {?}
- */
- function (moduleType, isSync) {
- var _this = this;
- return SyncAsync.then(this._loadModules(moduleType, isSync), function () {
- var /** @type {?} */ componentFactories = [];
- _this._compileComponents(moduleType, componentFactories);
- return {
- ngModuleFactory: _this._compileModule(moduleType),
- componentFactories: componentFactories
- };
- });
- };
- /**
- * @param {?} mainModule
- * @param {?} isSync
- * @return {?}
- */
- JitCompiler.prototype._loadModules = /**
- * @param {?} mainModule
- * @param {?} isSync
- * @return {?}
- */
- function (mainModule, isSync) {
- var _this = this;
- var /** @type {?} */ loading = [];
- var /** @type {?} */ mainNgModule = /** @type {?} */ ((this._metadataResolver.getNgModuleMetadata(mainModule)));
- // Note: for runtime compilation, we want to transitively compile all modules,
- // so we also need to load the declared directives / pipes for all nested modules.
- this._filterJitIdentifiers(mainNgModule.transitiveModule.modules).forEach(function (nestedNgModule) {
- // getNgModuleMetadata only returns null if the value passed in is not an NgModule
- var /** @type {?} */ moduleMeta = /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(nestedNgModule)));
- _this._filterJitIdentifiers(moduleMeta.declaredDirectives).forEach(function (ref) {
- var /** @type {?} */ promise = _this._metadataResolver.loadDirectiveMetadata(moduleMeta.type.reference, ref, isSync);
- if (promise) {
- loading.push(promise);
- }
- });
- _this._filterJitIdentifiers(moduleMeta.declaredPipes)
- .forEach(function (ref) { return _this._metadataResolver.getOrLoadPipeMetadata(ref); });
- });
- return SyncAsync.all(loading);
- };
- /**
- * @param {?} moduleType
- * @return {?}
- */
- JitCompiler.prototype._compileModule = /**
- * @param {?} moduleType
- * @return {?}
- */
- function (moduleType) {
- var /** @type {?} */ ngModuleFactory = /** @type {?} */ ((this._compiledNgModuleCache.get(moduleType)));
- if (!ngModuleFactory) {
- var /** @type {?} */ moduleMeta = /** @type {?} */ ((this._metadataResolver.getNgModuleMetadata(moduleType)));
- // Always provide a bound Compiler
- var /** @type {?} */ extraProviders = this.getExtraNgModuleProviders(moduleMeta.type.reference);
- var /** @type {?} */ outputCtx = createOutputContext();
- var /** @type {?} */ compileResult = this._ngModuleCompiler.compile(outputCtx, moduleMeta, extraProviders);
- ngModuleFactory = this._interpretOrJit(ngModuleJitUrl(moduleMeta), outputCtx.statements)[compileResult.ngModuleFactoryVar];
- this._compiledNgModuleCache.set(moduleMeta.type.reference, ngModuleFactory);
- }
- return ngModuleFactory;
- };
- /**
- * @internal
- */
- /**
- * \@internal
- * @param {?} mainModule
- * @param {?} allComponentFactories
- * @return {?}
- */
- JitCompiler.prototype._compileComponents = /**
- * \@internal
- * @param {?} mainModule
- * @param {?} allComponentFactories
- * @return {?}
- */
- function (mainModule, allComponentFactories) {
- var _this = this;
- var /** @type {?} */ ngModule = /** @type {?} */ ((this._metadataResolver.getNgModuleMetadata(mainModule)));
- var /** @type {?} */ moduleByJitDirective = new Map();
- var /** @type {?} */ templates = new Set();
- var /** @type {?} */ transJitModules = this._filterJitIdentifiers(ngModule.transitiveModule.modules);
- transJitModules.forEach(function (localMod) {
- var /** @type {?} */ localModuleMeta = /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(localMod)));
- _this._filterJitIdentifiers(localModuleMeta.declaredDirectives).forEach(function (dirRef) {
- moduleByJitDirective.set(dirRef, localModuleMeta);
- var /** @type {?} */ dirMeta = _this._metadataResolver.getDirectiveMetadata(dirRef);
- if (dirMeta.isComponent) {
- templates.add(_this._createCompiledTemplate(dirMeta, localModuleMeta));
- if (allComponentFactories) {
- var /** @type {?} */ template = _this._createCompiledHostTemplate(dirMeta.type.reference, localModuleMeta);
- templates.add(template);
- allComponentFactories.push(/** @type {?} */ (dirMeta.componentFactory));
- }
- }
- });
- });
- transJitModules.forEach(function (localMod) {
- var /** @type {?} */ localModuleMeta = /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(localMod)));
- _this._filterJitIdentifiers(localModuleMeta.declaredDirectives).forEach(function (dirRef) {
- var /** @type {?} */ dirMeta = _this._metadataResolver.getDirectiveMetadata(dirRef);
- if (dirMeta.isComponent) {
- dirMeta.entryComponents.forEach(function (entryComponentType) {
- var /** @type {?} */ moduleMeta = /** @type {?} */ ((moduleByJitDirective.get(entryComponentType.componentType)));
- templates.add(_this._createCompiledHostTemplate(entryComponentType.componentType, moduleMeta));
- });
- }
- });
- localModuleMeta.entryComponents.forEach(function (entryComponentType) {
- if (!_this.hasAotSummary(entryComponentType.componentType.reference)) {
- var /** @type {?} */ moduleMeta = /** @type {?} */ ((moduleByJitDirective.get(entryComponentType.componentType)));
- templates.add(_this._createCompiledHostTemplate(entryComponentType.componentType, moduleMeta));
- }
- });
- });
- templates.forEach(function (template) { return _this._compileTemplate(template); });
- };
- /**
- * @param {?} type
- * @return {?}
- */
- JitCompiler.prototype.clearCacheFor = /**
- * @param {?} type
- * @return {?}
- */
- function (type) {
- this._compiledNgModuleCache.delete(type);
- this._metadataResolver.clearCacheFor(type);
- this._compiledHostTemplateCache.delete(type);
- var /** @type {?} */ compiledTemplate = this._compiledTemplateCache.get(type);
- if (compiledTemplate) {
- this._compiledTemplateCache.delete(type);
- }
- };
- /**
- * @return {?}
- */
- JitCompiler.prototype.clearCache = /**
- * @return {?}
- */
- function () {
- // Note: don't clear the _addedAotSummaries, as they don't change!
- this._metadataResolver.clearCache();
- this._compiledTemplateCache.clear();
- this._compiledHostTemplateCache.clear();
- this._compiledNgModuleCache.clear();
- };
- /**
- * @param {?} compType
- * @param {?} ngModule
- * @return {?}
- */
- JitCompiler.prototype._createCompiledHostTemplate = /**
- * @param {?} compType
- * @param {?} ngModule
- * @return {?}
- */
- function (compType, ngModule) {
- if (!ngModule) {
- throw new Error("Component " + stringify(compType) + " is not part of any NgModule or the module has not been imported into your module.");
- }
- var /** @type {?} */ compiledTemplate = this._compiledHostTemplateCache.get(compType);
- if (!compiledTemplate) {
- var /** @type {?} */ compMeta = this._metadataResolver.getDirectiveMetadata(compType);
- assertComponent(compMeta);
- var /** @type {?} */ hostMeta = this._metadataResolver.getHostComponentMetadata(compMeta, (/** @type {?} */ (compMeta.componentFactory)).viewDefFactory);
- compiledTemplate =
- new CompiledTemplate(true, compMeta.type, hostMeta, ngModule, [compMeta.type]);
- this._compiledHostTemplateCache.set(compType, compiledTemplate);
- }
- return compiledTemplate;
- };
- /**
- * @param {?} compMeta
- * @param {?} ngModule
- * @return {?}
- */
- JitCompiler.prototype._createCompiledTemplate = /**
- * @param {?} compMeta
- * @param {?} ngModule
- * @return {?}
- */
- function (compMeta, ngModule) {
- var /** @type {?} */ compiledTemplate = this._compiledTemplateCache.get(compMeta.type.reference);
- if (!compiledTemplate) {
- assertComponent(compMeta);
- compiledTemplate = new CompiledTemplate(false, compMeta.type, compMeta, ngModule, ngModule.transitiveModule.directives);
- this._compiledTemplateCache.set(compMeta.type.reference, compiledTemplate);
- }
- return compiledTemplate;
- };
- /**
- * @param {?} template
- * @return {?}
- */
- JitCompiler.prototype._compileTemplate = /**
- * @param {?} template
- * @return {?}
- */
- function (template) {
- var _this = this;
- if (template.isCompiled) {
- return;
- }
- var /** @type {?} */ compMeta = template.compMeta;
- var /** @type {?} */ externalStylesheetsByModuleUrl = new Map();
- var /** @type {?} */ outputContext = createOutputContext();
- var /** @type {?} */ componentStylesheet = this._styleCompiler.compileComponent(outputContext, compMeta); /** @type {?} */
- ((compMeta.template)).externalStylesheets.forEach(function (stylesheetMeta) {
- var /** @type {?} */ compiledStylesheet = _this._styleCompiler.compileStyles(createOutputContext(), compMeta, stylesheetMeta);
- externalStylesheetsByModuleUrl.set(/** @type {?} */ ((stylesheetMeta.moduleUrl)), compiledStylesheet);
- });
- this._resolveStylesCompileResult(componentStylesheet, externalStylesheetsByModuleUrl);
- var /** @type {?} */ pipes = template.ngModule.transitiveModule.pipes.map(function (pipe) { return _this._metadataResolver.getPipeSummary(pipe.reference); });
- var _a = this._parseTemplate(compMeta, template.ngModule, template.directives), parsedTemplate = _a.template, usedPipes = _a.pipes;
- var /** @type {?} */ compileResult = this._viewCompiler.compileComponent(outputContext, compMeta, parsedTemplate, variable(componentStylesheet.stylesVar), usedPipes);
- var /** @type {?} */ evalResult = this._interpretOrJit(templateJitUrl(template.ngModule.type, template.compMeta), outputContext.statements);
- var /** @type {?} */ viewClass = evalResult[compileResult.viewClassVar];
- var /** @type {?} */ rendererType = evalResult[compileResult.rendererTypeVar];
- template.compiled(viewClass, rendererType);
- };
- /**
- * @param {?} compMeta
- * @param {?} ngModule
- * @param {?} directiveIdentifiers
- * @return {?}
- */
- JitCompiler.prototype._parseTemplate = /**
- * @param {?} compMeta
- * @param {?} ngModule
- * @param {?} directiveIdentifiers
- * @return {?}
- */
- function (compMeta, ngModule, directiveIdentifiers) {
- var _this = this;
- // Note: ! is ok here as components always have a template.
- var /** @type {?} */ preserveWhitespaces = /** @type {?} */ ((compMeta.template)).preserveWhitespaces;
- var /** @type {?} */ directives = directiveIdentifiers.map(function (dir) { return _this._metadataResolver.getDirectiveSummary(dir.reference); });
- var /** @type {?} */ pipes = ngModule.transitiveModule.pipes.map(function (pipe) { return _this._metadataResolver.getPipeSummary(pipe.reference); });
- return this._templateParser.parse(compMeta, /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).htmlAst)), directives, pipes, ngModule.schemas, templateSourceUrl(ngModule.type, compMeta, /** @type {?} */ ((compMeta.template))), preserveWhitespaces);
- };
- /**
- * @param {?} result
- * @param {?} externalStylesheetsByModuleUrl
- * @return {?}
- */
- JitCompiler.prototype._resolveStylesCompileResult = /**
- * @param {?} result
- * @param {?} externalStylesheetsByModuleUrl
- * @return {?}
- */
- function (result, externalStylesheetsByModuleUrl) {
- var _this = this;
- result.dependencies.forEach(function (dep, i) {
- var /** @type {?} */ nestedCompileResult = /** @type {?} */ ((externalStylesheetsByModuleUrl.get(dep.moduleUrl)));
- var /** @type {?} */ nestedStylesArr = _this._resolveAndEvalStylesCompileResult(nestedCompileResult, externalStylesheetsByModuleUrl);
- dep.setValue(nestedStylesArr);
- });
- };
- /**
- * @param {?} result
- * @param {?} externalStylesheetsByModuleUrl
- * @return {?}
- */
- JitCompiler.prototype._resolveAndEvalStylesCompileResult = /**
- * @param {?} result
- * @param {?} externalStylesheetsByModuleUrl
- * @return {?}
- */
- function (result, externalStylesheetsByModuleUrl) {
- this._resolveStylesCompileResult(result, externalStylesheetsByModuleUrl);
- return this._interpretOrJit(sharedStylesheetJitUrl(result.meta, this._sharedStylesheetCount++), result.outputCtx.statements)[result.stylesVar];
- };
- /**
- * @param {?} sourceUrl
- * @param {?} statements
- * @return {?}
- */
- JitCompiler.prototype._interpretOrJit = /**
- * @param {?} sourceUrl
- * @param {?} statements
- * @return {?}
- */
- function (sourceUrl, statements) {
- if (!this._compilerConfig.useJit) {
- return interpretStatements(statements, this._reflector);
- }
- else {
- return jitStatements(sourceUrl, statements, this._reflector, this._compilerConfig.jitDevMode);
- }
- };
- return JitCompiler;
- }());
- var CompiledTemplate = /** @class */ (function () {
- function CompiledTemplate(isHost, compType, compMeta, ngModule, directives) {
- this.isHost = isHost;
- this.compType = compType;
- this.compMeta = compMeta;
- this.ngModule = ngModule;
- this.directives = directives;
- this._viewClass = /** @type {?} */ ((null));
- this.isCompiled = false;
- }
- /**
- * @param {?} viewClass
- * @param {?} rendererType
- * @return {?}
- */
- CompiledTemplate.prototype.compiled = /**
- * @param {?} viewClass
- * @param {?} rendererType
- * @return {?}
- */
- function (viewClass, rendererType) {
- this._viewClass = viewClass;
- (/** @type {?} */ (this.compMeta.componentViewType)).setDelegate(viewClass);
- for (var /** @type {?} */ prop in rendererType) {
- (/** @type {?} */ (this.compMeta.rendererType))[prop] = rendererType[prop];
- }
- this.isCompiled = true;
- };
- return CompiledTemplate;
- }());
- /**
- * @param {?} meta
- * @return {?}
- */
- function assertComponent(meta) {
- if (!meta.isComponent) {
- throw new Error("Could not compile '" + identifierName(meta.type) + "' because it is not a component.");
- }
- }
- /**
- * @return {?}
- */
- function createOutputContext() {
- var /** @type {?} */ importExpr$$1 = function (symbol) {
- return importExpr({ name: identifierName(symbol), moduleName: null, runtime: symbol });
- };
- return { statements: [], genFilePath: '', importExpr: importExpr$$1 };
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Provides access to reflection data about symbols that the compiler needs.
- * @abstract
- */
- var CompileReflector = /** @class */ (function () {
- function CompileReflector() {
- }
- return CompileReflector;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Create a {\@link UrlResolver} with no package prefix.
- * @return {?}
- */
- function createUrlResolverWithoutPackagePrefix() {
- return new UrlResolver();
- }
- /**
- * @return {?}
- */
- function createOfflineCompileUrlResolver() {
- return new UrlResolver('.');
- }
- /**
- * @record
- */
-
- var UrlResolver = /** @class */ (function () {
- function UrlResolverImpl(_packagePrefix) {
- if (_packagePrefix === void 0) { _packagePrefix = null; }
- this._packagePrefix = _packagePrefix;
- }
- /**
- * Resolves the `url` given the `baseUrl`:
- * - when the `url` is null, the `baseUrl` is returned,
- * - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
- * `baseUrl` and `url`,
- * - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
- * returned as is (ignoring the `baseUrl`)
- */
- /**
- * Resolves the `url` given the `baseUrl`:
- * - when the `url` is null, the `baseUrl` is returned,
- * - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
- * `baseUrl` and `url`,
- * - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
- * returned as is (ignoring the `baseUrl`)
- * @param {?} baseUrl
- * @param {?} url
- * @return {?}
- */
- UrlResolverImpl.prototype.resolve = /**
- * Resolves the `url` given the `baseUrl`:
- * - when the `url` is null, the `baseUrl` is returned,
- * - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
- * `baseUrl` and `url`,
- * - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
- * returned as is (ignoring the `baseUrl`)
- * @param {?} baseUrl
- * @param {?} url
- * @return {?}
- */
- function (baseUrl, url) {
- var /** @type {?} */ resolvedUrl = url;
- if (baseUrl != null && baseUrl.length > 0) {
- resolvedUrl = _resolveUrl(baseUrl, resolvedUrl);
- }
- var /** @type {?} */ resolvedParts = _split(resolvedUrl);
- var /** @type {?} */ prefix = this._packagePrefix;
- if (prefix != null && resolvedParts != null &&
- resolvedParts[_ComponentIndex.Scheme] == 'package') {
- var /** @type {?} */ path = resolvedParts[_ComponentIndex.Path];
- prefix = prefix.replace(/\/+$/, '');
- path = path.replace(/^\/+/, '');
- return prefix + "/" + path;
- }
- return resolvedUrl;
- };
- return UrlResolverImpl;
- }());
- /**
- * Extract the scheme of a URL.
- * @param {?} url
- * @return {?}
- */
- function getUrlScheme(url) {
- var /** @type {?} */ match = _split(url);
- return (match && match[_ComponentIndex.Scheme]) || '';
- }
- /**
- * Builds a URI string from already-encoded parts.
- *
- * No encoding is performed. Any component may be omitted as either null or
- * undefined.
- *
- * @param {?=} opt_scheme The scheme such as 'http'.
- * @param {?=} opt_userInfo The user name before the '\@'.
- * @param {?=} opt_domain The domain such as 'www.google.com', already
- * URI-encoded.
- * @param {?=} opt_port The port number.
- * @param {?=} opt_path The path, already URI-encoded. If it is not
- * empty, it must begin with a slash.
- * @param {?=} opt_queryData The URI-encoded query data.
- * @param {?=} opt_fragment The URI-encoded fragment identifier.
- * @return {?} The fully combined URI.
- */
- function _buildFromEncodedParts(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) {
- var /** @type {?} */ out = [];
- if (opt_scheme != null) {
- out.push(opt_scheme + ':');
- }
- if (opt_domain != null) {
- out.push('//');
- if (opt_userInfo != null) {
- out.push(opt_userInfo + '@');
- }
- out.push(opt_domain);
- if (opt_port != null) {
- out.push(':' + opt_port);
- }
- }
- if (opt_path != null) {
- out.push(opt_path);
- }
- if (opt_queryData != null) {
- out.push('?' + opt_queryData);
- }
- if (opt_fragment != null) {
- out.push('#' + opt_fragment);
- }
- return out.join('');
- }
- /**
- * A regular expression for breaking a URI into its component parts.
- *
- * {\@link http://www.gbiv.com/protocols/uri/rfc/rfc3986.html#RFC2234} says
- * As the "first-match-wins" algorithm is identical to the "greedy"
- * disambiguation method used by POSIX regular expressions, it is natural and
- * commonplace to use a regular expression for parsing the potential five
- * components of a URI reference.
- *
- * The following line is the regular expression for breaking-down a
- * well-formed URI reference into its components.
- *
- * <pre>
- * ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
- * 12 3 4 5 6 7 8 9
- * </pre>
- *
- * The numbers in the second line above are only to assist readability; they
- * indicate the reference points for each subexpression (i.e., each paired
- * parenthesis). We refer to the value matched for subexpression <n> as $<n>.
- * For example, matching the above expression to
- * <pre>
- * http://www.ics.uci.edu/pub/ietf/uri/#Related
- * </pre>
- * results in the following subexpression matches:
- * <pre>
- * $1 = http:
- * $2 = http
- * $3 = //www.ics.uci.edu
- * $4 = www.ics.uci.edu
- * $5 = /pub/ietf/uri/
- * $6 = <undefined>
- * $7 = <undefined>
- * $8 = #Related
- * $9 = Related
- * </pre>
- * where <undefined> indicates that the component is not present, as is the
- * case for the query component in the above example. Therefore, we can
- * determine the value of the five components as
- * <pre>
- * scheme = $2
- * authority = $4
- * path = $5
- * query = $7
- * fragment = $9
- * </pre>
- *
- * The regular expression has been modified slightly to expose the
- * userInfo, domain, and port separately from the authority.
- * The modified version yields
- * <pre>
- * $1 = http scheme
- * $2 = <undefined> userInfo -\
- * $3 = www.ics.uci.edu domain | authority
- * $4 = <undefined> port -/
- * $5 = /pub/ietf/uri/ path
- * $6 = <undefined> query without ?
- * $7 = Related fragment without #
- * </pre>
- * \@internal
- */
- var _splitRe = new RegExp('^' +
- '(?:' +
- '([^:/?#.]+)' + // scheme - ignore special characters
- ':)?' +
- '(?://' +
- '(?:([^/?#]*)@)?' + // userInfo
- '([\\w\\d\\-\\u0100-\\uffff.%]*)' + // domain - restrict to letters,
- '(?::([0-9]+))?' + // port
- ')?' +
- '([^?#]+)?' + // path
- '(?:\\?([^#]*))?' + // query
- '(?:#(.*))?' + // fragment
- '$');
- /** @enum {number} */
- var _ComponentIndex = {
- Scheme: 1,
- UserInfo: 2,
- Domain: 3,
- Port: 4,
- Path: 5,
- QueryData: 6,
- Fragment: 7,
- };
- _ComponentIndex[_ComponentIndex.Scheme] = "Scheme";
- _ComponentIndex[_ComponentIndex.UserInfo] = "UserInfo";
- _ComponentIndex[_ComponentIndex.Domain] = "Domain";
- _ComponentIndex[_ComponentIndex.Port] = "Port";
- _ComponentIndex[_ComponentIndex.Path] = "Path";
- _ComponentIndex[_ComponentIndex.QueryData] = "QueryData";
- _ComponentIndex[_ComponentIndex.Fragment] = "Fragment";
- /**
- * Splits a URI into its component parts.
- *
- * Each component can be accessed via the component indices; for example:
- * <pre>
- * goog.uri.utils.split(someStr)[goog.uri.utils.CompontentIndex.QUERY_DATA];
- * </pre>
- *
- * @param {?} uri The URI string to examine.
- * @return {?} Each component still URI-encoded.
- * Each component that is present will contain the encoded value, whereas
- * components that are not present will be undefined or empty, depending
- * on the browser's regular expression implementation. Never null, since
- * arbitrary strings may still look like path names.
- */
- function _split(uri) {
- return /** @type {?} */ ((uri.match(_splitRe)));
- }
- /**
- * Removes dot segments in given path component, as described in
- * RFC 3986, section 5.2.4.
- *
- * @param {?} path A non-empty path component.
- * @return {?} Path component with removed dot segments.
- */
- function _removeDotSegments(path) {
- if (path == '/')
- return '/';
- var /** @type {?} */ leadingSlash = path[0] == '/' ? '/' : '';
- var /** @type {?} */ trailingSlash = path[path.length - 1] === '/' ? '/' : '';
- var /** @type {?} */ segments = path.split('/');
- var /** @type {?} */ out = [];
- var /** @type {?} */ up = 0;
- for (var /** @type {?} */ pos = 0; pos < segments.length; pos++) {
- var /** @type {?} */ segment = segments[pos];
- switch (segment) {
- case '':
- case '.':
- break;
- case '..':
- if (out.length > 0) {
- out.pop();
- }
- else {
- up++;
- }
- break;
- default:
- out.push(segment);
- }
- }
- if (leadingSlash == '') {
- while (up-- > 0) {
- out.unshift('..');
- }
- if (out.length === 0)
- out.push('.');
- }
- return leadingSlash + out.join('/') + trailingSlash;
- }
- /**
- * Takes an array of the parts from split and canonicalizes the path part
- * and then joins all the parts.
- * @param {?} parts
- * @return {?}
- */
- function _joinAndCanonicalizePath(parts) {
- var /** @type {?} */ path = parts[_ComponentIndex.Path];
- path = path == null ? '' : _removeDotSegments(path);
- parts[_ComponentIndex.Path] = path;
- return _buildFromEncodedParts(parts[_ComponentIndex.Scheme], parts[_ComponentIndex.UserInfo], parts[_ComponentIndex.Domain], parts[_ComponentIndex.Port], path, parts[_ComponentIndex.QueryData], parts[_ComponentIndex.Fragment]);
- }
- /**
- * Resolves a URL.
- * @param {?} base The URL acting as the base URL.
- * @param {?} url
- * @return {?}
- */
- function _resolveUrl(base, url) {
- var /** @type {?} */ parts = _split(encodeURI(url));
- var /** @type {?} */ baseParts = _split(base);
- if (parts[_ComponentIndex.Scheme] != null) {
- return _joinAndCanonicalizePath(parts);
- }
- else {
- parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme];
- }
- for (var /** @type {?} */ i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) {
- if (parts[i] == null) {
- parts[i] = baseParts[i];
- }
- }
- if (parts[_ComponentIndex.Path][0] == '/') {
- return _joinAndCanonicalizePath(parts);
- }
- var /** @type {?} */ path = baseParts[_ComponentIndex.Path];
- if (path == null)
- path = '/';
- var /** @type {?} */ index = path.lastIndexOf('/');
- path = path.substring(0, index + 1) + parts[_ComponentIndex.Path];
- parts[_ComponentIndex.Path] = path;
- return _joinAndCanonicalizePath(parts);
- }
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * An interface for retrieving documents by URL that the compiler uses
- * to load templates.
- */
- var ResourceLoader = /** @class */ (function () {
- function ResourceLoader() {
- }
- /**
- * @param {?} url
- * @return {?}
- */
- ResourceLoader.prototype.get = /**
- * @param {?} url
- * @return {?}
- */
- function (url) { return ''; };
- return ResourceLoader;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * The host of the Extractor disconnects the implementation from TypeScript / other language
- * services and from underlying file systems.
- * @record
- */
-
- var Extractor = /** @class */ (function () {
- function Extractor(host, staticSymbolResolver, messageBundle, metadataResolver) {
- this.host = host;
- this.staticSymbolResolver = staticSymbolResolver;
- this.messageBundle = messageBundle;
- this.metadataResolver = metadataResolver;
- }
- /**
- * @param {?} rootFiles
- * @return {?}
- */
- Extractor.prototype.extract = /**
- * @param {?} rootFiles
- * @return {?}
- */
- function (rootFiles) {
- var _this = this;
- var _a = analyzeAndValidateNgModules(rootFiles, this.host, this.staticSymbolResolver, this.metadataResolver), files = _a.files, ngModules = _a.ngModules;
- return Promise
- .all(ngModules.map(function (ngModule) {
- return _this.metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, false);
- }))
- .then(function () {
- var /** @type {?} */ errors = [];
- files.forEach(function (file) {
- var /** @type {?} */ compMetas = [];
- file.directives.forEach(function (directiveType) {
- var /** @type {?} */ dirMeta = _this.metadataResolver.getDirectiveMetadata(directiveType);
- if (dirMeta && dirMeta.isComponent) {
- compMetas.push(dirMeta);
- }
- });
- compMetas.forEach(function (compMeta) {
- var /** @type {?} */ html = /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).template));
- var /** @type {?} */ interpolationConfig = InterpolationConfig.fromArray(/** @type {?} */ ((compMeta.template)).interpolation);
- errors.push.apply(errors, /** @type {?} */ ((_this.messageBundle.updateFromTemplate(html, file.fileName, interpolationConfig))));
- });
- });
- if (errors.length) {
- throw new Error(errors.map(function (e) { return e.toString(); }).join('\n'));
- }
- return _this.messageBundle;
- });
- };
- /**
- * @param {?} host
- * @param {?} locale
- * @return {?}
- */
- Extractor.create = /**
- * @param {?} host
- * @param {?} locale
- * @return {?}
- */
- function (host, locale) {
- var /** @type {?} */ htmlParser = new HtmlParser();
- var /** @type {?} */ urlResolver = createAotUrlResolver(host);
- var /** @type {?} */ symbolCache = new StaticSymbolCache();
- var /** @type {?} */ summaryResolver = new AotSummaryResolver(host, symbolCache);
- var /** @type {?} */ staticSymbolResolver = new StaticSymbolResolver(host, symbolCache, summaryResolver);
- var /** @type {?} */ staticReflector = new StaticReflector(summaryResolver, staticSymbolResolver);
- var /** @type {?} */ config = new CompilerConfig({ defaultEncapsulation: ViewEncapsulation.Emulated, useJit: false });
- var /** @type {?} */ normalizer = new DirectiveNormalizer({ get: function (url) { return host.loadResource(url); } }, urlResolver, htmlParser, config);
- var /** @type {?} */ elementSchemaRegistry = new DomElementSchemaRegistry();
- var /** @type {?} */ resolver = new CompileMetadataResolver(config, htmlParser, new NgModuleResolver(staticReflector), new DirectiveResolver(staticReflector), new PipeResolver(staticReflector), summaryResolver, elementSchemaRegistry, normalizer, console, symbolCache, staticReflector);
- // TODO(vicb): implicit tags & attributes
- var /** @type {?} */ messageBundle = new MessageBundle(htmlParser, [], {}, locale);
- var /** @type {?} */ extractor = new Extractor(host, staticSymbolResolver, messageBundle, resolver);
- return { extractor: extractor, staticReflector: staticReflector };
- };
- return Extractor;
- }());
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
-
- // This file only reexports content of the `src` folder. Keep it that way.
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @module
- * @description
- * Entry point for all public APIs of this package.
- */
-
- // This file only reexports content of the `src` folder. Keep it that way.
-
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes} checked by tsc
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- // This file is not used to build this module. It is only used during editing
- // by the TypeScript language service and during build for verification. `ngc`
- // replaces this file with production index.ts when it rewrites private symbol
- // names.
-
- export { core, CompilerConfig, preserveWhitespacesDefault, isLoweredSymbol, createLoweredSymbol, Identifiers, JitCompiler, DirectiveResolver, PipeResolver, NgModuleResolver, DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig, NgModuleCompiler, AssertNotNull, BinaryOperator, BinaryOperatorExpr, BuiltinMethod, BuiltinVar, CastExpr, ClassStmt, CommaExpr, CommentStmt, ConditionalExpr, DeclareFunctionStmt, DeclareVarStmt, ExpressionStatement, ExternalExpr, ExternalReference, FunctionExpr, IfStmt, InstantiateExpr, InvokeFunctionExpr, InvokeMethodExpr, LiteralArrayExpr, LiteralExpr, LiteralMapExpr, NotExpr, ReadKeyExpr, ReadPropExpr, ReadVarExpr, ReturnStatement, ThrowStmt, TryCatchStmt, WriteKeyExpr, WritePropExpr, WriteVarExpr, StmtModifier, Statement, collectExternalReferences, EmitterVisitorContext, ViewCompiler, getParseErrors, isSyntaxError, syntaxError, Version, VERSION, TextAst, BoundTextAst, AttrAst, BoundElementPropertyAst, BoundEventAst, ReferenceAst, VariableAst, ElementAst, EmbeddedTemplateAst, BoundDirectivePropertyAst, DirectiveAst, ProviderAst, ProviderAstType, NgContentAst, PropertyBindingType, NullTemplateVisitor, RecursiveTemplateAstVisitor, templateVisitAll, identifierName, identifierModuleUrl, viewClassName, rendererTypeName, hostViewClassName, componentFactoryName, CompileSummaryKind, tokenName, tokenReference, CompileStylesheetMetadata, CompileTemplateMetadata, CompileDirectiveMetadata, CompilePipeMetadata, CompileNgModuleMetadata, TransitiveCompileNgModuleMetadata, ProviderMeta, flatten, templateSourceUrl, sharedStylesheetJitUrl, ngModuleJitUrl, templateJitUrl, createAotUrlResolver, createAotCompiler, AotCompiler, analyzeNgModules, analyzeAndValidateNgModules, analyzeFile, mergeAnalyzedFiles, GeneratedFile, toTypeScript, formattedError, isFormattedError, StaticReflector, StaticSymbol, StaticSymbolCache, ResolvedStaticSymbol, StaticSymbolResolver, unescapeIdentifier, unwrapResolvedMetadata, AotSummaryResolver, AstPath, SummaryResolver, JitSummaryResolver, CompileReflector, createUrlResolverWithoutPackagePrefix, createOfflineCompileUrlResolver, UrlResolver, getUrlScheme, ResourceLoader, ElementSchemaRegistry, Extractor, I18NHtmlParser, MessageBundle, Serializer, Xliff, Xliff2, Xmb, Xtb, DirectiveNormalizer, ParserError, ParseSpan, AST, Quote, EmptyExpr, ImplicitReceiver, Chain, Conditional, PropertyRead, PropertyWrite, SafePropertyRead, KeyedRead, KeyedWrite, BindingPipe, LiteralPrimitive, LiteralArray, LiteralMap, Interpolation, Binary, PrefixNot, NonNullAssert, MethodCall, SafeMethodCall, FunctionCall, ASTWithSource, TemplateBinding, NullAstVisitor, RecursiveAstVisitor, AstTransformer, visitAstChildren, TokenType, Lexer, Token, EOF, isIdentifier, isQuote, SplitInterpolation, TemplateBindingParseResult, Parser, _ParseAST, ERROR_COMPONENT_TYPE, CompileMetadataResolver, Text, Expansion, ExpansionCase, Attribute$1 as Attribute, Element, Comment, visitAll, RecursiveVisitor, findNode, ParseTreeResult, TreeError, HtmlParser, HtmlTagDefinition, getHtmlTagDefinition, TagContentType, splitNsName, isNgContainer, isNgContent, isNgTemplate, getNsPrefix, mergeNsAndName, NAMED_ENTITIES, NGSP_UNICODE, debugOutputAstAsTypeScript, TypeScriptEmitter, ParseLocation, ParseSourceFile, ParseSourceSpan, ParseErrorLevel, ParseError, typeSourceSpan, DomElementSchemaRegistry, CssSelector, SelectorMatcher, SelectorListContext, SelectorContext, StylesCompileDependency, CompiledStylesheet, StyleCompiler, TemplateParseError, TemplateParseResult, TemplateParser, splitClasses, createElementCssSelector, removeSummaryDuplicates };
- //# sourceMappingURL=compiler.js.map
|