chunk-QBQKEXLX.js 291 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790
  1. import {createRequire as __cjsCompatRequire} from 'module';
  2. const require = __cjsCompatRequire(import.meta.url);
  3. import {
  4. CompilationMode,
  5. CompletionKind,
  6. ComponentDecoratorHandler,
  7. ComponentScopeKind,
  8. CompoundComponentScopeReader,
  9. CompoundMetadataReader,
  10. CompoundMetadataRegistry,
  11. DirectiveDecoratorHandler,
  12. DtsMetadataReader,
  13. DtsTransformRegistry,
  14. ExportedProviderStatusResolver,
  15. HostDirectivesResolver,
  16. InjectableClassRegistry,
  17. InjectableDecoratorHandler,
  18. LocalMetadataRegistry,
  19. LocalModuleScopeRegistry,
  20. MetaKind,
  21. MetadataDtsModuleScopeResolver,
  22. NgModuleDecoratorHandler,
  23. NoopReferencesRegistry,
  24. OptimizeFor,
  25. PartialEvaluator,
  26. PipeDecoratorHandler,
  27. PotentialImportKind,
  28. PotentialImportMode,
  29. ResourceRegistry,
  30. SemanticDepGraphUpdater,
  31. SymbolKind,
  32. TraitCompiler,
  33. TypeCheckScopeRegistry,
  34. aliasTransformFactory,
  35. declarationTransformFactory,
  36. ivyTransformFactory
  37. } from "./chunk-FYJ5FZGI.js";
  38. import {
  39. TypeScriptReflectionHost,
  40. isNamedClassDeclaration
  41. } from "./chunk-4NU6EGYK.js";
  42. import {
  43. ImportManager,
  44. translateExpression,
  45. translateType
  46. } from "./chunk-JCLVSACV.js";
  47. import {
  48. AbsoluteModuleStrategy,
  49. AliasStrategy,
  50. COMPILER_ERRORS_WITH_GUIDES,
  51. DefaultImportTracker,
  52. ERROR_DETAILS_PAGE_BASE_URL,
  53. ErrorCode,
  54. ExtendedTemplateDiagnosticName,
  55. FatalDiagnosticError,
  56. ImportFlags,
  57. LocalIdentifierStrategy,
  58. LogicalProjectStrategy,
  59. ModuleResolver,
  60. NoopImportRewriter,
  61. PrivateExportAliasingHost,
  62. R3SymbolsImportRewriter,
  63. Reference,
  64. ReferenceEmitter,
  65. RelativePathStrategy,
  66. UnifiedModulesAliasingHost,
  67. UnifiedModulesStrategy,
  68. addDiagnosticChain,
  69. assertSuccessfulReferenceEmit,
  70. getRootDirs,
  71. getSourceFileOrNull,
  72. getTokenAtPosition,
  73. isAssignment,
  74. isDtsPath,
  75. isNonDeclarationTsPath,
  76. isSymbolWithValueDeclaration,
  77. makeDiagnostic,
  78. makeDiagnosticChain,
  79. makeRelatedInformation,
  80. ngErrorCode,
  81. normalizeSeparators,
  82. relativePathBetween,
  83. replaceTsWithNgInErrors,
  84. toUnredirectedSourceFile
  85. } from "./chunk-7RPZKH3B.js";
  86. import {
  87. ActivePerfRecorder,
  88. DelegatingPerfRecorder,
  89. PerfCheckpoint,
  90. PerfEvent,
  91. PerfPhase
  92. } from "./chunk-URH5LEAG.js";
  93. import {
  94. LogicalFileSystem,
  95. absoluteFrom,
  96. absoluteFromSourceFile,
  97. dirname,
  98. getFileSystem,
  99. getSourceFileOrError,
  100. join,
  101. resolve
  102. } from "./chunk-K2U2VZ7S.js";
  103. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/transformers/api.mjs
  104. var DEFAULT_ERROR_CODE = 100;
  105. var UNKNOWN_ERROR_CODE = 500;
  106. var SOURCE = "angular";
  107. function isTsDiagnostic(diagnostic) {
  108. return diagnostic != null && diagnostic.source !== "angular";
  109. }
  110. var EmitFlags;
  111. (function(EmitFlags2) {
  112. EmitFlags2[EmitFlags2["DTS"] = 1] = "DTS";
  113. EmitFlags2[EmitFlags2["JS"] = 2] = "JS";
  114. EmitFlags2[EmitFlags2["Metadata"] = 4] = "Metadata";
  115. EmitFlags2[EmitFlags2["I18nBundle"] = 8] = "I18nBundle";
  116. EmitFlags2[EmitFlags2["Codegen"] = 16] = "Codegen";
  117. EmitFlags2[EmitFlags2["Default"] = 19] = "Default";
  118. EmitFlags2[EmitFlags2["All"] = 31] = "All";
  119. })(EmitFlags || (EmitFlags = {}));
  120. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/transformers/compiler_host.mjs
  121. import ts from "typescript";
  122. var wrapHostForTest = null;
  123. function createCompilerHost({ options, tsHost = ts.createCompilerHost(options, true) }) {
  124. if (wrapHostForTest !== null) {
  125. tsHost = wrapHostForTest(tsHost);
  126. }
  127. return tsHost;
  128. }
  129. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/program.mjs
  130. import { HtmlParser, MessageBundle } from "@angular/compiler";
  131. import ts32 from "typescript";
  132. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/transformers/i18n.mjs
  133. import { Xliff, Xliff2, Xmb } from "@angular/compiler";
  134. import * as path from "path";
  135. function i18nGetExtension(formatName) {
  136. const format = formatName.toLowerCase();
  137. switch (format) {
  138. case "xmb":
  139. return "xmb";
  140. case "xlf":
  141. case "xlif":
  142. case "xliff":
  143. case "xlf2":
  144. case "xliff2":
  145. return "xlf";
  146. }
  147. throw new Error(`Unsupported format "${formatName}"`);
  148. }
  149. function i18nExtract(formatName, outFile, host, options, bundle, pathResolve = path.resolve) {
  150. formatName = formatName || "xlf";
  151. const ext = i18nGetExtension(formatName);
  152. const content = i18nSerialize(bundle, formatName, options);
  153. const dstFile = outFile || `messages.${ext}`;
  154. const dstPath = pathResolve(options.outDir || options.basePath, dstFile);
  155. host.writeFile(dstPath, content, false, void 0, []);
  156. return [dstPath];
  157. }
  158. function i18nSerialize(bundle, formatName, options) {
  159. const format = formatName.toLowerCase();
  160. let serializer;
  161. switch (format) {
  162. case "xmb":
  163. serializer = new Xmb();
  164. break;
  165. case "xliff2":
  166. case "xlf2":
  167. serializer = new Xliff2();
  168. break;
  169. case "xlf":
  170. case "xliff":
  171. default:
  172. serializer = new Xliff();
  173. }
  174. return bundle.write(serializer, getPathNormalizer(options.basePath));
  175. }
  176. function getPathNormalizer(basePath) {
  177. return (sourcePath) => {
  178. sourcePath = basePath ? path.relative(basePath, sourcePath) : sourcePath;
  179. return sourcePath.split(path.sep).join("/");
  180. };
  181. }
  182. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/typescript_support.mjs
  183. import ts2 from "typescript";
  184. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/version_helpers.mjs
  185. function toNumbers(value) {
  186. const suffixIndex = value.lastIndexOf("-");
  187. return value.slice(0, suffixIndex === -1 ? value.length : suffixIndex).split(".").map((segment) => {
  188. const parsed = parseInt(segment, 10);
  189. if (isNaN(parsed)) {
  190. throw Error(`Unable to parse version string ${value}.`);
  191. }
  192. return parsed;
  193. });
  194. }
  195. function compareNumbers(a, b) {
  196. const max = Math.max(a.length, b.length);
  197. const min = Math.min(a.length, b.length);
  198. for (let i = 0; i < min; i++) {
  199. if (a[i] > b[i])
  200. return 1;
  201. if (a[i] < b[i])
  202. return -1;
  203. }
  204. if (min !== max) {
  205. const longestArray = a.length === max ? a : b;
  206. const comparisonResult = a.length === max ? 1 : -1;
  207. for (let i = min; i < max; i++) {
  208. if (longestArray[i] > 0) {
  209. return comparisonResult;
  210. }
  211. }
  212. }
  213. return 0;
  214. }
  215. function compareVersions(v1, v2) {
  216. return compareNumbers(toNumbers(v1), toNumbers(v2));
  217. }
  218. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/typescript_support.mjs
  219. var MIN_TS_VERSION = "4.9.3";
  220. var MAX_TS_VERSION = "5.1.0";
  221. var tsVersion = ts2.version;
  222. function checkVersion(version, minVersion, maxVersion) {
  223. if (compareVersions(version, minVersion) < 0 || compareVersions(version, maxVersion) >= 0) {
  224. throw new Error(`The Angular Compiler requires TypeScript >=${minVersion} and <${maxVersion} but ${version} was found instead.`);
  225. }
  226. }
  227. function verifySupportedTypeScriptVersion() {
  228. checkVersion(tsVersion, MIN_TS_VERSION, MAX_TS_VERSION);
  229. }
  230. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/core/src/compiler.mjs
  231. import ts30 from "typescript";
  232. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/cycles/src/analyzer.mjs
  233. var CycleAnalyzer = class {
  234. constructor(importGraph) {
  235. this.importGraph = importGraph;
  236. this.cachedResults = null;
  237. }
  238. wouldCreateCycle(from, to) {
  239. if (this.cachedResults === null || this.cachedResults.from !== from) {
  240. this.cachedResults = new CycleResults(from, this.importGraph);
  241. }
  242. return this.cachedResults.wouldBeCyclic(to) ? new Cycle(this.importGraph, from, to) : null;
  243. }
  244. recordSyntheticImport(from, to) {
  245. this.cachedResults = null;
  246. this.importGraph.addSyntheticImport(from, to);
  247. }
  248. };
  249. var NgCyclicResult = Symbol("NgCyclicResult");
  250. var CycleResults = class {
  251. constructor(from, importGraph) {
  252. this.from = from;
  253. this.importGraph = importGraph;
  254. this.cyclic = {};
  255. this.acyclic = {};
  256. }
  257. wouldBeCyclic(sf) {
  258. const cached = this.getCachedResult(sf);
  259. if (cached !== null) {
  260. return cached;
  261. }
  262. if (sf === this.from) {
  263. return true;
  264. }
  265. this.markAcyclic(sf);
  266. const imports = this.importGraph.importsOf(sf);
  267. for (const imported of imports) {
  268. if (this.wouldBeCyclic(imported)) {
  269. this.markCyclic(sf);
  270. return true;
  271. }
  272. }
  273. return false;
  274. }
  275. getCachedResult(sf) {
  276. const result = sf[NgCyclicResult];
  277. if (result === this.cyclic) {
  278. return true;
  279. } else if (result === this.acyclic) {
  280. return false;
  281. } else {
  282. return null;
  283. }
  284. }
  285. markCyclic(sf) {
  286. sf[NgCyclicResult] = this.cyclic;
  287. }
  288. markAcyclic(sf) {
  289. sf[NgCyclicResult] = this.acyclic;
  290. }
  291. };
  292. var Cycle = class {
  293. constructor(importGraph, from, to) {
  294. this.importGraph = importGraph;
  295. this.from = from;
  296. this.to = to;
  297. }
  298. getPath() {
  299. return [this.from, ...this.importGraph.findPath(this.to, this.from)];
  300. }
  301. };
  302. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/cycles/src/imports.mjs
  303. import ts3 from "typescript";
  304. var ImportGraph = class {
  305. constructor(checker, perf) {
  306. this.checker = checker;
  307. this.perf = perf;
  308. this.imports = /* @__PURE__ */ new Map();
  309. }
  310. importsOf(sf) {
  311. if (!this.imports.has(sf)) {
  312. this.imports.set(sf, this.scanImports(sf));
  313. }
  314. return this.imports.get(sf);
  315. }
  316. findPath(start, end) {
  317. if (start === end) {
  318. return [start];
  319. }
  320. const found = /* @__PURE__ */ new Set([start]);
  321. const queue = [new Found(start, null)];
  322. while (queue.length > 0) {
  323. const current = queue.shift();
  324. const imports = this.importsOf(current.sourceFile);
  325. for (const importedFile of imports) {
  326. if (!found.has(importedFile)) {
  327. const next = new Found(importedFile, current);
  328. if (next.sourceFile === end) {
  329. return next.toPath();
  330. }
  331. found.add(importedFile);
  332. queue.push(next);
  333. }
  334. }
  335. }
  336. return null;
  337. }
  338. addSyntheticImport(sf, imported) {
  339. if (isLocalFile(imported)) {
  340. this.importsOf(sf).add(imported);
  341. }
  342. }
  343. scanImports(sf) {
  344. return this.perf.inPhase(PerfPhase.CycleDetection, () => {
  345. const imports = /* @__PURE__ */ new Set();
  346. for (const stmt of sf.statements) {
  347. if (!ts3.isImportDeclaration(stmt) && !ts3.isExportDeclaration(stmt) || stmt.moduleSpecifier === void 0) {
  348. continue;
  349. }
  350. if (ts3.isImportDeclaration(stmt) && stmt.importClause !== void 0 && isTypeOnlyImportClause(stmt.importClause)) {
  351. continue;
  352. }
  353. const symbol = this.checker.getSymbolAtLocation(stmt.moduleSpecifier);
  354. if (symbol === void 0 || symbol.valueDeclaration === void 0) {
  355. continue;
  356. }
  357. const moduleFile = symbol.valueDeclaration;
  358. if (ts3.isSourceFile(moduleFile) && isLocalFile(moduleFile)) {
  359. imports.add(moduleFile);
  360. }
  361. }
  362. return imports;
  363. });
  364. }
  365. };
  366. function isLocalFile(sf) {
  367. return !sf.isDeclarationFile;
  368. }
  369. function isTypeOnlyImportClause(node) {
  370. if (node.isTypeOnly) {
  371. return true;
  372. }
  373. if (node.namedBindings !== void 0 && ts3.isNamedImports(node.namedBindings) && node.namedBindings.elements.every((specifier) => specifier.isTypeOnly)) {
  374. return true;
  375. }
  376. return false;
  377. }
  378. var Found = class {
  379. constructor(sourceFile, parent) {
  380. this.sourceFile = sourceFile;
  381. this.parent = parent;
  382. }
  383. toPath() {
  384. const array = [];
  385. let current = this;
  386. while (current !== null) {
  387. array.push(current.sourceFile);
  388. current = current.parent;
  389. }
  390. return array.reverse();
  391. }
  392. };
  393. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/entry_point/src/generator.mjs
  394. import ts4 from "typescript";
  395. var FlatIndexGenerator = class {
  396. constructor(entryPoint, relativeFlatIndexPath, moduleName) {
  397. this.entryPoint = entryPoint;
  398. this.moduleName = moduleName;
  399. this.shouldEmit = true;
  400. this.flatIndexPath = join(dirname(entryPoint), relativeFlatIndexPath).replace(/\.js$/, "") + ".ts";
  401. }
  402. makeTopLevelShim() {
  403. const relativeEntryPoint = relativePathBetween(this.flatIndexPath, this.entryPoint);
  404. const contents = `/**
  405. * Generated bundle index. Do not edit.
  406. */
  407. export * from '${relativeEntryPoint}';
  408. `;
  409. const genFile = ts4.createSourceFile(this.flatIndexPath, contents, ts4.ScriptTarget.ES2015, true, ts4.ScriptKind.TS);
  410. if (this.moduleName !== null) {
  411. genFile.moduleName = this.moduleName;
  412. }
  413. return genFile;
  414. }
  415. };
  416. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/entry_point/src/logic.mjs
  417. function findFlatIndexEntryPoint(rootFiles) {
  418. const tsFiles = rootFiles.filter((file) => isNonDeclarationTsPath(file));
  419. let resolvedEntryPoint = null;
  420. if (tsFiles.length === 1) {
  421. resolvedEntryPoint = tsFiles[0];
  422. } else {
  423. for (const tsFile of tsFiles) {
  424. if (getFileSystem().basename(tsFile) === "index.ts" && (resolvedEntryPoint === null || tsFile.length <= resolvedEntryPoint.length)) {
  425. resolvedEntryPoint = tsFile;
  426. }
  427. }
  428. }
  429. return resolvedEntryPoint;
  430. }
  431. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/entry_point/src/private_export_checker.mjs
  432. import ts5 from "typescript";
  433. function checkForPrivateExports(entryPoint, checker, refGraph) {
  434. const diagnostics = [];
  435. const topLevelExports = /* @__PURE__ */ new Set();
  436. const moduleSymbol = checker.getSymbolAtLocation(entryPoint);
  437. if (moduleSymbol === void 0) {
  438. throw new Error(`Internal error: failed to get symbol for entrypoint`);
  439. }
  440. const exportedSymbols = checker.getExportsOfModule(moduleSymbol);
  441. exportedSymbols.forEach((symbol) => {
  442. if (symbol.flags & ts5.SymbolFlags.Alias) {
  443. symbol = checker.getAliasedSymbol(symbol);
  444. }
  445. const decl = symbol.valueDeclaration;
  446. if (decl !== void 0) {
  447. topLevelExports.add(decl);
  448. }
  449. });
  450. const checkedSet = /* @__PURE__ */ new Set();
  451. topLevelExports.forEach((mainExport) => {
  452. refGraph.transitiveReferencesOf(mainExport).forEach((transitiveReference) => {
  453. if (checkedSet.has(transitiveReference)) {
  454. return;
  455. }
  456. checkedSet.add(transitiveReference);
  457. if (!topLevelExports.has(transitiveReference)) {
  458. const descriptor = getDescriptorOfDeclaration(transitiveReference);
  459. const name = getNameOfDeclaration(transitiveReference);
  460. let visibleVia = "NgModule exports";
  461. const transitivePath = refGraph.pathFrom(mainExport, transitiveReference);
  462. if (transitivePath !== null) {
  463. visibleVia = transitivePath.map((seg) => getNameOfDeclaration(seg)).join(" -> ");
  464. }
  465. const diagnostic = {
  466. category: ts5.DiagnosticCategory.Error,
  467. code: ngErrorCode(ErrorCode.SYMBOL_NOT_EXPORTED),
  468. file: transitiveReference.getSourceFile(),
  469. ...getPosOfDeclaration(transitiveReference),
  470. messageText: `Unsupported private ${descriptor} ${name}. This ${descriptor} is visible to consumers via ${visibleVia}, but is not exported from the top-level library entrypoint.`
  471. };
  472. diagnostics.push(diagnostic);
  473. }
  474. });
  475. });
  476. return diagnostics;
  477. }
  478. function getPosOfDeclaration(decl) {
  479. const node = getIdentifierOfDeclaration(decl) || decl;
  480. return {
  481. start: node.getStart(),
  482. length: node.getEnd() + 1 - node.getStart()
  483. };
  484. }
  485. function getIdentifierOfDeclaration(decl) {
  486. if ((ts5.isClassDeclaration(decl) || ts5.isVariableDeclaration(decl) || ts5.isFunctionDeclaration(decl)) && decl.name !== void 0 && ts5.isIdentifier(decl.name)) {
  487. return decl.name;
  488. } else {
  489. return null;
  490. }
  491. }
  492. function getNameOfDeclaration(decl) {
  493. const id = getIdentifierOfDeclaration(decl);
  494. return id !== null ? id.text : "(unnamed)";
  495. }
  496. function getDescriptorOfDeclaration(decl) {
  497. switch (decl.kind) {
  498. case ts5.SyntaxKind.ClassDeclaration:
  499. return "class";
  500. case ts5.SyntaxKind.FunctionDeclaration:
  501. return "function";
  502. case ts5.SyntaxKind.VariableDeclaration:
  503. return "variable";
  504. case ts5.SyntaxKind.EnumDeclaration:
  505. return "enum";
  506. default:
  507. return "declaration";
  508. }
  509. }
  510. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/entry_point/src/reference_graph.mjs
  511. var ReferenceGraph = class {
  512. constructor() {
  513. this.references = /* @__PURE__ */ new Map();
  514. }
  515. add(from, to) {
  516. if (!this.references.has(from)) {
  517. this.references.set(from, /* @__PURE__ */ new Set());
  518. }
  519. this.references.get(from).add(to);
  520. }
  521. transitiveReferencesOf(target) {
  522. const set = /* @__PURE__ */ new Set();
  523. this.collectTransitiveReferences(set, target);
  524. return set;
  525. }
  526. pathFrom(source, target) {
  527. return this.collectPathFrom(source, target, /* @__PURE__ */ new Set());
  528. }
  529. collectPathFrom(source, target, seen) {
  530. if (source === target) {
  531. return [target];
  532. } else if (seen.has(source)) {
  533. return null;
  534. }
  535. seen.add(source);
  536. if (!this.references.has(source)) {
  537. return null;
  538. } else {
  539. let candidatePath = null;
  540. this.references.get(source).forEach((edge) => {
  541. if (candidatePath !== null) {
  542. return;
  543. }
  544. const partialPath = this.collectPathFrom(edge, target, seen);
  545. if (partialPath !== null) {
  546. candidatePath = [source, ...partialPath];
  547. }
  548. });
  549. return candidatePath;
  550. }
  551. }
  552. collectTransitiveReferences(set, decl) {
  553. if (this.references.has(decl)) {
  554. this.references.get(decl).forEach((ref) => {
  555. if (!set.has(ref)) {
  556. set.add(ref);
  557. this.collectTransitiveReferences(set, ref);
  558. }
  559. });
  560. }
  561. }
  562. };
  563. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/program_driver/src/api.mjs
  564. var NgOriginalFile = Symbol("NgOriginalFile");
  565. var UpdateMode;
  566. (function(UpdateMode2) {
  567. UpdateMode2[UpdateMode2["Complete"] = 0] = "Complete";
  568. UpdateMode2[UpdateMode2["Incremental"] = 1] = "Incremental";
  569. })(UpdateMode || (UpdateMode = {}));
  570. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/program_driver/src/ts_create_program_driver.mjs
  571. import ts7 from "typescript";
  572. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/adapter.mjs
  573. import ts6 from "typescript";
  574. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/expando.mjs
  575. var NgExtension = Symbol("NgExtension");
  576. function isExtended(sf) {
  577. return sf[NgExtension] !== void 0;
  578. }
  579. function sfExtensionData(sf) {
  580. const extSf = sf;
  581. if (extSf[NgExtension] !== void 0) {
  582. return extSf[NgExtension];
  583. }
  584. const extension = {
  585. isTopLevelShim: false,
  586. fileShim: null,
  587. originalReferencedFiles: null,
  588. taggedReferenceFiles: null
  589. };
  590. extSf[NgExtension] = extension;
  591. return extension;
  592. }
  593. function isFileShimSourceFile(sf) {
  594. return isExtended(sf) && sf[NgExtension].fileShim !== null;
  595. }
  596. function isShim(sf) {
  597. return isExtended(sf) && (sf[NgExtension].fileShim !== null || sf[NgExtension].isTopLevelShim);
  598. }
  599. function copyFileShimData(from, to) {
  600. if (!isFileShimSourceFile(from)) {
  601. return;
  602. }
  603. sfExtensionData(to).fileShim = sfExtensionData(from).fileShim;
  604. }
  605. function untagAllTsFiles(program) {
  606. for (const sf of program.getSourceFiles()) {
  607. untagTsFile(sf);
  608. }
  609. }
  610. function retagAllTsFiles(program) {
  611. for (const sf of program.getSourceFiles()) {
  612. retagTsFile(sf);
  613. }
  614. }
  615. function untagTsFile(sf) {
  616. if (sf.isDeclarationFile || !isExtended(sf)) {
  617. return;
  618. }
  619. const ext = sfExtensionData(sf);
  620. if (ext.originalReferencedFiles !== null) {
  621. sf.referencedFiles = ext.originalReferencedFiles;
  622. }
  623. }
  624. function retagTsFile(sf) {
  625. if (sf.isDeclarationFile || !isExtended(sf)) {
  626. return;
  627. }
  628. const ext = sfExtensionData(sf);
  629. if (ext.taggedReferenceFiles !== null) {
  630. sf.referencedFiles = ext.taggedReferenceFiles;
  631. }
  632. }
  633. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/util.mjs
  634. var TS_EXTENSIONS = /\.tsx?$/i;
  635. function makeShimFileName(fileName, suffix) {
  636. return absoluteFrom(fileName.replace(TS_EXTENSIONS, suffix));
  637. }
  638. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/adapter.mjs
  639. var ShimAdapter = class {
  640. constructor(delegate, tsRootFiles, topLevelGenerators, perFileGenerators, oldProgram) {
  641. this.delegate = delegate;
  642. this.shims = /* @__PURE__ */ new Map();
  643. this.priorShims = /* @__PURE__ */ new Map();
  644. this.notShims = /* @__PURE__ */ new Set();
  645. this.generators = [];
  646. this.ignoreForEmit = /* @__PURE__ */ new Set();
  647. this.extensionPrefixes = [];
  648. for (const gen of perFileGenerators) {
  649. const pattern = `^(.*)\\.${gen.extensionPrefix}\\.ts$`;
  650. const regexp = new RegExp(pattern, "i");
  651. this.generators.push({
  652. generator: gen,
  653. test: regexp,
  654. suffix: `.${gen.extensionPrefix}.ts`
  655. });
  656. this.extensionPrefixes.push(gen.extensionPrefix);
  657. }
  658. const extraInputFiles = [];
  659. for (const gen of topLevelGenerators) {
  660. const sf = gen.makeTopLevelShim();
  661. sfExtensionData(sf).isTopLevelShim = true;
  662. if (!gen.shouldEmit) {
  663. this.ignoreForEmit.add(sf);
  664. }
  665. const fileName = absoluteFromSourceFile(sf);
  666. this.shims.set(fileName, sf);
  667. extraInputFiles.push(fileName);
  668. }
  669. for (const rootFile of tsRootFiles) {
  670. for (const gen of this.generators) {
  671. extraInputFiles.push(makeShimFileName(rootFile, gen.suffix));
  672. }
  673. }
  674. this.extraInputFiles = extraInputFiles;
  675. if (oldProgram !== null) {
  676. for (const oldSf of oldProgram.getSourceFiles()) {
  677. if (oldSf.isDeclarationFile || !isFileShimSourceFile(oldSf)) {
  678. continue;
  679. }
  680. this.priorShims.set(absoluteFromSourceFile(oldSf), oldSf);
  681. }
  682. }
  683. }
  684. maybeGenerate(fileName) {
  685. if (this.notShims.has(fileName)) {
  686. return null;
  687. } else if (this.shims.has(fileName)) {
  688. return this.shims.get(fileName);
  689. }
  690. if (isDtsPath(fileName)) {
  691. this.notShims.add(fileName);
  692. return null;
  693. }
  694. for (const record of this.generators) {
  695. const match = record.test.exec(fileName);
  696. if (match === null) {
  697. continue;
  698. }
  699. const prefix = match[1];
  700. let baseFileName = absoluteFrom(prefix + ".ts");
  701. let inputFile = this.delegate.getSourceFile(baseFileName, ts6.ScriptTarget.Latest);
  702. if (inputFile === void 0) {
  703. baseFileName = absoluteFrom(prefix + ".tsx");
  704. inputFile = this.delegate.getSourceFile(baseFileName, ts6.ScriptTarget.Latest);
  705. }
  706. if (inputFile === void 0 || isShim(inputFile)) {
  707. return void 0;
  708. }
  709. return this.generateSpecific(fileName, record.generator, inputFile);
  710. }
  711. this.notShims.add(fileName);
  712. return null;
  713. }
  714. generateSpecific(fileName, generator, inputFile) {
  715. let priorShimSf = null;
  716. if (this.priorShims.has(fileName)) {
  717. priorShimSf = this.priorShims.get(fileName);
  718. this.priorShims.delete(fileName);
  719. }
  720. const shimSf = generator.generateShimForFile(inputFile, fileName, priorShimSf);
  721. sfExtensionData(shimSf).fileShim = {
  722. extension: generator.extensionPrefix,
  723. generatedFrom: absoluteFromSourceFile(inputFile)
  724. };
  725. if (!generator.shouldEmit) {
  726. this.ignoreForEmit.add(shimSf);
  727. }
  728. this.shims.set(fileName, shimSf);
  729. return shimSf;
  730. }
  731. };
  732. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/reference_tagger.mjs
  733. var ShimReferenceTagger = class {
  734. constructor(shimExtensions) {
  735. this.tagged = /* @__PURE__ */ new Set();
  736. this.enabled = true;
  737. this.suffixes = shimExtensions.map((extension) => `.${extension}.ts`);
  738. }
  739. tag(sf) {
  740. if (!this.enabled || sf.isDeclarationFile || isShim(sf) || this.tagged.has(sf) || !isNonDeclarationTsPath(sf.fileName)) {
  741. return;
  742. }
  743. const ext = sfExtensionData(sf);
  744. if (ext.originalReferencedFiles === null) {
  745. ext.originalReferencedFiles = sf.referencedFiles;
  746. }
  747. const referencedFiles = [...ext.originalReferencedFiles];
  748. const sfPath = absoluteFromSourceFile(sf);
  749. for (const suffix of this.suffixes) {
  750. referencedFiles.push({
  751. fileName: makeShimFileName(sfPath, suffix),
  752. pos: 0,
  753. end: 0
  754. });
  755. }
  756. ext.taggedReferenceFiles = referencedFiles;
  757. sf.referencedFiles = referencedFiles;
  758. this.tagged.add(sf);
  759. }
  760. finalize() {
  761. this.enabled = false;
  762. this.tagged.clear();
  763. }
  764. };
  765. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/program_driver/src/ts_create_program_driver.mjs
  766. var DelegatingCompilerHost = class {
  767. constructor(delegate) {
  768. this.delegate = delegate;
  769. this.createHash = this.delegateMethod("createHash");
  770. this.directoryExists = this.delegateMethod("directoryExists");
  771. this.getCancellationToken = this.delegateMethod("getCancellationToken");
  772. this.getCanonicalFileName = this.delegateMethod("getCanonicalFileName");
  773. this.getCurrentDirectory = this.delegateMethod("getCurrentDirectory");
  774. this.getDefaultLibFileName = this.delegateMethod("getDefaultLibFileName");
  775. this.getDefaultLibLocation = this.delegateMethod("getDefaultLibLocation");
  776. this.getDirectories = this.delegateMethod("getDirectories");
  777. this.getEnvironmentVariable = this.delegateMethod("getEnvironmentVariable");
  778. this.getNewLine = this.delegateMethod("getNewLine");
  779. this.getParsedCommandLine = this.delegateMethod("getParsedCommandLine");
  780. this.getSourceFileByPath = this.delegateMethod("getSourceFileByPath");
  781. this.readDirectory = this.delegateMethod("readDirectory");
  782. this.readFile = this.delegateMethod("readFile");
  783. this.realpath = this.delegateMethod("realpath");
  784. this.resolveModuleNames = this.delegateMethod("resolveModuleNames");
  785. this.resolveTypeReferenceDirectives = this.delegateMethod("resolveTypeReferenceDirectives");
  786. this.trace = this.delegateMethod("trace");
  787. this.useCaseSensitiveFileNames = this.delegateMethod("useCaseSensitiveFileNames");
  788. this.getModuleResolutionCache = this.delegateMethod("getModuleResolutionCache");
  789. this.hasInvalidatedResolutions = this.delegateMethod("hasInvalidatedResolutions");
  790. this.resolveModuleNameLiterals = this.delegateMethod("resolveModuleNameLiterals");
  791. this.resolveTypeReferenceDirectiveReferences = this.delegateMethod("resolveTypeReferenceDirectiveReferences");
  792. }
  793. delegateMethod(name) {
  794. return this.delegate[name] !== void 0 ? this.delegate[name].bind(this.delegate) : void 0;
  795. }
  796. };
  797. var UpdatedProgramHost = class extends DelegatingCompilerHost {
  798. constructor(sfMap, originalProgram, delegate, shimExtensionPrefixes) {
  799. super(delegate);
  800. this.originalProgram = originalProgram;
  801. this.shimExtensionPrefixes = shimExtensionPrefixes;
  802. this.shimTagger = new ShimReferenceTagger(this.shimExtensionPrefixes);
  803. this.sfMap = sfMap;
  804. }
  805. getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) {
  806. let delegateSf = this.originalProgram.getSourceFile(fileName);
  807. if (delegateSf === void 0) {
  808. delegateSf = this.delegate.getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
  809. }
  810. if (delegateSf === void 0) {
  811. return void 0;
  812. }
  813. let sf;
  814. if (this.sfMap.has(fileName)) {
  815. sf = this.sfMap.get(fileName);
  816. copyFileShimData(delegateSf, sf);
  817. } else {
  818. sf = delegateSf;
  819. }
  820. sf = toUnredirectedSourceFile(sf);
  821. this.shimTagger.tag(sf);
  822. return sf;
  823. }
  824. postProgramCreationCleanup() {
  825. this.shimTagger.finalize();
  826. }
  827. writeFile() {
  828. throw new Error(`TypeCheckProgramHost should never write files`);
  829. }
  830. fileExists(fileName) {
  831. return this.sfMap.has(fileName) || this.delegate.fileExists(fileName);
  832. }
  833. };
  834. var TsCreateProgramDriver = class {
  835. constructor(originalProgram, originalHost, options, shimExtensionPrefixes) {
  836. this.originalProgram = originalProgram;
  837. this.originalHost = originalHost;
  838. this.options = options;
  839. this.shimExtensionPrefixes = shimExtensionPrefixes;
  840. this.sfMap = /* @__PURE__ */ new Map();
  841. this.supportsInlineOperations = true;
  842. this.program = this.originalProgram;
  843. }
  844. getProgram() {
  845. return this.program;
  846. }
  847. updateFiles(contents, updateMode) {
  848. if (contents.size === 0) {
  849. if (updateMode !== UpdateMode.Complete || this.sfMap.size === 0) {
  850. return;
  851. }
  852. }
  853. if (updateMode === UpdateMode.Complete) {
  854. this.sfMap.clear();
  855. }
  856. for (const [filePath, { newText, originalFile }] of contents.entries()) {
  857. const sf = ts7.createSourceFile(filePath, newText, ts7.ScriptTarget.Latest, true);
  858. if (originalFile !== null) {
  859. sf[NgOriginalFile] = originalFile;
  860. }
  861. this.sfMap.set(filePath, sf);
  862. }
  863. const host = new UpdatedProgramHost(this.sfMap, this.originalProgram, this.originalHost, this.shimExtensionPrefixes);
  864. const oldProgram = this.program;
  865. retagAllTsFiles(oldProgram);
  866. this.program = ts7.createProgram({
  867. host,
  868. rootNames: this.program.getRootFileNames(),
  869. options: this.options,
  870. oldProgram
  871. });
  872. host.postProgramCreationCleanup();
  873. untagAllTsFiles(this.program);
  874. untagAllTsFiles(oldProgram);
  875. }
  876. };
  877. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/incremental/src/dependency_tracking.mjs
  878. var FileDependencyGraph = class {
  879. constructor() {
  880. this.nodes = /* @__PURE__ */ new Map();
  881. }
  882. addDependency(from, on) {
  883. this.nodeFor(from).dependsOn.add(absoluteFromSourceFile(on));
  884. }
  885. addResourceDependency(from, resource) {
  886. this.nodeFor(from).usesResources.add(resource);
  887. }
  888. recordDependencyAnalysisFailure(file) {
  889. this.nodeFor(file).failedAnalysis = true;
  890. }
  891. getResourceDependencies(from) {
  892. const node = this.nodes.get(from);
  893. return node ? [...node.usesResources] : [];
  894. }
  895. updateWithPhysicalChanges(previous, changedTsPaths, deletedTsPaths, changedResources) {
  896. const logicallyChanged = /* @__PURE__ */ new Set();
  897. for (const sf of previous.nodes.keys()) {
  898. const sfPath = absoluteFromSourceFile(sf);
  899. const node = previous.nodeFor(sf);
  900. if (isLogicallyChanged(sf, node, changedTsPaths, deletedTsPaths, changedResources)) {
  901. logicallyChanged.add(sfPath);
  902. } else if (!deletedTsPaths.has(sfPath)) {
  903. this.nodes.set(sf, {
  904. dependsOn: new Set(node.dependsOn),
  905. usesResources: new Set(node.usesResources),
  906. failedAnalysis: false
  907. });
  908. }
  909. }
  910. return logicallyChanged;
  911. }
  912. nodeFor(sf) {
  913. if (!this.nodes.has(sf)) {
  914. this.nodes.set(sf, {
  915. dependsOn: /* @__PURE__ */ new Set(),
  916. usesResources: /* @__PURE__ */ new Set(),
  917. failedAnalysis: false
  918. });
  919. }
  920. return this.nodes.get(sf);
  921. }
  922. };
  923. function isLogicallyChanged(sf, node, changedTsPaths, deletedTsPaths, changedResources) {
  924. if (node.failedAnalysis) {
  925. return true;
  926. }
  927. const sfPath = absoluteFromSourceFile(sf);
  928. if (changedTsPaths.has(sfPath) || deletedTsPaths.has(sfPath)) {
  929. return true;
  930. }
  931. for (const dep of node.dependsOn) {
  932. if (changedTsPaths.has(dep) || deletedTsPaths.has(dep)) {
  933. return true;
  934. }
  935. }
  936. for (const dep of node.usesResources) {
  937. if (changedResources.has(dep)) {
  938. return true;
  939. }
  940. }
  941. return false;
  942. }
  943. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/incremental/src/state.mjs
  944. var IncrementalStateKind;
  945. (function(IncrementalStateKind2) {
  946. IncrementalStateKind2[IncrementalStateKind2["Fresh"] = 0] = "Fresh";
  947. IncrementalStateKind2[IncrementalStateKind2["Delta"] = 1] = "Delta";
  948. IncrementalStateKind2[IncrementalStateKind2["Analyzed"] = 2] = "Analyzed";
  949. })(IncrementalStateKind || (IncrementalStateKind = {}));
  950. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/incremental/src/incremental.mjs
  951. var PhaseKind;
  952. (function(PhaseKind2) {
  953. PhaseKind2[PhaseKind2["Analysis"] = 0] = "Analysis";
  954. PhaseKind2[PhaseKind2["TypeCheckAndEmit"] = 1] = "TypeCheckAndEmit";
  955. })(PhaseKind || (PhaseKind = {}));
  956. var IncrementalCompilation = class {
  957. constructor(state, depGraph, versions, step) {
  958. this.depGraph = depGraph;
  959. this.versions = versions;
  960. this.step = step;
  961. this._state = state;
  962. this.phase = {
  963. kind: PhaseKind.Analysis,
  964. semanticDepGraphUpdater: new SemanticDepGraphUpdater(step !== null ? step.priorState.semanticDepGraph : null)
  965. };
  966. }
  967. static fresh(program, versions) {
  968. const state = {
  969. kind: IncrementalStateKind.Fresh
  970. };
  971. return new IncrementalCompilation(state, new FileDependencyGraph(), versions, null);
  972. }
  973. static incremental(program, newVersions, oldProgram, oldState, modifiedResourceFiles, perf) {
  974. return perf.inPhase(PerfPhase.Reconciliation, () => {
  975. const physicallyChangedTsFiles = /* @__PURE__ */ new Set();
  976. const changedResourceFiles = new Set(modifiedResourceFiles != null ? modifiedResourceFiles : []);
  977. let priorAnalysis;
  978. switch (oldState.kind) {
  979. case IncrementalStateKind.Fresh:
  980. return IncrementalCompilation.fresh(program, newVersions);
  981. case IncrementalStateKind.Analyzed:
  982. priorAnalysis = oldState;
  983. break;
  984. case IncrementalStateKind.Delta:
  985. priorAnalysis = oldState.lastAnalyzedState;
  986. for (const sfPath of oldState.physicallyChangedTsFiles) {
  987. physicallyChangedTsFiles.add(sfPath);
  988. }
  989. for (const resourcePath of oldState.changedResourceFiles) {
  990. changedResourceFiles.add(resourcePath);
  991. }
  992. break;
  993. }
  994. const oldVersions = priorAnalysis.versions;
  995. const oldFilesArray = oldProgram.getSourceFiles().map(toOriginalSourceFile);
  996. const oldFiles = new Set(oldFilesArray);
  997. const deletedTsFiles = new Set(oldFilesArray.map((sf) => absoluteFromSourceFile(sf)));
  998. for (const possiblyRedirectedNewFile of program.getSourceFiles()) {
  999. const sf = toOriginalSourceFile(possiblyRedirectedNewFile);
  1000. const sfPath = absoluteFromSourceFile(sf);
  1001. deletedTsFiles.delete(sfPath);
  1002. if (oldFiles.has(sf)) {
  1003. if (oldVersions === null || newVersions === null) {
  1004. continue;
  1005. }
  1006. if (oldVersions.has(sfPath) && newVersions.has(sfPath) && oldVersions.get(sfPath) === newVersions.get(sfPath)) {
  1007. continue;
  1008. }
  1009. }
  1010. if (sf.isDeclarationFile) {
  1011. return IncrementalCompilation.fresh(program, newVersions);
  1012. }
  1013. physicallyChangedTsFiles.add(sfPath);
  1014. }
  1015. for (const deletedFileName of deletedTsFiles) {
  1016. physicallyChangedTsFiles.delete(resolve(deletedFileName));
  1017. }
  1018. const depGraph = new FileDependencyGraph();
  1019. const logicallyChangedTsFiles = depGraph.updateWithPhysicalChanges(priorAnalysis.depGraph, physicallyChangedTsFiles, deletedTsFiles, changedResourceFiles);
  1020. for (const sfPath of physicallyChangedTsFiles) {
  1021. logicallyChangedTsFiles.add(sfPath);
  1022. }
  1023. const state = {
  1024. kind: IncrementalStateKind.Delta,
  1025. physicallyChangedTsFiles,
  1026. changedResourceFiles,
  1027. lastAnalyzedState: priorAnalysis
  1028. };
  1029. return new IncrementalCompilation(state, depGraph, newVersions, {
  1030. priorState: priorAnalysis,
  1031. logicallyChangedTsFiles
  1032. });
  1033. });
  1034. }
  1035. get state() {
  1036. return this._state;
  1037. }
  1038. get semanticDepGraphUpdater() {
  1039. if (this.phase.kind !== PhaseKind.Analysis) {
  1040. throw new Error(`AssertionError: Cannot update the SemanticDepGraph after analysis completes`);
  1041. }
  1042. return this.phase.semanticDepGraphUpdater;
  1043. }
  1044. recordSuccessfulAnalysis(traitCompiler) {
  1045. if (this.phase.kind !== PhaseKind.Analysis) {
  1046. throw new Error(`AssertionError: Incremental compilation in phase ${PhaseKind[this.phase.kind]}, expected Analysis`);
  1047. }
  1048. const { needsEmit, needsTypeCheckEmit, newGraph } = this.phase.semanticDepGraphUpdater.finalize();
  1049. let emitted;
  1050. if (this.step === null) {
  1051. emitted = /* @__PURE__ */ new Set();
  1052. } else {
  1053. emitted = new Set(this.step.priorState.emitted);
  1054. for (const sfPath of this.step.logicallyChangedTsFiles) {
  1055. emitted.delete(sfPath);
  1056. }
  1057. for (const sfPath of needsEmit) {
  1058. emitted.delete(sfPath);
  1059. }
  1060. }
  1061. this._state = {
  1062. kind: IncrementalStateKind.Analyzed,
  1063. versions: this.versions,
  1064. depGraph: this.depGraph,
  1065. semanticDepGraph: newGraph,
  1066. priorAnalysis: traitCompiler.getAnalyzedRecords(),
  1067. typeCheckResults: null,
  1068. emitted
  1069. };
  1070. this.phase = {
  1071. kind: PhaseKind.TypeCheckAndEmit,
  1072. needsEmit,
  1073. needsTypeCheckEmit
  1074. };
  1075. }
  1076. recordSuccessfulTypeCheck(results) {
  1077. if (this._state.kind !== IncrementalStateKind.Analyzed) {
  1078. throw new Error(`AssertionError: Expected successfully analyzed compilation.`);
  1079. } else if (this.phase.kind !== PhaseKind.TypeCheckAndEmit) {
  1080. throw new Error(`AssertionError: Incremental compilation in phase ${PhaseKind[this.phase.kind]}, expected TypeCheck`);
  1081. }
  1082. this._state.typeCheckResults = results;
  1083. }
  1084. recordSuccessfulEmit(sf) {
  1085. if (this._state.kind !== IncrementalStateKind.Analyzed) {
  1086. throw new Error(`AssertionError: Expected successfully analyzed compilation.`);
  1087. }
  1088. this._state.emitted.add(absoluteFromSourceFile(sf));
  1089. }
  1090. priorAnalysisFor(sf) {
  1091. if (this.step === null) {
  1092. return null;
  1093. }
  1094. const sfPath = absoluteFromSourceFile(sf);
  1095. if (this.step.logicallyChangedTsFiles.has(sfPath)) {
  1096. return null;
  1097. }
  1098. const priorAnalysis = this.step.priorState.priorAnalysis;
  1099. if (!priorAnalysis.has(sf)) {
  1100. return null;
  1101. }
  1102. return priorAnalysis.get(sf);
  1103. }
  1104. priorTypeCheckingResultsFor(sf) {
  1105. if (this.phase.kind !== PhaseKind.TypeCheckAndEmit) {
  1106. throw new Error(`AssertionError: Expected successfully analyzed compilation.`);
  1107. }
  1108. if (this.step === null) {
  1109. return null;
  1110. }
  1111. const sfPath = absoluteFromSourceFile(sf);
  1112. if (this.step.logicallyChangedTsFiles.has(sfPath) || this.phase.needsTypeCheckEmit.has(sfPath)) {
  1113. return null;
  1114. }
  1115. if (this.step.priorState.typeCheckResults === null || !this.step.priorState.typeCheckResults.has(sfPath)) {
  1116. return null;
  1117. }
  1118. const priorResults = this.step.priorState.typeCheckResults.get(sfPath);
  1119. if (priorResults.hasInlines) {
  1120. return null;
  1121. }
  1122. return priorResults;
  1123. }
  1124. safeToSkipEmit(sf) {
  1125. if (this.step === null) {
  1126. return false;
  1127. }
  1128. const sfPath = absoluteFromSourceFile(sf);
  1129. if (this.step.logicallyChangedTsFiles.has(sfPath)) {
  1130. return false;
  1131. }
  1132. if (this.phase.kind !== PhaseKind.TypeCheckAndEmit) {
  1133. throw new Error(`AssertionError: Expected successful analysis before attempting to emit files`);
  1134. }
  1135. if (this.phase.needsEmit.has(sfPath)) {
  1136. return false;
  1137. }
  1138. return this.step.priorState.emitted.has(sfPath);
  1139. }
  1140. };
  1141. function toOriginalSourceFile(sf) {
  1142. const unredirectedSf = toUnredirectedSourceFile(sf);
  1143. const originalFile = unredirectedSf[NgOriginalFile];
  1144. if (originalFile !== void 0) {
  1145. return originalFile;
  1146. } else {
  1147. return unredirectedSf;
  1148. }
  1149. }
  1150. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/incremental/src/strategy.mjs
  1151. var TrackedIncrementalBuildStrategy = class {
  1152. constructor() {
  1153. this.state = null;
  1154. this.isSet = false;
  1155. }
  1156. getIncrementalState() {
  1157. return this.state;
  1158. }
  1159. setIncrementalState(state) {
  1160. this.state = state;
  1161. this.isSet = true;
  1162. }
  1163. toNextBuildStrategy() {
  1164. const strategy = new TrackedIncrementalBuildStrategy();
  1165. strategy.state = this.isSet ? this.state : null;
  1166. return strategy;
  1167. }
  1168. };
  1169. var PatchedProgramIncrementalBuildStrategy = class {
  1170. getIncrementalState(program) {
  1171. const state = program[SYM_INCREMENTAL_STATE];
  1172. if (state === void 0) {
  1173. return null;
  1174. }
  1175. return state;
  1176. }
  1177. setIncrementalState(state, program) {
  1178. program[SYM_INCREMENTAL_STATE] = state;
  1179. }
  1180. toNextBuildStrategy() {
  1181. return this;
  1182. }
  1183. };
  1184. var SYM_INCREMENTAL_STATE = Symbol("NgIncrementalState");
  1185. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/indexer/src/api.mjs
  1186. var IdentifierKind;
  1187. (function(IdentifierKind2) {
  1188. IdentifierKind2[IdentifierKind2["Property"] = 0] = "Property";
  1189. IdentifierKind2[IdentifierKind2["Method"] = 1] = "Method";
  1190. IdentifierKind2[IdentifierKind2["Element"] = 2] = "Element";
  1191. IdentifierKind2[IdentifierKind2["Template"] = 3] = "Template";
  1192. IdentifierKind2[IdentifierKind2["Attribute"] = 4] = "Attribute";
  1193. IdentifierKind2[IdentifierKind2["Reference"] = 5] = "Reference";
  1194. IdentifierKind2[IdentifierKind2["Variable"] = 6] = "Variable";
  1195. })(IdentifierKind || (IdentifierKind = {}));
  1196. var AbsoluteSourceSpan = class {
  1197. constructor(start, end) {
  1198. this.start = start;
  1199. this.end = end;
  1200. }
  1201. };
  1202. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/indexer/src/context.mjs
  1203. var IndexingContext = class {
  1204. constructor() {
  1205. this.components = /* @__PURE__ */ new Set();
  1206. }
  1207. addComponent(info) {
  1208. this.components.add(info);
  1209. }
  1210. };
  1211. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/indexer/src/transform.mjs
  1212. import { ParseSourceFile } from "@angular/compiler";
  1213. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/indexer/src/template.mjs
  1214. import { ASTWithSource, ImplicitReceiver, PropertyRead, PropertyWrite, RecursiveAstVisitor, TmplAstElement, TmplAstRecursiveVisitor, TmplAstReference, TmplAstTemplate } from "@angular/compiler";
  1215. var ExpressionVisitor = class extends RecursiveAstVisitor {
  1216. constructor(expressionStr, absoluteOffset, boundTemplate, targetToIdentifier) {
  1217. super();
  1218. this.expressionStr = expressionStr;
  1219. this.absoluteOffset = absoluteOffset;
  1220. this.boundTemplate = boundTemplate;
  1221. this.targetToIdentifier = targetToIdentifier;
  1222. this.identifiers = [];
  1223. this.errors = [];
  1224. }
  1225. static getIdentifiers(ast, source, absoluteOffset, boundTemplate, targetToIdentifier) {
  1226. const visitor = new ExpressionVisitor(source, absoluteOffset, boundTemplate, targetToIdentifier);
  1227. visitor.visit(ast);
  1228. return { identifiers: visitor.identifiers, errors: visitor.errors };
  1229. }
  1230. visit(ast) {
  1231. ast.visit(this);
  1232. }
  1233. visitPropertyRead(ast, context) {
  1234. this.visitIdentifier(ast, IdentifierKind.Property);
  1235. super.visitPropertyRead(ast, context);
  1236. }
  1237. visitPropertyWrite(ast, context) {
  1238. this.visitIdentifier(ast, IdentifierKind.Property);
  1239. super.visitPropertyWrite(ast, context);
  1240. }
  1241. visitIdentifier(ast, kind) {
  1242. if (!(ast.receiver instanceof ImplicitReceiver)) {
  1243. return;
  1244. }
  1245. let identifierStart = ast.sourceSpan.start - this.absoluteOffset;
  1246. if (ast instanceof PropertyRead || ast instanceof PropertyWrite) {
  1247. identifierStart = ast.nameSpan.start - this.absoluteOffset;
  1248. }
  1249. if (!this.expressionStr.substring(identifierStart).startsWith(ast.name)) {
  1250. this.errors.push(new Error(`Impossible state: "${ast.name}" not found in "${this.expressionStr}" at location ${identifierStart}`));
  1251. return;
  1252. }
  1253. const absoluteStart = this.absoluteOffset + identifierStart;
  1254. const span = new AbsoluteSourceSpan(absoluteStart, absoluteStart + ast.name.length);
  1255. const targetAst = this.boundTemplate.getExpressionTarget(ast);
  1256. const target = targetAst ? this.targetToIdentifier(targetAst) : null;
  1257. const identifier = {
  1258. name: ast.name,
  1259. span,
  1260. kind,
  1261. target
  1262. };
  1263. this.identifiers.push(identifier);
  1264. }
  1265. };
  1266. var TemplateVisitor = class extends TmplAstRecursiveVisitor {
  1267. constructor(boundTemplate) {
  1268. super();
  1269. this.boundTemplate = boundTemplate;
  1270. this.identifiers = /* @__PURE__ */ new Set();
  1271. this.errors = [];
  1272. this.targetIdentifierCache = /* @__PURE__ */ new Map();
  1273. this.elementAndTemplateIdentifierCache = /* @__PURE__ */ new Map();
  1274. }
  1275. visit(node) {
  1276. node.visit(this);
  1277. }
  1278. visitAll(nodes) {
  1279. nodes.forEach((node) => this.visit(node));
  1280. }
  1281. visitElement(element) {
  1282. const elementIdentifier = this.elementOrTemplateToIdentifier(element);
  1283. if (elementIdentifier !== null) {
  1284. this.identifiers.add(elementIdentifier);
  1285. }
  1286. this.visitAll(element.references);
  1287. this.visitAll(element.inputs);
  1288. this.visitAll(element.attributes);
  1289. this.visitAll(element.children);
  1290. this.visitAll(element.outputs);
  1291. }
  1292. visitTemplate(template) {
  1293. const templateIdentifier = this.elementOrTemplateToIdentifier(template);
  1294. if (templateIdentifier !== null) {
  1295. this.identifiers.add(templateIdentifier);
  1296. }
  1297. this.visitAll(template.variables);
  1298. this.visitAll(template.attributes);
  1299. this.visitAll(template.templateAttrs);
  1300. this.visitAll(template.children);
  1301. this.visitAll(template.references);
  1302. }
  1303. visitBoundAttribute(attribute) {
  1304. if (attribute.valueSpan === void 0) {
  1305. return;
  1306. }
  1307. const { identifiers, errors } = ExpressionVisitor.getIdentifiers(attribute.value, attribute.valueSpan.toString(), attribute.valueSpan.start.offset, this.boundTemplate, this.targetToIdentifier.bind(this));
  1308. identifiers.forEach((id) => this.identifiers.add(id));
  1309. this.errors.push(...errors);
  1310. }
  1311. visitBoundEvent(attribute) {
  1312. this.visitExpression(attribute.handler);
  1313. }
  1314. visitBoundText(text) {
  1315. this.visitExpression(text.value);
  1316. }
  1317. visitReference(reference) {
  1318. const referenceIdentifier = this.targetToIdentifier(reference);
  1319. if (referenceIdentifier === null) {
  1320. return;
  1321. }
  1322. this.identifiers.add(referenceIdentifier);
  1323. }
  1324. visitVariable(variable) {
  1325. const variableIdentifier = this.targetToIdentifier(variable);
  1326. if (variableIdentifier === null) {
  1327. return;
  1328. }
  1329. this.identifiers.add(variableIdentifier);
  1330. }
  1331. elementOrTemplateToIdentifier(node) {
  1332. var _a;
  1333. if (this.elementAndTemplateIdentifierCache.has(node)) {
  1334. return this.elementAndTemplateIdentifierCache.get(node);
  1335. }
  1336. let name;
  1337. let kind;
  1338. if (node instanceof TmplAstTemplate) {
  1339. name = (_a = node.tagName) != null ? _a : "ng-template";
  1340. kind = IdentifierKind.Template;
  1341. } else {
  1342. name = node.name;
  1343. kind = IdentifierKind.Element;
  1344. }
  1345. if (name.startsWith(":")) {
  1346. name = name.split(":").pop();
  1347. }
  1348. const sourceSpan = node.startSourceSpan;
  1349. const start = this.getStartLocation(name, sourceSpan);
  1350. if (start === null) {
  1351. return null;
  1352. }
  1353. const absoluteSpan = new AbsoluteSourceSpan(start, start + name.length);
  1354. const attributes = node.attributes.map(({ name: name2, sourceSpan: sourceSpan2 }) => {
  1355. return {
  1356. name: name2,
  1357. span: new AbsoluteSourceSpan(sourceSpan2.start.offset, sourceSpan2.end.offset),
  1358. kind: IdentifierKind.Attribute
  1359. };
  1360. });
  1361. const usedDirectives = this.boundTemplate.getDirectivesOfNode(node) || [];
  1362. const identifier = {
  1363. name,
  1364. span: absoluteSpan,
  1365. kind,
  1366. attributes: new Set(attributes),
  1367. usedDirectives: new Set(usedDirectives.map((dir) => {
  1368. return {
  1369. node: dir.ref.node,
  1370. selector: dir.selector
  1371. };
  1372. }))
  1373. };
  1374. this.elementAndTemplateIdentifierCache.set(node, identifier);
  1375. return identifier;
  1376. }
  1377. targetToIdentifier(node) {
  1378. if (this.targetIdentifierCache.has(node)) {
  1379. return this.targetIdentifierCache.get(node);
  1380. }
  1381. const { name, sourceSpan } = node;
  1382. const start = this.getStartLocation(name, sourceSpan);
  1383. if (start === null) {
  1384. return null;
  1385. }
  1386. const span = new AbsoluteSourceSpan(start, start + name.length);
  1387. let identifier;
  1388. if (node instanceof TmplAstReference) {
  1389. const refTarget = this.boundTemplate.getReferenceTarget(node);
  1390. let target = null;
  1391. if (refTarget) {
  1392. let node2 = null;
  1393. let directive = null;
  1394. if (refTarget instanceof TmplAstElement || refTarget instanceof TmplAstTemplate) {
  1395. node2 = this.elementOrTemplateToIdentifier(refTarget);
  1396. } else {
  1397. node2 = this.elementOrTemplateToIdentifier(refTarget.node);
  1398. directive = refTarget.directive.ref.node;
  1399. }
  1400. if (node2 === null) {
  1401. return null;
  1402. }
  1403. target = {
  1404. node: node2,
  1405. directive
  1406. };
  1407. }
  1408. identifier = {
  1409. name,
  1410. span,
  1411. kind: IdentifierKind.Reference,
  1412. target
  1413. };
  1414. } else {
  1415. identifier = {
  1416. name,
  1417. span,
  1418. kind: IdentifierKind.Variable
  1419. };
  1420. }
  1421. this.targetIdentifierCache.set(node, identifier);
  1422. return identifier;
  1423. }
  1424. getStartLocation(name, context) {
  1425. const localStr = context.toString();
  1426. if (!localStr.includes(name)) {
  1427. this.errors.push(new Error(`Impossible state: "${name}" not found in "${localStr}"`));
  1428. return null;
  1429. }
  1430. return context.start.offset + localStr.indexOf(name);
  1431. }
  1432. visitExpression(ast) {
  1433. if (ast instanceof ASTWithSource && ast.source !== null) {
  1434. const targetToIdentifier = this.targetToIdentifier.bind(this);
  1435. const absoluteOffset = ast.sourceSpan.start;
  1436. const { identifiers, errors } = ExpressionVisitor.getIdentifiers(ast, ast.source, absoluteOffset, this.boundTemplate, targetToIdentifier);
  1437. identifiers.forEach((id) => this.identifiers.add(id));
  1438. this.errors.push(...errors);
  1439. }
  1440. }
  1441. };
  1442. function getTemplateIdentifiers(boundTemplate) {
  1443. const visitor = new TemplateVisitor(boundTemplate);
  1444. if (boundTemplate.target.template !== void 0) {
  1445. visitor.visitAll(boundTemplate.target.template);
  1446. }
  1447. return { identifiers: visitor.identifiers, errors: visitor.errors };
  1448. }
  1449. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/indexer/src/transform.mjs
  1450. function generateAnalysis(context) {
  1451. const analysis = /* @__PURE__ */ new Map();
  1452. context.components.forEach(({ declaration, selector, boundTemplate, templateMeta }) => {
  1453. const name = declaration.name.getText();
  1454. const usedComponents = /* @__PURE__ */ new Set();
  1455. const usedDirs = boundTemplate.getUsedDirectives();
  1456. usedDirs.forEach((dir) => {
  1457. if (dir.isComponent) {
  1458. usedComponents.add(dir.ref.node);
  1459. }
  1460. });
  1461. const componentFile = new ParseSourceFile(declaration.getSourceFile().getFullText(), declaration.getSourceFile().fileName);
  1462. let templateFile;
  1463. if (templateMeta.isInline) {
  1464. templateFile = componentFile;
  1465. } else {
  1466. templateFile = templateMeta.file;
  1467. }
  1468. const { identifiers, errors } = getTemplateIdentifiers(boundTemplate);
  1469. analysis.set(declaration, {
  1470. name,
  1471. selector,
  1472. file: componentFile,
  1473. template: {
  1474. identifiers,
  1475. usedComponents,
  1476. isInline: templateMeta.isInline,
  1477. file: templateFile
  1478. },
  1479. errors
  1480. });
  1481. });
  1482. return analysis;
  1483. }
  1484. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/ng_module_index.mjs
  1485. var NgModuleIndexImpl = class {
  1486. constructor(metaReader, localReader) {
  1487. this.metaReader = metaReader;
  1488. this.localReader = localReader;
  1489. this.ngModuleAuthoritativeReference = /* @__PURE__ */ new Map();
  1490. this.typeToExportingModules = /* @__PURE__ */ new Map();
  1491. this.indexed = false;
  1492. }
  1493. updateWith(cache, key, elem) {
  1494. if (cache.has(key)) {
  1495. cache.get(key).add(elem);
  1496. } else {
  1497. const set = /* @__PURE__ */ new Set();
  1498. set.add(elem);
  1499. cache.set(key, set);
  1500. }
  1501. }
  1502. index() {
  1503. const seenTypesWithReexports = /* @__PURE__ */ new Map();
  1504. const locallyDeclaredDirsAndNgModules = [
  1505. ...this.localReader.getKnown(MetaKind.NgModule),
  1506. ...this.localReader.getKnown(MetaKind.Directive)
  1507. ];
  1508. for (const decl of locallyDeclaredDirsAndNgModules) {
  1509. this.indexTrait(new Reference(decl), seenTypesWithReexports);
  1510. }
  1511. this.indexed = true;
  1512. }
  1513. indexTrait(ref, seenTypesWithReexports) {
  1514. var _a, _b, _c;
  1515. if (seenTypesWithReexports.has(ref.node)) {
  1516. return;
  1517. }
  1518. seenTypesWithReexports.set(ref.node, /* @__PURE__ */ new Set());
  1519. const meta = (_a = this.metaReader.getDirectiveMetadata(ref)) != null ? _a : this.metaReader.getNgModuleMetadata(ref);
  1520. if (meta === null) {
  1521. return;
  1522. }
  1523. if (meta.imports !== null) {
  1524. for (const childRef of meta.imports) {
  1525. this.indexTrait(childRef, seenTypesWithReexports);
  1526. }
  1527. }
  1528. if (meta.kind === MetaKind.NgModule) {
  1529. if (!this.ngModuleAuthoritativeReference.has(ref.node)) {
  1530. this.ngModuleAuthoritativeReference.set(ref.node, ref);
  1531. }
  1532. for (const childRef of meta.exports) {
  1533. this.indexTrait(childRef, seenTypesWithReexports);
  1534. const childMeta = (_c = (_b = this.metaReader.getDirectiveMetadata(childRef)) != null ? _b : this.metaReader.getPipeMetadata(childRef)) != null ? _c : this.metaReader.getNgModuleMetadata(childRef);
  1535. if (childMeta === null) {
  1536. continue;
  1537. }
  1538. switch (childMeta.kind) {
  1539. case MetaKind.Directive:
  1540. case MetaKind.Pipe:
  1541. this.updateWith(this.typeToExportingModules, childRef.node, ref.node);
  1542. this.updateWith(seenTypesWithReexports, ref.node, childRef.node);
  1543. break;
  1544. case MetaKind.NgModule:
  1545. if (seenTypesWithReexports.has(childRef.node)) {
  1546. for (const reexported of seenTypesWithReexports.get(childRef.node)) {
  1547. this.updateWith(this.typeToExportingModules, reexported, ref.node);
  1548. this.updateWith(seenTypesWithReexports, ref.node, reexported);
  1549. }
  1550. }
  1551. break;
  1552. }
  1553. }
  1554. }
  1555. }
  1556. getNgModulesExporting(directiveOrPipe) {
  1557. if (!this.indexed) {
  1558. this.index();
  1559. }
  1560. if (!this.typeToExportingModules.has(directiveOrPipe)) {
  1561. return [];
  1562. }
  1563. const refs = [];
  1564. for (const ngModule of this.typeToExportingModules.get(directiveOrPipe)) {
  1565. if (this.ngModuleAuthoritativeReference.has(ngModule)) {
  1566. refs.push(this.ngModuleAuthoritativeReference.get(ngModule));
  1567. }
  1568. }
  1569. return refs;
  1570. }
  1571. };
  1572. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/resource/src/loader.mjs
  1573. import ts8 from "typescript";
  1574. var CSS_PREPROCESSOR_EXT = /(\.scss|\.sass|\.less|\.styl)$/;
  1575. var RESOURCE_MARKER = ".$ngresource$";
  1576. var RESOURCE_MARKER_TS = RESOURCE_MARKER + ".ts";
  1577. var AdapterResourceLoader = class {
  1578. constructor(adapter, options) {
  1579. this.adapter = adapter;
  1580. this.options = options;
  1581. this.cache = /* @__PURE__ */ new Map();
  1582. this.fetching = /* @__PURE__ */ new Map();
  1583. this.lookupResolutionHost = createLookupResolutionHost(this.adapter);
  1584. this.canPreload = !!this.adapter.readResource;
  1585. this.canPreprocess = !!this.adapter.transformResource;
  1586. }
  1587. resolve(url, fromFile) {
  1588. let resolvedUrl = null;
  1589. if (this.adapter.resourceNameToFileName) {
  1590. resolvedUrl = this.adapter.resourceNameToFileName(url, fromFile, (url2, fromFile2) => this.fallbackResolve(url2, fromFile2));
  1591. } else {
  1592. resolvedUrl = this.fallbackResolve(url, fromFile);
  1593. }
  1594. if (resolvedUrl === null) {
  1595. throw new Error(`HostResourceResolver: could not resolve ${url} in context of ${fromFile})`);
  1596. }
  1597. return resolvedUrl;
  1598. }
  1599. preload(resolvedUrl, context) {
  1600. if (!this.adapter.readResource) {
  1601. throw new Error("HostResourceLoader: the CompilerHost provided does not support pre-loading resources.");
  1602. }
  1603. if (this.cache.has(resolvedUrl)) {
  1604. return void 0;
  1605. } else if (this.fetching.has(resolvedUrl)) {
  1606. return this.fetching.get(resolvedUrl);
  1607. }
  1608. let result = this.adapter.readResource(resolvedUrl);
  1609. if (this.adapter.transformResource && context.type === "style") {
  1610. const resourceContext = {
  1611. type: "style",
  1612. containingFile: context.containingFile,
  1613. resourceFile: resolvedUrl
  1614. };
  1615. result = Promise.resolve(result).then(async (str) => {
  1616. const transformResult = await this.adapter.transformResource(str, resourceContext);
  1617. return transformResult === null ? str : transformResult.content;
  1618. });
  1619. }
  1620. if (typeof result === "string") {
  1621. this.cache.set(resolvedUrl, result);
  1622. return void 0;
  1623. } else {
  1624. const fetchCompletion = result.then((str) => {
  1625. this.fetching.delete(resolvedUrl);
  1626. this.cache.set(resolvedUrl, str);
  1627. });
  1628. this.fetching.set(resolvedUrl, fetchCompletion);
  1629. return fetchCompletion;
  1630. }
  1631. }
  1632. async preprocessInline(data, context) {
  1633. if (!this.adapter.transformResource || context.type !== "style") {
  1634. return data;
  1635. }
  1636. const transformResult = await this.adapter.transformResource(data, { type: "style", containingFile: context.containingFile, resourceFile: null });
  1637. if (transformResult === null) {
  1638. return data;
  1639. }
  1640. return transformResult.content;
  1641. }
  1642. load(resolvedUrl) {
  1643. if (this.cache.has(resolvedUrl)) {
  1644. return this.cache.get(resolvedUrl);
  1645. }
  1646. const result = this.adapter.readResource ? this.adapter.readResource(resolvedUrl) : this.adapter.readFile(resolvedUrl);
  1647. if (typeof result !== "string") {
  1648. throw new Error(`HostResourceLoader: loader(${resolvedUrl}) returned a Promise`);
  1649. }
  1650. this.cache.set(resolvedUrl, result);
  1651. return result;
  1652. }
  1653. invalidate() {
  1654. this.cache.clear();
  1655. }
  1656. fallbackResolve(url, fromFile) {
  1657. let candidateLocations;
  1658. if (url.startsWith("/")) {
  1659. candidateLocations = this.getRootedCandidateLocations(url);
  1660. } else {
  1661. if (!url.startsWith(".")) {
  1662. url = `./${url}`;
  1663. }
  1664. candidateLocations = this.getResolvedCandidateLocations(url, fromFile);
  1665. }
  1666. for (const candidate of candidateLocations) {
  1667. if (this.adapter.fileExists(candidate)) {
  1668. return candidate;
  1669. } else if (CSS_PREPROCESSOR_EXT.test(candidate)) {
  1670. const cssFallbackUrl = candidate.replace(CSS_PREPROCESSOR_EXT, ".css");
  1671. if (this.adapter.fileExists(cssFallbackUrl)) {
  1672. return cssFallbackUrl;
  1673. }
  1674. }
  1675. }
  1676. return null;
  1677. }
  1678. getRootedCandidateLocations(url) {
  1679. const segment = "." + url;
  1680. return this.adapter.rootDirs.map((rootDir) => join(rootDir, segment));
  1681. }
  1682. getResolvedCandidateLocations(url, fromFile) {
  1683. const failedLookup = ts8.resolveModuleName(url + RESOURCE_MARKER, fromFile, this.options, this.lookupResolutionHost);
  1684. if (failedLookup.failedLookupLocations === void 0) {
  1685. throw new Error(`Internal error: expected to find failedLookupLocations during resolution of resource '${url}' in context of ${fromFile}`);
  1686. }
  1687. return failedLookup.failedLookupLocations.filter((candidate) => candidate.endsWith(RESOURCE_MARKER_TS)).map((candidate) => candidate.slice(0, -RESOURCE_MARKER_TS.length));
  1688. }
  1689. };
  1690. function createLookupResolutionHost(adapter) {
  1691. var _a, _b, _c;
  1692. return {
  1693. directoryExists(directoryName) {
  1694. if (directoryName.includes(RESOURCE_MARKER)) {
  1695. return false;
  1696. } else if (adapter.directoryExists !== void 0) {
  1697. return adapter.directoryExists(directoryName);
  1698. } else {
  1699. return true;
  1700. }
  1701. },
  1702. fileExists(fileName) {
  1703. if (fileName.includes(RESOURCE_MARKER)) {
  1704. return false;
  1705. } else {
  1706. return adapter.fileExists(fileName);
  1707. }
  1708. },
  1709. readFile: adapter.readFile.bind(adapter),
  1710. getCurrentDirectory: adapter.getCurrentDirectory.bind(adapter),
  1711. getDirectories: (_a = adapter.getDirectories) == null ? void 0 : _a.bind(adapter),
  1712. realpath: (_b = adapter.realpath) == null ? void 0 : _b.bind(adapter),
  1713. trace: (_c = adapter.trace) == null ? void 0 : _c.bind(adapter),
  1714. useCaseSensitiveFileNames: typeof adapter.useCaseSensitiveFileNames === "function" ? adapter.useCaseSensitiveFileNames.bind(adapter) : adapter.useCaseSensitiveFileNames
  1715. };
  1716. }
  1717. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/standalone.mjs
  1718. var StandaloneComponentScopeReader = class {
  1719. constructor(metaReader, localModuleReader, dtsModuleReader) {
  1720. this.metaReader = metaReader;
  1721. this.localModuleReader = localModuleReader;
  1722. this.dtsModuleReader = dtsModuleReader;
  1723. this.cache = /* @__PURE__ */ new Map();
  1724. }
  1725. getScopeForComponent(clazz) {
  1726. var _a;
  1727. if (!this.cache.has(clazz)) {
  1728. const clazzRef = new Reference(clazz);
  1729. const clazzMeta = this.metaReader.getDirectiveMetadata(clazzRef);
  1730. if (clazzMeta === null || !clazzMeta.isComponent || !clazzMeta.isStandalone) {
  1731. this.cache.set(clazz, null);
  1732. return null;
  1733. }
  1734. const dependencies = /* @__PURE__ */ new Set([clazzMeta]);
  1735. const seen = /* @__PURE__ */ new Set([clazz]);
  1736. let isPoisoned = clazzMeta.isPoisoned;
  1737. if (clazzMeta.imports !== null) {
  1738. for (const ref of clazzMeta.imports) {
  1739. if (seen.has(ref.node)) {
  1740. continue;
  1741. }
  1742. seen.add(ref.node);
  1743. const dirMeta = this.metaReader.getDirectiveMetadata(ref);
  1744. if (dirMeta !== null) {
  1745. dependencies.add({ ...dirMeta, ref });
  1746. isPoisoned = isPoisoned || dirMeta.isPoisoned || !dirMeta.isStandalone;
  1747. continue;
  1748. }
  1749. const pipeMeta = this.metaReader.getPipeMetadata(ref);
  1750. if (pipeMeta !== null) {
  1751. dependencies.add({ ...pipeMeta, ref });
  1752. isPoisoned = isPoisoned || !pipeMeta.isStandalone;
  1753. continue;
  1754. }
  1755. const ngModuleMeta = this.metaReader.getNgModuleMetadata(ref);
  1756. if (ngModuleMeta !== null) {
  1757. dependencies.add({ ...ngModuleMeta, ref });
  1758. let ngModuleScope;
  1759. if (ref.node.getSourceFile().isDeclarationFile) {
  1760. ngModuleScope = this.dtsModuleReader.resolve(ref);
  1761. } else {
  1762. ngModuleScope = this.localModuleReader.getScopeOfModule(ref.node);
  1763. }
  1764. if (ngModuleScope === null) {
  1765. isPoisoned = true;
  1766. continue;
  1767. }
  1768. isPoisoned = isPoisoned || ngModuleScope.exported.isPoisoned;
  1769. for (const dep of ngModuleScope.exported.dependencies) {
  1770. if (!seen.has(dep.ref.node)) {
  1771. seen.add(dep.ref.node);
  1772. dependencies.add(dep);
  1773. }
  1774. }
  1775. continue;
  1776. }
  1777. isPoisoned = true;
  1778. }
  1779. }
  1780. this.cache.set(clazz, {
  1781. kind: ComponentScopeKind.Standalone,
  1782. component: clazz,
  1783. dependencies: Array.from(dependencies),
  1784. isPoisoned,
  1785. schemas: (_a = clazzMeta.schemas) != null ? _a : []
  1786. });
  1787. }
  1788. return this.cache.get(clazz);
  1789. }
  1790. getRemoteScope() {
  1791. return null;
  1792. }
  1793. };
  1794. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/checker.mjs
  1795. import { CssSelector, DomElementSchemaRegistry as DomElementSchemaRegistry2, ExternalExpr as ExternalExpr2, WrappedNodeExpr } from "@angular/compiler";
  1796. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/diagnostics/src/diagnostic.mjs
  1797. import ts9 from "typescript";
  1798. function makeTemplateDiagnostic(templateId, mapping, span, category, code, messageText, relatedMessages) {
  1799. var _a;
  1800. if (mapping.type === "direct") {
  1801. let relatedInformation = void 0;
  1802. if (relatedMessages !== void 0) {
  1803. relatedInformation = [];
  1804. for (const relatedMessage of relatedMessages) {
  1805. relatedInformation.push({
  1806. category: ts9.DiagnosticCategory.Message,
  1807. code: 0,
  1808. file: relatedMessage.sourceFile,
  1809. start: relatedMessage.start,
  1810. length: relatedMessage.end - relatedMessage.start,
  1811. messageText: relatedMessage.text
  1812. });
  1813. }
  1814. }
  1815. return {
  1816. source: "ngtsc",
  1817. code,
  1818. category,
  1819. messageText,
  1820. file: mapping.node.getSourceFile(),
  1821. componentFile: mapping.node.getSourceFile(),
  1822. templateId,
  1823. start: span.start.offset,
  1824. length: span.end.offset - span.start.offset,
  1825. relatedInformation
  1826. };
  1827. } else if (mapping.type === "indirect" || mapping.type === "external") {
  1828. const componentSf = mapping.componentClass.getSourceFile();
  1829. const componentName = mapping.componentClass.name.text;
  1830. const fileName = mapping.type === "indirect" ? `${componentSf.fileName} (${componentName} template)` : mapping.templateUrl;
  1831. let relatedInformation = [];
  1832. if (relatedMessages !== void 0) {
  1833. for (const relatedMessage of relatedMessages) {
  1834. relatedInformation.push({
  1835. category: ts9.DiagnosticCategory.Message,
  1836. code: 0,
  1837. file: relatedMessage.sourceFile,
  1838. start: relatedMessage.start,
  1839. length: relatedMessage.end - relatedMessage.start,
  1840. messageText: relatedMessage.text
  1841. });
  1842. }
  1843. }
  1844. let sf;
  1845. try {
  1846. sf = getParsedTemplateSourceFile(fileName, mapping);
  1847. } catch (e) {
  1848. const failureChain = makeDiagnosticChain(`Failed to report an error in '${fileName}' at ${span.start.line + 1}:${span.start.col + 1}`, [
  1849. makeDiagnosticChain((_a = e == null ? void 0 : e.stack) != null ? _a : `${e}`)
  1850. ]);
  1851. return {
  1852. source: "ngtsc",
  1853. category,
  1854. code,
  1855. messageText: addDiagnosticChain(messageText, [failureChain]),
  1856. file: componentSf,
  1857. componentFile: componentSf,
  1858. templateId,
  1859. start: mapping.node.getStart(),
  1860. length: mapping.node.getEnd() - mapping.node.getStart(),
  1861. relatedInformation
  1862. };
  1863. }
  1864. relatedInformation.push({
  1865. category: ts9.DiagnosticCategory.Message,
  1866. code: 0,
  1867. file: componentSf,
  1868. start: mapping.node.getStart(),
  1869. length: mapping.node.getEnd() - mapping.node.getStart(),
  1870. messageText: `Error occurs in the template of component ${componentName}.`
  1871. });
  1872. return {
  1873. source: "ngtsc",
  1874. category,
  1875. code,
  1876. messageText,
  1877. file: sf,
  1878. componentFile: componentSf,
  1879. templateId,
  1880. start: span.start.offset,
  1881. length: span.end.offset - span.start.offset,
  1882. relatedInformation
  1883. };
  1884. } else {
  1885. throw new Error(`Unexpected source mapping type: ${mapping.type}`);
  1886. }
  1887. }
  1888. var TemplateSourceFile = Symbol("TemplateSourceFile");
  1889. function getParsedTemplateSourceFile(fileName, mapping) {
  1890. if (mapping[TemplateSourceFile] === void 0) {
  1891. mapping[TemplateSourceFile] = parseTemplateAsSourceFile(fileName, mapping.template);
  1892. }
  1893. return mapping[TemplateSourceFile];
  1894. }
  1895. var parseTemplateAsSourceFileForTest = null;
  1896. function parseTemplateAsSourceFile(fileName, template) {
  1897. if (parseTemplateAsSourceFileForTest !== null) {
  1898. return parseTemplateAsSourceFileForTest(fileName, template);
  1899. }
  1900. return ts9.createSourceFile(fileName, template, ts9.ScriptTarget.Latest, false, ts9.ScriptKind.JSX);
  1901. }
  1902. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/diagnostics/src/id.mjs
  1903. var TEMPLATE_ID = Symbol("ngTemplateId");
  1904. var NEXT_TEMPLATE_ID = Symbol("ngNextTemplateId");
  1905. function getTemplateId(clazz) {
  1906. const node = clazz;
  1907. if (node[TEMPLATE_ID] === void 0) {
  1908. node[TEMPLATE_ID] = allocateTemplateId(node.getSourceFile());
  1909. }
  1910. return node[TEMPLATE_ID];
  1911. }
  1912. function allocateTemplateId(sf) {
  1913. if (sf[NEXT_TEMPLATE_ID] === void 0) {
  1914. sf[NEXT_TEMPLATE_ID] = 1;
  1915. }
  1916. return `tcb${sf[NEXT_TEMPLATE_ID]++}`;
  1917. }
  1918. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/completion.mjs
  1919. import { EmptyExpr, ImplicitReceiver as ImplicitReceiver2, PropertyRead as PropertyRead2, PropertyWrite as PropertyWrite2, SafePropertyRead, TmplAstReference as TmplAstReference2, TmplAstTextAttribute } from "@angular/compiler";
  1920. import ts11 from "typescript";
  1921. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/comments.mjs
  1922. import { AbsoluteSourceSpan as AbsoluteSourceSpan2 } from "@angular/compiler";
  1923. import ts10 from "typescript";
  1924. var parseSpanComment = /^(\d+),(\d+)$/;
  1925. function readSpanComment(node, sourceFile = node.getSourceFile()) {
  1926. return ts10.forEachTrailingCommentRange(sourceFile.text, node.getEnd(), (pos, end, kind) => {
  1927. if (kind !== ts10.SyntaxKind.MultiLineCommentTrivia) {
  1928. return null;
  1929. }
  1930. const commentText = sourceFile.text.substring(pos + 2, end - 2);
  1931. const match = commentText.match(parseSpanComment);
  1932. if (match === null) {
  1933. return null;
  1934. }
  1935. return new AbsoluteSourceSpan2(+match[1], +match[2]);
  1936. }) || null;
  1937. }
  1938. var CommentTriviaType;
  1939. (function(CommentTriviaType2) {
  1940. CommentTriviaType2["DIAGNOSTIC"] = "D";
  1941. CommentTriviaType2["EXPRESSION_TYPE_IDENTIFIER"] = "T";
  1942. })(CommentTriviaType || (CommentTriviaType = {}));
  1943. var ExpressionIdentifier;
  1944. (function(ExpressionIdentifier2) {
  1945. ExpressionIdentifier2["DIRECTIVE"] = "DIR";
  1946. ExpressionIdentifier2["COMPONENT_COMPLETION"] = "COMPCOMP";
  1947. ExpressionIdentifier2["EVENT_PARAMETER"] = "EP";
  1948. })(ExpressionIdentifier || (ExpressionIdentifier = {}));
  1949. function addExpressionIdentifier(node, identifier) {
  1950. ts10.addSyntheticTrailingComment(
  1951. node,
  1952. ts10.SyntaxKind.MultiLineCommentTrivia,
  1953. `${CommentTriviaType.EXPRESSION_TYPE_IDENTIFIER}:${identifier}`,
  1954. false
  1955. );
  1956. }
  1957. var IGNORE_FOR_DIAGNOSTICS_MARKER = `${CommentTriviaType.DIAGNOSTIC}:ignore`;
  1958. function markIgnoreDiagnostics(node) {
  1959. ts10.addSyntheticTrailingComment(
  1960. node,
  1961. ts10.SyntaxKind.MultiLineCommentTrivia,
  1962. IGNORE_FOR_DIAGNOSTICS_MARKER,
  1963. false
  1964. );
  1965. }
  1966. function hasIgnoreForDiagnosticsMarker(node, sourceFile) {
  1967. return ts10.forEachTrailingCommentRange(sourceFile.text, node.getEnd(), (pos, end, kind) => {
  1968. if (kind !== ts10.SyntaxKind.MultiLineCommentTrivia) {
  1969. return null;
  1970. }
  1971. const commentText = sourceFile.text.substring(pos + 2, end - 2);
  1972. return commentText === IGNORE_FOR_DIAGNOSTICS_MARKER;
  1973. }) === true;
  1974. }
  1975. function makeRecursiveVisitor(visitor) {
  1976. function recursiveVisitor(node) {
  1977. const res = visitor(node);
  1978. return res !== null ? res : node.forEachChild(recursiveVisitor);
  1979. }
  1980. return recursiveVisitor;
  1981. }
  1982. function getSpanFromOptions(opts) {
  1983. let withSpan = null;
  1984. if (opts.withSpan !== void 0) {
  1985. if (opts.withSpan instanceof AbsoluteSourceSpan2) {
  1986. withSpan = opts.withSpan;
  1987. } else {
  1988. withSpan = { start: opts.withSpan.start.offset, end: opts.withSpan.end.offset };
  1989. }
  1990. }
  1991. return withSpan;
  1992. }
  1993. function findFirstMatchingNode(tcb, opts) {
  1994. var _a;
  1995. const withSpan = getSpanFromOptions(opts);
  1996. const withExpressionIdentifier = opts.withExpressionIdentifier;
  1997. const sf = tcb.getSourceFile();
  1998. const visitor = makeRecursiveVisitor((node) => {
  1999. if (!opts.filter(node)) {
  2000. return null;
  2001. }
  2002. if (withSpan !== null) {
  2003. const comment = readSpanComment(node, sf);
  2004. if (comment === null || withSpan.start !== comment.start || withSpan.end !== comment.end) {
  2005. return null;
  2006. }
  2007. }
  2008. if (withExpressionIdentifier !== void 0 && !hasExpressionIdentifier(sf, node, withExpressionIdentifier)) {
  2009. return null;
  2010. }
  2011. return node;
  2012. });
  2013. return (_a = tcb.forEachChild(visitor)) != null ? _a : null;
  2014. }
  2015. function findAllMatchingNodes(tcb, opts) {
  2016. const withSpan = getSpanFromOptions(opts);
  2017. const withExpressionIdentifier = opts.withExpressionIdentifier;
  2018. const results = [];
  2019. const stack = [tcb];
  2020. const sf = tcb.getSourceFile();
  2021. while (stack.length > 0) {
  2022. const node = stack.pop();
  2023. if (!opts.filter(node)) {
  2024. stack.push(...node.getChildren());
  2025. continue;
  2026. }
  2027. if (withSpan !== null) {
  2028. const comment = readSpanComment(node, sf);
  2029. if (comment === null || withSpan.start !== comment.start || withSpan.end !== comment.end) {
  2030. stack.push(...node.getChildren());
  2031. continue;
  2032. }
  2033. }
  2034. if (withExpressionIdentifier !== void 0 && !hasExpressionIdentifier(sf, node, withExpressionIdentifier)) {
  2035. continue;
  2036. }
  2037. results.push(node);
  2038. }
  2039. return results;
  2040. }
  2041. function hasExpressionIdentifier(sourceFile, node, identifier) {
  2042. return ts10.forEachTrailingCommentRange(sourceFile.text, node.getEnd(), (pos, end, kind) => {
  2043. if (kind !== ts10.SyntaxKind.MultiLineCommentTrivia) {
  2044. return false;
  2045. }
  2046. const commentText = sourceFile.text.substring(pos + 2, end - 2);
  2047. return commentText === `${CommentTriviaType.EXPRESSION_TYPE_IDENTIFIER}:${identifier}`;
  2048. }) || false;
  2049. }
  2050. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/completion.mjs
  2051. var CompletionEngine = class {
  2052. constructor(tcb, data, tcbPath, tcbIsShim) {
  2053. this.tcb = tcb;
  2054. this.data = data;
  2055. this.tcbPath = tcbPath;
  2056. this.tcbIsShim = tcbIsShim;
  2057. this.templateContextCache = /* @__PURE__ */ new Map();
  2058. this.expressionCompletionCache = /* @__PURE__ */ new Map();
  2059. const globalRead = findFirstMatchingNode(this.tcb, {
  2060. filter: ts11.isPropertyAccessExpression,
  2061. withExpressionIdentifier: ExpressionIdentifier.COMPONENT_COMPLETION
  2062. });
  2063. if (globalRead !== null) {
  2064. this.componentContext = {
  2065. tcbPath: this.tcbPath,
  2066. isShimFile: this.tcbIsShim,
  2067. positionInFile: globalRead.name.getStart()
  2068. };
  2069. } else {
  2070. this.componentContext = null;
  2071. }
  2072. }
  2073. getGlobalCompletions(context, node) {
  2074. if (this.componentContext === null) {
  2075. return null;
  2076. }
  2077. const templateContext = this.getTemplateContextCompletions(context);
  2078. if (templateContext === null) {
  2079. return null;
  2080. }
  2081. let nodeContext = null;
  2082. if (node instanceof EmptyExpr) {
  2083. const nodeLocation = findFirstMatchingNode(this.tcb, {
  2084. filter: ts11.isIdentifier,
  2085. withSpan: node.sourceSpan
  2086. });
  2087. if (nodeLocation !== null) {
  2088. nodeContext = {
  2089. tcbPath: this.tcbPath,
  2090. isShimFile: this.tcbIsShim,
  2091. positionInFile: nodeLocation.getStart()
  2092. };
  2093. }
  2094. }
  2095. if (node instanceof PropertyRead2 && node.receiver instanceof ImplicitReceiver2) {
  2096. const nodeLocation = findFirstMatchingNode(this.tcb, {
  2097. filter: ts11.isPropertyAccessExpression,
  2098. withSpan: node.sourceSpan
  2099. });
  2100. if (nodeLocation) {
  2101. nodeContext = {
  2102. tcbPath: this.tcbPath,
  2103. isShimFile: this.tcbIsShim,
  2104. positionInFile: nodeLocation.getStart()
  2105. };
  2106. }
  2107. }
  2108. return {
  2109. componentContext: this.componentContext,
  2110. templateContext,
  2111. nodeContext
  2112. };
  2113. }
  2114. getExpressionCompletionLocation(expr) {
  2115. if (this.expressionCompletionCache.has(expr)) {
  2116. return this.expressionCompletionCache.get(expr);
  2117. }
  2118. let tsExpr = null;
  2119. if (expr instanceof PropertyRead2 || expr instanceof PropertyWrite2) {
  2120. tsExpr = findFirstMatchingNode(this.tcb, {
  2121. filter: ts11.isPropertyAccessExpression,
  2122. withSpan: expr.nameSpan
  2123. });
  2124. } else if (expr instanceof SafePropertyRead) {
  2125. const ternaryExpr = findFirstMatchingNode(this.tcb, {
  2126. filter: ts11.isParenthesizedExpression,
  2127. withSpan: expr.sourceSpan
  2128. });
  2129. if (ternaryExpr === null || !ts11.isConditionalExpression(ternaryExpr.expression)) {
  2130. return null;
  2131. }
  2132. const whenTrue = ternaryExpr.expression.whenTrue;
  2133. if (ts11.isPropertyAccessExpression(whenTrue)) {
  2134. tsExpr = whenTrue;
  2135. } else if (ts11.isCallExpression(whenTrue) && ts11.isPropertyAccessExpression(whenTrue.expression)) {
  2136. tsExpr = whenTrue.expression;
  2137. }
  2138. }
  2139. if (tsExpr === null) {
  2140. return null;
  2141. }
  2142. const res = {
  2143. tcbPath: this.tcbPath,
  2144. isShimFile: this.tcbIsShim,
  2145. positionInFile: tsExpr.name.getEnd()
  2146. };
  2147. this.expressionCompletionCache.set(expr, res);
  2148. return res;
  2149. }
  2150. getLiteralCompletionLocation(expr) {
  2151. if (this.expressionCompletionCache.has(expr)) {
  2152. return this.expressionCompletionCache.get(expr);
  2153. }
  2154. let tsExpr = null;
  2155. if (expr instanceof TmplAstTextAttribute) {
  2156. const strNode = findFirstMatchingNode(this.tcb, {
  2157. filter: ts11.isParenthesizedExpression,
  2158. withSpan: expr.sourceSpan
  2159. });
  2160. if (strNode !== null && ts11.isStringLiteral(strNode.expression)) {
  2161. tsExpr = strNode.expression;
  2162. }
  2163. } else {
  2164. tsExpr = findFirstMatchingNode(this.tcb, {
  2165. filter: (n) => ts11.isStringLiteral(n) || ts11.isNumericLiteral(n),
  2166. withSpan: expr.sourceSpan
  2167. });
  2168. }
  2169. if (tsExpr === null) {
  2170. return null;
  2171. }
  2172. let positionInShimFile = tsExpr.getEnd();
  2173. if (ts11.isStringLiteral(tsExpr)) {
  2174. positionInShimFile -= 1;
  2175. }
  2176. const res = {
  2177. tcbPath: this.tcbPath,
  2178. isShimFile: this.tcbIsShim,
  2179. positionInFile: positionInShimFile
  2180. };
  2181. this.expressionCompletionCache.set(expr, res);
  2182. return res;
  2183. }
  2184. getTemplateContextCompletions(context) {
  2185. if (this.templateContextCache.has(context)) {
  2186. return this.templateContextCache.get(context);
  2187. }
  2188. const templateContext = /* @__PURE__ */ new Map();
  2189. for (const node of this.data.boundTarget.getEntitiesInTemplateScope(context)) {
  2190. if (node instanceof TmplAstReference2) {
  2191. templateContext.set(node.name, {
  2192. kind: CompletionKind.Reference,
  2193. node
  2194. });
  2195. } else {
  2196. templateContext.set(node.name, {
  2197. kind: CompletionKind.Variable,
  2198. node
  2199. });
  2200. }
  2201. }
  2202. this.templateContextCache.set(context, templateContext);
  2203. return templateContext;
  2204. }
  2205. };
  2206. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/context.mjs
  2207. import ts25 from "typescript";
  2208. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/dom.mjs
  2209. import { DomElementSchemaRegistry } from "@angular/compiler";
  2210. import ts12 from "typescript";
  2211. var REGISTRY = new DomElementSchemaRegistry();
  2212. var REMOVE_XHTML_REGEX = /^:xhtml:/;
  2213. var RegistryDomSchemaChecker = class {
  2214. get diagnostics() {
  2215. return this._diagnostics;
  2216. }
  2217. constructor(resolver) {
  2218. this.resolver = resolver;
  2219. this._diagnostics = [];
  2220. }
  2221. checkElement(id, element, schemas, hostIsStandalone) {
  2222. const name = element.name.replace(REMOVE_XHTML_REGEX, "");
  2223. if (!REGISTRY.hasElement(name, schemas)) {
  2224. const mapping = this.resolver.getSourceMapping(id);
  2225. const schemas2 = `'${hostIsStandalone ? "@Component" : "@NgModule"}.schemas'`;
  2226. let errorMsg = `'${name}' is not a known element:
  2227. `;
  2228. errorMsg += `1. If '${name}' is an Angular component, then verify that it is ${hostIsStandalone ? "included in the '@Component.imports' of this component" : "part of this module"}.
  2229. `;
  2230. if (name.indexOf("-") > -1) {
  2231. errorMsg += `2. If '${name}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${schemas2} of this component to suppress this message.`;
  2232. } else {
  2233. errorMsg += `2. To allow any element add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
  2234. }
  2235. const diag = makeTemplateDiagnostic(id, mapping, element.startSourceSpan, ts12.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SCHEMA_INVALID_ELEMENT), errorMsg);
  2236. this._diagnostics.push(diag);
  2237. }
  2238. }
  2239. checkProperty(id, element, name, span, schemas, hostIsStandalone) {
  2240. if (!REGISTRY.hasProperty(element.name, name, schemas)) {
  2241. const mapping = this.resolver.getSourceMapping(id);
  2242. const decorator = hostIsStandalone ? "@Component" : "@NgModule";
  2243. const schemas2 = `'${decorator}.schemas'`;
  2244. let errorMsg = `Can't bind to '${name}' since it isn't a known property of '${element.name}'.`;
  2245. if (element.name.startsWith("ng-")) {
  2246. errorMsg += `
  2247. 1. If '${name}' is an Angular directive, then add 'CommonModule' to the '${decorator}.imports' of this component.
  2248. 2. To allow any property add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
  2249. } else if (element.name.indexOf("-") > -1) {
  2250. errorMsg += `
  2251. 1. If '${element.name}' is an Angular component and it has '${name}' input, then verify that it is ${hostIsStandalone ? "included in the '@Component.imports' of this component" : "part of this module"}.
  2252. 2. If '${element.name}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${schemas2} of this component to suppress this message.
  2253. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
  2254. }
  2255. const diag = makeTemplateDiagnostic(id, mapping, span, ts12.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SCHEMA_INVALID_ATTRIBUTE), errorMsg);
  2256. this._diagnostics.push(diag);
  2257. }
  2258. }
  2259. };
  2260. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/environment.mjs
  2261. import { ExpressionType, ExternalExpr, TypeModifier } from "@angular/compiler";
  2262. import ts18 from "typescript";
  2263. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/ts_util.mjs
  2264. import ts13 from "typescript";
  2265. var SAFE_TO_CAST_WITHOUT_PARENS = /* @__PURE__ */ new Set([
  2266. ts13.SyntaxKind.ParenthesizedExpression,
  2267. ts13.SyntaxKind.Identifier,
  2268. ts13.SyntaxKind.CallExpression,
  2269. ts13.SyntaxKind.NonNullExpression,
  2270. ts13.SyntaxKind.ElementAccessExpression,
  2271. ts13.SyntaxKind.PropertyAccessExpression,
  2272. ts13.SyntaxKind.ArrayLiteralExpression,
  2273. ts13.SyntaxKind.ObjectLiteralExpression,
  2274. ts13.SyntaxKind.StringLiteral,
  2275. ts13.SyntaxKind.NumericLiteral,
  2276. ts13.SyntaxKind.TrueKeyword,
  2277. ts13.SyntaxKind.FalseKeyword,
  2278. ts13.SyntaxKind.NullKeyword,
  2279. ts13.SyntaxKind.UndefinedKeyword
  2280. ]);
  2281. function tsCastToAny(expr) {
  2282. if (!SAFE_TO_CAST_WITHOUT_PARENS.has(expr.kind)) {
  2283. expr = ts13.factory.createParenthesizedExpression(expr);
  2284. }
  2285. return ts13.factory.createParenthesizedExpression(ts13.factory.createAsExpression(expr, ts13.factory.createKeywordTypeNode(ts13.SyntaxKind.AnyKeyword)));
  2286. }
  2287. function tsCreateElement(tagName) {
  2288. const createElement = ts13.factory.createPropertyAccessExpression(
  2289. ts13.factory.createIdentifier("document"),
  2290. "createElement"
  2291. );
  2292. return ts13.factory.createCallExpression(
  2293. createElement,
  2294. void 0,
  2295. [ts13.factory.createStringLiteral(tagName)]
  2296. );
  2297. }
  2298. function tsDeclareVariable(id, type) {
  2299. const decl = ts13.factory.createVariableDeclaration(
  2300. id,
  2301. void 0,
  2302. type,
  2303. ts13.factory.createNonNullExpression(ts13.factory.createNull())
  2304. );
  2305. return ts13.factory.createVariableStatement(
  2306. void 0,
  2307. [decl]
  2308. );
  2309. }
  2310. function tsCreateTypeQueryForCoercedInput(typeName, coercedInputName) {
  2311. return ts13.factory.createTypeQueryNode(ts13.factory.createQualifiedName(typeName, `ngAcceptInputType_${coercedInputName}`));
  2312. }
  2313. function tsCreateVariable(id, initializer) {
  2314. const decl = ts13.factory.createVariableDeclaration(
  2315. id,
  2316. void 0,
  2317. void 0,
  2318. initializer
  2319. );
  2320. return ts13.factory.createVariableStatement(
  2321. void 0,
  2322. [decl]
  2323. );
  2324. }
  2325. function tsCallMethod(receiver, methodName, args = []) {
  2326. const methodAccess = ts13.factory.createPropertyAccessExpression(receiver, methodName);
  2327. return ts13.factory.createCallExpression(
  2328. methodAccess,
  2329. void 0,
  2330. args
  2331. );
  2332. }
  2333. function isAccessExpression(node) {
  2334. return ts13.isPropertyAccessExpression(node) || ts13.isElementAccessExpression(node);
  2335. }
  2336. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_constructor.mjs
  2337. import ts17 from "typescript";
  2338. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/tcb_util.mjs
  2339. import ts16 from "typescript";
  2340. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_parameter_emitter.mjs
  2341. import ts15 from "typescript";
  2342. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_emitter.mjs
  2343. import ts14 from "typescript";
  2344. var INELIGIBLE = {};
  2345. function canEmitType(type, canEmit) {
  2346. return canEmitTypeWorker(type);
  2347. function canEmitTypeWorker(type2) {
  2348. return visitNode(type2) !== INELIGIBLE;
  2349. }
  2350. function visitNode(node) {
  2351. if (ts14.isImportTypeNode(node)) {
  2352. return INELIGIBLE;
  2353. }
  2354. if (ts14.isTypeReferenceNode(node) && !canEmitTypeReference(node)) {
  2355. return INELIGIBLE;
  2356. } else {
  2357. return ts14.forEachChild(node, visitNode);
  2358. }
  2359. }
  2360. function canEmitTypeReference(type2) {
  2361. if (!canEmit(type2)) {
  2362. return false;
  2363. }
  2364. return type2.typeArguments === void 0 || type2.typeArguments.every(canEmitTypeWorker);
  2365. }
  2366. }
  2367. var TypeEmitter = class {
  2368. constructor(translator) {
  2369. this.translator = translator;
  2370. }
  2371. emitType(type) {
  2372. const typeReferenceTransformer = (context) => {
  2373. const visitNode = (node) => {
  2374. if (ts14.isImportTypeNode(node)) {
  2375. throw new Error("Unable to emit import type");
  2376. }
  2377. if (ts14.isTypeReferenceNode(node)) {
  2378. return this.emitTypeReference(node);
  2379. } else if (ts14.isLiteralExpression(node)) {
  2380. let clone;
  2381. if (ts14.isStringLiteral(node)) {
  2382. clone = ts14.factory.createStringLiteral(node.text);
  2383. } else if (ts14.isNumericLiteral(node)) {
  2384. clone = ts14.factory.createNumericLiteral(node.text);
  2385. } else if (ts14.isBigIntLiteral(node)) {
  2386. clone = ts14.factory.createBigIntLiteral(node.text);
  2387. } else if (ts14.isNoSubstitutionTemplateLiteral(node)) {
  2388. clone = ts14.factory.createNoSubstitutionTemplateLiteral(node.text, node.rawText);
  2389. } else if (ts14.isRegularExpressionLiteral(node)) {
  2390. clone = ts14.factory.createRegularExpressionLiteral(node.text);
  2391. } else {
  2392. throw new Error(`Unsupported literal kind ${ts14.SyntaxKind[node.kind]}`);
  2393. }
  2394. ts14.setTextRange(clone, { pos: -1, end: -1 });
  2395. return clone;
  2396. } else {
  2397. return ts14.visitEachChild(node, visitNode, context);
  2398. }
  2399. };
  2400. return (node) => ts14.visitNode(node, visitNode, ts14.isTypeNode);
  2401. };
  2402. return ts14.transform(type, [typeReferenceTransformer]).transformed[0];
  2403. }
  2404. emitTypeReference(type) {
  2405. const translatedType = this.translator(type);
  2406. if (translatedType === null) {
  2407. throw new Error("Unable to emit an unresolved reference");
  2408. }
  2409. let typeArguments = void 0;
  2410. if (type.typeArguments !== void 0) {
  2411. typeArguments = ts14.factory.createNodeArray(type.typeArguments.map((typeArg) => this.emitType(typeArg)));
  2412. }
  2413. return ts14.factory.updateTypeReferenceNode(type, translatedType.typeName, typeArguments);
  2414. }
  2415. };
  2416. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_parameter_emitter.mjs
  2417. var TypeParameterEmitter = class {
  2418. constructor(typeParameters, reflector) {
  2419. this.typeParameters = typeParameters;
  2420. this.reflector = reflector;
  2421. }
  2422. canEmit(canEmitReference) {
  2423. if (this.typeParameters === void 0) {
  2424. return true;
  2425. }
  2426. return this.typeParameters.every((typeParam) => {
  2427. return this.canEmitType(typeParam.constraint, canEmitReference) && this.canEmitType(typeParam.default, canEmitReference);
  2428. });
  2429. }
  2430. canEmitType(type, canEmitReference) {
  2431. if (type === void 0) {
  2432. return true;
  2433. }
  2434. return canEmitType(type, (typeReference) => {
  2435. const reference = this.resolveTypeReference(typeReference);
  2436. if (reference === null) {
  2437. return false;
  2438. }
  2439. if (reference instanceof Reference) {
  2440. return canEmitReference(reference);
  2441. }
  2442. return true;
  2443. });
  2444. }
  2445. emit(emitReference) {
  2446. if (this.typeParameters === void 0) {
  2447. return void 0;
  2448. }
  2449. const emitter = new TypeEmitter((type) => this.translateTypeReference(type, emitReference));
  2450. return this.typeParameters.map((typeParam) => {
  2451. const constraint = typeParam.constraint !== void 0 ? emitter.emitType(typeParam.constraint) : void 0;
  2452. const defaultType = typeParam.default !== void 0 ? emitter.emitType(typeParam.default) : void 0;
  2453. return ts15.factory.updateTypeParameterDeclaration(typeParam, typeParam.modifiers, typeParam.name, constraint, defaultType);
  2454. });
  2455. }
  2456. resolveTypeReference(type) {
  2457. const target = ts15.isIdentifier(type.typeName) ? type.typeName : type.typeName.right;
  2458. const declaration = this.reflector.getDeclarationOfIdentifier(target);
  2459. if (declaration === null || declaration.node === null) {
  2460. return null;
  2461. }
  2462. if (this.isLocalTypeParameter(declaration.node)) {
  2463. return type;
  2464. }
  2465. let owningModule = null;
  2466. if (declaration.viaModule !== null) {
  2467. owningModule = {
  2468. specifier: declaration.viaModule,
  2469. resolutionContext: type.getSourceFile().fileName
  2470. };
  2471. }
  2472. return new Reference(declaration.node, owningModule);
  2473. }
  2474. translateTypeReference(type, emitReference) {
  2475. const reference = this.resolveTypeReference(type);
  2476. if (!(reference instanceof Reference)) {
  2477. return reference;
  2478. }
  2479. const typeNode = emitReference(reference);
  2480. if (typeNode === null) {
  2481. return null;
  2482. }
  2483. if (!ts15.isTypeReferenceNode(typeNode)) {
  2484. throw new Error(`Expected TypeReferenceNode for emitted reference, got ${ts15.SyntaxKind[typeNode.kind]}.`);
  2485. }
  2486. return typeNode;
  2487. }
  2488. isLocalTypeParameter(decl) {
  2489. return this.typeParameters.some((param) => param === decl);
  2490. }
  2491. };
  2492. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/tcb_util.mjs
  2493. var TcbInliningRequirement;
  2494. (function(TcbInliningRequirement2) {
  2495. TcbInliningRequirement2[TcbInliningRequirement2["MustInline"] = 0] = "MustInline";
  2496. TcbInliningRequirement2[TcbInliningRequirement2["ShouldInlineForGenericBounds"] = 1] = "ShouldInlineForGenericBounds";
  2497. TcbInliningRequirement2[TcbInliningRequirement2["None"] = 2] = "None";
  2498. })(TcbInliningRequirement || (TcbInliningRequirement = {}));
  2499. function requiresInlineTypeCheckBlock(ref, env, usedPipes, reflector) {
  2500. if (!env.canReferenceType(ref)) {
  2501. return TcbInliningRequirement.MustInline;
  2502. } else if (!checkIfGenericTypeBoundsCanBeEmitted(ref.node, reflector, env)) {
  2503. return TcbInliningRequirement.ShouldInlineForGenericBounds;
  2504. } else if (usedPipes.some((pipeRef) => !env.canReferenceType(pipeRef))) {
  2505. return TcbInliningRequirement.MustInline;
  2506. } else {
  2507. return TcbInliningRequirement.None;
  2508. }
  2509. }
  2510. function getTemplateMapping(shimSf, position, resolver, isDiagnosticRequest) {
  2511. const node = getTokenAtPosition(shimSf, position);
  2512. const sourceLocation = findSourceLocation(node, shimSf, isDiagnosticRequest);
  2513. if (sourceLocation === null) {
  2514. return null;
  2515. }
  2516. const mapping = resolver.getSourceMapping(sourceLocation.id);
  2517. const span = resolver.toParseSourceSpan(sourceLocation.id, sourceLocation.span);
  2518. if (span === null) {
  2519. return null;
  2520. }
  2521. return { sourceLocation, templateSourceMapping: mapping, span };
  2522. }
  2523. function findTypeCheckBlock(file, id, isDiagnosticRequest) {
  2524. for (const stmt of file.statements) {
  2525. if (ts16.isFunctionDeclaration(stmt) && getTemplateId2(stmt, file, isDiagnosticRequest) === id) {
  2526. return stmt;
  2527. }
  2528. }
  2529. return null;
  2530. }
  2531. function findSourceLocation(node, sourceFile, isDiagnosticsRequest) {
  2532. while (node !== void 0 && !ts16.isFunctionDeclaration(node)) {
  2533. if (hasIgnoreForDiagnosticsMarker(node, sourceFile) && isDiagnosticsRequest) {
  2534. return null;
  2535. }
  2536. const span = readSpanComment(node, sourceFile);
  2537. if (span !== null) {
  2538. const id = getTemplateId2(node, sourceFile, isDiagnosticsRequest);
  2539. if (id === null) {
  2540. return null;
  2541. }
  2542. return { id, span };
  2543. }
  2544. node = node.parent;
  2545. }
  2546. return null;
  2547. }
  2548. function getTemplateId2(node, sourceFile, isDiagnosticRequest) {
  2549. while (!ts16.isFunctionDeclaration(node)) {
  2550. if (hasIgnoreForDiagnosticsMarker(node, sourceFile) && isDiagnosticRequest) {
  2551. return null;
  2552. }
  2553. node = node.parent;
  2554. if (node === void 0) {
  2555. return null;
  2556. }
  2557. }
  2558. const start = node.getFullStart();
  2559. return ts16.forEachLeadingCommentRange(sourceFile.text, start, (pos, end, kind) => {
  2560. if (kind !== ts16.SyntaxKind.MultiLineCommentTrivia) {
  2561. return null;
  2562. }
  2563. const commentText = sourceFile.text.substring(pos + 2, end - 2);
  2564. return commentText;
  2565. }) || null;
  2566. }
  2567. function checkIfGenericTypeBoundsCanBeEmitted(node, reflector, env) {
  2568. const emitter = new TypeParameterEmitter(node.typeParameters, reflector);
  2569. return emitter.canEmit((ref) => env.canReferenceType(ref));
  2570. }
  2571. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_constructor.mjs
  2572. function generateTypeCtorDeclarationFn(node, meta, nodeTypeRef, typeParams) {
  2573. const rawTypeArgs = typeParams !== void 0 ? generateGenericArgs(typeParams) : void 0;
  2574. const rawType = ts17.factory.createTypeReferenceNode(nodeTypeRef, rawTypeArgs);
  2575. const initParam = constructTypeCtorParameter(node, meta, rawType);
  2576. const typeParameters = typeParametersWithDefaultTypes(typeParams);
  2577. if (meta.body) {
  2578. const fnType = ts17.factory.createFunctionTypeNode(
  2579. typeParameters,
  2580. [initParam],
  2581. rawType
  2582. );
  2583. const decl = ts17.factory.createVariableDeclaration(
  2584. meta.fnName,
  2585. void 0,
  2586. fnType,
  2587. ts17.factory.createNonNullExpression(ts17.factory.createNull())
  2588. );
  2589. const declList = ts17.factory.createVariableDeclarationList([decl], ts17.NodeFlags.Const);
  2590. return ts17.factory.createVariableStatement(
  2591. void 0,
  2592. declList
  2593. );
  2594. } else {
  2595. return ts17.factory.createFunctionDeclaration(
  2596. [ts17.factory.createModifier(ts17.SyntaxKind.DeclareKeyword)],
  2597. void 0,
  2598. meta.fnName,
  2599. typeParameters,
  2600. [initParam],
  2601. rawType,
  2602. void 0
  2603. );
  2604. }
  2605. }
  2606. function generateInlineTypeCtor(node, meta) {
  2607. const rawTypeArgs = node.typeParameters !== void 0 ? generateGenericArgs(node.typeParameters) : void 0;
  2608. const rawType = ts17.factory.createTypeReferenceNode(node.name, rawTypeArgs);
  2609. const initParam = constructTypeCtorParameter(node, meta, rawType);
  2610. let body = void 0;
  2611. if (meta.body) {
  2612. body = ts17.factory.createBlock([
  2613. ts17.factory.createReturnStatement(ts17.factory.createNonNullExpression(ts17.factory.createNull()))
  2614. ]);
  2615. }
  2616. return ts17.factory.createMethodDeclaration(
  2617. [ts17.factory.createModifier(ts17.SyntaxKind.StaticKeyword)],
  2618. void 0,
  2619. meta.fnName,
  2620. void 0,
  2621. typeParametersWithDefaultTypes(node.typeParameters),
  2622. [initParam],
  2623. rawType,
  2624. body
  2625. );
  2626. }
  2627. function constructTypeCtorParameter(node, meta, rawType) {
  2628. let initType = null;
  2629. const keys = meta.fields.inputs;
  2630. const plainKeys = [];
  2631. const coercedKeys = [];
  2632. for (const key of keys) {
  2633. if (!meta.coercedInputFields.has(key)) {
  2634. plainKeys.push(ts17.factory.createLiteralTypeNode(ts17.factory.createStringLiteral(key)));
  2635. } else {
  2636. coercedKeys.push(ts17.factory.createPropertySignature(
  2637. void 0,
  2638. key,
  2639. void 0,
  2640. tsCreateTypeQueryForCoercedInput(rawType.typeName, key)
  2641. ));
  2642. }
  2643. }
  2644. if (plainKeys.length > 0) {
  2645. const keyTypeUnion = ts17.factory.createUnionTypeNode(plainKeys);
  2646. initType = ts17.factory.createTypeReferenceNode("Pick", [rawType, keyTypeUnion]);
  2647. }
  2648. if (coercedKeys.length > 0) {
  2649. const coercedLiteral = ts17.factory.createTypeLiteralNode(coercedKeys);
  2650. initType = initType !== null ? ts17.factory.createIntersectionTypeNode([initType, coercedLiteral]) : coercedLiteral;
  2651. }
  2652. if (initType === null) {
  2653. initType = ts17.factory.createTypeLiteralNode([]);
  2654. }
  2655. return ts17.factory.createParameterDeclaration(
  2656. void 0,
  2657. void 0,
  2658. "init",
  2659. void 0,
  2660. initType,
  2661. void 0
  2662. );
  2663. }
  2664. function generateGenericArgs(params) {
  2665. return params.map((param) => ts17.factory.createTypeReferenceNode(param.name, void 0));
  2666. }
  2667. function requiresInlineTypeCtor(node, host, env) {
  2668. return !checkIfGenericTypeBoundsCanBeEmitted(node, host, env);
  2669. }
  2670. function typeParametersWithDefaultTypes(params) {
  2671. if (params === void 0) {
  2672. return void 0;
  2673. }
  2674. return params.map((param) => {
  2675. if (param.default === void 0) {
  2676. return ts17.factory.updateTypeParameterDeclaration(param, param.modifiers, param.name, param.constraint, ts17.factory.createKeywordTypeNode(ts17.SyntaxKind.AnyKeyword));
  2677. } else {
  2678. return param;
  2679. }
  2680. });
  2681. }
  2682. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/environment.mjs
  2683. var Environment = class {
  2684. constructor(config, importManager, refEmitter, reflector, contextFile) {
  2685. this.config = config;
  2686. this.importManager = importManager;
  2687. this.refEmitter = refEmitter;
  2688. this.reflector = reflector;
  2689. this.contextFile = contextFile;
  2690. this.nextIds = {
  2691. pipeInst: 1,
  2692. typeCtor: 1
  2693. };
  2694. this.typeCtors = /* @__PURE__ */ new Map();
  2695. this.typeCtorStatements = [];
  2696. this.pipeInsts = /* @__PURE__ */ new Map();
  2697. this.pipeInstStatements = [];
  2698. }
  2699. typeCtorFor(dir) {
  2700. const dirRef = dir.ref;
  2701. const node = dirRef.node;
  2702. if (this.typeCtors.has(node)) {
  2703. return this.typeCtors.get(node);
  2704. }
  2705. if (requiresInlineTypeCtor(node, this.reflector, this)) {
  2706. const ref = this.reference(dirRef);
  2707. const typeCtorExpr = ts18.factory.createPropertyAccessExpression(ref, "ngTypeCtor");
  2708. this.typeCtors.set(node, typeCtorExpr);
  2709. return typeCtorExpr;
  2710. } else {
  2711. const fnName = `_ctor${this.nextIds.typeCtor++}`;
  2712. const nodeTypeRef = this.referenceType(dirRef);
  2713. if (!ts18.isTypeReferenceNode(nodeTypeRef)) {
  2714. throw new Error(`Expected TypeReferenceNode from reference to ${dirRef.debugName}`);
  2715. }
  2716. const meta = {
  2717. fnName,
  2718. body: true,
  2719. fields: {
  2720. inputs: dir.inputs.classPropertyNames,
  2721. outputs: dir.outputs.classPropertyNames,
  2722. queries: dir.queries
  2723. },
  2724. coercedInputFields: dir.coercedInputFields
  2725. };
  2726. const typeParams = this.emitTypeParameters(node);
  2727. const typeCtor = generateTypeCtorDeclarationFn(node, meta, nodeTypeRef.typeName, typeParams);
  2728. this.typeCtorStatements.push(typeCtor);
  2729. const fnId = ts18.factory.createIdentifier(fnName);
  2730. this.typeCtors.set(node, fnId);
  2731. return fnId;
  2732. }
  2733. }
  2734. pipeInst(ref) {
  2735. if (this.pipeInsts.has(ref.node)) {
  2736. return this.pipeInsts.get(ref.node);
  2737. }
  2738. const pipeType = this.referenceType(ref);
  2739. const pipeInstId = ts18.factory.createIdentifier(`_pipe${this.nextIds.pipeInst++}`);
  2740. this.pipeInstStatements.push(tsDeclareVariable(pipeInstId, pipeType));
  2741. this.pipeInsts.set(ref.node, pipeInstId);
  2742. return pipeInstId;
  2743. }
  2744. reference(ref) {
  2745. const ngExpr = this.refEmitter.emit(ref, this.contextFile, ImportFlags.NoAliasing);
  2746. assertSuccessfulReferenceEmit(ngExpr, this.contextFile, "class");
  2747. return translateExpression(ngExpr.expression, this.importManager);
  2748. }
  2749. canReferenceType(ref) {
  2750. const result = this.refEmitter.emit(ref, this.contextFile, ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowRelativeDtsImports);
  2751. return result.kind === 0;
  2752. }
  2753. referenceType(ref) {
  2754. const ngExpr = this.refEmitter.emit(ref, this.contextFile, ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowRelativeDtsImports);
  2755. assertSuccessfulReferenceEmit(ngExpr, this.contextFile, "symbol");
  2756. return translateType(new ExpressionType(ngExpr.expression), this.contextFile, this.reflector, this.refEmitter, this.importManager);
  2757. }
  2758. emitTypeParameters(declaration) {
  2759. const emitter = new TypeParameterEmitter(declaration.typeParameters, this.reflector);
  2760. return emitter.emit((ref) => this.referenceType(ref));
  2761. }
  2762. referenceExternalType(moduleName, name, typeParams) {
  2763. const external = new ExternalExpr({ moduleName, name });
  2764. return translateType(new ExpressionType(external, TypeModifier.None, typeParams), this.contextFile, this.reflector, this.refEmitter, this.importManager);
  2765. }
  2766. referenceTransplantedType(type) {
  2767. return translateType(type, this.contextFile, this.reflector, this.refEmitter, this.importManager);
  2768. }
  2769. getPreludeStatements() {
  2770. return [
  2771. ...this.pipeInstStatements,
  2772. ...this.typeCtorStatements
  2773. ];
  2774. }
  2775. };
  2776. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/oob.mjs
  2777. import { TmplAstElement as TmplAstElement2 } from "@angular/compiler";
  2778. import ts19 from "typescript";
  2779. var OutOfBandDiagnosticRecorderImpl = class {
  2780. constructor(resolver) {
  2781. this.resolver = resolver;
  2782. this._diagnostics = [];
  2783. this.recordedPipes = /* @__PURE__ */ new Set();
  2784. }
  2785. get diagnostics() {
  2786. return this._diagnostics;
  2787. }
  2788. missingReferenceTarget(templateId, ref) {
  2789. const mapping = this.resolver.getSourceMapping(templateId);
  2790. const value = ref.value.trim();
  2791. const errorMsg = `No directive found with exportAs '${value}'.`;
  2792. this._diagnostics.push(makeTemplateDiagnostic(templateId, mapping, ref.valueSpan || ref.sourceSpan, ts19.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_REFERENCE_TARGET), errorMsg));
  2793. }
  2794. missingPipe(templateId, ast) {
  2795. if (this.recordedPipes.has(ast)) {
  2796. return;
  2797. }
  2798. const mapping = this.resolver.getSourceMapping(templateId);
  2799. const errorMsg = `No pipe found with name '${ast.name}'.`;
  2800. const sourceSpan = this.resolver.toParseSourceSpan(templateId, ast.nameSpan);
  2801. if (sourceSpan === null) {
  2802. throw new Error(`Assertion failure: no SourceLocation found for usage of pipe '${ast.name}'.`);
  2803. }
  2804. this._diagnostics.push(makeTemplateDiagnostic(templateId, mapping, sourceSpan, ts19.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_PIPE), errorMsg));
  2805. this.recordedPipes.add(ast);
  2806. }
  2807. illegalAssignmentToTemplateVar(templateId, assignment, target) {
  2808. var _a, _b;
  2809. const mapping = this.resolver.getSourceMapping(templateId);
  2810. const errorMsg = `Cannot use variable '${assignment.name}' as the left-hand side of an assignment expression. Template variables are read-only.`;
  2811. const sourceSpan = this.resolver.toParseSourceSpan(templateId, assignment.sourceSpan);
  2812. if (sourceSpan === null) {
  2813. throw new Error(`Assertion failure: no SourceLocation found for property binding.`);
  2814. }
  2815. this._diagnostics.push(makeTemplateDiagnostic(templateId, mapping, sourceSpan, ts19.DiagnosticCategory.Error, ngErrorCode(ErrorCode.WRITE_TO_READ_ONLY_VARIABLE), errorMsg, [{
  2816. text: `The variable ${assignment.name} is declared here.`,
  2817. start: ((_a = target.valueSpan) == null ? void 0 : _a.start.offset) || target.sourceSpan.start.offset,
  2818. end: ((_b = target.valueSpan) == null ? void 0 : _b.end.offset) || target.sourceSpan.end.offset,
  2819. sourceFile: mapping.node.getSourceFile()
  2820. }]));
  2821. }
  2822. duplicateTemplateVar(templateId, variable, firstDecl) {
  2823. const mapping = this.resolver.getSourceMapping(templateId);
  2824. const errorMsg = `Cannot redeclare variable '${variable.name}' as it was previously declared elsewhere for the same template.`;
  2825. this._diagnostics.push(makeTemplateDiagnostic(templateId, mapping, variable.sourceSpan, ts19.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DUPLICATE_VARIABLE_DECLARATION), errorMsg, [{
  2826. text: `The variable '${firstDecl.name}' was first declared here.`,
  2827. start: firstDecl.sourceSpan.start.offset,
  2828. end: firstDecl.sourceSpan.end.offset,
  2829. sourceFile: mapping.node.getSourceFile()
  2830. }]));
  2831. }
  2832. requiresInlineTcb(templateId, node) {
  2833. this._diagnostics.push(makeInlineDiagnostic(templateId, ErrorCode.INLINE_TCB_REQUIRED, node.name, `This component requires inline template type-checking, which is not supported by the current environment.`));
  2834. }
  2835. requiresInlineTypeConstructors(templateId, node, directives) {
  2836. let message;
  2837. if (directives.length > 1) {
  2838. message = `This component uses directives which require inline type constructors, which are not supported by the current environment.`;
  2839. } else {
  2840. message = `This component uses a directive which requires an inline type constructor, which is not supported by the current environment.`;
  2841. }
  2842. this._diagnostics.push(makeInlineDiagnostic(templateId, ErrorCode.INLINE_TYPE_CTOR_REQUIRED, node.name, message, directives.map((dir) => makeRelatedInformation(dir.name, `Requires an inline type constructor.`))));
  2843. }
  2844. suboptimalTypeInference(templateId, variables) {
  2845. const mapping = this.resolver.getSourceMapping(templateId);
  2846. let diagnosticVar = null;
  2847. for (const variable of variables) {
  2848. if (diagnosticVar === null || (variable.value === "" || variable.value === "$implicit")) {
  2849. diagnosticVar = variable;
  2850. }
  2851. }
  2852. if (diagnosticVar === null) {
  2853. return;
  2854. }
  2855. let varIdentification = `'${diagnosticVar.name}'`;
  2856. if (variables.length === 2) {
  2857. varIdentification += ` (and 1 other)`;
  2858. } else if (variables.length > 2) {
  2859. varIdentification += ` (and ${variables.length - 1} others)`;
  2860. }
  2861. const message = `This structural directive supports advanced type inference, but the current compiler configuration prevents its usage. The variable ${varIdentification} will have type 'any' as a result.
  2862. Consider enabling the 'strictTemplates' option in your tsconfig.json for better type inference within this template.`;
  2863. this._diagnostics.push(makeTemplateDiagnostic(templateId, mapping, diagnosticVar.keySpan, ts19.DiagnosticCategory.Suggestion, ngErrorCode(ErrorCode.SUGGEST_SUBOPTIMAL_TYPE_INFERENCE), message));
  2864. }
  2865. splitTwoWayBinding(templateId, input, output, inputConsumer, outputConsumer) {
  2866. const mapping = this.resolver.getSourceMapping(templateId);
  2867. const errorMsg = `The property and event halves of the two-way binding '${input.name}' are not bound to the same target.
  2868. Find more at https://angular.io/guide/two-way-binding#how-two-way-binding-works`;
  2869. const relatedMessages = [];
  2870. relatedMessages.push({
  2871. text: `The property half of the binding is to the '${inputConsumer.name.text}' component.`,
  2872. start: inputConsumer.name.getStart(),
  2873. end: inputConsumer.name.getEnd(),
  2874. sourceFile: inputConsumer.name.getSourceFile()
  2875. });
  2876. if (outputConsumer instanceof TmplAstElement2) {
  2877. let message = `The event half of the binding is to a native event called '${input.name}' on the <${outputConsumer.name}> DOM element.`;
  2878. if (!mapping.node.getSourceFile().isDeclarationFile) {
  2879. message += `
  2880. Are you missing an output declaration called '${output.name}'?`;
  2881. }
  2882. relatedMessages.push({
  2883. text: message,
  2884. start: outputConsumer.sourceSpan.start.offset + 1,
  2885. end: outputConsumer.sourceSpan.start.offset + outputConsumer.name.length + 1,
  2886. sourceFile: mapping.node.getSourceFile()
  2887. });
  2888. } else {
  2889. relatedMessages.push({
  2890. text: `The event half of the binding is to the '${outputConsumer.name.text}' component.`,
  2891. start: outputConsumer.name.getStart(),
  2892. end: outputConsumer.name.getEnd(),
  2893. sourceFile: outputConsumer.name.getSourceFile()
  2894. });
  2895. }
  2896. this._diagnostics.push(makeTemplateDiagnostic(templateId, mapping, input.keySpan, ts19.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SPLIT_TWO_WAY_BINDING), errorMsg, relatedMessages));
  2897. }
  2898. missingRequiredInputs(templateId, element, directiveName, isComponent, inputAliases) {
  2899. const message = `Required input${inputAliases.length === 1 ? "" : "s"} ${inputAliases.map((n) => `'${n}'`).join(", ")} from ${isComponent ? "component" : "directive"} ${directiveName} must be specified.`;
  2900. this._diagnostics.push(makeTemplateDiagnostic(templateId, this.resolver.getSourceMapping(templateId), element.startSourceSpan, ts19.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_REQUIRED_INPUTS), message));
  2901. }
  2902. };
  2903. function makeInlineDiagnostic(templateId, code, node, messageText, relatedInformation) {
  2904. return {
  2905. ...makeDiagnostic(code, node, messageText, relatedInformation),
  2906. componentFile: node.getSourceFile(),
  2907. templateId
  2908. };
  2909. }
  2910. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/shim.mjs
  2911. import ts20 from "typescript";
  2912. var TypeCheckShimGenerator = class {
  2913. constructor() {
  2914. this.extensionPrefix = "ngtypecheck";
  2915. this.shouldEmit = false;
  2916. }
  2917. generateShimForFile(sf, genFilePath, priorShimSf) {
  2918. if (priorShimSf !== null) {
  2919. return priorShimSf;
  2920. }
  2921. return ts20.createSourceFile(genFilePath, "export const USED_FOR_NG_TYPE_CHECKING = true;", ts20.ScriptTarget.Latest, true, ts20.ScriptKind.TS);
  2922. }
  2923. static shimFor(fileName) {
  2924. return absoluteFrom(fileName.replace(/\.tsx?$/, ".ngtypecheck.ts"));
  2925. }
  2926. };
  2927. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.mjs
  2928. import { BindingPipe, Call as Call2, DYNAMIC_TYPE, ImplicitReceiver as ImplicitReceiver4, PropertyRead as PropertyRead4, PropertyWrite as PropertyWrite3, SafeCall, SafePropertyRead as SafePropertyRead3, ThisReceiver, TmplAstBoundAttribute, TmplAstBoundText, TmplAstElement as TmplAstElement3, TmplAstIcu, TmplAstReference as TmplAstReference3, TmplAstTemplate as TmplAstTemplate2, TmplAstTextAttribute as TmplAstTextAttribute2, TmplAstVariable as TmplAstVariable2 } from "@angular/compiler";
  2929. import ts23 from "typescript";
  2930. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/diagnostics.mjs
  2931. import { AbsoluteSourceSpan as AbsoluteSourceSpan3 } from "@angular/compiler";
  2932. import ts21 from "typescript";
  2933. function wrapForDiagnostics(expr) {
  2934. return ts21.factory.createParenthesizedExpression(expr);
  2935. }
  2936. function wrapForTypeChecker(expr) {
  2937. return ts21.factory.createParenthesizedExpression(expr);
  2938. }
  2939. function addParseSpanInfo(node, span) {
  2940. let commentText;
  2941. if (span instanceof AbsoluteSourceSpan3) {
  2942. commentText = `${span.start},${span.end}`;
  2943. } else {
  2944. commentText = `${span.start.offset},${span.end.offset}`;
  2945. }
  2946. ts21.addSyntheticTrailingComment(node, ts21.SyntaxKind.MultiLineCommentTrivia, commentText, false);
  2947. }
  2948. function addTemplateId(tcb, id) {
  2949. ts21.addSyntheticLeadingComment(tcb, ts21.SyntaxKind.MultiLineCommentTrivia, id, true);
  2950. }
  2951. function shouldReportDiagnostic(diagnostic) {
  2952. const { code } = diagnostic;
  2953. if (code === 6133) {
  2954. return false;
  2955. } else if (code === 6199) {
  2956. return false;
  2957. } else if (code === 2695) {
  2958. return false;
  2959. } else if (code === 7006) {
  2960. return false;
  2961. }
  2962. return true;
  2963. }
  2964. function translateDiagnostic(diagnostic, resolver) {
  2965. if (diagnostic.file === void 0 || diagnostic.start === void 0) {
  2966. return null;
  2967. }
  2968. const fullMapping = getTemplateMapping(diagnostic.file, diagnostic.start, resolver, true);
  2969. if (fullMapping === null) {
  2970. return null;
  2971. }
  2972. const { sourceLocation, templateSourceMapping, span } = fullMapping;
  2973. return makeTemplateDiagnostic(sourceLocation.id, templateSourceMapping, span, diagnostic.category, diagnostic.code, diagnostic.messageText);
  2974. }
  2975. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/expression.mjs
  2976. import { ASTWithSource as ASTWithSource2, Call, EmptyExpr as EmptyExpr2, PropertyRead as PropertyRead3, SafeKeyedRead, SafePropertyRead as SafePropertyRead2 } from "@angular/compiler";
  2977. import ts22 from "typescript";
  2978. var NULL_AS_ANY = ts22.factory.createAsExpression(ts22.factory.createNull(), ts22.factory.createKeywordTypeNode(ts22.SyntaxKind.AnyKeyword));
  2979. var UNDEFINED = ts22.factory.createIdentifier("undefined");
  2980. var UNARY_OPS = /* @__PURE__ */ new Map([
  2981. ["+", ts22.SyntaxKind.PlusToken],
  2982. ["-", ts22.SyntaxKind.MinusToken]
  2983. ]);
  2984. var BINARY_OPS = /* @__PURE__ */ new Map([
  2985. ["+", ts22.SyntaxKind.PlusToken],
  2986. ["-", ts22.SyntaxKind.MinusToken],
  2987. ["<", ts22.SyntaxKind.LessThanToken],
  2988. [">", ts22.SyntaxKind.GreaterThanToken],
  2989. ["<=", ts22.SyntaxKind.LessThanEqualsToken],
  2990. [">=", ts22.SyntaxKind.GreaterThanEqualsToken],
  2991. ["==", ts22.SyntaxKind.EqualsEqualsToken],
  2992. ["===", ts22.SyntaxKind.EqualsEqualsEqualsToken],
  2993. ["*", ts22.SyntaxKind.AsteriskToken],
  2994. ["/", ts22.SyntaxKind.SlashToken],
  2995. ["%", ts22.SyntaxKind.PercentToken],
  2996. ["!=", ts22.SyntaxKind.ExclamationEqualsToken],
  2997. ["!==", ts22.SyntaxKind.ExclamationEqualsEqualsToken],
  2998. ["||", ts22.SyntaxKind.BarBarToken],
  2999. ["&&", ts22.SyntaxKind.AmpersandAmpersandToken],
  3000. ["&", ts22.SyntaxKind.AmpersandToken],
  3001. ["|", ts22.SyntaxKind.BarToken],
  3002. ["??", ts22.SyntaxKind.QuestionQuestionToken]
  3003. ]);
  3004. function astToTypescript(ast, maybeResolve, config) {
  3005. const translator = new AstTranslator(maybeResolve, config);
  3006. return translator.translate(ast);
  3007. }
  3008. var AstTranslator = class {
  3009. constructor(maybeResolve, config) {
  3010. this.maybeResolve = maybeResolve;
  3011. this.config = config;
  3012. }
  3013. translate(ast) {
  3014. if (ast instanceof ASTWithSource2) {
  3015. ast = ast.ast;
  3016. }
  3017. if (ast instanceof EmptyExpr2) {
  3018. const res = ts22.factory.createIdentifier("undefined");
  3019. addParseSpanInfo(res, ast.sourceSpan);
  3020. return res;
  3021. }
  3022. const resolved = this.maybeResolve(ast);
  3023. if (resolved !== null) {
  3024. return resolved;
  3025. }
  3026. return ast.visit(this);
  3027. }
  3028. visitUnary(ast) {
  3029. const expr = this.translate(ast.expr);
  3030. const op = UNARY_OPS.get(ast.operator);
  3031. if (op === void 0) {
  3032. throw new Error(`Unsupported Unary.operator: ${ast.operator}`);
  3033. }
  3034. const node = wrapForDiagnostics(ts22.factory.createPrefixUnaryExpression(op, expr));
  3035. addParseSpanInfo(node, ast.sourceSpan);
  3036. return node;
  3037. }
  3038. visitBinary(ast) {
  3039. const lhs = wrapForDiagnostics(this.translate(ast.left));
  3040. const rhs = wrapForDiagnostics(this.translate(ast.right));
  3041. const op = BINARY_OPS.get(ast.operation);
  3042. if (op === void 0) {
  3043. throw new Error(`Unsupported Binary.operation: ${ast.operation}`);
  3044. }
  3045. const node = ts22.factory.createBinaryExpression(lhs, op, rhs);
  3046. addParseSpanInfo(node, ast.sourceSpan);
  3047. return node;
  3048. }
  3049. visitChain(ast) {
  3050. const elements = ast.expressions.map((expr) => this.translate(expr));
  3051. const node = wrapForDiagnostics(ts22.factory.createCommaListExpression(elements));
  3052. addParseSpanInfo(node, ast.sourceSpan);
  3053. return node;
  3054. }
  3055. visitConditional(ast) {
  3056. const condExpr = this.translate(ast.condition);
  3057. const trueExpr = this.translate(ast.trueExp);
  3058. const falseExpr = wrapForTypeChecker(this.translate(ast.falseExp));
  3059. const node = ts22.factory.createParenthesizedExpression(ts22.factory.createConditionalExpression(condExpr, void 0, trueExpr, void 0, falseExpr));
  3060. addParseSpanInfo(node, ast.sourceSpan);
  3061. return node;
  3062. }
  3063. visitImplicitReceiver(ast) {
  3064. throw new Error("Method not implemented.");
  3065. }
  3066. visitThisReceiver(ast) {
  3067. throw new Error("Method not implemented.");
  3068. }
  3069. visitInterpolation(ast) {
  3070. return ast.expressions.reduce((lhs, ast2) => ts22.factory.createBinaryExpression(lhs, ts22.SyntaxKind.PlusToken, wrapForTypeChecker(this.translate(ast2))), ts22.factory.createStringLiteral(""));
  3071. }
  3072. visitKeyedRead(ast) {
  3073. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  3074. const key = this.translate(ast.key);
  3075. const node = ts22.factory.createElementAccessExpression(receiver, key);
  3076. addParseSpanInfo(node, ast.sourceSpan);
  3077. return node;
  3078. }
  3079. visitKeyedWrite(ast) {
  3080. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  3081. const left = ts22.factory.createElementAccessExpression(receiver, this.translate(ast.key));
  3082. const right = wrapForTypeChecker(this.translate(ast.value));
  3083. const node = wrapForDiagnostics(ts22.factory.createBinaryExpression(left, ts22.SyntaxKind.EqualsToken, right));
  3084. addParseSpanInfo(node, ast.sourceSpan);
  3085. return node;
  3086. }
  3087. visitLiteralArray(ast) {
  3088. const elements = ast.expressions.map((expr) => this.translate(expr));
  3089. const literal = ts22.factory.createArrayLiteralExpression(elements);
  3090. const node = this.config.strictLiteralTypes ? literal : tsCastToAny(literal);
  3091. addParseSpanInfo(node, ast.sourceSpan);
  3092. return node;
  3093. }
  3094. visitLiteralMap(ast) {
  3095. const properties = ast.keys.map(({ key }, idx) => {
  3096. const value = this.translate(ast.values[idx]);
  3097. return ts22.factory.createPropertyAssignment(ts22.factory.createStringLiteral(key), value);
  3098. });
  3099. const literal = ts22.factory.createObjectLiteralExpression(properties, true);
  3100. const node = this.config.strictLiteralTypes ? literal : tsCastToAny(literal);
  3101. addParseSpanInfo(node, ast.sourceSpan);
  3102. return node;
  3103. }
  3104. visitLiteralPrimitive(ast) {
  3105. let node;
  3106. if (ast.value === void 0) {
  3107. node = ts22.factory.createIdentifier("undefined");
  3108. } else if (ast.value === null) {
  3109. node = ts22.factory.createNull();
  3110. } else if (typeof ast.value === "string") {
  3111. node = ts22.factory.createStringLiteral(ast.value);
  3112. } else if (typeof ast.value === "number") {
  3113. node = ts22.factory.createNumericLiteral(ast.value);
  3114. } else if (typeof ast.value === "boolean") {
  3115. node = ast.value ? ts22.factory.createTrue() : ts22.factory.createFalse();
  3116. } else {
  3117. throw Error(`Unsupported AST value of type ${typeof ast.value}`);
  3118. }
  3119. addParseSpanInfo(node, ast.sourceSpan);
  3120. return node;
  3121. }
  3122. visitNonNullAssert(ast) {
  3123. const expr = wrapForDiagnostics(this.translate(ast.expression));
  3124. const node = ts22.factory.createNonNullExpression(expr);
  3125. addParseSpanInfo(node, ast.sourceSpan);
  3126. return node;
  3127. }
  3128. visitPipe(ast) {
  3129. throw new Error("Method not implemented.");
  3130. }
  3131. visitPrefixNot(ast) {
  3132. const expression = wrapForDiagnostics(this.translate(ast.expression));
  3133. const node = ts22.factory.createLogicalNot(expression);
  3134. addParseSpanInfo(node, ast.sourceSpan);
  3135. return node;
  3136. }
  3137. visitPropertyRead(ast) {
  3138. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  3139. const name = ts22.factory.createPropertyAccessExpression(receiver, ast.name);
  3140. addParseSpanInfo(name, ast.nameSpan);
  3141. const node = wrapForDiagnostics(name);
  3142. addParseSpanInfo(node, ast.sourceSpan);
  3143. return node;
  3144. }
  3145. visitPropertyWrite(ast) {
  3146. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  3147. const left = ts22.factory.createPropertyAccessExpression(receiver, ast.name);
  3148. addParseSpanInfo(left, ast.nameSpan);
  3149. const leftWithPath = wrapForDiagnostics(left);
  3150. addParseSpanInfo(leftWithPath, ast.sourceSpan);
  3151. const right = wrapForTypeChecker(this.translate(ast.value));
  3152. const node = wrapForDiagnostics(ts22.factory.createBinaryExpression(leftWithPath, ts22.SyntaxKind.EqualsToken, right));
  3153. addParseSpanInfo(node, ast.sourceSpan);
  3154. return node;
  3155. }
  3156. visitSafePropertyRead(ast) {
  3157. let node;
  3158. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  3159. if (this.config.strictSafeNavigationTypes) {
  3160. const expr = ts22.factory.createPropertyAccessExpression(ts22.factory.createNonNullExpression(receiver), ast.name);
  3161. addParseSpanInfo(expr, ast.nameSpan);
  3162. node = ts22.factory.createParenthesizedExpression(ts22.factory.createConditionalExpression(NULL_AS_ANY, void 0, expr, void 0, UNDEFINED));
  3163. } else if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
  3164. node = ts22.factory.createPropertyAccessExpression(tsCastToAny(receiver), ast.name);
  3165. } else {
  3166. const expr = ts22.factory.createPropertyAccessExpression(ts22.factory.createNonNullExpression(receiver), ast.name);
  3167. addParseSpanInfo(expr, ast.nameSpan);
  3168. node = tsCastToAny(expr);
  3169. }
  3170. addParseSpanInfo(node, ast.sourceSpan);
  3171. return node;
  3172. }
  3173. visitSafeKeyedRead(ast) {
  3174. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  3175. const key = this.translate(ast.key);
  3176. let node;
  3177. if (this.config.strictSafeNavigationTypes) {
  3178. const expr = ts22.factory.createElementAccessExpression(ts22.factory.createNonNullExpression(receiver), key);
  3179. addParseSpanInfo(expr, ast.sourceSpan);
  3180. node = ts22.factory.createParenthesizedExpression(ts22.factory.createConditionalExpression(NULL_AS_ANY, void 0, expr, void 0, UNDEFINED));
  3181. } else if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
  3182. node = ts22.factory.createElementAccessExpression(tsCastToAny(receiver), key);
  3183. } else {
  3184. const expr = ts22.factory.createElementAccessExpression(ts22.factory.createNonNullExpression(receiver), key);
  3185. addParseSpanInfo(expr, ast.sourceSpan);
  3186. node = tsCastToAny(expr);
  3187. }
  3188. addParseSpanInfo(node, ast.sourceSpan);
  3189. return node;
  3190. }
  3191. visitCall(ast) {
  3192. const args = ast.args.map((expr2) => this.translate(expr2));
  3193. let expr;
  3194. const receiver = ast.receiver;
  3195. if (receiver instanceof PropertyRead3) {
  3196. const resolved = this.maybeResolve(receiver);
  3197. if (resolved !== null) {
  3198. expr = resolved;
  3199. } else {
  3200. const propertyReceiver = wrapForDiagnostics(this.translate(receiver.receiver));
  3201. expr = ts22.factory.createPropertyAccessExpression(propertyReceiver, receiver.name);
  3202. addParseSpanInfo(expr, receiver.nameSpan);
  3203. }
  3204. } else {
  3205. expr = this.translate(receiver);
  3206. }
  3207. let node;
  3208. if (ast.receiver instanceof SafePropertyRead2 || ast.receiver instanceof SafeKeyedRead) {
  3209. node = this.convertToSafeCall(ast, expr, args);
  3210. } else {
  3211. node = ts22.factory.createCallExpression(expr, void 0, args);
  3212. }
  3213. addParseSpanInfo(node, ast.sourceSpan);
  3214. return node;
  3215. }
  3216. visitSafeCall(ast) {
  3217. const args = ast.args.map((expr2) => this.translate(expr2));
  3218. const expr = wrapForDiagnostics(this.translate(ast.receiver));
  3219. const node = this.convertToSafeCall(ast, expr, args);
  3220. addParseSpanInfo(node, ast.sourceSpan);
  3221. return node;
  3222. }
  3223. convertToSafeCall(ast, expr, args) {
  3224. if (this.config.strictSafeNavigationTypes) {
  3225. const call = ts22.factory.createCallExpression(ts22.factory.createNonNullExpression(expr), void 0, args);
  3226. return ts22.factory.createParenthesizedExpression(ts22.factory.createConditionalExpression(NULL_AS_ANY, void 0, call, void 0, UNDEFINED));
  3227. }
  3228. if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
  3229. return ts22.factory.createCallExpression(tsCastToAny(expr), void 0, args);
  3230. }
  3231. return tsCastToAny(ts22.factory.createCallExpression(ts22.factory.createNonNullExpression(expr), void 0, args));
  3232. }
  3233. };
  3234. var _VeSafeLhsInferenceBugDetector = class {
  3235. static veWillInferAnyFor(ast) {
  3236. const visitor = _VeSafeLhsInferenceBugDetector.SINGLETON;
  3237. return ast instanceof Call ? ast.visit(visitor) : ast.receiver.visit(visitor);
  3238. }
  3239. visitUnary(ast) {
  3240. return ast.expr.visit(this);
  3241. }
  3242. visitBinary(ast) {
  3243. return ast.left.visit(this) || ast.right.visit(this);
  3244. }
  3245. visitChain(ast) {
  3246. return false;
  3247. }
  3248. visitConditional(ast) {
  3249. return ast.condition.visit(this) || ast.trueExp.visit(this) || ast.falseExp.visit(this);
  3250. }
  3251. visitCall(ast) {
  3252. return true;
  3253. }
  3254. visitSafeCall(ast) {
  3255. return false;
  3256. }
  3257. visitImplicitReceiver(ast) {
  3258. return false;
  3259. }
  3260. visitThisReceiver(ast) {
  3261. return false;
  3262. }
  3263. visitInterpolation(ast) {
  3264. return ast.expressions.some((exp) => exp.visit(this));
  3265. }
  3266. visitKeyedRead(ast) {
  3267. return false;
  3268. }
  3269. visitKeyedWrite(ast) {
  3270. return false;
  3271. }
  3272. visitLiteralArray(ast) {
  3273. return true;
  3274. }
  3275. visitLiteralMap(ast) {
  3276. return true;
  3277. }
  3278. visitLiteralPrimitive(ast) {
  3279. return false;
  3280. }
  3281. visitPipe(ast) {
  3282. return true;
  3283. }
  3284. visitPrefixNot(ast) {
  3285. return ast.expression.visit(this);
  3286. }
  3287. visitNonNullAssert(ast) {
  3288. return ast.expression.visit(this);
  3289. }
  3290. visitPropertyRead(ast) {
  3291. return false;
  3292. }
  3293. visitPropertyWrite(ast) {
  3294. return false;
  3295. }
  3296. visitSafePropertyRead(ast) {
  3297. return false;
  3298. }
  3299. visitSafeKeyedRead(ast) {
  3300. return false;
  3301. }
  3302. };
  3303. var VeSafeLhsInferenceBugDetector = _VeSafeLhsInferenceBugDetector;
  3304. (() => {
  3305. _VeSafeLhsInferenceBugDetector.SINGLETON = new _VeSafeLhsInferenceBugDetector();
  3306. })();
  3307. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/template_semantics.mjs
  3308. import { ImplicitReceiver as ImplicitReceiver3, RecursiveAstVisitor as RecursiveAstVisitor2, TmplAstVariable } from "@angular/compiler";
  3309. var ExpressionSemanticVisitor = class extends RecursiveAstVisitor2 {
  3310. constructor(templateId, boundTarget, oob) {
  3311. super();
  3312. this.templateId = templateId;
  3313. this.boundTarget = boundTarget;
  3314. this.oob = oob;
  3315. }
  3316. visitPropertyWrite(ast, context) {
  3317. super.visitPropertyWrite(ast, context);
  3318. if (!(ast.receiver instanceof ImplicitReceiver3)) {
  3319. return;
  3320. }
  3321. const target = this.boundTarget.getExpressionTarget(ast);
  3322. if (target instanceof TmplAstVariable) {
  3323. this.oob.illegalAssignmentToTemplateVar(this.templateId, ast, target);
  3324. }
  3325. }
  3326. static visit(ast, id, boundTarget, oob) {
  3327. ast.visit(new ExpressionSemanticVisitor(id, boundTarget, oob));
  3328. }
  3329. };
  3330. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.mjs
  3331. var TcbGenericContextBehavior;
  3332. (function(TcbGenericContextBehavior2) {
  3333. TcbGenericContextBehavior2[TcbGenericContextBehavior2["UseEmitter"] = 0] = "UseEmitter";
  3334. TcbGenericContextBehavior2[TcbGenericContextBehavior2["CopyClassNodes"] = 1] = "CopyClassNodes";
  3335. TcbGenericContextBehavior2[TcbGenericContextBehavior2["FallbackToAny"] = 2] = "FallbackToAny";
  3336. })(TcbGenericContextBehavior || (TcbGenericContextBehavior = {}));
  3337. function generateTypeCheckBlock(env, ref, name, meta, domSchemaChecker, oobRecorder, genericContextBehavior) {
  3338. const tcb = new Context(env, domSchemaChecker, oobRecorder, meta.id, meta.boundTarget, meta.pipes, meta.schemas, meta.isStandalone);
  3339. const scope = Scope.forNodes(tcb, null, tcb.boundTarget.target.template, null);
  3340. const ctxRawType = env.referenceType(ref);
  3341. if (!ts23.isTypeReferenceNode(ctxRawType)) {
  3342. throw new Error(`Expected TypeReferenceNode when referencing the ctx param for ${ref.debugName}`);
  3343. }
  3344. let typeParameters = void 0;
  3345. let typeArguments = void 0;
  3346. if (ref.node.typeParameters !== void 0) {
  3347. if (!env.config.useContextGenericType) {
  3348. genericContextBehavior = TcbGenericContextBehavior.FallbackToAny;
  3349. }
  3350. switch (genericContextBehavior) {
  3351. case TcbGenericContextBehavior.UseEmitter:
  3352. typeParameters = new TypeParameterEmitter(ref.node.typeParameters, env.reflector).emit((typeRef) => env.referenceType(typeRef));
  3353. typeArguments = typeParameters.map((param) => ts23.factory.createTypeReferenceNode(param.name));
  3354. break;
  3355. case TcbGenericContextBehavior.CopyClassNodes:
  3356. typeParameters = [...ref.node.typeParameters];
  3357. typeArguments = typeParameters.map((param) => ts23.factory.createTypeReferenceNode(param.name));
  3358. break;
  3359. case TcbGenericContextBehavior.FallbackToAny:
  3360. typeArguments = ref.node.typeParameters.map(() => ts23.factory.createKeywordTypeNode(ts23.SyntaxKind.AnyKeyword));
  3361. break;
  3362. }
  3363. }
  3364. const paramList = [tcbThisParam(ctxRawType.typeName, typeArguments)];
  3365. const scopeStatements = scope.render();
  3366. const innerBody = ts23.factory.createBlock([
  3367. ...env.getPreludeStatements(),
  3368. ...scopeStatements
  3369. ]);
  3370. const body = ts23.factory.createBlock([ts23.factory.createIfStatement(ts23.factory.createTrue(), innerBody, void 0)]);
  3371. const fnDecl = ts23.factory.createFunctionDeclaration(
  3372. void 0,
  3373. void 0,
  3374. name,
  3375. env.config.useContextGenericType ? typeParameters : void 0,
  3376. paramList,
  3377. void 0,
  3378. body
  3379. );
  3380. addTemplateId(fnDecl, meta.id);
  3381. return fnDecl;
  3382. }
  3383. var TcbOp = class {
  3384. circularFallback() {
  3385. return INFER_TYPE_FOR_CIRCULAR_OP_EXPR;
  3386. }
  3387. };
  3388. var TcbElementOp = class extends TcbOp {
  3389. constructor(tcb, scope, element) {
  3390. super();
  3391. this.tcb = tcb;
  3392. this.scope = scope;
  3393. this.element = element;
  3394. }
  3395. get optional() {
  3396. return true;
  3397. }
  3398. execute() {
  3399. const id = this.tcb.allocateId();
  3400. const initializer = tsCreateElement(this.element.name);
  3401. addParseSpanInfo(initializer, this.element.startSourceSpan || this.element.sourceSpan);
  3402. this.scope.addStatement(tsCreateVariable(id, initializer));
  3403. return id;
  3404. }
  3405. };
  3406. var TcbVariableOp = class extends TcbOp {
  3407. constructor(tcb, scope, template, variable) {
  3408. super();
  3409. this.tcb = tcb;
  3410. this.scope = scope;
  3411. this.template = template;
  3412. this.variable = variable;
  3413. }
  3414. get optional() {
  3415. return false;
  3416. }
  3417. execute() {
  3418. const ctx = this.scope.resolve(this.template);
  3419. const id = this.tcb.allocateId();
  3420. const initializer = ts23.factory.createPropertyAccessExpression(
  3421. ctx,
  3422. this.variable.value || "$implicit"
  3423. );
  3424. addParseSpanInfo(id, this.variable.keySpan);
  3425. let variable;
  3426. if (this.variable.valueSpan !== void 0) {
  3427. addParseSpanInfo(initializer, this.variable.valueSpan);
  3428. variable = tsCreateVariable(id, wrapForTypeChecker(initializer));
  3429. } else {
  3430. variable = tsCreateVariable(id, initializer);
  3431. }
  3432. addParseSpanInfo(variable.declarationList.declarations[0], this.variable.sourceSpan);
  3433. this.scope.addStatement(variable);
  3434. return id;
  3435. }
  3436. };
  3437. var TcbTemplateContextOp = class extends TcbOp {
  3438. constructor(tcb, scope) {
  3439. super();
  3440. this.tcb = tcb;
  3441. this.scope = scope;
  3442. this.optional = true;
  3443. }
  3444. execute() {
  3445. const ctx = this.tcb.allocateId();
  3446. const type = ts23.factory.createKeywordTypeNode(ts23.SyntaxKind.AnyKeyword);
  3447. this.scope.addStatement(tsDeclareVariable(ctx, type));
  3448. return ctx;
  3449. }
  3450. };
  3451. var TcbTemplateBodyOp = class extends TcbOp {
  3452. constructor(tcb, scope, template) {
  3453. super();
  3454. this.tcb = tcb;
  3455. this.scope = scope;
  3456. this.template = template;
  3457. }
  3458. get optional() {
  3459. return false;
  3460. }
  3461. execute() {
  3462. const directiveGuards = [];
  3463. const directives = this.tcb.boundTarget.getDirectivesOfNode(this.template);
  3464. if (directives !== null) {
  3465. for (const dir of directives) {
  3466. const dirInstId = this.scope.resolve(this.template, dir);
  3467. const dirId = this.tcb.env.reference(dir.ref);
  3468. dir.ngTemplateGuards.forEach((guard2) => {
  3469. const boundInput = this.template.inputs.find((i) => i.name === guard2.inputName) || this.template.templateAttrs.find((i) => i instanceof TmplAstBoundAttribute && i.name === guard2.inputName);
  3470. if (boundInput !== void 0) {
  3471. const expr = tcbExpression(boundInput.value, this.tcb, this.scope);
  3472. markIgnoreDiagnostics(expr);
  3473. if (guard2.type === "binding") {
  3474. directiveGuards.push(expr);
  3475. } else {
  3476. const guardInvoke = tsCallMethod(dirId, `ngTemplateGuard_${guard2.inputName}`, [
  3477. dirInstId,
  3478. expr
  3479. ]);
  3480. addParseSpanInfo(guardInvoke, boundInput.value.sourceSpan);
  3481. directiveGuards.push(guardInvoke);
  3482. }
  3483. }
  3484. });
  3485. if (dir.hasNgTemplateContextGuard) {
  3486. if (this.tcb.env.config.applyTemplateContextGuards) {
  3487. const ctx = this.scope.resolve(this.template);
  3488. const guardInvoke = tsCallMethod(dirId, "ngTemplateContextGuard", [dirInstId, ctx]);
  3489. addParseSpanInfo(guardInvoke, this.template.sourceSpan);
  3490. directiveGuards.push(guardInvoke);
  3491. } else if (this.template.variables.length > 0 && this.tcb.env.config.suggestionsForSuboptimalTypeInference) {
  3492. this.tcb.oobRecorder.suboptimalTypeInference(this.tcb.id, this.template.variables);
  3493. }
  3494. }
  3495. }
  3496. }
  3497. let guard = null;
  3498. if (directiveGuards.length > 0) {
  3499. guard = directiveGuards.reduce((expr, dirGuard) => ts23.factory.createBinaryExpression(expr, ts23.SyntaxKind.AmpersandAmpersandToken, dirGuard), directiveGuards.pop());
  3500. }
  3501. const tmplScope = Scope.forNodes(this.tcb, this.scope, this.template, guard);
  3502. const statements = tmplScope.render();
  3503. if (statements.length === 0) {
  3504. return null;
  3505. }
  3506. let tmplBlock = ts23.factory.createBlock(statements);
  3507. if (guard !== null) {
  3508. tmplBlock = ts23.factory.createIfStatement(guard, tmplBlock);
  3509. }
  3510. this.scope.addStatement(tmplBlock);
  3511. return null;
  3512. }
  3513. };
  3514. var TcbTextInterpolationOp = class extends TcbOp {
  3515. constructor(tcb, scope, binding) {
  3516. super();
  3517. this.tcb = tcb;
  3518. this.scope = scope;
  3519. this.binding = binding;
  3520. }
  3521. get optional() {
  3522. return false;
  3523. }
  3524. execute() {
  3525. const expr = tcbExpression(this.binding.value, this.tcb, this.scope);
  3526. this.scope.addStatement(ts23.factory.createExpressionStatement(expr));
  3527. return null;
  3528. }
  3529. };
  3530. var TcbDirectiveTypeOpBase = class extends TcbOp {
  3531. constructor(tcb, scope, node, dir) {
  3532. super();
  3533. this.tcb = tcb;
  3534. this.scope = scope;
  3535. this.node = node;
  3536. this.dir = dir;
  3537. }
  3538. get optional() {
  3539. return true;
  3540. }
  3541. execute() {
  3542. const dirRef = this.dir.ref;
  3543. const rawType = this.tcb.env.referenceType(this.dir.ref);
  3544. let type;
  3545. if (this.dir.isGeneric === false || dirRef.node.typeParameters === void 0) {
  3546. type = rawType;
  3547. } else {
  3548. if (!ts23.isTypeReferenceNode(rawType)) {
  3549. throw new Error(`Expected TypeReferenceNode when referencing the type for ${this.dir.ref.debugName}`);
  3550. }
  3551. const typeArguments = dirRef.node.typeParameters.map(() => ts23.factory.createKeywordTypeNode(ts23.SyntaxKind.AnyKeyword));
  3552. type = ts23.factory.createTypeReferenceNode(rawType.typeName, typeArguments);
  3553. }
  3554. const id = this.tcb.allocateId();
  3555. addExpressionIdentifier(type, ExpressionIdentifier.DIRECTIVE);
  3556. addParseSpanInfo(type, this.node.startSourceSpan || this.node.sourceSpan);
  3557. this.scope.addStatement(tsDeclareVariable(id, type));
  3558. return id;
  3559. }
  3560. };
  3561. var TcbNonGenericDirectiveTypeOp = class extends TcbDirectiveTypeOpBase {
  3562. execute() {
  3563. const dirRef = this.dir.ref;
  3564. if (this.dir.isGeneric) {
  3565. throw new Error(`Assertion Error: expected ${dirRef.debugName} not to be generic.`);
  3566. }
  3567. return super.execute();
  3568. }
  3569. };
  3570. var TcbGenericDirectiveTypeWithAnyParamsOp = class extends TcbDirectiveTypeOpBase {
  3571. execute() {
  3572. const dirRef = this.dir.ref;
  3573. if (dirRef.node.typeParameters === void 0) {
  3574. throw new Error(`Assertion Error: expected typeParameters when creating a declaration for ${dirRef.debugName}`);
  3575. }
  3576. return super.execute();
  3577. }
  3578. };
  3579. var TcbReferenceOp = class extends TcbOp {
  3580. constructor(tcb, scope, node, host, target) {
  3581. super();
  3582. this.tcb = tcb;
  3583. this.scope = scope;
  3584. this.node = node;
  3585. this.host = host;
  3586. this.target = target;
  3587. this.optional = true;
  3588. }
  3589. execute() {
  3590. const id = this.tcb.allocateId();
  3591. let initializer = this.target instanceof TmplAstTemplate2 || this.target instanceof TmplAstElement3 ? this.scope.resolve(this.target) : this.scope.resolve(this.host, this.target);
  3592. if (this.target instanceof TmplAstElement3 && !this.tcb.env.config.checkTypeOfDomReferences || !this.tcb.env.config.checkTypeOfNonDomReferences) {
  3593. initializer = ts23.factory.createAsExpression(initializer, ts23.factory.createKeywordTypeNode(ts23.SyntaxKind.AnyKeyword));
  3594. } else if (this.target instanceof TmplAstTemplate2) {
  3595. initializer = ts23.factory.createAsExpression(initializer, ts23.factory.createKeywordTypeNode(ts23.SyntaxKind.AnyKeyword));
  3596. initializer = ts23.factory.createAsExpression(initializer, this.tcb.env.referenceExternalType("@angular/core", "TemplateRef", [DYNAMIC_TYPE]));
  3597. initializer = ts23.factory.createParenthesizedExpression(initializer);
  3598. }
  3599. addParseSpanInfo(initializer, this.node.sourceSpan);
  3600. addParseSpanInfo(id, this.node.keySpan);
  3601. this.scope.addStatement(tsCreateVariable(id, initializer));
  3602. return id;
  3603. }
  3604. };
  3605. var TcbInvalidReferenceOp = class extends TcbOp {
  3606. constructor(tcb, scope) {
  3607. super();
  3608. this.tcb = tcb;
  3609. this.scope = scope;
  3610. this.optional = true;
  3611. }
  3612. execute() {
  3613. const id = this.tcb.allocateId();
  3614. this.scope.addStatement(tsCreateVariable(id, NULL_AS_ANY));
  3615. return id;
  3616. }
  3617. };
  3618. var TcbDirectiveCtorOp = class extends TcbOp {
  3619. constructor(tcb, scope, node, dir) {
  3620. super();
  3621. this.tcb = tcb;
  3622. this.scope = scope;
  3623. this.node = node;
  3624. this.dir = dir;
  3625. }
  3626. get optional() {
  3627. return true;
  3628. }
  3629. execute() {
  3630. const id = this.tcb.allocateId();
  3631. addExpressionIdentifier(id, ExpressionIdentifier.DIRECTIVE);
  3632. addParseSpanInfo(id, this.node.startSourceSpan || this.node.sourceSpan);
  3633. const genericInputs = /* @__PURE__ */ new Map();
  3634. const boundAttrs = getBoundAttributes(this.dir, this.node);
  3635. for (const attr of boundAttrs) {
  3636. if (!this.tcb.env.config.checkTypeOfAttributes && attr.attribute instanceof TmplAstTextAttribute2) {
  3637. continue;
  3638. }
  3639. for (const { fieldName } of attr.inputs) {
  3640. if (genericInputs.has(fieldName)) {
  3641. continue;
  3642. }
  3643. const expression = translateInput(attr.attribute, this.tcb, this.scope);
  3644. genericInputs.set(fieldName, { type: "binding", field: fieldName, expression, sourceSpan: attr.attribute.sourceSpan });
  3645. }
  3646. }
  3647. for (const { classPropertyName } of this.dir.inputs) {
  3648. if (!genericInputs.has(classPropertyName)) {
  3649. genericInputs.set(classPropertyName, { type: "unset", field: classPropertyName });
  3650. }
  3651. }
  3652. const typeCtor = tcbCallTypeCtor(this.dir, this.tcb, Array.from(genericInputs.values()));
  3653. markIgnoreDiagnostics(typeCtor);
  3654. this.scope.addStatement(tsCreateVariable(id, typeCtor));
  3655. return id;
  3656. }
  3657. circularFallback() {
  3658. return new TcbDirectiveCtorCircularFallbackOp(this.tcb, this.scope, this.node, this.dir);
  3659. }
  3660. };
  3661. var TcbDirectiveInputsOp = class extends TcbOp {
  3662. constructor(tcb, scope, node, dir) {
  3663. super();
  3664. this.tcb = tcb;
  3665. this.scope = scope;
  3666. this.node = node;
  3667. this.dir = dir;
  3668. }
  3669. get optional() {
  3670. return false;
  3671. }
  3672. execute() {
  3673. let dirId = null;
  3674. const boundAttrs = getBoundAttributes(this.dir, this.node);
  3675. const seenRequiredInputs = /* @__PURE__ */ new Set();
  3676. for (const attr of boundAttrs) {
  3677. const expr = widenBinding(translateInput(attr.attribute, this.tcb, this.scope), this.tcb);
  3678. let assignment = wrapForDiagnostics(expr);
  3679. for (const { fieldName, required } of attr.inputs) {
  3680. let target;
  3681. if (required) {
  3682. seenRequiredInputs.add(fieldName);
  3683. }
  3684. if (this.dir.coercedInputFields.has(fieldName)) {
  3685. const dirTypeRef = this.tcb.env.referenceType(this.dir.ref);
  3686. if (!ts23.isTypeReferenceNode(dirTypeRef)) {
  3687. throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.debugName}`);
  3688. }
  3689. const id = this.tcb.allocateId();
  3690. const type = tsCreateTypeQueryForCoercedInput(dirTypeRef.typeName, fieldName);
  3691. this.scope.addStatement(tsDeclareVariable(id, type));
  3692. target = id;
  3693. } else if (this.dir.undeclaredInputFields.has(fieldName)) {
  3694. continue;
  3695. } else if (!this.tcb.env.config.honorAccessModifiersForInputBindings && this.dir.restrictedInputFields.has(fieldName)) {
  3696. if (dirId === null) {
  3697. dirId = this.scope.resolve(this.node, this.dir);
  3698. }
  3699. const id = this.tcb.allocateId();
  3700. const dirTypeRef = this.tcb.env.referenceType(this.dir.ref);
  3701. if (!ts23.isTypeReferenceNode(dirTypeRef)) {
  3702. throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.debugName}`);
  3703. }
  3704. const type = ts23.factory.createIndexedAccessTypeNode(ts23.factory.createTypeQueryNode(dirId), ts23.factory.createLiteralTypeNode(ts23.factory.createStringLiteral(fieldName)));
  3705. const temp = tsDeclareVariable(id, type);
  3706. this.scope.addStatement(temp);
  3707. target = id;
  3708. } else {
  3709. if (dirId === null) {
  3710. dirId = this.scope.resolve(this.node, this.dir);
  3711. }
  3712. target = this.dir.stringLiteralInputFields.has(fieldName) ? ts23.factory.createElementAccessExpression(dirId, ts23.factory.createStringLiteral(fieldName)) : ts23.factory.createPropertyAccessExpression(dirId, ts23.factory.createIdentifier(fieldName));
  3713. }
  3714. if (attr.attribute.keySpan !== void 0) {
  3715. addParseSpanInfo(target, attr.attribute.keySpan);
  3716. }
  3717. assignment = ts23.factory.createBinaryExpression(target, ts23.SyntaxKind.EqualsToken, assignment);
  3718. }
  3719. addParseSpanInfo(assignment, attr.attribute.sourceSpan);
  3720. if (!this.tcb.env.config.checkTypeOfAttributes && attr.attribute instanceof TmplAstTextAttribute2) {
  3721. markIgnoreDiagnostics(assignment);
  3722. }
  3723. this.scope.addStatement(ts23.factory.createExpressionStatement(assignment));
  3724. }
  3725. this.checkRequiredInputs(seenRequiredInputs);
  3726. return null;
  3727. }
  3728. checkRequiredInputs(seenRequiredInputs) {
  3729. const missing = [];
  3730. for (const input of this.dir.inputs) {
  3731. if (input.required && !seenRequiredInputs.has(input.classPropertyName)) {
  3732. missing.push(input.bindingPropertyName);
  3733. }
  3734. }
  3735. if (missing.length > 0) {
  3736. this.tcb.oobRecorder.missingRequiredInputs(this.tcb.id, this.node, this.dir.name, this.dir.isComponent, missing);
  3737. }
  3738. }
  3739. };
  3740. var TcbDirectiveCtorCircularFallbackOp = class extends TcbOp {
  3741. constructor(tcb, scope, node, dir) {
  3742. super();
  3743. this.tcb = tcb;
  3744. this.scope = scope;
  3745. this.node = node;
  3746. this.dir = dir;
  3747. }
  3748. get optional() {
  3749. return false;
  3750. }
  3751. execute() {
  3752. const id = this.tcb.allocateId();
  3753. const typeCtor = this.tcb.env.typeCtorFor(this.dir);
  3754. const circularPlaceholder = ts23.factory.createCallExpression(typeCtor, void 0, [ts23.factory.createNonNullExpression(ts23.factory.createNull())]);
  3755. this.scope.addStatement(tsCreateVariable(id, circularPlaceholder));
  3756. return id;
  3757. }
  3758. };
  3759. var TcbDomSchemaCheckerOp = class extends TcbOp {
  3760. constructor(tcb, element, checkElement, claimedInputs) {
  3761. super();
  3762. this.tcb = tcb;
  3763. this.element = element;
  3764. this.checkElement = checkElement;
  3765. this.claimedInputs = claimedInputs;
  3766. }
  3767. get optional() {
  3768. return false;
  3769. }
  3770. execute() {
  3771. var _a;
  3772. if (this.checkElement) {
  3773. this.tcb.domSchemaChecker.checkElement(this.tcb.id, this.element, this.tcb.schemas, this.tcb.hostIsStandalone);
  3774. }
  3775. for (const binding of this.element.inputs) {
  3776. if (binding.type === 0 && this.claimedInputs.has(binding.name)) {
  3777. continue;
  3778. }
  3779. if (binding.type === 0) {
  3780. if (binding.name !== "style" && binding.name !== "class") {
  3781. const propertyName = (_a = ATTR_TO_PROP.get(binding.name)) != null ? _a : binding.name;
  3782. this.tcb.domSchemaChecker.checkProperty(this.tcb.id, this.element, propertyName, binding.sourceSpan, this.tcb.schemas, this.tcb.hostIsStandalone);
  3783. }
  3784. }
  3785. }
  3786. return null;
  3787. }
  3788. };
  3789. var ATTR_TO_PROP = new Map(Object.entries({
  3790. "class": "className",
  3791. "for": "htmlFor",
  3792. "formaction": "formAction",
  3793. "innerHtml": "innerHTML",
  3794. "readonly": "readOnly",
  3795. "tabindex": "tabIndex"
  3796. }));
  3797. var TcbUnclaimedInputsOp = class extends TcbOp {
  3798. constructor(tcb, scope, element, claimedInputs) {
  3799. super();
  3800. this.tcb = tcb;
  3801. this.scope = scope;
  3802. this.element = element;
  3803. this.claimedInputs = claimedInputs;
  3804. }
  3805. get optional() {
  3806. return false;
  3807. }
  3808. execute() {
  3809. var _a;
  3810. let elId = null;
  3811. for (const binding of this.element.inputs) {
  3812. if (binding.type === 0 && this.claimedInputs.has(binding.name)) {
  3813. continue;
  3814. }
  3815. const expr = widenBinding(tcbExpression(binding.value, this.tcb, this.scope), this.tcb);
  3816. if (this.tcb.env.config.checkTypeOfDomBindings && binding.type === 0) {
  3817. if (binding.name !== "style" && binding.name !== "class") {
  3818. if (elId === null) {
  3819. elId = this.scope.resolve(this.element);
  3820. }
  3821. const propertyName = (_a = ATTR_TO_PROP.get(binding.name)) != null ? _a : binding.name;
  3822. const prop = ts23.factory.createElementAccessExpression(elId, ts23.factory.createStringLiteral(propertyName));
  3823. const stmt = ts23.factory.createBinaryExpression(prop, ts23.SyntaxKind.EqualsToken, wrapForDiagnostics(expr));
  3824. addParseSpanInfo(stmt, binding.sourceSpan);
  3825. this.scope.addStatement(ts23.factory.createExpressionStatement(stmt));
  3826. } else {
  3827. this.scope.addStatement(ts23.factory.createExpressionStatement(expr));
  3828. }
  3829. } else {
  3830. this.scope.addStatement(ts23.factory.createExpressionStatement(expr));
  3831. }
  3832. }
  3833. return null;
  3834. }
  3835. };
  3836. var TcbDirectiveOutputsOp = class extends TcbOp {
  3837. constructor(tcb, scope, node, dir) {
  3838. super();
  3839. this.tcb = tcb;
  3840. this.scope = scope;
  3841. this.node = node;
  3842. this.dir = dir;
  3843. }
  3844. get optional() {
  3845. return false;
  3846. }
  3847. execute() {
  3848. let dirId = null;
  3849. const outputs = this.dir.outputs;
  3850. for (const output of this.node.outputs) {
  3851. if (output.type !== 0 || !outputs.hasBindingPropertyName(output.name)) {
  3852. continue;
  3853. }
  3854. if (this.tcb.env.config.checkTypeOfOutputEvents && output.name.endsWith("Change")) {
  3855. const inputName = output.name.slice(0, -6);
  3856. isSplitTwoWayBinding(inputName, output, this.node.inputs, this.tcb);
  3857. }
  3858. const field = outputs.getByBindingPropertyName(output.name)[0].classPropertyName;
  3859. if (dirId === null) {
  3860. dirId = this.scope.resolve(this.node, this.dir);
  3861. }
  3862. const outputField = ts23.factory.createElementAccessExpression(dirId, ts23.factory.createStringLiteral(field));
  3863. addParseSpanInfo(outputField, output.keySpan);
  3864. if (this.tcb.env.config.checkTypeOfOutputEvents) {
  3865. const handler = tcbCreateEventHandler(output, this.tcb, this.scope, 0);
  3866. const subscribeFn = ts23.factory.createPropertyAccessExpression(outputField, "subscribe");
  3867. const call = ts23.factory.createCallExpression(subscribeFn, void 0, [handler]);
  3868. addParseSpanInfo(call, output.sourceSpan);
  3869. this.scope.addStatement(ts23.factory.createExpressionStatement(call));
  3870. } else {
  3871. this.scope.addStatement(ts23.factory.createExpressionStatement(outputField));
  3872. const handler = tcbCreateEventHandler(output, this.tcb, this.scope, 1);
  3873. this.scope.addStatement(ts23.factory.createExpressionStatement(handler));
  3874. }
  3875. ExpressionSemanticVisitor.visit(output.handler, this.tcb.id, this.tcb.boundTarget, this.tcb.oobRecorder);
  3876. }
  3877. return null;
  3878. }
  3879. };
  3880. var TcbUnclaimedOutputsOp = class extends TcbOp {
  3881. constructor(tcb, scope, element, claimedOutputs) {
  3882. super();
  3883. this.tcb = tcb;
  3884. this.scope = scope;
  3885. this.element = element;
  3886. this.claimedOutputs = claimedOutputs;
  3887. }
  3888. get optional() {
  3889. return false;
  3890. }
  3891. execute() {
  3892. let elId = null;
  3893. for (const output of this.element.outputs) {
  3894. if (this.claimedOutputs.has(output.name)) {
  3895. continue;
  3896. }
  3897. if (this.tcb.env.config.checkTypeOfOutputEvents && output.name.endsWith("Change")) {
  3898. const inputName = output.name.slice(0, -6);
  3899. if (isSplitTwoWayBinding(inputName, output, this.element.inputs, this.tcb)) {
  3900. continue;
  3901. }
  3902. }
  3903. if (output.type === 1) {
  3904. const eventType = this.tcb.env.config.checkTypeOfAnimationEvents ? this.tcb.env.referenceExternalType("@angular/animations", "AnimationEvent") : 1;
  3905. const handler = tcbCreateEventHandler(output, this.tcb, this.scope, eventType);
  3906. this.scope.addStatement(ts23.factory.createExpressionStatement(handler));
  3907. } else if (this.tcb.env.config.checkTypeOfDomEvents) {
  3908. const handler = tcbCreateEventHandler(output, this.tcb, this.scope, 0);
  3909. if (elId === null) {
  3910. elId = this.scope.resolve(this.element);
  3911. }
  3912. const propertyAccess = ts23.factory.createPropertyAccessExpression(elId, "addEventListener");
  3913. addParseSpanInfo(propertyAccess, output.keySpan);
  3914. const call = ts23.factory.createCallExpression(
  3915. propertyAccess,
  3916. void 0,
  3917. [ts23.factory.createStringLiteral(output.name), handler]
  3918. );
  3919. addParseSpanInfo(call, output.sourceSpan);
  3920. this.scope.addStatement(ts23.factory.createExpressionStatement(call));
  3921. } else {
  3922. const handler = tcbCreateEventHandler(output, this.tcb, this.scope, 1);
  3923. this.scope.addStatement(ts23.factory.createExpressionStatement(handler));
  3924. }
  3925. ExpressionSemanticVisitor.visit(output.handler, this.tcb.id, this.tcb.boundTarget, this.tcb.oobRecorder);
  3926. }
  3927. return null;
  3928. }
  3929. };
  3930. var TcbComponentContextCompletionOp = class extends TcbOp {
  3931. constructor(scope) {
  3932. super();
  3933. this.scope = scope;
  3934. this.optional = false;
  3935. }
  3936. execute() {
  3937. const ctx = ts23.factory.createThis();
  3938. const ctxDot = ts23.factory.createPropertyAccessExpression(ctx, "");
  3939. markIgnoreDiagnostics(ctxDot);
  3940. addExpressionIdentifier(ctxDot, ExpressionIdentifier.COMPONENT_COMPLETION);
  3941. this.scope.addStatement(ts23.factory.createExpressionStatement(ctxDot));
  3942. return null;
  3943. }
  3944. };
  3945. var INFER_TYPE_FOR_CIRCULAR_OP_EXPR = ts23.factory.createNonNullExpression(ts23.factory.createNull());
  3946. var Context = class {
  3947. constructor(env, domSchemaChecker, oobRecorder, id, boundTarget, pipes, schemas, hostIsStandalone) {
  3948. this.env = env;
  3949. this.domSchemaChecker = domSchemaChecker;
  3950. this.oobRecorder = oobRecorder;
  3951. this.id = id;
  3952. this.boundTarget = boundTarget;
  3953. this.pipes = pipes;
  3954. this.schemas = schemas;
  3955. this.hostIsStandalone = hostIsStandalone;
  3956. this.nextId = 1;
  3957. }
  3958. allocateId() {
  3959. return ts23.factory.createIdentifier(`_t${this.nextId++}`);
  3960. }
  3961. getPipeByName(name) {
  3962. if (!this.pipes.has(name)) {
  3963. return null;
  3964. }
  3965. return this.pipes.get(name);
  3966. }
  3967. };
  3968. var Scope = class {
  3969. constructor(tcb, parent = null, guard = null) {
  3970. this.tcb = tcb;
  3971. this.parent = parent;
  3972. this.guard = guard;
  3973. this.opQueue = [];
  3974. this.elementOpMap = /* @__PURE__ */ new Map();
  3975. this.directiveOpMap = /* @__PURE__ */ new Map();
  3976. this.referenceOpMap = /* @__PURE__ */ new Map();
  3977. this.templateCtxOpMap = /* @__PURE__ */ new Map();
  3978. this.varMap = /* @__PURE__ */ new Map();
  3979. this.statements = [];
  3980. }
  3981. static forNodes(tcb, parent, templateOrNodes, guard) {
  3982. const scope = new Scope(tcb, parent, guard);
  3983. if (parent === null && tcb.env.config.enableTemplateTypeChecker) {
  3984. scope.opQueue.push(new TcbComponentContextCompletionOp(scope));
  3985. }
  3986. let children;
  3987. if (templateOrNodes instanceof TmplAstTemplate2) {
  3988. const varMap = /* @__PURE__ */ new Map();
  3989. for (const v of templateOrNodes.variables) {
  3990. if (!varMap.has(v.name)) {
  3991. varMap.set(v.name, v);
  3992. } else {
  3993. const firstDecl = varMap.get(v.name);
  3994. tcb.oobRecorder.duplicateTemplateVar(tcb.id, v, firstDecl);
  3995. }
  3996. const opIndex = scope.opQueue.push(new TcbVariableOp(tcb, scope, templateOrNodes, v)) - 1;
  3997. scope.varMap.set(v, opIndex);
  3998. }
  3999. children = templateOrNodes.children;
  4000. } else {
  4001. children = templateOrNodes;
  4002. }
  4003. for (const node of children) {
  4004. scope.appendNode(node);
  4005. }
  4006. return scope;
  4007. }
  4008. resolve(node, directive) {
  4009. const res = this.resolveLocal(node, directive);
  4010. if (res !== null) {
  4011. let clone;
  4012. if (ts23.isIdentifier(res)) {
  4013. clone = ts23.factory.createIdentifier(res.text);
  4014. } else if (ts23.isNonNullExpression(res)) {
  4015. clone = ts23.factory.createNonNullExpression(res.expression);
  4016. } else {
  4017. throw new Error(`Could not resolve ${node} to an Identifier or a NonNullExpression`);
  4018. }
  4019. ts23.setOriginalNode(clone, res);
  4020. clone.parent = clone.parent;
  4021. return ts23.setSyntheticTrailingComments(clone, []);
  4022. } else if (this.parent !== null) {
  4023. return this.parent.resolve(node, directive);
  4024. } else {
  4025. throw new Error(`Could not resolve ${node} / ${directive}`);
  4026. }
  4027. }
  4028. addStatement(stmt) {
  4029. this.statements.push(stmt);
  4030. }
  4031. render() {
  4032. for (let i = 0; i < this.opQueue.length; i++) {
  4033. const skipOptional = !this.tcb.env.config.enableTemplateTypeChecker;
  4034. this.executeOp(i, skipOptional);
  4035. }
  4036. return this.statements;
  4037. }
  4038. guards() {
  4039. let parentGuards = null;
  4040. if (this.parent !== null) {
  4041. parentGuards = this.parent.guards();
  4042. }
  4043. if (this.guard === null) {
  4044. return parentGuards;
  4045. } else if (parentGuards === null) {
  4046. return this.guard;
  4047. } else {
  4048. return ts23.factory.createBinaryExpression(parentGuards, ts23.SyntaxKind.AmpersandAmpersandToken, this.guard);
  4049. }
  4050. }
  4051. resolveLocal(ref, directive) {
  4052. if (ref instanceof TmplAstReference3 && this.referenceOpMap.has(ref)) {
  4053. return this.resolveOp(this.referenceOpMap.get(ref));
  4054. } else if (ref instanceof TmplAstVariable2 && this.varMap.has(ref)) {
  4055. return this.resolveOp(this.varMap.get(ref));
  4056. } else if (ref instanceof TmplAstTemplate2 && directive === void 0 && this.templateCtxOpMap.has(ref)) {
  4057. return this.resolveOp(this.templateCtxOpMap.get(ref));
  4058. } else if ((ref instanceof TmplAstElement3 || ref instanceof TmplAstTemplate2) && directive !== void 0 && this.directiveOpMap.has(ref)) {
  4059. const dirMap = this.directiveOpMap.get(ref);
  4060. if (dirMap.has(directive)) {
  4061. return this.resolveOp(dirMap.get(directive));
  4062. } else {
  4063. return null;
  4064. }
  4065. } else if (ref instanceof TmplAstElement3 && this.elementOpMap.has(ref)) {
  4066. return this.resolveOp(this.elementOpMap.get(ref));
  4067. } else {
  4068. return null;
  4069. }
  4070. }
  4071. resolveOp(opIndex) {
  4072. const res = this.executeOp(opIndex, false);
  4073. if (res === null) {
  4074. throw new Error(`Error resolving operation, got null`);
  4075. }
  4076. return res;
  4077. }
  4078. executeOp(opIndex, skipOptional) {
  4079. const op = this.opQueue[opIndex];
  4080. if (!(op instanceof TcbOp)) {
  4081. return op;
  4082. }
  4083. if (skipOptional && op.optional) {
  4084. return null;
  4085. }
  4086. this.opQueue[opIndex] = op.circularFallback();
  4087. const res = op.execute();
  4088. this.opQueue[opIndex] = res;
  4089. return res;
  4090. }
  4091. appendNode(node) {
  4092. if (node instanceof TmplAstElement3) {
  4093. const opIndex = this.opQueue.push(new TcbElementOp(this.tcb, this, node)) - 1;
  4094. this.elementOpMap.set(node, opIndex);
  4095. this.appendDirectivesAndInputsOfNode(node);
  4096. this.appendOutputsOfNode(node);
  4097. for (const child of node.children) {
  4098. this.appendNode(child);
  4099. }
  4100. this.checkAndAppendReferencesOfNode(node);
  4101. } else if (node instanceof TmplAstTemplate2) {
  4102. this.appendDirectivesAndInputsOfNode(node);
  4103. this.appendOutputsOfNode(node);
  4104. const ctxIndex = this.opQueue.push(new TcbTemplateContextOp(this.tcb, this)) - 1;
  4105. this.templateCtxOpMap.set(node, ctxIndex);
  4106. if (this.tcb.env.config.checkTemplateBodies) {
  4107. this.opQueue.push(new TcbTemplateBodyOp(this.tcb, this, node));
  4108. } else if (this.tcb.env.config.alwaysCheckSchemaInTemplateBodies) {
  4109. this.appendDeepSchemaChecks(node.children);
  4110. }
  4111. this.checkAndAppendReferencesOfNode(node);
  4112. } else if (node instanceof TmplAstBoundText) {
  4113. this.opQueue.push(new TcbTextInterpolationOp(this.tcb, this, node));
  4114. } else if (node instanceof TmplAstIcu) {
  4115. this.appendIcuExpressions(node);
  4116. }
  4117. }
  4118. checkAndAppendReferencesOfNode(node) {
  4119. for (const ref of node.references) {
  4120. const target = this.tcb.boundTarget.getReferenceTarget(ref);
  4121. let ctxIndex;
  4122. if (target === null) {
  4123. this.tcb.oobRecorder.missingReferenceTarget(this.tcb.id, ref);
  4124. ctxIndex = this.opQueue.push(new TcbInvalidReferenceOp(this.tcb, this)) - 1;
  4125. } else if (target instanceof TmplAstTemplate2 || target instanceof TmplAstElement3) {
  4126. ctxIndex = this.opQueue.push(new TcbReferenceOp(this.tcb, this, ref, node, target)) - 1;
  4127. } else {
  4128. ctxIndex = this.opQueue.push(new TcbReferenceOp(this.tcb, this, ref, node, target.directive)) - 1;
  4129. }
  4130. this.referenceOpMap.set(ref, ctxIndex);
  4131. }
  4132. }
  4133. appendDirectivesAndInputsOfNode(node) {
  4134. const claimedInputs = /* @__PURE__ */ new Set();
  4135. const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
  4136. if (directives === null || directives.length === 0) {
  4137. if (node instanceof TmplAstElement3) {
  4138. this.opQueue.push(new TcbUnclaimedInputsOp(this.tcb, this, node, claimedInputs));
  4139. this.opQueue.push(new TcbDomSchemaCheckerOp(this.tcb, node, true, claimedInputs));
  4140. }
  4141. return;
  4142. }
  4143. const dirMap = /* @__PURE__ */ new Map();
  4144. for (const dir of directives) {
  4145. let directiveOp;
  4146. const host = this.tcb.env.reflector;
  4147. const dirRef = dir.ref;
  4148. if (!dir.isGeneric) {
  4149. directiveOp = new TcbNonGenericDirectiveTypeOp(this.tcb, this, node, dir);
  4150. } else if (!requiresInlineTypeCtor(dirRef.node, host, this.tcb.env) || this.tcb.env.config.useInlineTypeConstructors) {
  4151. directiveOp = new TcbDirectiveCtorOp(this.tcb, this, node, dir);
  4152. } else {
  4153. directiveOp = new TcbGenericDirectiveTypeWithAnyParamsOp(this.tcb, this, node, dir);
  4154. }
  4155. const dirIndex = this.opQueue.push(directiveOp) - 1;
  4156. dirMap.set(dir, dirIndex);
  4157. this.opQueue.push(new TcbDirectiveInputsOp(this.tcb, this, node, dir));
  4158. }
  4159. this.directiveOpMap.set(node, dirMap);
  4160. if (node instanceof TmplAstElement3) {
  4161. for (const dir of directives) {
  4162. for (const propertyName of dir.inputs.propertyNames) {
  4163. claimedInputs.add(propertyName);
  4164. }
  4165. }
  4166. this.opQueue.push(new TcbUnclaimedInputsOp(this.tcb, this, node, claimedInputs));
  4167. const checkElement = directives.length === 0;
  4168. this.opQueue.push(new TcbDomSchemaCheckerOp(this.tcb, node, checkElement, claimedInputs));
  4169. }
  4170. }
  4171. appendOutputsOfNode(node) {
  4172. const claimedOutputs = /* @__PURE__ */ new Set();
  4173. const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
  4174. if (directives === null || directives.length === 0) {
  4175. if (node instanceof TmplAstElement3) {
  4176. this.opQueue.push(new TcbUnclaimedOutputsOp(this.tcb, this, node, claimedOutputs));
  4177. }
  4178. return;
  4179. }
  4180. for (const dir of directives) {
  4181. this.opQueue.push(new TcbDirectiveOutputsOp(this.tcb, this, node, dir));
  4182. }
  4183. if (node instanceof TmplAstElement3) {
  4184. for (const dir of directives) {
  4185. for (const outputProperty of dir.outputs.propertyNames) {
  4186. claimedOutputs.add(outputProperty);
  4187. }
  4188. }
  4189. this.opQueue.push(new TcbUnclaimedOutputsOp(this.tcb, this, node, claimedOutputs));
  4190. }
  4191. }
  4192. appendDeepSchemaChecks(nodes) {
  4193. for (const node of nodes) {
  4194. if (!(node instanceof TmplAstElement3 || node instanceof TmplAstTemplate2)) {
  4195. continue;
  4196. }
  4197. if (node instanceof TmplAstElement3) {
  4198. const claimedInputs = /* @__PURE__ */ new Set();
  4199. const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
  4200. let hasDirectives;
  4201. if (directives === null || directives.length === 0) {
  4202. hasDirectives = false;
  4203. } else {
  4204. hasDirectives = true;
  4205. for (const dir of directives) {
  4206. for (const propertyName of dir.inputs.propertyNames) {
  4207. claimedInputs.add(propertyName);
  4208. }
  4209. }
  4210. }
  4211. this.opQueue.push(new TcbDomSchemaCheckerOp(this.tcb, node, !hasDirectives, claimedInputs));
  4212. }
  4213. this.appendDeepSchemaChecks(node.children);
  4214. }
  4215. }
  4216. appendIcuExpressions(node) {
  4217. for (const variable of Object.values(node.vars)) {
  4218. this.opQueue.push(new TcbTextInterpolationOp(this.tcb, this, variable));
  4219. }
  4220. for (const placeholder of Object.values(node.placeholders)) {
  4221. if (placeholder instanceof TmplAstBoundText) {
  4222. this.opQueue.push(new TcbTextInterpolationOp(this.tcb, this, placeholder));
  4223. }
  4224. }
  4225. }
  4226. };
  4227. function tcbThisParam(name, typeArguments) {
  4228. return ts23.factory.createParameterDeclaration(
  4229. void 0,
  4230. void 0,
  4231. "this",
  4232. void 0,
  4233. ts23.factory.createTypeReferenceNode(name, typeArguments),
  4234. void 0
  4235. );
  4236. }
  4237. function tcbExpression(ast, tcb, scope) {
  4238. const translator = new TcbExpressionTranslator(tcb, scope);
  4239. return translator.translate(ast);
  4240. }
  4241. var TcbExpressionTranslator = class {
  4242. constructor(tcb, scope) {
  4243. this.tcb = tcb;
  4244. this.scope = scope;
  4245. }
  4246. translate(ast) {
  4247. return astToTypescript(ast, (ast2) => this.resolve(ast2), this.tcb.env.config);
  4248. }
  4249. resolve(ast) {
  4250. if (ast instanceof PropertyRead4 && ast.receiver instanceof ImplicitReceiver4) {
  4251. return this.resolveTarget(ast);
  4252. } else if (ast instanceof PropertyWrite3 && ast.receiver instanceof ImplicitReceiver4) {
  4253. const target = this.resolveTarget(ast);
  4254. if (target === null) {
  4255. return null;
  4256. }
  4257. const expr = this.translate(ast.value);
  4258. const result = ts23.factory.createParenthesizedExpression(ts23.factory.createBinaryExpression(target, ts23.SyntaxKind.EqualsToken, expr));
  4259. addParseSpanInfo(result, ast.sourceSpan);
  4260. return result;
  4261. } else if (ast instanceof ImplicitReceiver4) {
  4262. return ts23.factory.createThis();
  4263. } else if (ast instanceof BindingPipe) {
  4264. const expr = this.translate(ast.exp);
  4265. const pipeRef = this.tcb.getPipeByName(ast.name);
  4266. let pipe;
  4267. if (pipeRef === null) {
  4268. this.tcb.oobRecorder.missingPipe(this.tcb.id, ast);
  4269. pipe = NULL_AS_ANY;
  4270. } else {
  4271. pipe = this.tcb.env.pipeInst(pipeRef);
  4272. }
  4273. const args = ast.args.map((arg) => this.translate(arg));
  4274. let methodAccess = ts23.factory.createPropertyAccessExpression(pipe, "transform");
  4275. addParseSpanInfo(methodAccess, ast.nameSpan);
  4276. if (!this.tcb.env.config.checkTypeOfPipes) {
  4277. methodAccess = ts23.factory.createAsExpression(methodAccess, ts23.factory.createKeywordTypeNode(ts23.SyntaxKind.AnyKeyword));
  4278. }
  4279. const result = ts23.factory.createCallExpression(
  4280. methodAccess,
  4281. void 0,
  4282. [expr, ...args]
  4283. );
  4284. addParseSpanInfo(result, ast.sourceSpan);
  4285. return result;
  4286. } else if ((ast instanceof Call2 || ast instanceof SafeCall) && (ast.receiver instanceof PropertyRead4 || ast.receiver instanceof SafePropertyRead3)) {
  4287. if (ast.receiver.receiver instanceof ImplicitReceiver4 && !(ast.receiver.receiver instanceof ThisReceiver) && ast.receiver.name === "$any" && ast.args.length === 1) {
  4288. const expr = this.translate(ast.args[0]);
  4289. const exprAsAny = ts23.factory.createAsExpression(expr, ts23.factory.createKeywordTypeNode(ts23.SyntaxKind.AnyKeyword));
  4290. const result = ts23.factory.createParenthesizedExpression(exprAsAny);
  4291. addParseSpanInfo(result, ast.sourceSpan);
  4292. return result;
  4293. }
  4294. const receiver = this.resolveTarget(ast);
  4295. if (receiver === null) {
  4296. return null;
  4297. }
  4298. const method = wrapForDiagnostics(receiver);
  4299. addParseSpanInfo(method, ast.receiver.nameSpan);
  4300. const args = ast.args.map((arg) => this.translate(arg));
  4301. const node = ts23.factory.createCallExpression(method, void 0, args);
  4302. addParseSpanInfo(node, ast.sourceSpan);
  4303. return node;
  4304. } else {
  4305. return null;
  4306. }
  4307. }
  4308. resolveTarget(ast) {
  4309. const binding = this.tcb.boundTarget.getExpressionTarget(ast);
  4310. if (binding === null) {
  4311. return null;
  4312. }
  4313. const expr = this.scope.resolve(binding);
  4314. addParseSpanInfo(expr, ast.sourceSpan);
  4315. return expr;
  4316. }
  4317. };
  4318. function tcbCallTypeCtor(dir, tcb, inputs) {
  4319. const typeCtor = tcb.env.typeCtorFor(dir);
  4320. const members = inputs.map((input) => {
  4321. const propertyName = ts23.factory.createStringLiteral(input.field);
  4322. if (input.type === "binding") {
  4323. const expr = widenBinding(input.expression, tcb);
  4324. const assignment = ts23.factory.createPropertyAssignment(propertyName, wrapForDiagnostics(expr));
  4325. addParseSpanInfo(assignment, input.sourceSpan);
  4326. return assignment;
  4327. } else {
  4328. return ts23.factory.createPropertyAssignment(propertyName, NULL_AS_ANY);
  4329. }
  4330. });
  4331. return ts23.factory.createCallExpression(
  4332. typeCtor,
  4333. void 0,
  4334. [ts23.factory.createObjectLiteralExpression(members)]
  4335. );
  4336. }
  4337. function getBoundAttributes(directive, node) {
  4338. const boundInputs = [];
  4339. const processAttribute = (attr) => {
  4340. if (attr instanceof TmplAstBoundAttribute && attr.type !== 0) {
  4341. return;
  4342. }
  4343. const inputs = directive.inputs.getByBindingPropertyName(attr.name);
  4344. if (inputs !== null) {
  4345. boundInputs.push({
  4346. attribute: attr,
  4347. inputs: inputs.map((input) => ({ fieldName: input.classPropertyName, required: input.required }))
  4348. });
  4349. }
  4350. };
  4351. node.inputs.forEach(processAttribute);
  4352. node.attributes.forEach(processAttribute);
  4353. if (node instanceof TmplAstTemplate2) {
  4354. node.templateAttrs.forEach(processAttribute);
  4355. }
  4356. return boundInputs;
  4357. }
  4358. function translateInput(attr, tcb, scope) {
  4359. if (attr instanceof TmplAstBoundAttribute) {
  4360. return tcbExpression(attr.value, tcb, scope);
  4361. } else {
  4362. return ts23.factory.createStringLiteral(attr.value);
  4363. }
  4364. }
  4365. function widenBinding(expr, tcb) {
  4366. if (!tcb.env.config.checkTypeOfInputBindings) {
  4367. return tsCastToAny(expr);
  4368. } else if (!tcb.env.config.strictNullInputBindings) {
  4369. if (ts23.isObjectLiteralExpression(expr) || ts23.isArrayLiteralExpression(expr)) {
  4370. return expr;
  4371. } else {
  4372. return ts23.factory.createNonNullExpression(expr);
  4373. }
  4374. } else {
  4375. return expr;
  4376. }
  4377. }
  4378. var EVENT_PARAMETER = "$event";
  4379. function tcbCreateEventHandler(event, tcb, scope, eventType) {
  4380. const handler = tcbEventHandlerExpression(event.handler, tcb, scope);
  4381. let eventParamType;
  4382. if (eventType === 0) {
  4383. eventParamType = void 0;
  4384. } else if (eventType === 1) {
  4385. eventParamType = ts23.factory.createKeywordTypeNode(ts23.SyntaxKind.AnyKeyword);
  4386. } else {
  4387. eventParamType = eventType;
  4388. }
  4389. const guards = scope.guards();
  4390. let body = ts23.factory.createExpressionStatement(handler);
  4391. if (guards !== null) {
  4392. body = ts23.factory.createIfStatement(guards, body);
  4393. }
  4394. const eventParam = ts23.factory.createParameterDeclaration(
  4395. void 0,
  4396. void 0,
  4397. EVENT_PARAMETER,
  4398. void 0,
  4399. eventParamType
  4400. );
  4401. addExpressionIdentifier(eventParam, ExpressionIdentifier.EVENT_PARAMETER);
  4402. return ts23.factory.createArrowFunction(
  4403. void 0,
  4404. void 0,
  4405. [eventParam],
  4406. ts23.factory.createKeywordTypeNode(ts23.SyntaxKind.AnyKeyword),
  4407. void 0,
  4408. ts23.factory.createBlock([body])
  4409. );
  4410. }
  4411. function tcbEventHandlerExpression(ast, tcb, scope) {
  4412. const translator = new TcbEventHandlerTranslator(tcb, scope);
  4413. return translator.translate(ast);
  4414. }
  4415. function isSplitTwoWayBinding(inputName, output, inputs, tcb) {
  4416. const input = inputs.find((input2) => input2.name === inputName);
  4417. if (input === void 0 || input.sourceSpan !== output.sourceSpan) {
  4418. return false;
  4419. }
  4420. const inputConsumer = tcb.boundTarget.getConsumerOfBinding(input);
  4421. const outputConsumer = tcb.boundTarget.getConsumerOfBinding(output);
  4422. if (outputConsumer === null || inputConsumer.ref === void 0 || outputConsumer instanceof TmplAstTemplate2) {
  4423. return false;
  4424. }
  4425. if (outputConsumer instanceof TmplAstElement3) {
  4426. tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer.ref.node, outputConsumer);
  4427. return true;
  4428. } else if (outputConsumer.ref !== inputConsumer.ref) {
  4429. tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer.ref.node, outputConsumer.ref.node);
  4430. return true;
  4431. }
  4432. return false;
  4433. }
  4434. var TcbEventHandlerTranslator = class extends TcbExpressionTranslator {
  4435. resolve(ast) {
  4436. if (ast instanceof PropertyRead4 && ast.receiver instanceof ImplicitReceiver4 && !(ast.receiver instanceof ThisReceiver) && ast.name === EVENT_PARAMETER) {
  4437. const event = ts23.factory.createIdentifier(EVENT_PARAMETER);
  4438. addParseSpanInfo(event, ast.nameSpan);
  4439. return event;
  4440. }
  4441. return super.resolve(ast);
  4442. }
  4443. };
  4444. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_file.mjs
  4445. import ts24 from "typescript";
  4446. var TypeCheckFile = class extends Environment {
  4447. constructor(fileName, config, refEmitter, reflector, compilerHost) {
  4448. super(config, new ImportManager(new NoopImportRewriter(), "i"), refEmitter, reflector, ts24.createSourceFile(compilerHost.getCanonicalFileName(fileName), "", ts24.ScriptTarget.Latest, true));
  4449. this.fileName = fileName;
  4450. this.nextTcbId = 1;
  4451. this.tcbStatements = [];
  4452. }
  4453. addTypeCheckBlock(ref, meta, domSchemaChecker, oobRecorder, genericContextBehavior) {
  4454. const fnId = ts24.factory.createIdentifier(`_tcb${this.nextTcbId++}`);
  4455. const fn = generateTypeCheckBlock(this, ref, fnId, meta, domSchemaChecker, oobRecorder, genericContextBehavior);
  4456. this.tcbStatements.push(fn);
  4457. }
  4458. render(removeComments) {
  4459. let source = this.importManager.getAllImports(this.contextFile.fileName).map((i) => `import * as ${i.qualifier.text} from '${i.specifier}';`).join("\n") + "\n\n";
  4460. const printer = ts24.createPrinter({ removeComments });
  4461. source += "\n";
  4462. for (const stmt of this.pipeInstStatements) {
  4463. source += printer.printNode(ts24.EmitHint.Unspecified, stmt, this.contextFile) + "\n";
  4464. }
  4465. for (const stmt of this.typeCtorStatements) {
  4466. source += printer.printNode(ts24.EmitHint.Unspecified, stmt, this.contextFile) + "\n";
  4467. }
  4468. source += "\n";
  4469. for (const stmt of this.tcbStatements) {
  4470. source += printer.printNode(ts24.EmitHint.Unspecified, stmt, this.contextFile) + "\n";
  4471. }
  4472. source += "\nexport const IS_A_MODULE = true;\n";
  4473. return source;
  4474. }
  4475. getPreludeStatements() {
  4476. return [];
  4477. }
  4478. };
  4479. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/context.mjs
  4480. var InliningMode;
  4481. (function(InliningMode2) {
  4482. InliningMode2[InliningMode2["InlineOps"] = 0] = "InlineOps";
  4483. InliningMode2[InliningMode2["Error"] = 1] = "Error";
  4484. })(InliningMode || (InliningMode = {}));
  4485. var TypeCheckContextImpl = class {
  4486. constructor(config, compilerHost, refEmitter, reflector, host, inlining, perf) {
  4487. this.config = config;
  4488. this.compilerHost = compilerHost;
  4489. this.refEmitter = refEmitter;
  4490. this.reflector = reflector;
  4491. this.host = host;
  4492. this.inlining = inlining;
  4493. this.perf = perf;
  4494. this.fileMap = /* @__PURE__ */ new Map();
  4495. this.opMap = /* @__PURE__ */ new Map();
  4496. this.typeCtorPending = /* @__PURE__ */ new Set();
  4497. if (inlining === InliningMode.Error && config.useInlineTypeConstructors) {
  4498. throw new Error(`AssertionError: invalid inlining configuration.`);
  4499. }
  4500. }
  4501. addTemplate(ref, binder, template, pipes, schemas, sourceMapping, file, parseErrors, isStandalone) {
  4502. if (!this.host.shouldCheckComponent(ref.node)) {
  4503. return;
  4504. }
  4505. const fileData = this.dataForFile(ref.node.getSourceFile());
  4506. const shimData = this.pendingShimForComponent(ref.node);
  4507. const templateId = fileData.sourceManager.getTemplateId(ref.node);
  4508. const templateDiagnostics = [];
  4509. if (parseErrors !== null) {
  4510. templateDiagnostics.push(...this.getTemplateDiagnostics(parseErrors, templateId, sourceMapping));
  4511. }
  4512. const boundTarget = binder.bind({ template });
  4513. if (this.inlining === InliningMode.InlineOps) {
  4514. for (const dir of boundTarget.getUsedDirectives()) {
  4515. const dirRef = dir.ref;
  4516. const dirNode = dirRef.node;
  4517. if (!dir.isGeneric || !requiresInlineTypeCtor(dirNode, this.reflector, shimData.file)) {
  4518. continue;
  4519. }
  4520. this.addInlineTypeCtor(fileData, dirNode.getSourceFile(), dirRef, {
  4521. fnName: "ngTypeCtor",
  4522. body: !dirNode.getSourceFile().isDeclarationFile,
  4523. fields: {
  4524. inputs: dir.inputs.classPropertyNames,
  4525. outputs: dir.outputs.classPropertyNames,
  4526. queries: dir.queries
  4527. },
  4528. coercedInputFields: dir.coercedInputFields
  4529. });
  4530. }
  4531. }
  4532. shimData.templates.set(templateId, {
  4533. template,
  4534. boundTarget,
  4535. templateDiagnostics
  4536. });
  4537. const usedPipes = [];
  4538. for (const name of boundTarget.getUsedPipes()) {
  4539. if (!pipes.has(name)) {
  4540. continue;
  4541. }
  4542. usedPipes.push(pipes.get(name));
  4543. }
  4544. const inliningRequirement = requiresInlineTypeCheckBlock(ref, shimData.file, usedPipes, this.reflector);
  4545. if (this.inlining === InliningMode.Error && inliningRequirement === TcbInliningRequirement.MustInline) {
  4546. shimData.oobRecorder.requiresInlineTcb(templateId, ref.node);
  4547. this.perf.eventCount(PerfEvent.SkipGenerateTcbNoInline);
  4548. return;
  4549. }
  4550. const meta = {
  4551. id: fileData.sourceManager.captureSource(ref.node, sourceMapping, file),
  4552. boundTarget,
  4553. pipes,
  4554. schemas,
  4555. isStandalone
  4556. };
  4557. this.perf.eventCount(PerfEvent.GenerateTcb);
  4558. if (inliningRequirement !== TcbInliningRequirement.None && this.inlining === InliningMode.InlineOps) {
  4559. this.addInlineTypeCheckBlock(fileData, shimData, ref, meta);
  4560. } else if (inliningRequirement === TcbInliningRequirement.ShouldInlineForGenericBounds && this.inlining === InliningMode.Error) {
  4561. shimData.file.addTypeCheckBlock(ref, meta, shimData.domSchemaChecker, shimData.oobRecorder, TcbGenericContextBehavior.FallbackToAny);
  4562. } else {
  4563. shimData.file.addTypeCheckBlock(ref, meta, shimData.domSchemaChecker, shimData.oobRecorder, TcbGenericContextBehavior.UseEmitter);
  4564. }
  4565. }
  4566. addInlineTypeCtor(fileData, sf, ref, ctorMeta) {
  4567. if (this.typeCtorPending.has(ref.node)) {
  4568. return;
  4569. }
  4570. this.typeCtorPending.add(ref.node);
  4571. if (!this.opMap.has(sf)) {
  4572. this.opMap.set(sf, []);
  4573. }
  4574. const ops = this.opMap.get(sf);
  4575. ops.push(new TypeCtorOp(ref, ctorMeta));
  4576. fileData.hasInlines = true;
  4577. }
  4578. transform(sf) {
  4579. if (!this.opMap.has(sf)) {
  4580. return null;
  4581. }
  4582. const importManager = new ImportManager(new NoopImportRewriter(), "_i");
  4583. const ops = this.opMap.get(sf).sort(orderOps);
  4584. const textParts = splitStringAtPoints(sf.text, ops.map((op) => op.splitPoint));
  4585. const printer = ts25.createPrinter({ omitTrailingSemicolon: true });
  4586. let code = textParts[0];
  4587. ops.forEach((op, idx) => {
  4588. const text = op.execute(importManager, sf, this.refEmitter, printer);
  4589. code += "\n\n" + text + textParts[idx + 1];
  4590. });
  4591. let imports = importManager.getAllImports(sf.fileName).map((i) => `import * as ${i.qualifier.text} from '${i.specifier}';`).join("\n");
  4592. code = imports + "\n" + code;
  4593. return code;
  4594. }
  4595. finalize() {
  4596. const updates = /* @__PURE__ */ new Map();
  4597. for (const originalSf of this.opMap.keys()) {
  4598. const newText = this.transform(originalSf);
  4599. if (newText !== null) {
  4600. updates.set(absoluteFromSourceFile(originalSf), {
  4601. newText,
  4602. originalFile: originalSf
  4603. });
  4604. }
  4605. }
  4606. for (const [sfPath, pendingFileData] of this.fileMap) {
  4607. for (const pendingShimData of pendingFileData.shimData.values()) {
  4608. this.host.recordShimData(sfPath, {
  4609. genesisDiagnostics: [
  4610. ...pendingShimData.domSchemaChecker.diagnostics,
  4611. ...pendingShimData.oobRecorder.diagnostics
  4612. ],
  4613. hasInlines: pendingFileData.hasInlines,
  4614. path: pendingShimData.file.fileName,
  4615. templates: pendingShimData.templates
  4616. });
  4617. const sfText = pendingShimData.file.render(false);
  4618. updates.set(pendingShimData.file.fileName, {
  4619. newText: sfText,
  4620. originalFile: null
  4621. });
  4622. }
  4623. }
  4624. return updates;
  4625. }
  4626. addInlineTypeCheckBlock(fileData, shimData, ref, tcbMeta) {
  4627. const sf = ref.node.getSourceFile();
  4628. if (!this.opMap.has(sf)) {
  4629. this.opMap.set(sf, []);
  4630. }
  4631. const ops = this.opMap.get(sf);
  4632. ops.push(new InlineTcbOp(ref, tcbMeta, this.config, this.reflector, shimData.domSchemaChecker, shimData.oobRecorder));
  4633. fileData.hasInlines = true;
  4634. }
  4635. pendingShimForComponent(node) {
  4636. const fileData = this.dataForFile(node.getSourceFile());
  4637. const shimPath = TypeCheckShimGenerator.shimFor(absoluteFromSourceFile(node.getSourceFile()));
  4638. if (!fileData.shimData.has(shimPath)) {
  4639. fileData.shimData.set(shimPath, {
  4640. domSchemaChecker: new RegistryDomSchemaChecker(fileData.sourceManager),
  4641. oobRecorder: new OutOfBandDiagnosticRecorderImpl(fileData.sourceManager),
  4642. file: new TypeCheckFile(shimPath, this.config, this.refEmitter, this.reflector, this.compilerHost),
  4643. templates: /* @__PURE__ */ new Map()
  4644. });
  4645. }
  4646. return fileData.shimData.get(shimPath);
  4647. }
  4648. dataForFile(sf) {
  4649. const sfPath = absoluteFromSourceFile(sf);
  4650. if (!this.fileMap.has(sfPath)) {
  4651. const data = {
  4652. hasInlines: false,
  4653. sourceManager: this.host.getSourceManager(sfPath),
  4654. shimData: /* @__PURE__ */ new Map()
  4655. };
  4656. this.fileMap.set(sfPath, data);
  4657. }
  4658. return this.fileMap.get(sfPath);
  4659. }
  4660. getTemplateDiagnostics(parseErrors, templateId, sourceMapping) {
  4661. return parseErrors.map((error) => {
  4662. const span = error.span;
  4663. if (span.start.offset === span.end.offset) {
  4664. span.end.offset++;
  4665. }
  4666. return makeTemplateDiagnostic(templateId, sourceMapping, span, ts25.DiagnosticCategory.Error, ngErrorCode(ErrorCode.TEMPLATE_PARSE_ERROR), error.msg);
  4667. });
  4668. }
  4669. };
  4670. var InlineTcbOp = class {
  4671. constructor(ref, meta, config, reflector, domSchemaChecker, oobRecorder) {
  4672. this.ref = ref;
  4673. this.meta = meta;
  4674. this.config = config;
  4675. this.reflector = reflector;
  4676. this.domSchemaChecker = domSchemaChecker;
  4677. this.oobRecorder = oobRecorder;
  4678. }
  4679. get splitPoint() {
  4680. return this.ref.node.end + 1;
  4681. }
  4682. execute(im, sf, refEmitter, printer) {
  4683. const env = new Environment(this.config, im, refEmitter, this.reflector, sf);
  4684. const fnName = ts25.factory.createIdentifier(`_tcb_${this.ref.node.pos}`);
  4685. const fn = generateTypeCheckBlock(env, this.ref, fnName, this.meta, this.domSchemaChecker, this.oobRecorder, TcbGenericContextBehavior.CopyClassNodes);
  4686. return printer.printNode(ts25.EmitHint.Unspecified, fn, sf);
  4687. }
  4688. };
  4689. var TypeCtorOp = class {
  4690. constructor(ref, meta) {
  4691. this.ref = ref;
  4692. this.meta = meta;
  4693. }
  4694. get splitPoint() {
  4695. return this.ref.node.end - 1;
  4696. }
  4697. execute(im, sf, refEmitter, printer) {
  4698. const tcb = generateInlineTypeCtor(this.ref.node, this.meta);
  4699. return printer.printNode(ts25.EmitHint.Unspecified, tcb, sf);
  4700. }
  4701. };
  4702. function orderOps(op1, op2) {
  4703. return op1.splitPoint - op2.splitPoint;
  4704. }
  4705. function splitStringAtPoints(str, points) {
  4706. const splits = [];
  4707. let start = 0;
  4708. for (let i = 0; i < points.length; i++) {
  4709. const point = points[i];
  4710. splits.push(str.substring(start, point));
  4711. start = point;
  4712. }
  4713. splits.push(str.substring(start));
  4714. return splits;
  4715. }
  4716. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/source.mjs
  4717. import { ParseLocation, ParseSourceSpan } from "@angular/compiler";
  4718. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/line_mappings.mjs
  4719. var LF_CHAR = 10;
  4720. var CR_CHAR = 13;
  4721. var LINE_SEP_CHAR = 8232;
  4722. var PARAGRAPH_CHAR = 8233;
  4723. function getLineAndCharacterFromPosition(lineStartsMap, position) {
  4724. const lineIndex = findClosestLineStartPosition(lineStartsMap, position);
  4725. return { character: position - lineStartsMap[lineIndex], line: lineIndex };
  4726. }
  4727. function computeLineStartsMap(text) {
  4728. const result = [0];
  4729. let pos = 0;
  4730. while (pos < text.length) {
  4731. const char = text.charCodeAt(pos++);
  4732. if (char === CR_CHAR) {
  4733. if (text.charCodeAt(pos) === LF_CHAR) {
  4734. pos++;
  4735. }
  4736. result.push(pos);
  4737. } else if (char === LF_CHAR || char === LINE_SEP_CHAR || char === PARAGRAPH_CHAR) {
  4738. result.push(pos);
  4739. }
  4740. }
  4741. result.push(pos);
  4742. return result;
  4743. }
  4744. function findClosestLineStartPosition(linesMap, position, low = 0, high = linesMap.length - 1) {
  4745. while (low <= high) {
  4746. const pivotIdx = Math.floor((low + high) / 2);
  4747. const pivotEl = linesMap[pivotIdx];
  4748. if (pivotEl === position) {
  4749. return pivotIdx;
  4750. } else if (position > pivotEl) {
  4751. low = pivotIdx + 1;
  4752. } else {
  4753. high = pivotIdx - 1;
  4754. }
  4755. }
  4756. return low - 1;
  4757. }
  4758. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/source.mjs
  4759. var TemplateSource = class {
  4760. constructor(mapping, file) {
  4761. this.mapping = mapping;
  4762. this.file = file;
  4763. this.lineStarts = null;
  4764. }
  4765. toParseSourceSpan(start, end) {
  4766. const startLoc = this.toParseLocation(start);
  4767. const endLoc = this.toParseLocation(end);
  4768. return new ParseSourceSpan(startLoc, endLoc);
  4769. }
  4770. toParseLocation(position) {
  4771. const lineStarts = this.acquireLineStarts();
  4772. const { line, character } = getLineAndCharacterFromPosition(lineStarts, position);
  4773. return new ParseLocation(this.file, position, line, character);
  4774. }
  4775. acquireLineStarts() {
  4776. if (this.lineStarts === null) {
  4777. this.lineStarts = computeLineStartsMap(this.file.content);
  4778. }
  4779. return this.lineStarts;
  4780. }
  4781. };
  4782. var TemplateSourceManager = class {
  4783. constructor() {
  4784. this.templateSources = /* @__PURE__ */ new Map();
  4785. }
  4786. getTemplateId(node) {
  4787. return getTemplateId(node);
  4788. }
  4789. captureSource(node, mapping, file) {
  4790. const id = getTemplateId(node);
  4791. this.templateSources.set(id, new TemplateSource(mapping, file));
  4792. return id;
  4793. }
  4794. getSourceMapping(id) {
  4795. if (!this.templateSources.has(id)) {
  4796. throw new Error(`Unexpected unknown template ID: ${id}`);
  4797. }
  4798. return this.templateSources.get(id).mapping;
  4799. }
  4800. toParseSourceSpan(id, span) {
  4801. if (!this.templateSources.has(id)) {
  4802. return null;
  4803. }
  4804. const templateSource = this.templateSources.get(id);
  4805. return templateSource.toParseSourceSpan(span.start, span.end);
  4806. }
  4807. };
  4808. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/template_symbol_builder.mjs
  4809. import { AST, ASTWithSource as ASTWithSource3, BindingPipe as BindingPipe2, PropertyRead as PropertyRead5, PropertyWrite as PropertyWrite4, SafePropertyRead as SafePropertyRead4, TmplAstBoundAttribute as TmplAstBoundAttribute2, TmplAstBoundEvent, TmplAstElement as TmplAstElement4, TmplAstReference as TmplAstReference4, TmplAstTemplate as TmplAstTemplate3, TmplAstTextAttribute as TmplAstTextAttribute3, TmplAstVariable as TmplAstVariable3 } from "@angular/compiler";
  4810. import ts26 from "typescript";
  4811. var SymbolBuilder = class {
  4812. constructor(tcbPath, tcbIsShim, typeCheckBlock, templateData, componentScopeReader, getTypeChecker) {
  4813. this.tcbPath = tcbPath;
  4814. this.tcbIsShim = tcbIsShim;
  4815. this.typeCheckBlock = typeCheckBlock;
  4816. this.templateData = templateData;
  4817. this.componentScopeReader = componentScopeReader;
  4818. this.getTypeChecker = getTypeChecker;
  4819. this.symbolCache = /* @__PURE__ */ new Map();
  4820. }
  4821. getSymbol(node) {
  4822. if (this.symbolCache.has(node)) {
  4823. return this.symbolCache.get(node);
  4824. }
  4825. let symbol = null;
  4826. if (node instanceof TmplAstBoundAttribute2 || node instanceof TmplAstTextAttribute3) {
  4827. symbol = this.getSymbolOfInputBinding(node);
  4828. } else if (node instanceof TmplAstBoundEvent) {
  4829. symbol = this.getSymbolOfBoundEvent(node);
  4830. } else if (node instanceof TmplAstElement4) {
  4831. symbol = this.getSymbolOfElement(node);
  4832. } else if (node instanceof TmplAstTemplate3) {
  4833. symbol = this.getSymbolOfAstTemplate(node);
  4834. } else if (node instanceof TmplAstVariable3) {
  4835. symbol = this.getSymbolOfVariable(node);
  4836. } else if (node instanceof TmplAstReference4) {
  4837. symbol = this.getSymbolOfReference(node);
  4838. } else if (node instanceof BindingPipe2) {
  4839. symbol = this.getSymbolOfPipe(node);
  4840. } else if (node instanceof AST) {
  4841. symbol = this.getSymbolOfTemplateExpression(node);
  4842. } else {
  4843. }
  4844. this.symbolCache.set(node, symbol);
  4845. return symbol;
  4846. }
  4847. getSymbolOfAstTemplate(template) {
  4848. const directives = this.getDirectivesOfNode(template);
  4849. return { kind: SymbolKind.Template, directives, templateNode: template };
  4850. }
  4851. getSymbolOfElement(element) {
  4852. var _a;
  4853. const elementSourceSpan = (_a = element.startSourceSpan) != null ? _a : element.sourceSpan;
  4854. const node = findFirstMatchingNode(this.typeCheckBlock, { withSpan: elementSourceSpan, filter: ts26.isVariableDeclaration });
  4855. if (node === null) {
  4856. return null;
  4857. }
  4858. const symbolFromDeclaration = this.getSymbolOfTsNode(node);
  4859. if (symbolFromDeclaration === null || symbolFromDeclaration.tsSymbol === null) {
  4860. return null;
  4861. }
  4862. const directives = this.getDirectivesOfNode(element);
  4863. return {
  4864. ...symbolFromDeclaration,
  4865. kind: SymbolKind.Element,
  4866. directives,
  4867. templateNode: element
  4868. };
  4869. }
  4870. getDirectivesOfNode(element) {
  4871. var _a;
  4872. const elementSourceSpan = (_a = element.startSourceSpan) != null ? _a : element.sourceSpan;
  4873. const tcbSourceFile = this.typeCheckBlock.getSourceFile();
  4874. const isDirectiveDeclaration = (node) => (ts26.isTypeNode(node) || ts26.isIdentifier(node)) && ts26.isVariableDeclaration(node.parent) && hasExpressionIdentifier(tcbSourceFile, node, ExpressionIdentifier.DIRECTIVE);
  4875. const nodes = findAllMatchingNodes(this.typeCheckBlock, { withSpan: elementSourceSpan, filter: isDirectiveDeclaration });
  4876. const symbols = [];
  4877. for (const node of nodes) {
  4878. const symbol = this.getSymbolOfTsNode(node.parent);
  4879. if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !ts26.isClassDeclaration(symbol.tsSymbol.valueDeclaration)) {
  4880. continue;
  4881. }
  4882. const meta = this.getDirectiveMeta(element, symbol.tsSymbol.valueDeclaration);
  4883. if (meta !== null && meta.selector !== null) {
  4884. const ref = new Reference(symbol.tsSymbol.valueDeclaration);
  4885. if (meta.hostDirectives !== null) {
  4886. this.addHostDirectiveSymbols(element, meta.hostDirectives, symbols);
  4887. }
  4888. const directiveSymbol = {
  4889. ...symbol,
  4890. ref,
  4891. tsSymbol: symbol.tsSymbol,
  4892. selector: meta.selector,
  4893. isComponent: meta.isComponent,
  4894. ngModule: this.getDirectiveModule(symbol.tsSymbol.valueDeclaration),
  4895. kind: SymbolKind.Directive,
  4896. isStructural: meta.isStructural,
  4897. isInScope: true,
  4898. isHostDirective: false
  4899. };
  4900. symbols.push(directiveSymbol);
  4901. }
  4902. }
  4903. return symbols;
  4904. }
  4905. addHostDirectiveSymbols(host, hostDirectives, symbols) {
  4906. for (const current of hostDirectives) {
  4907. if (!ts26.isClassDeclaration(current.directive.node)) {
  4908. continue;
  4909. }
  4910. const symbol = this.getSymbolOfTsNode(current.directive.node);
  4911. const meta = this.getDirectiveMeta(host, current.directive.node);
  4912. if (meta !== null && symbol !== null && isSymbolWithValueDeclaration(symbol.tsSymbol)) {
  4913. if (meta.hostDirectives !== null) {
  4914. this.addHostDirectiveSymbols(host, meta.hostDirectives, symbols);
  4915. }
  4916. const directiveSymbol = {
  4917. ...symbol,
  4918. isHostDirective: true,
  4919. ref: current.directive,
  4920. tsSymbol: symbol.tsSymbol,
  4921. exposedInputs: current.inputs,
  4922. exposedOutputs: current.outputs,
  4923. selector: meta.selector,
  4924. isComponent: meta.isComponent,
  4925. ngModule: this.getDirectiveModule(current.directive.node),
  4926. kind: SymbolKind.Directive,
  4927. isStructural: meta.isStructural,
  4928. isInScope: true
  4929. };
  4930. symbols.push(directiveSymbol);
  4931. }
  4932. }
  4933. }
  4934. getDirectiveMeta(host, directiveDeclaration) {
  4935. var _a;
  4936. let directives = this.templateData.boundTarget.getDirectivesOfNode(host);
  4937. const firstChild = host.children[0];
  4938. if (firstChild instanceof TmplAstElement4) {
  4939. const isMicrosyntaxTemplate = host instanceof TmplAstTemplate3 && sourceSpanEqual(firstChild.sourceSpan, host.sourceSpan);
  4940. if (isMicrosyntaxTemplate) {
  4941. const firstChildDirectives = this.templateData.boundTarget.getDirectivesOfNode(firstChild);
  4942. if (firstChildDirectives !== null && directives !== null) {
  4943. directives = directives.concat(firstChildDirectives);
  4944. } else {
  4945. directives = directives != null ? directives : firstChildDirectives;
  4946. }
  4947. }
  4948. }
  4949. if (directives === null) {
  4950. return null;
  4951. }
  4952. return (_a = directives.find((m) => m.ref.node === directiveDeclaration)) != null ? _a : null;
  4953. }
  4954. getDirectiveModule(declaration) {
  4955. const scope = this.componentScopeReader.getScopeForComponent(declaration);
  4956. if (scope === null || scope.kind !== ComponentScopeKind.NgModule) {
  4957. return null;
  4958. }
  4959. return scope.ngModule;
  4960. }
  4961. getSymbolOfBoundEvent(eventBinding) {
  4962. const consumer = this.templateData.boundTarget.getConsumerOfBinding(eventBinding);
  4963. if (consumer === null) {
  4964. return null;
  4965. }
  4966. let expectedAccess;
  4967. if (consumer instanceof TmplAstTemplate3 || consumer instanceof TmplAstElement4) {
  4968. expectedAccess = "addEventListener";
  4969. } else {
  4970. const bindingPropertyNames = consumer.outputs.getByBindingPropertyName(eventBinding.name);
  4971. if (bindingPropertyNames === null || bindingPropertyNames.length === 0) {
  4972. return null;
  4973. }
  4974. expectedAccess = bindingPropertyNames[0].classPropertyName;
  4975. }
  4976. function filter(n) {
  4977. if (!isAccessExpression(n)) {
  4978. return false;
  4979. }
  4980. if (ts26.isPropertyAccessExpression(n)) {
  4981. return n.name.getText() === expectedAccess;
  4982. } else {
  4983. return ts26.isStringLiteral(n.argumentExpression) && n.argumentExpression.text === expectedAccess;
  4984. }
  4985. }
  4986. const outputFieldAccesses = findAllMatchingNodes(this.typeCheckBlock, { withSpan: eventBinding.keySpan, filter });
  4987. const bindings = [];
  4988. for (const outputFieldAccess of outputFieldAccesses) {
  4989. if (consumer instanceof TmplAstTemplate3 || consumer instanceof TmplAstElement4) {
  4990. if (!ts26.isPropertyAccessExpression(outputFieldAccess)) {
  4991. continue;
  4992. }
  4993. const addEventListener = outputFieldAccess.name;
  4994. const tsSymbol = this.getTypeChecker().getSymbolAtLocation(addEventListener);
  4995. const tsType = this.getTypeChecker().getTypeAtLocation(addEventListener);
  4996. const positionInFile = this.getTcbPositionForNode(addEventListener);
  4997. const target = this.getSymbol(consumer);
  4998. if (target === null || tsSymbol === void 0) {
  4999. continue;
  5000. }
  5001. bindings.push({
  5002. kind: SymbolKind.Binding,
  5003. tsSymbol,
  5004. tsType,
  5005. target,
  5006. tcbLocation: {
  5007. tcbPath: this.tcbPath,
  5008. isShimFile: this.tcbIsShim,
  5009. positionInFile
  5010. }
  5011. });
  5012. } else {
  5013. if (!ts26.isElementAccessExpression(outputFieldAccess)) {
  5014. continue;
  5015. }
  5016. const tsSymbol = this.getTypeChecker().getSymbolAtLocation(outputFieldAccess.argumentExpression);
  5017. if (tsSymbol === void 0) {
  5018. continue;
  5019. }
  5020. const target = this.getDirectiveSymbolForAccessExpression(outputFieldAccess, consumer);
  5021. if (target === null) {
  5022. continue;
  5023. }
  5024. const positionInFile = this.getTcbPositionForNode(outputFieldAccess);
  5025. const tsType = this.getTypeChecker().getTypeAtLocation(outputFieldAccess);
  5026. bindings.push({
  5027. kind: SymbolKind.Binding,
  5028. tsSymbol,
  5029. tsType,
  5030. target,
  5031. tcbLocation: {
  5032. tcbPath: this.tcbPath,
  5033. isShimFile: this.tcbIsShim,
  5034. positionInFile
  5035. }
  5036. });
  5037. }
  5038. }
  5039. if (bindings.length === 0) {
  5040. return null;
  5041. }
  5042. return { kind: SymbolKind.Output, bindings };
  5043. }
  5044. getSymbolOfInputBinding(binding) {
  5045. const consumer = this.templateData.boundTarget.getConsumerOfBinding(binding);
  5046. if (consumer === null) {
  5047. return null;
  5048. }
  5049. if (consumer instanceof TmplAstElement4 || consumer instanceof TmplAstTemplate3) {
  5050. const host = this.getSymbol(consumer);
  5051. return host !== null ? { kind: SymbolKind.DomBinding, host } : null;
  5052. }
  5053. const nodes = findAllMatchingNodes(this.typeCheckBlock, { withSpan: binding.sourceSpan, filter: isAssignment });
  5054. const bindings = [];
  5055. for (const node of nodes) {
  5056. if (!isAccessExpression(node.left)) {
  5057. continue;
  5058. }
  5059. const symbolInfo = this.getSymbolOfTsNode(node.left);
  5060. if (symbolInfo === null || symbolInfo.tsSymbol === null) {
  5061. continue;
  5062. }
  5063. const target = this.getDirectiveSymbolForAccessExpression(node.left, consumer);
  5064. if (target === null) {
  5065. continue;
  5066. }
  5067. bindings.push({
  5068. ...symbolInfo,
  5069. tsSymbol: symbolInfo.tsSymbol,
  5070. kind: SymbolKind.Binding,
  5071. target
  5072. });
  5073. }
  5074. if (bindings.length === 0) {
  5075. return null;
  5076. }
  5077. return { kind: SymbolKind.Input, bindings };
  5078. }
  5079. getDirectiveSymbolForAccessExpression(node, { isComponent, selector, isStructural }) {
  5080. var _a;
  5081. const tsSymbol = this.getTypeChecker().getSymbolAtLocation(node.expression);
  5082. if ((tsSymbol == null ? void 0 : tsSymbol.declarations) === void 0 || tsSymbol.declarations.length === 0 || selector === null) {
  5083. return null;
  5084. }
  5085. const [declaration] = tsSymbol.declarations;
  5086. if (!ts26.isVariableDeclaration(declaration) || !hasExpressionIdentifier(
  5087. declaration.getSourceFile(),
  5088. (_a = declaration.type) != null ? _a : declaration.name,
  5089. ExpressionIdentifier.DIRECTIVE
  5090. )) {
  5091. return null;
  5092. }
  5093. const symbol = this.getSymbolOfTsNode(declaration);
  5094. if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !ts26.isClassDeclaration(symbol.tsSymbol.valueDeclaration)) {
  5095. return null;
  5096. }
  5097. const ref = new Reference(symbol.tsSymbol.valueDeclaration);
  5098. const ngModule = this.getDirectiveModule(symbol.tsSymbol.valueDeclaration);
  5099. return {
  5100. ref,
  5101. kind: SymbolKind.Directive,
  5102. tsSymbol: symbol.tsSymbol,
  5103. tsType: symbol.tsType,
  5104. tcbLocation: symbol.tcbLocation,
  5105. isComponent,
  5106. isStructural,
  5107. selector,
  5108. ngModule,
  5109. isHostDirective: false,
  5110. isInScope: true
  5111. };
  5112. }
  5113. getSymbolOfVariable(variable) {
  5114. const node = findFirstMatchingNode(this.typeCheckBlock, { withSpan: variable.sourceSpan, filter: ts26.isVariableDeclaration });
  5115. if (node === null || node.initializer === void 0) {
  5116. return null;
  5117. }
  5118. const expressionSymbol = this.getSymbolOfTsNode(node.initializer);
  5119. if (expressionSymbol === null) {
  5120. return null;
  5121. }
  5122. return {
  5123. tsType: expressionSymbol.tsType,
  5124. tsSymbol: expressionSymbol.tsSymbol,
  5125. initializerLocation: expressionSymbol.tcbLocation,
  5126. kind: SymbolKind.Variable,
  5127. declaration: variable,
  5128. localVarLocation: {
  5129. tcbPath: this.tcbPath,
  5130. isShimFile: this.tcbIsShim,
  5131. positionInFile: this.getTcbPositionForNode(node.name)
  5132. }
  5133. };
  5134. }
  5135. getSymbolOfReference(ref) {
  5136. const target = this.templateData.boundTarget.getReferenceTarget(ref);
  5137. let node = findFirstMatchingNode(this.typeCheckBlock, { withSpan: ref.sourceSpan, filter: ts26.isVariableDeclaration });
  5138. if (node === null || target === null || node.initializer === void 0) {
  5139. return null;
  5140. }
  5141. const originalDeclaration = ts26.isParenthesizedExpression(node.initializer) && ts26.isAsExpression(node.initializer.expression) ? this.getTypeChecker().getSymbolAtLocation(node.name) : this.getTypeChecker().getSymbolAtLocation(node.initializer);
  5142. if (originalDeclaration === void 0 || originalDeclaration.valueDeclaration === void 0) {
  5143. return null;
  5144. }
  5145. const symbol = this.getSymbolOfTsNode(originalDeclaration.valueDeclaration);
  5146. if (symbol === null || symbol.tsSymbol === null) {
  5147. return null;
  5148. }
  5149. const referenceVarTcbLocation = {
  5150. tcbPath: this.tcbPath,
  5151. isShimFile: this.tcbIsShim,
  5152. positionInFile: this.getTcbPositionForNode(node)
  5153. };
  5154. if (target instanceof TmplAstTemplate3 || target instanceof TmplAstElement4) {
  5155. return {
  5156. kind: SymbolKind.Reference,
  5157. tsSymbol: symbol.tsSymbol,
  5158. tsType: symbol.tsType,
  5159. target,
  5160. declaration: ref,
  5161. targetLocation: symbol.tcbLocation,
  5162. referenceVarLocation: referenceVarTcbLocation
  5163. };
  5164. } else {
  5165. if (!ts26.isClassDeclaration(target.directive.ref.node)) {
  5166. return null;
  5167. }
  5168. return {
  5169. kind: SymbolKind.Reference,
  5170. tsSymbol: symbol.tsSymbol,
  5171. tsType: symbol.tsType,
  5172. declaration: ref,
  5173. target: target.directive.ref.node,
  5174. targetLocation: symbol.tcbLocation,
  5175. referenceVarLocation: referenceVarTcbLocation
  5176. };
  5177. }
  5178. }
  5179. getSymbolOfPipe(expression) {
  5180. const methodAccess = findFirstMatchingNode(this.typeCheckBlock, { withSpan: expression.nameSpan, filter: ts26.isPropertyAccessExpression });
  5181. if (methodAccess === null) {
  5182. return null;
  5183. }
  5184. const pipeVariableNode = methodAccess.expression;
  5185. const pipeDeclaration = this.getTypeChecker().getSymbolAtLocation(pipeVariableNode);
  5186. if (pipeDeclaration === void 0 || pipeDeclaration.valueDeclaration === void 0) {
  5187. return null;
  5188. }
  5189. const pipeInstance = this.getSymbolOfTsNode(pipeDeclaration.valueDeclaration);
  5190. if (pipeInstance === null || !isSymbolWithValueDeclaration(pipeInstance.tsSymbol)) {
  5191. return null;
  5192. }
  5193. const symbolInfo = this.getSymbolOfTsNode(methodAccess);
  5194. if (symbolInfo === null) {
  5195. return null;
  5196. }
  5197. return {
  5198. kind: SymbolKind.Pipe,
  5199. ...symbolInfo,
  5200. classSymbol: {
  5201. ...pipeInstance,
  5202. tsSymbol: pipeInstance.tsSymbol
  5203. }
  5204. };
  5205. }
  5206. getSymbolOfTemplateExpression(expression) {
  5207. if (expression instanceof ASTWithSource3) {
  5208. expression = expression.ast;
  5209. }
  5210. const expressionTarget = this.templateData.boundTarget.getExpressionTarget(expression);
  5211. if (expressionTarget !== null) {
  5212. return this.getSymbol(expressionTarget);
  5213. }
  5214. let withSpan = expression.sourceSpan;
  5215. if (expression instanceof PropertyWrite4) {
  5216. withSpan = expression.nameSpan;
  5217. }
  5218. let node = null;
  5219. if (expression instanceof PropertyRead5) {
  5220. node = findFirstMatchingNode(this.typeCheckBlock, { withSpan, filter: ts26.isPropertyAccessExpression });
  5221. }
  5222. if (node === null) {
  5223. node = findFirstMatchingNode(this.typeCheckBlock, { withSpan, filter: anyNodeFilter });
  5224. }
  5225. if (node === null) {
  5226. return null;
  5227. }
  5228. while (ts26.isParenthesizedExpression(node)) {
  5229. node = node.expression;
  5230. }
  5231. if (expression instanceof SafePropertyRead4 && ts26.isConditionalExpression(node)) {
  5232. const whenTrueSymbol = this.getSymbolOfTsNode(node.whenTrue);
  5233. if (whenTrueSymbol === null) {
  5234. return null;
  5235. }
  5236. return {
  5237. ...whenTrueSymbol,
  5238. kind: SymbolKind.Expression,
  5239. tsType: this.getTypeChecker().getTypeAtLocation(node)
  5240. };
  5241. } else {
  5242. const symbolInfo = this.getSymbolOfTsNode(node);
  5243. return symbolInfo === null ? null : { ...symbolInfo, kind: SymbolKind.Expression };
  5244. }
  5245. }
  5246. getSymbolOfTsNode(node) {
  5247. var _a;
  5248. while (ts26.isParenthesizedExpression(node)) {
  5249. node = node.expression;
  5250. }
  5251. let tsSymbol;
  5252. if (ts26.isPropertyAccessExpression(node)) {
  5253. tsSymbol = this.getTypeChecker().getSymbolAtLocation(node.name);
  5254. } else if (ts26.isElementAccessExpression(node)) {
  5255. tsSymbol = this.getTypeChecker().getSymbolAtLocation(node.argumentExpression);
  5256. } else {
  5257. tsSymbol = this.getTypeChecker().getSymbolAtLocation(node);
  5258. }
  5259. const positionInFile = this.getTcbPositionForNode(node);
  5260. const type = this.getTypeChecker().getTypeAtLocation(node);
  5261. return {
  5262. tsSymbol: (_a = tsSymbol != null ? tsSymbol : type.symbol) != null ? _a : null,
  5263. tsType: type,
  5264. tcbLocation: {
  5265. tcbPath: this.tcbPath,
  5266. isShimFile: this.tcbIsShim,
  5267. positionInFile
  5268. }
  5269. };
  5270. }
  5271. getTcbPositionForNode(node) {
  5272. if (ts26.isTypeReferenceNode(node)) {
  5273. return this.getTcbPositionForNode(node.typeName);
  5274. } else if (ts26.isQualifiedName(node)) {
  5275. return node.right.getStart();
  5276. } else if (ts26.isPropertyAccessExpression(node)) {
  5277. return node.name.getStart();
  5278. } else if (ts26.isElementAccessExpression(node)) {
  5279. return node.argumentExpression.getStart();
  5280. } else {
  5281. return node.getStart();
  5282. }
  5283. }
  5284. };
  5285. function anyNodeFilter(n) {
  5286. return true;
  5287. }
  5288. function sourceSpanEqual(a, b) {
  5289. return a.start.offset === b.start.offset && a.end.offset === b.end.offset;
  5290. }
  5291. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/checker.mjs
  5292. var REGISTRY2 = new DomElementSchemaRegistry2();
  5293. var TemplateTypeCheckerImpl = class {
  5294. constructor(originalProgram, programDriver, typeCheckAdapter, config, refEmitter, reflector, compilerHost, priorBuild, metaReader, localMetaReader, ngModuleIndex, componentScopeReader, typeCheckScopeRegistry, perf) {
  5295. this.originalProgram = originalProgram;
  5296. this.programDriver = programDriver;
  5297. this.typeCheckAdapter = typeCheckAdapter;
  5298. this.config = config;
  5299. this.refEmitter = refEmitter;
  5300. this.reflector = reflector;
  5301. this.compilerHost = compilerHost;
  5302. this.priorBuild = priorBuild;
  5303. this.metaReader = metaReader;
  5304. this.localMetaReader = localMetaReader;
  5305. this.ngModuleIndex = ngModuleIndex;
  5306. this.componentScopeReader = componentScopeReader;
  5307. this.typeCheckScopeRegistry = typeCheckScopeRegistry;
  5308. this.perf = perf;
  5309. this.state = /* @__PURE__ */ new Map();
  5310. this.completionCache = /* @__PURE__ */ new Map();
  5311. this.symbolBuilderCache = /* @__PURE__ */ new Map();
  5312. this.scopeCache = /* @__PURE__ */ new Map();
  5313. this.elementTagCache = /* @__PURE__ */ new Map();
  5314. this.isComplete = false;
  5315. }
  5316. getTemplate(component) {
  5317. const { data } = this.getLatestComponentState(component);
  5318. if (data === null) {
  5319. return null;
  5320. }
  5321. return data.template;
  5322. }
  5323. getUsedDirectives(component) {
  5324. var _a;
  5325. return ((_a = this.getLatestComponentState(component).data) == null ? void 0 : _a.boundTarget.getUsedDirectives()) || null;
  5326. }
  5327. getUsedPipes(component) {
  5328. var _a;
  5329. return ((_a = this.getLatestComponentState(component).data) == null ? void 0 : _a.boundTarget.getUsedPipes()) || null;
  5330. }
  5331. getLatestComponentState(component) {
  5332. this.ensureShimForComponent(component);
  5333. const sf = component.getSourceFile();
  5334. const sfPath = absoluteFromSourceFile(sf);
  5335. const shimPath = TypeCheckShimGenerator.shimFor(sfPath);
  5336. const fileRecord = this.getFileData(sfPath);
  5337. if (!fileRecord.shimData.has(shimPath)) {
  5338. return { data: null, tcb: null, tcbPath: shimPath, tcbIsShim: true };
  5339. }
  5340. const templateId = fileRecord.sourceManager.getTemplateId(component);
  5341. const shimRecord = fileRecord.shimData.get(shimPath);
  5342. const id = fileRecord.sourceManager.getTemplateId(component);
  5343. const program = this.programDriver.getProgram();
  5344. const shimSf = getSourceFileOrNull(program, shimPath);
  5345. if (shimSf === null || !fileRecord.shimData.has(shimPath)) {
  5346. throw new Error(`Error: no shim file in program: ${shimPath}`);
  5347. }
  5348. let tcb = findTypeCheckBlock(shimSf, id, false);
  5349. let tcbPath = shimPath;
  5350. if (tcb === null) {
  5351. const inlineSf = getSourceFileOrError(program, sfPath);
  5352. tcb = findTypeCheckBlock(inlineSf, id, false);
  5353. if (tcb !== null) {
  5354. tcbPath = sfPath;
  5355. }
  5356. }
  5357. let data = null;
  5358. if (shimRecord.templates.has(templateId)) {
  5359. data = shimRecord.templates.get(templateId);
  5360. }
  5361. return { data, tcb, tcbPath, tcbIsShim: tcbPath === shimPath };
  5362. }
  5363. isTrackedTypeCheckFile(filePath) {
  5364. return this.getFileAndShimRecordsForPath(filePath) !== null;
  5365. }
  5366. getFileRecordForTcbLocation({ tcbPath, isShimFile }) {
  5367. if (!isShimFile) {
  5368. if (this.state.has(tcbPath)) {
  5369. return this.state.get(tcbPath);
  5370. } else {
  5371. return null;
  5372. }
  5373. }
  5374. const records = this.getFileAndShimRecordsForPath(tcbPath);
  5375. if (records !== null) {
  5376. return records.fileRecord;
  5377. } else {
  5378. return null;
  5379. }
  5380. }
  5381. getFileAndShimRecordsForPath(shimPath) {
  5382. for (const fileRecord of this.state.values()) {
  5383. if (fileRecord.shimData.has(shimPath)) {
  5384. return { fileRecord, shimRecord: fileRecord.shimData.get(shimPath) };
  5385. }
  5386. }
  5387. return null;
  5388. }
  5389. getTemplateMappingAtTcbLocation(tcbLocation) {
  5390. const fileRecord = this.getFileRecordForTcbLocation(tcbLocation);
  5391. if (fileRecord === null) {
  5392. return null;
  5393. }
  5394. const shimSf = this.programDriver.getProgram().getSourceFile(tcbLocation.tcbPath);
  5395. if (shimSf === void 0) {
  5396. return null;
  5397. }
  5398. return getTemplateMapping(
  5399. shimSf,
  5400. tcbLocation.positionInFile,
  5401. fileRecord.sourceManager,
  5402. false
  5403. );
  5404. }
  5405. generateAllTypeCheckBlocks() {
  5406. this.ensureAllShimsForAllFiles();
  5407. }
  5408. getDiagnosticsForFile(sf, optimizeFor) {
  5409. switch (optimizeFor) {
  5410. case OptimizeFor.WholeProgram:
  5411. this.ensureAllShimsForAllFiles();
  5412. break;
  5413. case OptimizeFor.SingleFile:
  5414. this.ensureAllShimsForOneFile(sf);
  5415. break;
  5416. }
  5417. return this.perf.inPhase(PerfPhase.TtcDiagnostics, () => {
  5418. const sfPath = absoluteFromSourceFile(sf);
  5419. const fileRecord = this.state.get(sfPath);
  5420. const typeCheckProgram = this.programDriver.getProgram();
  5421. const diagnostics = [];
  5422. if (fileRecord.hasInlines) {
  5423. const inlineSf = getSourceFileOrError(typeCheckProgram, sfPath);
  5424. diagnostics.push(...typeCheckProgram.getSemanticDiagnostics(inlineSf).map((diag) => convertDiagnostic(diag, fileRecord.sourceManager)));
  5425. }
  5426. for (const [shimPath, shimRecord] of fileRecord.shimData) {
  5427. const shimSf = getSourceFileOrError(typeCheckProgram, shimPath);
  5428. diagnostics.push(...typeCheckProgram.getSemanticDiagnostics(shimSf).map((diag) => convertDiagnostic(diag, fileRecord.sourceManager)));
  5429. diagnostics.push(...shimRecord.genesisDiagnostics);
  5430. for (const templateData of shimRecord.templates.values()) {
  5431. diagnostics.push(...templateData.templateDiagnostics);
  5432. }
  5433. }
  5434. return diagnostics.filter((diag) => diag !== null);
  5435. });
  5436. }
  5437. getDiagnosticsForComponent(component) {
  5438. this.ensureShimForComponent(component);
  5439. return this.perf.inPhase(PerfPhase.TtcDiagnostics, () => {
  5440. const sf = component.getSourceFile();
  5441. const sfPath = absoluteFromSourceFile(sf);
  5442. const shimPath = TypeCheckShimGenerator.shimFor(sfPath);
  5443. const fileRecord = this.getFileData(sfPath);
  5444. if (!fileRecord.shimData.has(shimPath)) {
  5445. return [];
  5446. }
  5447. const templateId = fileRecord.sourceManager.getTemplateId(component);
  5448. const shimRecord = fileRecord.shimData.get(shimPath);
  5449. const typeCheckProgram = this.programDriver.getProgram();
  5450. const diagnostics = [];
  5451. if (shimRecord.hasInlines) {
  5452. const inlineSf = getSourceFileOrError(typeCheckProgram, sfPath);
  5453. diagnostics.push(...typeCheckProgram.getSemanticDiagnostics(inlineSf).map((diag) => convertDiagnostic(diag, fileRecord.sourceManager)));
  5454. }
  5455. const shimSf = getSourceFileOrError(typeCheckProgram, shimPath);
  5456. diagnostics.push(...typeCheckProgram.getSemanticDiagnostics(shimSf).map((diag) => convertDiagnostic(diag, fileRecord.sourceManager)));
  5457. diagnostics.push(...shimRecord.genesisDiagnostics);
  5458. for (const templateData of shimRecord.templates.values()) {
  5459. diagnostics.push(...templateData.templateDiagnostics);
  5460. }
  5461. return diagnostics.filter((diag) => diag !== null && diag.templateId === templateId);
  5462. });
  5463. }
  5464. getTypeCheckBlock(component) {
  5465. return this.getLatestComponentState(component).tcb;
  5466. }
  5467. getGlobalCompletions(context, component, node) {
  5468. const engine = this.getOrCreateCompletionEngine(component);
  5469. if (engine === null) {
  5470. return null;
  5471. }
  5472. return this.perf.inPhase(PerfPhase.TtcAutocompletion, () => engine.getGlobalCompletions(context, node));
  5473. }
  5474. getExpressionCompletionLocation(ast, component) {
  5475. const engine = this.getOrCreateCompletionEngine(component);
  5476. if (engine === null) {
  5477. return null;
  5478. }
  5479. return this.perf.inPhase(PerfPhase.TtcAutocompletion, () => engine.getExpressionCompletionLocation(ast));
  5480. }
  5481. getLiteralCompletionLocation(node, component) {
  5482. const engine = this.getOrCreateCompletionEngine(component);
  5483. if (engine === null) {
  5484. return null;
  5485. }
  5486. return this.perf.inPhase(PerfPhase.TtcAutocompletion, () => engine.getLiteralCompletionLocation(node));
  5487. }
  5488. invalidateClass(clazz) {
  5489. this.completionCache.delete(clazz);
  5490. this.symbolBuilderCache.delete(clazz);
  5491. this.scopeCache.delete(clazz);
  5492. this.elementTagCache.delete(clazz);
  5493. const sf = clazz.getSourceFile();
  5494. const sfPath = absoluteFromSourceFile(sf);
  5495. const shimPath = TypeCheckShimGenerator.shimFor(sfPath);
  5496. const fileData = this.getFileData(sfPath);
  5497. const templateId = fileData.sourceManager.getTemplateId(clazz);
  5498. fileData.shimData.delete(shimPath);
  5499. fileData.isComplete = false;
  5500. this.isComplete = false;
  5501. }
  5502. makeTemplateDiagnostic(clazz, sourceSpan, category, errorCode, message, relatedInformation) {
  5503. const sfPath = absoluteFromSourceFile(clazz.getSourceFile());
  5504. const fileRecord = this.state.get(sfPath);
  5505. const templateId = fileRecord.sourceManager.getTemplateId(clazz);
  5506. const mapping = fileRecord.sourceManager.getSourceMapping(templateId);
  5507. return {
  5508. ...makeTemplateDiagnostic(templateId, mapping, sourceSpan, category, ngErrorCode(errorCode), message, relatedInformation),
  5509. __ngCode: errorCode
  5510. };
  5511. }
  5512. getOrCreateCompletionEngine(component) {
  5513. if (this.completionCache.has(component)) {
  5514. return this.completionCache.get(component);
  5515. }
  5516. const { tcb, data, tcbPath, tcbIsShim } = this.getLatestComponentState(component);
  5517. if (tcb === null || data === null) {
  5518. return null;
  5519. }
  5520. const engine = new CompletionEngine(tcb, data, tcbPath, tcbIsShim);
  5521. this.completionCache.set(component, engine);
  5522. return engine;
  5523. }
  5524. maybeAdoptPriorResultsForFile(sf) {
  5525. const sfPath = absoluteFromSourceFile(sf);
  5526. if (this.state.has(sfPath)) {
  5527. const existingResults = this.state.get(sfPath);
  5528. if (existingResults.isComplete) {
  5529. return;
  5530. }
  5531. }
  5532. const previousResults = this.priorBuild.priorTypeCheckingResultsFor(sf);
  5533. if (previousResults === null || !previousResults.isComplete) {
  5534. return;
  5535. }
  5536. this.perf.eventCount(PerfEvent.ReuseTypeCheckFile);
  5537. this.state.set(sfPath, previousResults);
  5538. }
  5539. ensureAllShimsForAllFiles() {
  5540. if (this.isComplete) {
  5541. return;
  5542. }
  5543. this.perf.inPhase(PerfPhase.TcbGeneration, () => {
  5544. const host = new WholeProgramTypeCheckingHost(this);
  5545. const ctx = this.newContext(host);
  5546. for (const sf of this.originalProgram.getSourceFiles()) {
  5547. if (sf.isDeclarationFile || isShim(sf)) {
  5548. continue;
  5549. }
  5550. this.maybeAdoptPriorResultsForFile(sf);
  5551. const sfPath = absoluteFromSourceFile(sf);
  5552. const fileData = this.getFileData(sfPath);
  5553. if (fileData.isComplete) {
  5554. continue;
  5555. }
  5556. this.typeCheckAdapter.typeCheck(sf, ctx);
  5557. fileData.isComplete = true;
  5558. }
  5559. this.updateFromContext(ctx);
  5560. this.isComplete = true;
  5561. });
  5562. }
  5563. ensureAllShimsForOneFile(sf) {
  5564. this.perf.inPhase(PerfPhase.TcbGeneration, () => {
  5565. this.maybeAdoptPriorResultsForFile(sf);
  5566. const sfPath = absoluteFromSourceFile(sf);
  5567. const fileData = this.getFileData(sfPath);
  5568. if (fileData.isComplete) {
  5569. return;
  5570. }
  5571. const host = new SingleFileTypeCheckingHost(sfPath, fileData, this);
  5572. const ctx = this.newContext(host);
  5573. this.typeCheckAdapter.typeCheck(sf, ctx);
  5574. fileData.isComplete = true;
  5575. this.updateFromContext(ctx);
  5576. });
  5577. }
  5578. ensureShimForComponent(component) {
  5579. const sf = component.getSourceFile();
  5580. const sfPath = absoluteFromSourceFile(sf);
  5581. const shimPath = TypeCheckShimGenerator.shimFor(sfPath);
  5582. this.maybeAdoptPriorResultsForFile(sf);
  5583. const fileData = this.getFileData(sfPath);
  5584. if (fileData.shimData.has(shimPath)) {
  5585. return;
  5586. }
  5587. const host = new SingleShimTypeCheckingHost(sfPath, fileData, this, shimPath);
  5588. const ctx = this.newContext(host);
  5589. this.typeCheckAdapter.typeCheck(sf, ctx);
  5590. this.updateFromContext(ctx);
  5591. }
  5592. newContext(host) {
  5593. const inlining = this.programDriver.supportsInlineOperations ? InliningMode.InlineOps : InliningMode.Error;
  5594. return new TypeCheckContextImpl(this.config, this.compilerHost, this.refEmitter, this.reflector, host, inlining, this.perf);
  5595. }
  5596. clearAllShimDataUsingInlines() {
  5597. for (const fileData of this.state.values()) {
  5598. if (!fileData.hasInlines) {
  5599. continue;
  5600. }
  5601. for (const [shimFile, shimData] of fileData.shimData.entries()) {
  5602. if (shimData.hasInlines) {
  5603. fileData.shimData.delete(shimFile);
  5604. }
  5605. }
  5606. fileData.hasInlines = false;
  5607. fileData.isComplete = false;
  5608. this.isComplete = false;
  5609. }
  5610. }
  5611. updateFromContext(ctx) {
  5612. const updates = ctx.finalize();
  5613. return this.perf.inPhase(PerfPhase.TcbUpdateProgram, () => {
  5614. if (updates.size > 0) {
  5615. this.perf.eventCount(PerfEvent.UpdateTypeCheckProgram);
  5616. }
  5617. this.programDriver.updateFiles(updates, UpdateMode.Incremental);
  5618. this.priorBuild.recordSuccessfulTypeCheck(this.state);
  5619. this.perf.memory(PerfCheckpoint.TtcUpdateProgram);
  5620. });
  5621. }
  5622. getFileData(path2) {
  5623. if (!this.state.has(path2)) {
  5624. this.state.set(path2, {
  5625. hasInlines: false,
  5626. sourceManager: new TemplateSourceManager(),
  5627. isComplete: false,
  5628. shimData: /* @__PURE__ */ new Map()
  5629. });
  5630. }
  5631. return this.state.get(path2);
  5632. }
  5633. getSymbolOfNode(node, component) {
  5634. const builder = this.getOrCreateSymbolBuilder(component);
  5635. if (builder === null) {
  5636. return null;
  5637. }
  5638. return this.perf.inPhase(PerfPhase.TtcSymbol, () => builder.getSymbol(node));
  5639. }
  5640. getOrCreateSymbolBuilder(component) {
  5641. if (this.symbolBuilderCache.has(component)) {
  5642. return this.symbolBuilderCache.get(component);
  5643. }
  5644. const { tcb, data, tcbPath, tcbIsShim } = this.getLatestComponentState(component);
  5645. if (tcb === null || data === null) {
  5646. return null;
  5647. }
  5648. const builder = new SymbolBuilder(tcbPath, tcbIsShim, tcb, data, this.componentScopeReader, () => this.programDriver.getProgram().getTypeChecker());
  5649. this.symbolBuilderCache.set(component, builder);
  5650. return builder;
  5651. }
  5652. getPotentialTemplateDirectives(component) {
  5653. var _a, _b;
  5654. const typeChecker = this.programDriver.getProgram().getTypeChecker();
  5655. const inScopeDirectives = (_b = (_a = this.getScopeData(component)) == null ? void 0 : _a.directives) != null ? _b : [];
  5656. const resultingDirectives = /* @__PURE__ */ new Map();
  5657. for (const d of inScopeDirectives) {
  5658. resultingDirectives.set(d.ref.node, d);
  5659. }
  5660. for (const directiveClass of this.localMetaReader.getKnown(MetaKind.Directive)) {
  5661. const directiveMeta = this.metaReader.getDirectiveMetadata(new Reference(directiveClass));
  5662. if (directiveMeta === null)
  5663. continue;
  5664. if (resultingDirectives.has(directiveClass))
  5665. continue;
  5666. const withScope = this.scopeDataOfDirectiveMeta(typeChecker, directiveMeta);
  5667. if (withScope === null)
  5668. continue;
  5669. resultingDirectives.set(directiveClass, { ...withScope, isInScope: false });
  5670. }
  5671. return Array.from(resultingDirectives.values());
  5672. }
  5673. getPotentialPipes(component) {
  5674. var _a, _b;
  5675. const typeChecker = this.programDriver.getProgram().getTypeChecker();
  5676. const inScopePipes = (_b = (_a = this.getScopeData(component)) == null ? void 0 : _a.pipes) != null ? _b : [];
  5677. const resultingPipes = /* @__PURE__ */ new Map();
  5678. for (const p of inScopePipes) {
  5679. resultingPipes.set(p.ref.node, p);
  5680. }
  5681. for (const pipeClass of this.localMetaReader.getKnown(MetaKind.Pipe)) {
  5682. const pipeMeta = this.metaReader.getPipeMetadata(new Reference(pipeClass));
  5683. if (pipeMeta === null)
  5684. continue;
  5685. if (resultingPipes.has(pipeClass))
  5686. continue;
  5687. const withScope = this.scopeDataOfPipeMeta(typeChecker, pipeMeta);
  5688. if (withScope === null)
  5689. continue;
  5690. resultingPipes.set(pipeClass, { ...withScope, isInScope: false });
  5691. }
  5692. return Array.from(resultingPipes.values());
  5693. }
  5694. getDirectiveMetadata(dir) {
  5695. if (!isNamedClassDeclaration(dir)) {
  5696. return null;
  5697. }
  5698. return this.typeCheckScopeRegistry.getTypeCheckDirectiveMetadata(new Reference(dir));
  5699. }
  5700. getNgModuleMetadata(module) {
  5701. if (!isNamedClassDeclaration(module)) {
  5702. return null;
  5703. }
  5704. return this.metaReader.getNgModuleMetadata(new Reference(module));
  5705. }
  5706. getPipeMetadata(pipe) {
  5707. if (!isNamedClassDeclaration(pipe)) {
  5708. return null;
  5709. }
  5710. return this.metaReader.getPipeMetadata(new Reference(pipe));
  5711. }
  5712. getPotentialElementTags(component) {
  5713. if (this.elementTagCache.has(component)) {
  5714. return this.elementTagCache.get(component);
  5715. }
  5716. const tagMap = /* @__PURE__ */ new Map();
  5717. for (const tag of REGISTRY2.allKnownElementNames()) {
  5718. tagMap.set(tag, null);
  5719. }
  5720. const scope = this.getScopeData(component);
  5721. if (scope !== null) {
  5722. for (const directive of scope.directives) {
  5723. if (directive.selector === null) {
  5724. continue;
  5725. }
  5726. for (const selector of CssSelector.parse(directive.selector)) {
  5727. if (selector.element === null || tagMap.has(selector.element)) {
  5728. continue;
  5729. }
  5730. tagMap.set(selector.element, directive);
  5731. }
  5732. }
  5733. }
  5734. this.elementTagCache.set(component, tagMap);
  5735. return tagMap;
  5736. }
  5737. getPotentialDomBindings(tagName) {
  5738. const attributes = REGISTRY2.allKnownAttributesOfElement(tagName);
  5739. return attributes.map((attribute) => ({
  5740. attribute,
  5741. property: REGISTRY2.getMappedPropName(attribute)
  5742. }));
  5743. }
  5744. getPotentialDomEvents(tagName) {
  5745. return REGISTRY2.allKnownEventsOfElement(tagName);
  5746. }
  5747. getPrimaryAngularDecorator(target) {
  5748. this.ensureAllShimsForOneFile(target.getSourceFile());
  5749. if (!isNamedClassDeclaration(target)) {
  5750. return null;
  5751. }
  5752. const ref = new Reference(target);
  5753. const dirMeta = this.metaReader.getDirectiveMetadata(ref);
  5754. if (dirMeta !== null) {
  5755. return dirMeta.decorator;
  5756. }
  5757. const pipeMeta = this.metaReader.getPipeMetadata(ref);
  5758. if (pipeMeta !== null) {
  5759. return pipeMeta.decorator;
  5760. }
  5761. const ngModuleMeta = this.metaReader.getNgModuleMetadata(ref);
  5762. if (ngModuleMeta !== null) {
  5763. return ngModuleMeta.decorator;
  5764. }
  5765. return null;
  5766. }
  5767. getOwningNgModule(component) {
  5768. if (!isNamedClassDeclaration(component)) {
  5769. return null;
  5770. }
  5771. const dirMeta = this.metaReader.getDirectiveMetadata(new Reference(component));
  5772. if (dirMeta !== null && dirMeta.isStandalone) {
  5773. return null;
  5774. }
  5775. const scope = this.componentScopeReader.getScopeForComponent(component);
  5776. if (scope === null || scope.kind !== ComponentScopeKind.NgModule || !isNamedClassDeclaration(scope.ngModule)) {
  5777. return null;
  5778. }
  5779. return scope.ngModule;
  5780. }
  5781. emit(kind, refTo, inContext) {
  5782. var _a, _b;
  5783. const emittedRef = this.refEmitter.emit(refTo, inContext.getSourceFile());
  5784. if (emittedRef.kind === 1) {
  5785. return null;
  5786. }
  5787. const emitted = emittedRef.expression;
  5788. if (emitted instanceof WrappedNodeExpr) {
  5789. let isForwardReference = false;
  5790. if (emitted.node.getStart() > inContext.getStart()) {
  5791. const declaration = (_b = (_a = this.programDriver.getProgram().getTypeChecker().getTypeAtLocation(emitted.node).getSymbol()) == null ? void 0 : _a.declarations) == null ? void 0 : _b[0];
  5792. if (declaration && declaration.getSourceFile() === inContext.getSourceFile()) {
  5793. isForwardReference = true;
  5794. }
  5795. }
  5796. return { kind, symbolName: emitted.node.text, isForwardReference };
  5797. } else if (emitted instanceof ExternalExpr2 && emitted.value.moduleName !== null && emitted.value.name !== null) {
  5798. return {
  5799. kind,
  5800. moduleSpecifier: emitted.value.moduleName,
  5801. symbolName: emitted.value.name,
  5802. isForwardReference: false
  5803. };
  5804. }
  5805. return null;
  5806. }
  5807. getPotentialImportsFor(toImport, inContext, importMode) {
  5808. var _a;
  5809. const imports = [];
  5810. const meta = (_a = this.metaReader.getDirectiveMetadata(toImport)) != null ? _a : this.metaReader.getPipeMetadata(toImport);
  5811. if (meta === null) {
  5812. return imports;
  5813. }
  5814. if (meta.isStandalone || importMode === PotentialImportMode.ForceDirect) {
  5815. const emitted = this.emit(PotentialImportKind.Standalone, toImport, inContext);
  5816. if (emitted !== null) {
  5817. imports.push(emitted);
  5818. }
  5819. }
  5820. const exportingNgModules = this.ngModuleIndex.getNgModulesExporting(meta.ref.node);
  5821. if (exportingNgModules !== null) {
  5822. for (const exporter of exportingNgModules) {
  5823. const emittedRef = this.emit(PotentialImportKind.NgModule, exporter, inContext);
  5824. if (emittedRef !== null) {
  5825. imports.push(emittedRef);
  5826. }
  5827. }
  5828. }
  5829. return imports;
  5830. }
  5831. getScopeData(component) {
  5832. if (this.scopeCache.has(component)) {
  5833. return this.scopeCache.get(component);
  5834. }
  5835. if (!isNamedClassDeclaration(component)) {
  5836. throw new Error(`AssertionError: components must have names`);
  5837. }
  5838. const scope = this.componentScopeReader.getScopeForComponent(component);
  5839. if (scope === null) {
  5840. return null;
  5841. }
  5842. const dependencies = scope.kind === ComponentScopeKind.NgModule ? scope.compilation.dependencies : scope.dependencies;
  5843. const data = {
  5844. directives: [],
  5845. pipes: [],
  5846. isPoisoned: scope.kind === ComponentScopeKind.NgModule ? scope.compilation.isPoisoned : scope.isPoisoned
  5847. };
  5848. const typeChecker = this.programDriver.getProgram().getTypeChecker();
  5849. for (const dep of dependencies) {
  5850. if (dep.kind === MetaKind.Directive) {
  5851. const dirScope = this.scopeDataOfDirectiveMeta(typeChecker, dep);
  5852. if (dirScope === null)
  5853. continue;
  5854. data.directives.push({ ...dirScope, isInScope: true });
  5855. } else if (dep.kind === MetaKind.Pipe) {
  5856. const pipeScope = this.scopeDataOfPipeMeta(typeChecker, dep);
  5857. if (pipeScope === null)
  5858. continue;
  5859. data.pipes.push({ ...pipeScope, isInScope: true });
  5860. }
  5861. }
  5862. this.scopeCache.set(component, data);
  5863. return data;
  5864. }
  5865. scopeDataOfDirectiveMeta(typeChecker, dep) {
  5866. if (dep.selector === null) {
  5867. return null;
  5868. }
  5869. const tsSymbol = typeChecker.getSymbolAtLocation(dep.ref.node.name);
  5870. if (!isSymbolWithValueDeclaration(tsSymbol)) {
  5871. return null;
  5872. }
  5873. let ngModule = null;
  5874. const moduleScopeOfDir = this.componentScopeReader.getScopeForComponent(dep.ref.node);
  5875. if (moduleScopeOfDir !== null && moduleScopeOfDir.kind === ComponentScopeKind.NgModule) {
  5876. ngModule = moduleScopeOfDir.ngModule;
  5877. }
  5878. return {
  5879. ref: dep.ref,
  5880. isComponent: dep.isComponent,
  5881. isStructural: dep.isStructural,
  5882. selector: dep.selector,
  5883. tsSymbol,
  5884. ngModule
  5885. };
  5886. }
  5887. scopeDataOfPipeMeta(typeChecker, dep) {
  5888. const tsSymbol = typeChecker.getSymbolAtLocation(dep.ref.node.name);
  5889. if (tsSymbol === void 0) {
  5890. return null;
  5891. }
  5892. return {
  5893. ref: dep.ref,
  5894. name: dep.name,
  5895. tsSymbol
  5896. };
  5897. }
  5898. };
  5899. function convertDiagnostic(diag, sourceResolver) {
  5900. if (!shouldReportDiagnostic(diag)) {
  5901. return null;
  5902. }
  5903. return translateDiagnostic(diag, sourceResolver);
  5904. }
  5905. var WholeProgramTypeCheckingHost = class {
  5906. constructor(impl) {
  5907. this.impl = impl;
  5908. }
  5909. getSourceManager(sfPath) {
  5910. return this.impl.getFileData(sfPath).sourceManager;
  5911. }
  5912. shouldCheckComponent(node) {
  5913. const sfPath = absoluteFromSourceFile(node.getSourceFile());
  5914. const shimPath = TypeCheckShimGenerator.shimFor(sfPath);
  5915. const fileData = this.impl.getFileData(sfPath);
  5916. return !fileData.shimData.has(shimPath);
  5917. }
  5918. recordShimData(sfPath, data) {
  5919. const fileData = this.impl.getFileData(sfPath);
  5920. fileData.shimData.set(data.path, data);
  5921. if (data.hasInlines) {
  5922. fileData.hasInlines = true;
  5923. }
  5924. }
  5925. recordComplete(sfPath) {
  5926. this.impl.getFileData(sfPath).isComplete = true;
  5927. }
  5928. };
  5929. var SingleFileTypeCheckingHost = class {
  5930. constructor(sfPath, fileData, impl) {
  5931. this.sfPath = sfPath;
  5932. this.fileData = fileData;
  5933. this.impl = impl;
  5934. this.seenInlines = false;
  5935. }
  5936. assertPath(sfPath) {
  5937. if (this.sfPath !== sfPath) {
  5938. throw new Error(`AssertionError: querying TypeCheckingHost outside of assigned file`);
  5939. }
  5940. }
  5941. getSourceManager(sfPath) {
  5942. this.assertPath(sfPath);
  5943. return this.fileData.sourceManager;
  5944. }
  5945. shouldCheckComponent(node) {
  5946. if (this.sfPath !== absoluteFromSourceFile(node.getSourceFile())) {
  5947. return false;
  5948. }
  5949. const shimPath = TypeCheckShimGenerator.shimFor(this.sfPath);
  5950. return !this.fileData.shimData.has(shimPath);
  5951. }
  5952. recordShimData(sfPath, data) {
  5953. this.assertPath(sfPath);
  5954. if (data.hasInlines && !this.seenInlines) {
  5955. this.impl.clearAllShimDataUsingInlines();
  5956. this.seenInlines = true;
  5957. }
  5958. this.fileData.shimData.set(data.path, data);
  5959. if (data.hasInlines) {
  5960. this.fileData.hasInlines = true;
  5961. }
  5962. }
  5963. recordComplete(sfPath) {
  5964. this.assertPath(sfPath);
  5965. this.fileData.isComplete = true;
  5966. }
  5967. };
  5968. var SingleShimTypeCheckingHost = class extends SingleFileTypeCheckingHost {
  5969. constructor(sfPath, fileData, impl, shimPath) {
  5970. super(sfPath, fileData, impl);
  5971. this.shimPath = shimPath;
  5972. }
  5973. shouldCheckNode(node) {
  5974. if (this.sfPath !== absoluteFromSourceFile(node.getSourceFile())) {
  5975. return false;
  5976. }
  5977. const shimPath = TypeCheckShimGenerator.shimFor(this.sfPath);
  5978. if (shimPath !== this.shimPath) {
  5979. return false;
  5980. }
  5981. return !this.fileData.shimData.has(shimPath);
  5982. }
  5983. };
  5984. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/invalid_banana_in_box/index.mjs
  5985. import { TmplAstBoundEvent as TmplAstBoundEvent2 } from "@angular/compiler";
  5986. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/api/api.mjs
  5987. import { ASTWithSource as ASTWithSource4, RecursiveAstVisitor as RecursiveAstVisitor3 } from "@angular/compiler";
  5988. var TemplateCheckWithVisitor = class {
  5989. run(ctx, component, template) {
  5990. const visitor = new TemplateVisitor2(ctx, component, this);
  5991. return visitor.getDiagnostics(template);
  5992. }
  5993. };
  5994. var TemplateVisitor2 = class extends RecursiveAstVisitor3 {
  5995. constructor(ctx, component, check) {
  5996. super();
  5997. this.ctx = ctx;
  5998. this.component = component;
  5999. this.check = check;
  6000. this.diagnostics = [];
  6001. }
  6002. visit(node, context) {
  6003. this.diagnostics.push(...this.check.visitNode(this.ctx, this.component, node));
  6004. node.visit(this);
  6005. }
  6006. visitAllNodes(nodes) {
  6007. for (const node of nodes) {
  6008. this.visit(node);
  6009. }
  6010. }
  6011. visitAst(ast) {
  6012. if (ast instanceof ASTWithSource4) {
  6013. ast = ast.ast;
  6014. }
  6015. this.visit(ast);
  6016. }
  6017. visitElement(element) {
  6018. this.visitAllNodes(element.attributes);
  6019. this.visitAllNodes(element.inputs);
  6020. this.visitAllNodes(element.outputs);
  6021. this.visitAllNodes(element.references);
  6022. this.visitAllNodes(element.children);
  6023. }
  6024. visitTemplate(template) {
  6025. this.visitAllNodes(template.attributes);
  6026. if (template.tagName === "ng-template") {
  6027. this.visitAllNodes(template.inputs);
  6028. this.visitAllNodes(template.outputs);
  6029. this.visitAllNodes(template.templateAttrs);
  6030. }
  6031. this.visitAllNodes(template.variables);
  6032. this.visitAllNodes(template.references);
  6033. this.visitAllNodes(template.children);
  6034. }
  6035. visitContent(content) {
  6036. }
  6037. visitVariable(variable) {
  6038. }
  6039. visitReference(reference) {
  6040. }
  6041. visitTextAttribute(attribute) {
  6042. }
  6043. visitBoundAttribute(attribute) {
  6044. this.visitAst(attribute.value);
  6045. }
  6046. visitBoundEvent(attribute) {
  6047. this.visitAst(attribute.handler);
  6048. }
  6049. visitText(text) {
  6050. }
  6051. visitBoundText(text) {
  6052. this.visitAst(text.value);
  6053. }
  6054. visitIcu(icu) {
  6055. }
  6056. getDiagnostics(template) {
  6057. this.diagnostics = [];
  6058. this.visitAllNodes(template);
  6059. return this.diagnostics;
  6060. }
  6061. };
  6062. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/invalid_banana_in_box/index.mjs
  6063. var InvalidBananaInBoxCheck = class extends TemplateCheckWithVisitor {
  6064. constructor() {
  6065. super(...arguments);
  6066. this.code = ErrorCode.INVALID_BANANA_IN_BOX;
  6067. }
  6068. visitNode(ctx, component, node) {
  6069. if (!(node instanceof TmplAstBoundEvent2))
  6070. return [];
  6071. const name = node.name;
  6072. if (!name.startsWith("[") || !name.endsWith("]"))
  6073. return [];
  6074. const boundSyntax = node.sourceSpan.toString();
  6075. const expectedBoundSyntax = boundSyntax.replace(`(${name})`, `[(${name.slice(1, -1)})]`);
  6076. const diagnostic = ctx.makeTemplateDiagnostic(node.sourceSpan, `In the two-way binding syntax the parentheses should be inside the brackets, ex. '${expectedBoundSyntax}'.
  6077. Find more at https://angular.io/guide/two-way-binding`);
  6078. return [diagnostic];
  6079. }
  6080. };
  6081. var factory = {
  6082. code: ErrorCode.INVALID_BANANA_IN_BOX,
  6083. name: ExtendedTemplateDiagnosticName.INVALID_BANANA_IN_BOX,
  6084. create: () => new InvalidBananaInBoxCheck()
  6085. };
  6086. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_control_flow_directive/index.mjs
  6087. import { TmplAstTemplate as TmplAstTemplate4 } from "@angular/compiler";
  6088. var KNOWN_CONTROL_FLOW_DIRECTIVES = /* @__PURE__ */ new Map([
  6089. ["ngIf", "NgIf"],
  6090. ["ngFor", "NgFor"],
  6091. ["ngSwitchCase", "NgSwitchCase"],
  6092. ["ngSwitchDefault", "NgSwitchDefault"]
  6093. ]);
  6094. var MissingControlFlowDirectiveCheck = class extends TemplateCheckWithVisitor {
  6095. constructor() {
  6096. super(...arguments);
  6097. this.code = ErrorCode.MISSING_CONTROL_FLOW_DIRECTIVE;
  6098. }
  6099. run(ctx, component, template) {
  6100. const componentMetadata = ctx.templateTypeChecker.getDirectiveMetadata(component);
  6101. if (!componentMetadata || !componentMetadata.isStandalone) {
  6102. return [];
  6103. }
  6104. return super.run(ctx, component, template);
  6105. }
  6106. visitNode(ctx, component, node) {
  6107. if (!(node instanceof TmplAstTemplate4))
  6108. return [];
  6109. const controlFlowAttr = node.templateAttrs.find((attr) => KNOWN_CONTROL_FLOW_DIRECTIVES.has(attr.name));
  6110. if (!controlFlowAttr)
  6111. return [];
  6112. const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
  6113. if (symbol === null || symbol.directives.length > 0) {
  6114. return [];
  6115. }
  6116. const sourceSpan = controlFlowAttr.keySpan || controlFlowAttr.sourceSpan;
  6117. const correspondingImport = KNOWN_CONTROL_FLOW_DIRECTIVES.get(controlFlowAttr.name);
  6118. const errorMessage = `The \`*${controlFlowAttr.name}\` directive was used in the template, but neither the \`${correspondingImport}\` directive nor the \`CommonModule\` was imported. Please make sure that either the \`${correspondingImport}\` directive or the \`CommonModule\` is included in the \`@Component.imports\` array of this component.`;
  6119. const diagnostic = ctx.makeTemplateDiagnostic(sourceSpan, errorMessage);
  6120. return [diagnostic];
  6121. }
  6122. };
  6123. var factory2 = {
  6124. code: ErrorCode.MISSING_CONTROL_FLOW_DIRECTIVE,
  6125. name: ExtendedTemplateDiagnosticName.MISSING_CONTROL_FLOW_DIRECTIVE,
  6126. create: (options) => {
  6127. return new MissingControlFlowDirectiveCheck();
  6128. }
  6129. };
  6130. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_ngforof_let/index.mjs
  6131. import { TmplAstTemplate as TmplAstTemplate5 } from "@angular/compiler";
  6132. var MissingNgForOfLetCheck = class extends TemplateCheckWithVisitor {
  6133. constructor() {
  6134. super(...arguments);
  6135. this.code = ErrorCode.MISSING_NGFOROF_LET;
  6136. }
  6137. visitNode(ctx, component, node) {
  6138. const isTemplate = node instanceof TmplAstTemplate5;
  6139. if (!(node instanceof TmplAstTemplate5)) {
  6140. return [];
  6141. }
  6142. if (node.templateAttrs.length === 0) {
  6143. return [];
  6144. }
  6145. const attr = node.templateAttrs.find((x) => x.name === "ngFor");
  6146. if (attr === void 0) {
  6147. return [];
  6148. }
  6149. if (node.variables.length > 0) {
  6150. return [];
  6151. }
  6152. const errorString = "Your ngFor is missing a value. Did you forget to add the `let` keyword?";
  6153. const diagnostic = ctx.makeTemplateDiagnostic(attr.sourceSpan, errorString);
  6154. return [diagnostic];
  6155. }
  6156. };
  6157. var factory3 = {
  6158. code: ErrorCode.MISSING_NGFOROF_LET,
  6159. name: ExtendedTemplateDiagnosticName.MISSING_NGFOROF_LET,
  6160. create: () => new MissingNgForOfLetCheck()
  6161. };
  6162. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.mjs
  6163. import { Binary } from "@angular/compiler";
  6164. import ts27 from "typescript";
  6165. var NullishCoalescingNotNullableCheck = class extends TemplateCheckWithVisitor {
  6166. constructor() {
  6167. super(...arguments);
  6168. this.code = ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
  6169. }
  6170. visitNode(ctx, component, node) {
  6171. if (!(node instanceof Binary) || node.operation !== "??")
  6172. return [];
  6173. const symbolLeft = ctx.templateTypeChecker.getSymbolOfNode(node.left, component);
  6174. if (symbolLeft === null || symbolLeft.kind !== SymbolKind.Expression) {
  6175. return [];
  6176. }
  6177. const typeLeft = symbolLeft.tsType;
  6178. if (typeLeft.flags & (ts27.TypeFlags.Any | ts27.TypeFlags.Unknown)) {
  6179. return [];
  6180. }
  6181. if (typeLeft.getNonNullableType() !== typeLeft)
  6182. return [];
  6183. const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
  6184. if (symbol.kind !== SymbolKind.Expression) {
  6185. return [];
  6186. }
  6187. const templateMapping = ctx.templateTypeChecker.getTemplateMappingAtTcbLocation(symbol.tcbLocation);
  6188. if (templateMapping === null) {
  6189. return [];
  6190. }
  6191. const diagnostic = ctx.makeTemplateDiagnostic(templateMapping.span, `The left side of this nullish coalescing operation does not include 'null' or 'undefined' in its type, therefore the '??' operator can be safely removed.`);
  6192. return [diagnostic];
  6193. }
  6194. };
  6195. var factory4 = {
  6196. code: ErrorCode.NULLISH_COALESCING_NOT_NULLABLE,
  6197. name: ExtendedTemplateDiagnosticName.NULLISH_COALESCING_NOT_NULLABLE,
  6198. create: (options) => {
  6199. const strictNullChecks = options.strictNullChecks === void 0 ? !!options.strict : !!options.strictNullChecks;
  6200. if (!strictNullChecks) {
  6201. return null;
  6202. }
  6203. return new NullishCoalescingNotNullableCheck();
  6204. }
  6205. };
  6206. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/optional_chain_not_nullable/index.mjs
  6207. import { SafeCall as SafeCall2, SafeKeyedRead as SafeKeyedRead2, SafePropertyRead as SafePropertyRead5 } from "@angular/compiler";
  6208. import ts28 from "typescript";
  6209. var OptionalChainNotNullableCheck = class extends TemplateCheckWithVisitor {
  6210. constructor() {
  6211. super(...arguments);
  6212. this.code = ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE;
  6213. }
  6214. visitNode(ctx, component, node) {
  6215. if (!(node instanceof SafeCall2) && !(node instanceof SafePropertyRead5) && !(node instanceof SafeKeyedRead2))
  6216. return [];
  6217. const symbolLeft = ctx.templateTypeChecker.getSymbolOfNode(node.receiver, component);
  6218. if (symbolLeft === null || symbolLeft.kind !== SymbolKind.Expression) {
  6219. return [];
  6220. }
  6221. const typeLeft = symbolLeft.tsType;
  6222. if (typeLeft.flags & (ts28.TypeFlags.Any | ts28.TypeFlags.Unknown)) {
  6223. return [];
  6224. }
  6225. if (typeLeft.getNonNullableType() !== typeLeft)
  6226. return [];
  6227. const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
  6228. if (symbol.kind !== SymbolKind.Expression) {
  6229. return [];
  6230. }
  6231. const templateMapping = ctx.templateTypeChecker.getTemplateMappingAtTcbLocation(symbol.tcbLocation);
  6232. if (templateMapping === null) {
  6233. return [];
  6234. }
  6235. const advice = node instanceof SafePropertyRead5 ? `the '?.' operator can be replaced with the '.' operator` : `the '?.' operator can be safely removed`;
  6236. const diagnostic = ctx.makeTemplateDiagnostic(templateMapping.span, `The left side of this optional chain operation does not include 'null' or 'undefined' in its type, therefore ${advice}.`);
  6237. return [diagnostic];
  6238. }
  6239. };
  6240. var factory5 = {
  6241. code: ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE,
  6242. name: ExtendedTemplateDiagnosticName.OPTIONAL_CHAIN_NOT_NULLABLE,
  6243. create: (options) => {
  6244. const strictNullChecks = options.strictNullChecks === void 0 ? !!options.strict : !!options.strictNullChecks;
  6245. if (!strictNullChecks) {
  6246. return null;
  6247. }
  6248. return new OptionalChainNotNullableCheck();
  6249. }
  6250. };
  6251. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/suffix_not_supported/index.mjs
  6252. import { TmplAstBoundAttribute as TmplAstBoundAttribute3 } from "@angular/compiler";
  6253. var STYLE_SUFFIXES = ["px", "%", "em"];
  6254. var SuffixNotSupportedCheck = class extends TemplateCheckWithVisitor {
  6255. constructor() {
  6256. super(...arguments);
  6257. this.code = ErrorCode.SUFFIX_NOT_SUPPORTED;
  6258. }
  6259. visitNode(ctx, component, node) {
  6260. if (!(node instanceof TmplAstBoundAttribute3))
  6261. return [];
  6262. if (!node.keySpan.toString().startsWith("attr.") || !STYLE_SUFFIXES.some((suffix) => node.name.endsWith(`.${suffix}`))) {
  6263. return [];
  6264. }
  6265. const diagnostic = ctx.makeTemplateDiagnostic(node.keySpan, `The ${STYLE_SUFFIXES.map((suffix) => `'.${suffix}'`).join(", ")} suffixes are only supported on style bindings.`);
  6266. return [diagnostic];
  6267. }
  6268. };
  6269. var factory6 = {
  6270. code: ErrorCode.SUFFIX_NOT_SUPPORTED,
  6271. name: ExtendedTemplateDiagnosticName.SUFFIX_NOT_SUPPORTED,
  6272. create: () => new SuffixNotSupportedCheck()
  6273. };
  6274. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/text_attribute_not_binding/index.mjs
  6275. import { TmplAstTextAttribute as TmplAstTextAttribute4 } from "@angular/compiler";
  6276. var TextAttributeNotBindingSpec = class extends TemplateCheckWithVisitor {
  6277. constructor() {
  6278. super(...arguments);
  6279. this.code = ErrorCode.TEXT_ATTRIBUTE_NOT_BINDING;
  6280. }
  6281. visitNode(ctx, component, node) {
  6282. if (!(node instanceof TmplAstTextAttribute4))
  6283. return [];
  6284. const name = node.name;
  6285. if (!name.startsWith("attr.") && !name.startsWith("style.") && !name.startsWith("class.")) {
  6286. return [];
  6287. }
  6288. let errorString;
  6289. if (name.startsWith("attr.")) {
  6290. const staticAttr = name.replace("attr.", "");
  6291. errorString = `Static attributes should be written without the 'attr.' prefix.`;
  6292. if (node.value) {
  6293. errorString += ` For example, ${staticAttr}="${node.value}".`;
  6294. }
  6295. } else {
  6296. const expectedKey = `[${name}]`;
  6297. const expectedValue = node.value === "true" || node.value === "false" ? node.value : `'${node.value}'`;
  6298. errorString = "Attribute, style, and class bindings should be enclosed with square braces.";
  6299. if (node.value) {
  6300. errorString += ` For example, '${expectedKey}="${expectedValue}"'.`;
  6301. }
  6302. }
  6303. const diagnostic = ctx.makeTemplateDiagnostic(node.sourceSpan, errorString);
  6304. return [diagnostic];
  6305. }
  6306. };
  6307. var factory7 = {
  6308. code: ErrorCode.TEXT_ATTRIBUTE_NOT_BINDING,
  6309. name: ExtendedTemplateDiagnosticName.TEXT_ATTRIBUTE_NOT_BINDING,
  6310. create: () => new TextAttributeNotBindingSpec()
  6311. };
  6312. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker.mjs
  6313. import ts29 from "typescript";
  6314. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/core/api/src/public_options.mjs
  6315. var DiagnosticCategoryLabel;
  6316. (function(DiagnosticCategoryLabel2) {
  6317. DiagnosticCategoryLabel2["Warning"] = "warning";
  6318. DiagnosticCategoryLabel2["Error"] = "error";
  6319. DiagnosticCategoryLabel2["Suppress"] = "suppress";
  6320. })(DiagnosticCategoryLabel || (DiagnosticCategoryLabel = {}));
  6321. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker.mjs
  6322. var ExtendedTemplateCheckerImpl = class {
  6323. constructor(templateTypeChecker, typeChecker, templateCheckFactories, options) {
  6324. var _a, _b, _c, _d, _e;
  6325. this.partialCtx = { templateTypeChecker, typeChecker };
  6326. this.templateChecks = /* @__PURE__ */ new Map();
  6327. for (const factory8 of templateCheckFactories) {
  6328. const category = diagnosticLabelToCategory((_e = (_d = (_b = (_a = options == null ? void 0 : options.extendedDiagnostics) == null ? void 0 : _a.checks) == null ? void 0 : _b[factory8.name]) != null ? _d : (_c = options == null ? void 0 : options.extendedDiagnostics) == null ? void 0 : _c.defaultCategory) != null ? _e : DiagnosticCategoryLabel.Warning);
  6329. if (category === null) {
  6330. continue;
  6331. }
  6332. const check = factory8.create(options);
  6333. if (check === null) {
  6334. continue;
  6335. }
  6336. this.templateChecks.set(check, category);
  6337. }
  6338. }
  6339. getDiagnosticsForComponent(component) {
  6340. const template = this.partialCtx.templateTypeChecker.getTemplate(component);
  6341. if (template === null) {
  6342. return [];
  6343. }
  6344. const diagnostics = [];
  6345. for (const [check, category] of this.templateChecks.entries()) {
  6346. const ctx = {
  6347. ...this.partialCtx,
  6348. makeTemplateDiagnostic: (span, message, relatedInformation) => {
  6349. return this.partialCtx.templateTypeChecker.makeTemplateDiagnostic(component, span, category, check.code, message, relatedInformation);
  6350. }
  6351. };
  6352. diagnostics.push(...check.run(ctx, component, template));
  6353. }
  6354. return diagnostics;
  6355. }
  6356. };
  6357. function diagnosticLabelToCategory(label) {
  6358. switch (label) {
  6359. case DiagnosticCategoryLabel.Warning:
  6360. return ts29.DiagnosticCategory.Warning;
  6361. case DiagnosticCategoryLabel.Error:
  6362. return ts29.DiagnosticCategory.Error;
  6363. case DiagnosticCategoryLabel.Suppress:
  6364. return null;
  6365. default:
  6366. return assertNever(label);
  6367. }
  6368. }
  6369. function assertNever(value) {
  6370. throw new Error(`Unexpected call to 'assertNever()' with value:
  6371. ${value}`);
  6372. }
  6373. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/index.mjs
  6374. var ALL_DIAGNOSTIC_FACTORIES = [
  6375. factory,
  6376. factory4,
  6377. factory5,
  6378. factory2,
  6379. factory7,
  6380. factory3,
  6381. factory6
  6382. ];
  6383. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/core/src/compiler.mjs
  6384. var CompilationTicketKind;
  6385. (function(CompilationTicketKind2) {
  6386. CompilationTicketKind2[CompilationTicketKind2["Fresh"] = 0] = "Fresh";
  6387. CompilationTicketKind2[CompilationTicketKind2["IncrementalTypeScript"] = 1] = "IncrementalTypeScript";
  6388. CompilationTicketKind2[CompilationTicketKind2["IncrementalResource"] = 2] = "IncrementalResource";
  6389. })(CompilationTicketKind || (CompilationTicketKind = {}));
  6390. function freshCompilationTicket(tsProgram, options, incrementalBuildStrategy, programDriver, perfRecorder, enableTemplateTypeChecker, usePoisonedData) {
  6391. return {
  6392. kind: CompilationTicketKind.Fresh,
  6393. tsProgram,
  6394. options,
  6395. incrementalBuildStrategy,
  6396. programDriver,
  6397. enableTemplateTypeChecker,
  6398. usePoisonedData,
  6399. perfRecorder: perfRecorder != null ? perfRecorder : ActivePerfRecorder.zeroedToNow()
  6400. };
  6401. }
  6402. function incrementalFromCompilerTicket(oldCompiler, newProgram, incrementalBuildStrategy, programDriver, modifiedResourceFiles, perfRecorder) {
  6403. const oldProgram = oldCompiler.getCurrentProgram();
  6404. const oldState = oldCompiler.incrementalStrategy.getIncrementalState(oldProgram);
  6405. if (oldState === null) {
  6406. return freshCompilationTicket(newProgram, oldCompiler.options, incrementalBuildStrategy, programDriver, perfRecorder, oldCompiler.enableTemplateTypeChecker, oldCompiler.usePoisonedData);
  6407. }
  6408. if (perfRecorder === null) {
  6409. perfRecorder = ActivePerfRecorder.zeroedToNow();
  6410. }
  6411. const incrementalCompilation = IncrementalCompilation.incremental(newProgram, versionMapFromProgram(newProgram, programDriver), oldProgram, oldState, modifiedResourceFiles, perfRecorder);
  6412. return {
  6413. kind: CompilationTicketKind.IncrementalTypeScript,
  6414. enableTemplateTypeChecker: oldCompiler.enableTemplateTypeChecker,
  6415. usePoisonedData: oldCompiler.usePoisonedData,
  6416. options: oldCompiler.options,
  6417. incrementalBuildStrategy,
  6418. incrementalCompilation,
  6419. programDriver,
  6420. newProgram,
  6421. perfRecorder
  6422. };
  6423. }
  6424. function incrementalFromStateTicket(oldProgram, oldState, newProgram, options, incrementalBuildStrategy, programDriver, modifiedResourceFiles, perfRecorder, enableTemplateTypeChecker, usePoisonedData) {
  6425. if (perfRecorder === null) {
  6426. perfRecorder = ActivePerfRecorder.zeroedToNow();
  6427. }
  6428. const incrementalCompilation = IncrementalCompilation.incremental(newProgram, versionMapFromProgram(newProgram, programDriver), oldProgram, oldState, modifiedResourceFiles, perfRecorder);
  6429. return {
  6430. kind: CompilationTicketKind.IncrementalTypeScript,
  6431. newProgram,
  6432. options,
  6433. incrementalBuildStrategy,
  6434. incrementalCompilation,
  6435. programDriver,
  6436. enableTemplateTypeChecker,
  6437. usePoisonedData,
  6438. perfRecorder
  6439. };
  6440. }
  6441. var NgCompiler = class {
  6442. static fromTicket(ticket, adapter) {
  6443. switch (ticket.kind) {
  6444. case CompilationTicketKind.Fresh:
  6445. return new NgCompiler(adapter, ticket.options, ticket.tsProgram, ticket.programDriver, ticket.incrementalBuildStrategy, IncrementalCompilation.fresh(ticket.tsProgram, versionMapFromProgram(ticket.tsProgram, ticket.programDriver)), ticket.enableTemplateTypeChecker, ticket.usePoisonedData, ticket.perfRecorder);
  6446. case CompilationTicketKind.IncrementalTypeScript:
  6447. return new NgCompiler(adapter, ticket.options, ticket.newProgram, ticket.programDriver, ticket.incrementalBuildStrategy, ticket.incrementalCompilation, ticket.enableTemplateTypeChecker, ticket.usePoisonedData, ticket.perfRecorder);
  6448. case CompilationTicketKind.IncrementalResource:
  6449. const compiler = ticket.compiler;
  6450. compiler.updateWithChangedResources(ticket.modifiedResourceFiles, ticket.perfRecorder);
  6451. return compiler;
  6452. }
  6453. }
  6454. constructor(adapter, options, inputProgram, programDriver, incrementalStrategy, incrementalCompilation, enableTemplateTypeChecker, usePoisonedData, livePerfRecorder) {
  6455. var _a;
  6456. this.adapter = adapter;
  6457. this.options = options;
  6458. this.inputProgram = inputProgram;
  6459. this.programDriver = programDriver;
  6460. this.incrementalStrategy = incrementalStrategy;
  6461. this.incrementalCompilation = incrementalCompilation;
  6462. this.usePoisonedData = usePoisonedData;
  6463. this.livePerfRecorder = livePerfRecorder;
  6464. this.compilation = null;
  6465. this.constructionDiagnostics = [];
  6466. this.nonTemplateDiagnostics = null;
  6467. this.delegatingPerfRecorder = new DelegatingPerfRecorder(this.perfRecorder);
  6468. this.enableTemplateTypeChecker = enableTemplateTypeChecker || ((_a = options._enableTemplateTypeChecker) != null ? _a : false);
  6469. this.constructionDiagnostics.push(...this.adapter.constructionDiagnostics, ...verifyCompatibleTypeCheckOptions(this.options));
  6470. this.currentProgram = inputProgram;
  6471. this.closureCompilerEnabled = !!this.options.annotateForClosureCompiler;
  6472. this.entryPoint = adapter.entryPoint !== null ? getSourceFileOrNull(inputProgram, adapter.entryPoint) : null;
  6473. const moduleResolutionCache = ts30.createModuleResolutionCache(
  6474. this.adapter.getCurrentDirectory(),
  6475. this.adapter.getCanonicalFileName.bind(this.adapter)
  6476. );
  6477. this.moduleResolver = new ModuleResolver(inputProgram, this.options, this.adapter, moduleResolutionCache);
  6478. this.resourceManager = new AdapterResourceLoader(adapter, this.options);
  6479. this.cycleAnalyzer = new CycleAnalyzer(new ImportGraph(inputProgram.getTypeChecker(), this.delegatingPerfRecorder));
  6480. this.incrementalStrategy.setIncrementalState(this.incrementalCompilation.state, inputProgram);
  6481. this.ignoreForDiagnostics = new Set(inputProgram.getSourceFiles().filter((sf) => this.adapter.isShim(sf)));
  6482. this.ignoreForEmit = this.adapter.ignoreForEmit;
  6483. let dtsFileCount = 0;
  6484. let nonDtsFileCount = 0;
  6485. for (const sf of inputProgram.getSourceFiles()) {
  6486. if (sf.isDeclarationFile) {
  6487. dtsFileCount++;
  6488. } else {
  6489. nonDtsFileCount++;
  6490. }
  6491. }
  6492. livePerfRecorder.eventCount(PerfEvent.InputDtsFile, dtsFileCount);
  6493. livePerfRecorder.eventCount(PerfEvent.InputTsFile, nonDtsFileCount);
  6494. }
  6495. get perfRecorder() {
  6496. return this.livePerfRecorder;
  6497. }
  6498. updateWithChangedResources(changedResources, perfRecorder) {
  6499. this.livePerfRecorder = perfRecorder;
  6500. this.delegatingPerfRecorder.target = perfRecorder;
  6501. perfRecorder.inPhase(PerfPhase.ResourceUpdate, () => {
  6502. if (this.compilation === null) {
  6503. return;
  6504. }
  6505. this.resourceManager.invalidate();
  6506. const classesToUpdate = /* @__PURE__ */ new Set();
  6507. for (const resourceFile of changedResources) {
  6508. for (const templateClass of this.getComponentsWithTemplateFile(resourceFile)) {
  6509. classesToUpdate.add(templateClass);
  6510. }
  6511. for (const styleClass of this.getComponentsWithStyleFile(resourceFile)) {
  6512. classesToUpdate.add(styleClass);
  6513. }
  6514. }
  6515. for (const clazz of classesToUpdate) {
  6516. this.compilation.traitCompiler.updateResources(clazz);
  6517. if (!ts30.isClassDeclaration(clazz)) {
  6518. continue;
  6519. }
  6520. this.compilation.templateTypeChecker.invalidateClass(clazz);
  6521. }
  6522. });
  6523. }
  6524. getResourceDependencies(file) {
  6525. this.ensureAnalyzed();
  6526. return this.incrementalCompilation.depGraph.getResourceDependencies(file);
  6527. }
  6528. getDiagnostics() {
  6529. const diagnostics = [];
  6530. diagnostics.push(...this.getNonTemplateDiagnostics(), ...this.getTemplateDiagnostics());
  6531. if (this.options.strictTemplates) {
  6532. diagnostics.push(...this.getExtendedTemplateDiagnostics());
  6533. }
  6534. return this.addMessageTextDetails(diagnostics);
  6535. }
  6536. getDiagnosticsForFile(file, optimizeFor) {
  6537. const diagnostics = [];
  6538. diagnostics.push(...this.getNonTemplateDiagnostics().filter((diag) => diag.file === file), ...this.getTemplateDiagnosticsForFile(file, optimizeFor));
  6539. if (this.options.strictTemplates) {
  6540. diagnostics.push(...this.getExtendedTemplateDiagnostics(file));
  6541. }
  6542. return this.addMessageTextDetails(diagnostics);
  6543. }
  6544. getDiagnosticsForComponent(component) {
  6545. const compilation = this.ensureAnalyzed();
  6546. const ttc = compilation.templateTypeChecker;
  6547. const diagnostics = [];
  6548. try {
  6549. diagnostics.push(...ttc.getDiagnosticsForComponent(component));
  6550. const extendedTemplateChecker = compilation.extendedTemplateChecker;
  6551. if (this.options.strictTemplates && extendedTemplateChecker) {
  6552. diagnostics.push(...extendedTemplateChecker.getDiagnosticsForComponent(component));
  6553. }
  6554. } catch (err) {
  6555. if (!(err instanceof FatalDiagnosticError)) {
  6556. throw err;
  6557. }
  6558. diagnostics.push(err.toDiagnostic());
  6559. }
  6560. return this.addMessageTextDetails(diagnostics);
  6561. }
  6562. addMessageTextDetails(diagnostics) {
  6563. return diagnostics.map((diag) => {
  6564. if (diag.code && COMPILER_ERRORS_WITH_GUIDES.has(ngErrorCode(diag.code))) {
  6565. return {
  6566. ...diag,
  6567. messageText: diag.messageText + `. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG${ngErrorCode(diag.code)}`
  6568. };
  6569. }
  6570. return diag;
  6571. });
  6572. }
  6573. getOptionDiagnostics() {
  6574. return this.constructionDiagnostics;
  6575. }
  6576. getCurrentProgram() {
  6577. return this.currentProgram;
  6578. }
  6579. getTemplateTypeChecker() {
  6580. if (!this.enableTemplateTypeChecker) {
  6581. throw new Error("The `TemplateTypeChecker` does not work without `enableTemplateTypeChecker`.");
  6582. }
  6583. return this.ensureAnalyzed().templateTypeChecker;
  6584. }
  6585. getComponentsWithTemplateFile(templateFilePath) {
  6586. const { resourceRegistry } = this.ensureAnalyzed();
  6587. return resourceRegistry.getComponentsWithTemplate(resolve(templateFilePath));
  6588. }
  6589. getComponentsWithStyleFile(styleFilePath) {
  6590. const { resourceRegistry } = this.ensureAnalyzed();
  6591. return resourceRegistry.getComponentsWithStyle(resolve(styleFilePath));
  6592. }
  6593. getComponentResources(classDecl) {
  6594. if (!isNamedClassDeclaration(classDecl)) {
  6595. return null;
  6596. }
  6597. const { resourceRegistry } = this.ensureAnalyzed();
  6598. const styles = resourceRegistry.getStyles(classDecl);
  6599. const template = resourceRegistry.getTemplate(classDecl);
  6600. if (template === null) {
  6601. return null;
  6602. }
  6603. return { styles, template };
  6604. }
  6605. getMeta(classDecl) {
  6606. var _a;
  6607. if (!isNamedClassDeclaration(classDecl)) {
  6608. return null;
  6609. }
  6610. const ref = new Reference(classDecl);
  6611. const { metaReader } = this.ensureAnalyzed();
  6612. const meta = (_a = metaReader.getPipeMetadata(ref)) != null ? _a : metaReader.getDirectiveMetadata(ref);
  6613. if (meta === null) {
  6614. return null;
  6615. }
  6616. return meta;
  6617. }
  6618. async analyzeAsync() {
  6619. if (this.compilation !== null) {
  6620. return;
  6621. }
  6622. await this.perfRecorder.inPhase(PerfPhase.Analysis, async () => {
  6623. this.compilation = this.makeCompilation();
  6624. const promises = [];
  6625. for (const sf of this.inputProgram.getSourceFiles()) {
  6626. if (sf.isDeclarationFile) {
  6627. continue;
  6628. }
  6629. let analysisPromise = this.compilation.traitCompiler.analyzeAsync(sf);
  6630. if (analysisPromise !== void 0) {
  6631. promises.push(analysisPromise);
  6632. }
  6633. }
  6634. await Promise.all(promises);
  6635. this.perfRecorder.memory(PerfCheckpoint.Analysis);
  6636. this.resolveCompilation(this.compilation.traitCompiler);
  6637. });
  6638. }
  6639. prepareEmit() {
  6640. const compilation = this.ensureAnalyzed();
  6641. const coreImportsFrom = compilation.isCore ? getR3SymbolsFile(this.inputProgram) : null;
  6642. let importRewriter;
  6643. if (coreImportsFrom !== null) {
  6644. importRewriter = new R3SymbolsImportRewriter(coreImportsFrom.fileName);
  6645. } else {
  6646. importRewriter = new NoopImportRewriter();
  6647. }
  6648. const defaultImportTracker = new DefaultImportTracker();
  6649. const before = [
  6650. ivyTransformFactory(compilation.traitCompiler, compilation.reflector, importRewriter, defaultImportTracker, this.delegatingPerfRecorder, compilation.isCore, this.closureCompilerEnabled),
  6651. aliasTransformFactory(compilation.traitCompiler.exportStatements),
  6652. defaultImportTracker.importPreservingTransformer()
  6653. ];
  6654. const afterDeclarations = [];
  6655. if (compilation.dtsTransforms !== null) {
  6656. afterDeclarations.push(declarationTransformFactory(compilation.dtsTransforms, compilation.reflector, compilation.refEmitter, importRewriter));
  6657. }
  6658. if (compilation.aliasingHost !== null && compilation.aliasingHost.aliasExportsInDts) {
  6659. afterDeclarations.push(aliasTransformFactory(compilation.traitCompiler.exportStatements));
  6660. }
  6661. return { transformers: { before, afterDeclarations } };
  6662. }
  6663. getIndexedComponents() {
  6664. const compilation = this.ensureAnalyzed();
  6665. const context = new IndexingContext();
  6666. compilation.traitCompiler.index(context);
  6667. return generateAnalysis(context);
  6668. }
  6669. xi18n(ctx) {
  6670. const compilation = this.ensureAnalyzed();
  6671. compilation.traitCompiler.xi18n(ctx);
  6672. }
  6673. ensureAnalyzed() {
  6674. if (this.compilation === null) {
  6675. this.analyzeSync();
  6676. }
  6677. return this.compilation;
  6678. }
  6679. analyzeSync() {
  6680. this.perfRecorder.inPhase(PerfPhase.Analysis, () => {
  6681. this.compilation = this.makeCompilation();
  6682. for (const sf of this.inputProgram.getSourceFiles()) {
  6683. if (sf.isDeclarationFile) {
  6684. continue;
  6685. }
  6686. this.compilation.traitCompiler.analyzeSync(sf);
  6687. }
  6688. this.perfRecorder.memory(PerfCheckpoint.Analysis);
  6689. this.resolveCompilation(this.compilation.traitCompiler);
  6690. });
  6691. }
  6692. resolveCompilation(traitCompiler) {
  6693. this.perfRecorder.inPhase(PerfPhase.Resolve, () => {
  6694. traitCompiler.resolve();
  6695. this.incrementalCompilation.recordSuccessfulAnalysis(traitCompiler);
  6696. this.perfRecorder.memory(PerfCheckpoint.Resolve);
  6697. });
  6698. }
  6699. get fullTemplateTypeCheck() {
  6700. const strictTemplates = !!this.options.strictTemplates;
  6701. return strictTemplates || !!this.options.fullTemplateTypeCheck;
  6702. }
  6703. getTypeCheckingConfig() {
  6704. const strictTemplates = !!this.options.strictTemplates;
  6705. const useInlineTypeConstructors = this.programDriver.supportsInlineOperations;
  6706. let typeCheckingConfig;
  6707. if (this.fullTemplateTypeCheck) {
  6708. typeCheckingConfig = {
  6709. applyTemplateContextGuards: strictTemplates,
  6710. checkQueries: false,
  6711. checkTemplateBodies: true,
  6712. alwaysCheckSchemaInTemplateBodies: true,
  6713. checkTypeOfInputBindings: strictTemplates,
  6714. honorAccessModifiersForInputBindings: false,
  6715. strictNullInputBindings: strictTemplates,
  6716. checkTypeOfAttributes: strictTemplates,
  6717. checkTypeOfDomBindings: false,
  6718. checkTypeOfOutputEvents: strictTemplates,
  6719. checkTypeOfAnimationEvents: strictTemplates,
  6720. checkTypeOfDomEvents: strictTemplates,
  6721. checkTypeOfDomReferences: strictTemplates,
  6722. checkTypeOfNonDomReferences: true,
  6723. checkTypeOfPipes: true,
  6724. strictSafeNavigationTypes: strictTemplates,
  6725. useContextGenericType: strictTemplates,
  6726. strictLiteralTypes: true,
  6727. enableTemplateTypeChecker: this.enableTemplateTypeChecker,
  6728. useInlineTypeConstructors,
  6729. suggestionsForSuboptimalTypeInference: this.enableTemplateTypeChecker && !strictTemplates
  6730. };
  6731. } else {
  6732. typeCheckingConfig = {
  6733. applyTemplateContextGuards: false,
  6734. checkQueries: false,
  6735. checkTemplateBodies: false,
  6736. alwaysCheckSchemaInTemplateBodies: this.closureCompilerEnabled,
  6737. checkTypeOfInputBindings: false,
  6738. strictNullInputBindings: false,
  6739. honorAccessModifiersForInputBindings: false,
  6740. checkTypeOfAttributes: false,
  6741. checkTypeOfDomBindings: false,
  6742. checkTypeOfOutputEvents: false,
  6743. checkTypeOfAnimationEvents: false,
  6744. checkTypeOfDomEvents: false,
  6745. checkTypeOfDomReferences: false,
  6746. checkTypeOfNonDomReferences: false,
  6747. checkTypeOfPipes: false,
  6748. strictSafeNavigationTypes: false,
  6749. useContextGenericType: false,
  6750. strictLiteralTypes: false,
  6751. enableTemplateTypeChecker: this.enableTemplateTypeChecker,
  6752. useInlineTypeConstructors,
  6753. suggestionsForSuboptimalTypeInference: false
  6754. };
  6755. }
  6756. if (this.options.strictInputTypes !== void 0) {
  6757. typeCheckingConfig.checkTypeOfInputBindings = this.options.strictInputTypes;
  6758. typeCheckingConfig.applyTemplateContextGuards = this.options.strictInputTypes;
  6759. }
  6760. if (this.options.strictInputAccessModifiers !== void 0) {
  6761. typeCheckingConfig.honorAccessModifiersForInputBindings = this.options.strictInputAccessModifiers;
  6762. }
  6763. if (this.options.strictNullInputTypes !== void 0) {
  6764. typeCheckingConfig.strictNullInputBindings = this.options.strictNullInputTypes;
  6765. }
  6766. if (this.options.strictOutputEventTypes !== void 0) {
  6767. typeCheckingConfig.checkTypeOfOutputEvents = this.options.strictOutputEventTypes;
  6768. typeCheckingConfig.checkTypeOfAnimationEvents = this.options.strictOutputEventTypes;
  6769. }
  6770. if (this.options.strictDomEventTypes !== void 0) {
  6771. typeCheckingConfig.checkTypeOfDomEvents = this.options.strictDomEventTypes;
  6772. }
  6773. if (this.options.strictSafeNavigationTypes !== void 0) {
  6774. typeCheckingConfig.strictSafeNavigationTypes = this.options.strictSafeNavigationTypes;
  6775. }
  6776. if (this.options.strictDomLocalRefTypes !== void 0) {
  6777. typeCheckingConfig.checkTypeOfDomReferences = this.options.strictDomLocalRefTypes;
  6778. }
  6779. if (this.options.strictAttributeTypes !== void 0) {
  6780. typeCheckingConfig.checkTypeOfAttributes = this.options.strictAttributeTypes;
  6781. }
  6782. if (this.options.strictContextGenerics !== void 0) {
  6783. typeCheckingConfig.useContextGenericType = this.options.strictContextGenerics;
  6784. }
  6785. if (this.options.strictLiteralTypes !== void 0) {
  6786. typeCheckingConfig.strictLiteralTypes = this.options.strictLiteralTypes;
  6787. }
  6788. return typeCheckingConfig;
  6789. }
  6790. getTemplateDiagnostics() {
  6791. const compilation = this.ensureAnalyzed();
  6792. const diagnostics = [];
  6793. for (const sf of this.inputProgram.getSourceFiles()) {
  6794. if (sf.isDeclarationFile || this.adapter.isShim(sf)) {
  6795. continue;
  6796. }
  6797. try {
  6798. diagnostics.push(...compilation.templateTypeChecker.getDiagnosticsForFile(sf, OptimizeFor.WholeProgram));
  6799. } catch (err) {
  6800. if (!(err instanceof FatalDiagnosticError)) {
  6801. throw err;
  6802. }
  6803. diagnostics.push(err.toDiagnostic());
  6804. }
  6805. }
  6806. const program = this.programDriver.getProgram();
  6807. this.incrementalStrategy.setIncrementalState(this.incrementalCompilation.state, program);
  6808. this.currentProgram = program;
  6809. return diagnostics;
  6810. }
  6811. getTemplateDiagnosticsForFile(sf, optimizeFor) {
  6812. const compilation = this.ensureAnalyzed();
  6813. const diagnostics = [];
  6814. if (!sf.isDeclarationFile && !this.adapter.isShim(sf)) {
  6815. try {
  6816. diagnostics.push(...compilation.templateTypeChecker.getDiagnosticsForFile(sf, optimizeFor));
  6817. } catch (err) {
  6818. if (!(err instanceof FatalDiagnosticError)) {
  6819. throw err;
  6820. }
  6821. diagnostics.push(err.toDiagnostic());
  6822. }
  6823. }
  6824. const program = this.programDriver.getProgram();
  6825. this.incrementalStrategy.setIncrementalState(this.incrementalCompilation.state, program);
  6826. this.currentProgram = program;
  6827. return diagnostics;
  6828. }
  6829. getNonTemplateDiagnostics() {
  6830. if (this.nonTemplateDiagnostics === null) {
  6831. const compilation = this.ensureAnalyzed();
  6832. this.nonTemplateDiagnostics = [...compilation.traitCompiler.diagnostics];
  6833. if (this.entryPoint !== null && compilation.exportReferenceGraph !== null) {
  6834. this.nonTemplateDiagnostics.push(...checkForPrivateExports(this.entryPoint, this.inputProgram.getTypeChecker(), compilation.exportReferenceGraph));
  6835. }
  6836. }
  6837. return this.nonTemplateDiagnostics;
  6838. }
  6839. getExtendedTemplateDiagnostics(sf) {
  6840. const diagnostics = [];
  6841. const compilation = this.ensureAnalyzed();
  6842. const extendedTemplateChecker = compilation.extendedTemplateChecker;
  6843. if (!extendedTemplateChecker) {
  6844. return [];
  6845. }
  6846. if (sf !== void 0) {
  6847. return compilation.traitCompiler.extendedTemplateCheck(sf, extendedTemplateChecker);
  6848. }
  6849. for (const sf2 of this.inputProgram.getSourceFiles()) {
  6850. diagnostics.push(...compilation.traitCompiler.extendedTemplateCheck(sf2, extendedTemplateChecker));
  6851. }
  6852. return diagnostics;
  6853. }
  6854. makeCompilation() {
  6855. var _a;
  6856. const checker = this.inputProgram.getTypeChecker();
  6857. const reflector = new TypeScriptReflectionHost(checker);
  6858. let refEmitter;
  6859. let aliasingHost = null;
  6860. if (this.adapter.unifiedModulesHost === null || !this.options._useHostForImportGeneration) {
  6861. let localImportStrategy;
  6862. if (this.options.rootDir !== void 0 || this.options.rootDirs !== void 0 && this.options.rootDirs.length > 0) {
  6863. localImportStrategy = new LogicalProjectStrategy(reflector, new LogicalFileSystem([...this.adapter.rootDirs], this.adapter));
  6864. } else {
  6865. localImportStrategy = new RelativePathStrategy(reflector);
  6866. }
  6867. refEmitter = new ReferenceEmitter([
  6868. new LocalIdentifierStrategy(),
  6869. new AbsoluteModuleStrategy(this.inputProgram, checker, this.moduleResolver, reflector),
  6870. localImportStrategy
  6871. ]);
  6872. if (this.entryPoint === null && this.options.generateDeepReexports === true) {
  6873. aliasingHost = new PrivateExportAliasingHost(reflector);
  6874. }
  6875. } else {
  6876. refEmitter = new ReferenceEmitter([
  6877. new LocalIdentifierStrategy(),
  6878. new AliasStrategy(),
  6879. new UnifiedModulesStrategy(reflector, this.adapter.unifiedModulesHost)
  6880. ]);
  6881. aliasingHost = new UnifiedModulesAliasingHost(this.adapter.unifiedModulesHost);
  6882. }
  6883. const isCore = isAngularCorePackage(this.inputProgram);
  6884. const evaluator = new PartialEvaluator(reflector, checker, this.incrementalCompilation.depGraph);
  6885. const dtsReader = new DtsMetadataReader(checker, reflector);
  6886. const localMetaRegistry = new LocalMetadataRegistry();
  6887. const localMetaReader = localMetaRegistry;
  6888. const depScopeReader = new MetadataDtsModuleScopeResolver(dtsReader, aliasingHost);
  6889. const metaReader = new CompoundMetadataReader([localMetaReader, dtsReader]);
  6890. const ngModuleIndex = new NgModuleIndexImpl(metaReader, localMetaReader);
  6891. const ngModuleScopeRegistry = new LocalModuleScopeRegistry(localMetaReader, metaReader, depScopeReader, refEmitter, aliasingHost);
  6892. const standaloneScopeReader = new StandaloneComponentScopeReader(metaReader, ngModuleScopeRegistry, depScopeReader);
  6893. const scopeReader = new CompoundComponentScopeReader([ngModuleScopeRegistry, standaloneScopeReader]);
  6894. const semanticDepGraphUpdater = this.incrementalCompilation.semanticDepGraphUpdater;
  6895. const metaRegistry = new CompoundMetadataRegistry([localMetaRegistry, ngModuleScopeRegistry]);
  6896. const injectableRegistry = new InjectableClassRegistry(reflector, isCore);
  6897. const hostDirectivesResolver = new HostDirectivesResolver(metaReader);
  6898. const exportedProviderStatusResolver = new ExportedProviderStatusResolver(metaReader);
  6899. const typeCheckScopeRegistry = new TypeCheckScopeRegistry(scopeReader, metaReader, hostDirectivesResolver);
  6900. let referencesRegistry;
  6901. let exportReferenceGraph = null;
  6902. if (this.entryPoint !== null) {
  6903. exportReferenceGraph = new ReferenceGraph();
  6904. referencesRegistry = new ReferenceGraphAdapter(exportReferenceGraph);
  6905. } else {
  6906. referencesRegistry = new NoopReferencesRegistry();
  6907. }
  6908. const dtsTransforms = new DtsTransformRegistry();
  6909. const resourceRegistry = new ResourceRegistry();
  6910. let compilationMode = CompilationMode.FULL;
  6911. if (!isCore) {
  6912. switch (this.options.compilationMode) {
  6913. case "full":
  6914. compilationMode = CompilationMode.FULL;
  6915. break;
  6916. case "partial":
  6917. compilationMode = CompilationMode.PARTIAL;
  6918. break;
  6919. case "experimental-local":
  6920. compilationMode = CompilationMode.LOCAL;
  6921. break;
  6922. }
  6923. }
  6924. const cycleHandlingStrategy = compilationMode === CompilationMode.FULL ? 0 : 1;
  6925. const strictCtorDeps = this.options.strictInjectionParameters || false;
  6926. const handlers = [
  6927. new ComponentDecoratorHandler(reflector, evaluator, metaRegistry, metaReader, scopeReader, depScopeReader, ngModuleScopeRegistry, typeCheckScopeRegistry, resourceRegistry, isCore, strictCtorDeps, this.resourceManager, this.adapter.rootDirs, this.options.preserveWhitespaces || false, this.options.i18nUseExternalIds !== false, this.options.enableI18nLegacyMessageIdFormat !== false, this.usePoisonedData, this.options.i18nNormalizeLineEndingsInICUs === true, this.moduleResolver, this.cycleAnalyzer, cycleHandlingStrategy, refEmitter, referencesRegistry, this.incrementalCompilation.depGraph, injectableRegistry, semanticDepGraphUpdater, this.closureCompilerEnabled, this.delegatingPerfRecorder, hostDirectivesResolver),
  6928. new DirectiveDecoratorHandler(reflector, evaluator, metaRegistry, ngModuleScopeRegistry, metaReader, injectableRegistry, refEmitter, referencesRegistry, isCore, strictCtorDeps, semanticDepGraphUpdater, this.closureCompilerEnabled, this.delegatingPerfRecorder),
  6929. new PipeDecoratorHandler(reflector, evaluator, metaRegistry, ngModuleScopeRegistry, injectableRegistry, isCore, this.delegatingPerfRecorder),
  6930. new InjectableDecoratorHandler(reflector, evaluator, isCore, strictCtorDeps, injectableRegistry, this.delegatingPerfRecorder),
  6931. new NgModuleDecoratorHandler(reflector, evaluator, metaReader, metaRegistry, ngModuleScopeRegistry, referencesRegistry, exportedProviderStatusResolver, semanticDepGraphUpdater, isCore, refEmitter, this.closureCompilerEnabled, (_a = this.options.onlyPublishPublicTypingsForNgModules) != null ? _a : false, injectableRegistry, this.delegatingPerfRecorder)
  6932. ];
  6933. const traitCompiler = new TraitCompiler(handlers, reflector, this.delegatingPerfRecorder, this.incrementalCompilation, this.options.compileNonExportedClasses !== false, compilationMode, dtsTransforms, semanticDepGraphUpdater, this.adapter);
  6934. const notifyingDriver = new NotifyingProgramDriverWrapper(this.programDriver, (program) => {
  6935. this.incrementalStrategy.setIncrementalState(this.incrementalCompilation.state, program);
  6936. this.currentProgram = program;
  6937. });
  6938. const templateTypeChecker = new TemplateTypeCheckerImpl(this.inputProgram, notifyingDriver, traitCompiler, this.getTypeCheckingConfig(), refEmitter, reflector, this.adapter, this.incrementalCompilation, metaReader, localMetaReader, ngModuleIndex, scopeReader, typeCheckScopeRegistry, this.delegatingPerfRecorder);
  6939. const extendedTemplateChecker = this.constructionDiagnostics.length === 0 ? new ExtendedTemplateCheckerImpl(templateTypeChecker, checker, ALL_DIAGNOSTIC_FACTORIES, this.options) : null;
  6940. return {
  6941. isCore,
  6942. traitCompiler,
  6943. reflector,
  6944. scopeRegistry: ngModuleScopeRegistry,
  6945. dtsTransforms,
  6946. exportReferenceGraph,
  6947. metaReader,
  6948. typeCheckScopeRegistry,
  6949. aliasingHost,
  6950. refEmitter,
  6951. templateTypeChecker,
  6952. resourceRegistry,
  6953. extendedTemplateChecker
  6954. };
  6955. }
  6956. };
  6957. function isAngularCorePackage(program) {
  6958. const r3Symbols = getR3SymbolsFile(program);
  6959. if (r3Symbols === null) {
  6960. return false;
  6961. }
  6962. return r3Symbols.statements.some((stmt) => {
  6963. if (!ts30.isVariableStatement(stmt)) {
  6964. return false;
  6965. }
  6966. const modifiers = ts30.getModifiers(stmt);
  6967. if (modifiers === void 0 || !modifiers.some((mod) => mod.kind === ts30.SyntaxKind.ExportKeyword)) {
  6968. return false;
  6969. }
  6970. return stmt.declarationList.declarations.some((decl) => {
  6971. if (!ts30.isIdentifier(decl.name) || decl.name.text !== "ITS_JUST_ANGULAR") {
  6972. return false;
  6973. }
  6974. if (decl.initializer === void 0 || decl.initializer.kind !== ts30.SyntaxKind.TrueKeyword) {
  6975. return false;
  6976. }
  6977. return true;
  6978. });
  6979. });
  6980. }
  6981. function getR3SymbolsFile(program) {
  6982. return program.getSourceFiles().find((file) => file.fileName.indexOf("r3_symbols.ts") >= 0) || null;
  6983. }
  6984. function* verifyCompatibleTypeCheckOptions(options) {
  6985. var _a, _b, _c;
  6986. if (options.fullTemplateTypeCheck === false && options.strictTemplates === true) {
  6987. yield makeConfigDiagnostic({
  6988. category: ts30.DiagnosticCategory.Error,
  6989. code: ErrorCode.CONFIG_STRICT_TEMPLATES_IMPLIES_FULL_TEMPLATE_TYPECHECK,
  6990. messageText: `
  6991. Angular compiler option "strictTemplates" is enabled, however "fullTemplateTypeCheck" is disabled.
  6992. Having the "strictTemplates" flag enabled implies that "fullTemplateTypeCheck" is also enabled, so
  6993. the latter can not be explicitly disabled.
  6994. One of the following actions is required:
  6995. 1. Remove the "fullTemplateTypeCheck" option.
  6996. 2. Remove "strictTemplates" or set it to 'false'.
  6997. More information about the template type checking compiler options can be found in the documentation:
  6998. https://angular.io/guide/template-typecheck
  6999. `.trim()
  7000. });
  7001. }
  7002. if (options.extendedDiagnostics && options.strictTemplates === false) {
  7003. yield makeConfigDiagnostic({
  7004. category: ts30.DiagnosticCategory.Error,
  7005. code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_IMPLIES_STRICT_TEMPLATES,
  7006. messageText: `
  7007. Angular compiler option "extendedDiagnostics" is configured, however "strictTemplates" is disabled.
  7008. Using "extendedDiagnostics" requires that "strictTemplates" is also enabled.
  7009. One of the following actions is required:
  7010. 1. Remove "strictTemplates: false" to enable it.
  7011. 2. Remove "extendedDiagnostics" configuration to disable them.
  7012. `.trim()
  7013. });
  7014. }
  7015. const allowedCategoryLabels = Array.from(Object.values(DiagnosticCategoryLabel));
  7016. const defaultCategory = (_a = options.extendedDiagnostics) == null ? void 0 : _a.defaultCategory;
  7017. if (defaultCategory && !allowedCategoryLabels.includes(defaultCategory)) {
  7018. yield makeConfigDiagnostic({
  7019. category: ts30.DiagnosticCategory.Error,
  7020. code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
  7021. messageText: `
  7022. Angular compiler option "extendedDiagnostics.defaultCategory" has an unknown diagnostic category: "${defaultCategory}".
  7023. Allowed diagnostic categories are:
  7024. ${allowedCategoryLabels.join("\n")}
  7025. `.trim()
  7026. });
  7027. }
  7028. const allExtendedDiagnosticNames = ALL_DIAGNOSTIC_FACTORIES.map((factory8) => factory8.name);
  7029. for (const [checkName, category] of Object.entries((_c = (_b = options.extendedDiagnostics) == null ? void 0 : _b.checks) != null ? _c : {})) {
  7030. if (!allExtendedDiagnosticNames.includes(checkName)) {
  7031. yield makeConfigDiagnostic({
  7032. category: ts30.DiagnosticCategory.Error,
  7033. code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CHECK,
  7034. messageText: `
  7035. Angular compiler option "extendedDiagnostics.checks" has an unknown check: "${checkName}".
  7036. Allowed check names are:
  7037. ${allExtendedDiagnosticNames.join("\n")}
  7038. `.trim()
  7039. });
  7040. }
  7041. if (!allowedCategoryLabels.includes(category)) {
  7042. yield makeConfigDiagnostic({
  7043. category: ts30.DiagnosticCategory.Error,
  7044. code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
  7045. messageText: `
  7046. Angular compiler option "extendedDiagnostics.checks['${checkName}']" has an unknown diagnostic category: "${category}".
  7047. Allowed diagnostic categories are:
  7048. ${allowedCategoryLabels.join("\n")}
  7049. `.trim()
  7050. });
  7051. }
  7052. }
  7053. }
  7054. function makeConfigDiagnostic({ category, code, messageText }) {
  7055. return {
  7056. category,
  7057. code: ngErrorCode(code),
  7058. file: void 0,
  7059. start: void 0,
  7060. length: void 0,
  7061. messageText
  7062. };
  7063. }
  7064. var ReferenceGraphAdapter = class {
  7065. constructor(graph) {
  7066. this.graph = graph;
  7067. }
  7068. add(source, ...references) {
  7069. for (const { node } of references) {
  7070. let sourceFile = node.getSourceFile();
  7071. if (sourceFile === void 0) {
  7072. sourceFile = ts30.getOriginalNode(node).getSourceFile();
  7073. }
  7074. if (sourceFile === void 0 || !isDtsPath(sourceFile.fileName)) {
  7075. this.graph.add(source, node);
  7076. }
  7077. }
  7078. }
  7079. };
  7080. var NotifyingProgramDriverWrapper = class {
  7081. constructor(delegate, notifyNewProgram) {
  7082. var _a;
  7083. this.delegate = delegate;
  7084. this.notifyNewProgram = notifyNewProgram;
  7085. this.getSourceFileVersion = (_a = this.delegate.getSourceFileVersion) == null ? void 0 : _a.bind(this);
  7086. }
  7087. get supportsInlineOperations() {
  7088. return this.delegate.supportsInlineOperations;
  7089. }
  7090. getProgram() {
  7091. return this.delegate.getProgram();
  7092. }
  7093. updateFiles(contents, updateMode) {
  7094. this.delegate.updateFiles(contents, updateMode);
  7095. this.notifyNewProgram(this.delegate.getProgram());
  7096. }
  7097. };
  7098. function versionMapFromProgram(program, driver) {
  7099. if (driver.getSourceFileVersion === void 0) {
  7100. return null;
  7101. }
  7102. const versions = /* @__PURE__ */ new Map();
  7103. for (const possiblyRedirectedSourceFile of program.getSourceFiles()) {
  7104. const sf = toUnredirectedSourceFile(possiblyRedirectedSourceFile);
  7105. versions.set(absoluteFromSourceFile(sf), driver.getSourceFileVersion(sf));
  7106. }
  7107. return versions;
  7108. }
  7109. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/core/src/host.mjs
  7110. import ts31 from "typescript";
  7111. var DelegatingCompilerHost2 = class {
  7112. constructor(delegate) {
  7113. this.delegate = delegate;
  7114. this.createHash = this.delegateMethod("createHash");
  7115. this.directoryExists = this.delegateMethod("directoryExists");
  7116. this.fileNameToModuleName = this.delegateMethod("fileNameToModuleName");
  7117. this.getCancellationToken = this.delegateMethod("getCancellationToken");
  7118. this.getCanonicalFileName = this.delegateMethod("getCanonicalFileName");
  7119. this.getCurrentDirectory = this.delegateMethod("getCurrentDirectory");
  7120. this.getDefaultLibFileName = this.delegateMethod("getDefaultLibFileName");
  7121. this.getDefaultLibLocation = this.delegateMethod("getDefaultLibLocation");
  7122. this.getDirectories = this.delegateMethod("getDirectories");
  7123. this.getEnvironmentVariable = this.delegateMethod("getEnvironmentVariable");
  7124. this.getModifiedResourceFiles = this.delegateMethod("getModifiedResourceFiles");
  7125. this.getNewLine = this.delegateMethod("getNewLine");
  7126. this.getParsedCommandLine = this.delegateMethod("getParsedCommandLine");
  7127. this.getSourceFileByPath = this.delegateMethod("getSourceFileByPath");
  7128. this.readDirectory = this.delegateMethod("readDirectory");
  7129. this.readFile = this.delegateMethod("readFile");
  7130. this.readResource = this.delegateMethod("readResource");
  7131. this.transformResource = this.delegateMethod("transformResource");
  7132. this.realpath = this.delegateMethod("realpath");
  7133. this.resolveModuleNames = this.delegateMethod("resolveModuleNames");
  7134. this.resolveTypeReferenceDirectives = this.delegateMethod("resolveTypeReferenceDirectives");
  7135. this.resourceNameToFileName = this.delegateMethod("resourceNameToFileName");
  7136. this.trace = this.delegateMethod("trace");
  7137. this.useCaseSensitiveFileNames = this.delegateMethod("useCaseSensitiveFileNames");
  7138. this.writeFile = this.delegateMethod("writeFile");
  7139. this.getModuleResolutionCache = this.delegateMethod("getModuleResolutionCache");
  7140. this.hasInvalidatedResolutions = this.delegateMethod("hasInvalidatedResolutions");
  7141. this.resolveModuleNameLiterals = this.delegateMethod("resolveModuleNameLiterals");
  7142. this.resolveTypeReferenceDirectiveReferences = this.delegateMethod("resolveTypeReferenceDirectiveReferences");
  7143. }
  7144. delegateMethod(name) {
  7145. return this.delegate[name] !== void 0 ? this.delegate[name].bind(this.delegate) : void 0;
  7146. }
  7147. };
  7148. var NgCompilerHost = class extends DelegatingCompilerHost2 {
  7149. constructor(delegate, inputFiles, rootDirs, shimAdapter, shimTagger, entryPoint, diagnostics) {
  7150. super(delegate);
  7151. this.shimAdapter = shimAdapter;
  7152. this.shimTagger = shimTagger;
  7153. this.entryPoint = null;
  7154. this.entryPoint = entryPoint;
  7155. this.constructionDiagnostics = diagnostics;
  7156. this.inputFiles = [...inputFiles, ...shimAdapter.extraInputFiles];
  7157. this.rootDirs = rootDirs;
  7158. if (this.resolveModuleNames === void 0) {
  7159. this.resolveModuleNames = this.createCachedResolveModuleNamesFunction();
  7160. }
  7161. }
  7162. get ignoreForEmit() {
  7163. return this.shimAdapter.ignoreForEmit;
  7164. }
  7165. get shimExtensionPrefixes() {
  7166. return this.shimAdapter.extensionPrefixes;
  7167. }
  7168. postProgramCreationCleanup() {
  7169. this.shimTagger.finalize();
  7170. }
  7171. static wrap(delegate, inputFiles, options, oldProgram) {
  7172. const topLevelShimGenerators = [];
  7173. const perFileShimGenerators = [];
  7174. const rootDirs = getRootDirs(delegate, options);
  7175. perFileShimGenerators.push(new TypeCheckShimGenerator());
  7176. let diagnostics = [];
  7177. const normalizedTsInputFiles = [];
  7178. for (const inputFile of inputFiles) {
  7179. if (!isNonDeclarationTsPath(inputFile)) {
  7180. continue;
  7181. }
  7182. normalizedTsInputFiles.push(resolve(inputFile));
  7183. }
  7184. let entryPoint = null;
  7185. if (options.flatModuleOutFile != null && options.flatModuleOutFile !== "") {
  7186. entryPoint = findFlatIndexEntryPoint(normalizedTsInputFiles);
  7187. if (entryPoint === null) {
  7188. diagnostics.push({
  7189. category: ts31.DiagnosticCategory.Error,
  7190. code: ngErrorCode(ErrorCode.CONFIG_FLAT_MODULE_NO_INDEX),
  7191. file: void 0,
  7192. start: void 0,
  7193. length: void 0,
  7194. messageText: 'Angular compiler option "flatModuleOutFile" requires one and only one .ts file in the "files" field.'
  7195. });
  7196. } else {
  7197. const flatModuleId = options.flatModuleId || null;
  7198. const flatModuleOutFile = normalizeSeparators(options.flatModuleOutFile);
  7199. const flatIndexGenerator = new FlatIndexGenerator(entryPoint, flatModuleOutFile, flatModuleId);
  7200. topLevelShimGenerators.push(flatIndexGenerator);
  7201. }
  7202. }
  7203. const shimAdapter = new ShimAdapter(delegate, normalizedTsInputFiles, topLevelShimGenerators, perFileShimGenerators, oldProgram);
  7204. const shimTagger = new ShimReferenceTagger(perFileShimGenerators.map((gen) => gen.extensionPrefix));
  7205. return new NgCompilerHost(delegate, inputFiles, rootDirs, shimAdapter, shimTagger, entryPoint, diagnostics);
  7206. }
  7207. isShim(sf) {
  7208. return isShim(sf);
  7209. }
  7210. isResource(sf) {
  7211. return false;
  7212. }
  7213. getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) {
  7214. const shimSf = this.shimAdapter.maybeGenerate(resolve(fileName));
  7215. if (shimSf !== null) {
  7216. return shimSf;
  7217. }
  7218. const sf = this.delegate.getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
  7219. if (sf === void 0) {
  7220. return void 0;
  7221. }
  7222. this.shimTagger.tag(sf);
  7223. return sf;
  7224. }
  7225. fileExists(fileName) {
  7226. return this.delegate.fileExists(fileName) || this.shimAdapter.maybeGenerate(resolve(fileName)) != null;
  7227. }
  7228. get unifiedModulesHost() {
  7229. return this.fileNameToModuleName !== void 0 ? this : null;
  7230. }
  7231. createCachedResolveModuleNamesFunction() {
  7232. const moduleResolutionCache = ts31.createModuleResolutionCache(this.getCurrentDirectory(), this.getCanonicalFileName.bind(this));
  7233. return (moduleNames, containingFile, reusedNames, redirectedReference, options) => {
  7234. return moduleNames.map((moduleName) => {
  7235. const module = ts31.resolveModuleName(moduleName, containingFile, options, this, moduleResolutionCache, redirectedReference);
  7236. return module.resolvedModule;
  7237. });
  7238. };
  7239. }
  7240. };
  7241. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/program.mjs
  7242. var NgtscProgram = class {
  7243. constructor(rootNames, options, delegateHost, oldProgram) {
  7244. this.options = options;
  7245. const perfRecorder = ActivePerfRecorder.zeroedToNow();
  7246. perfRecorder.phase(PerfPhase.Setup);
  7247. if (!options.disableTypeScriptVersionCheck) {
  7248. verifySupportedTypeScriptVersion();
  7249. }
  7250. const reuseProgram = oldProgram == null ? void 0 : oldProgram.compiler.getCurrentProgram();
  7251. this.host = NgCompilerHost.wrap(delegateHost, rootNames, options, reuseProgram != null ? reuseProgram : null);
  7252. if (reuseProgram !== void 0) {
  7253. retagAllTsFiles(reuseProgram);
  7254. }
  7255. this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () => ts32.createProgram(this.host.inputFiles, options, this.host, reuseProgram));
  7256. perfRecorder.phase(PerfPhase.Unaccounted);
  7257. perfRecorder.memory(PerfCheckpoint.TypeScriptProgramCreate);
  7258. this.host.postProgramCreationCleanup();
  7259. untagAllTsFiles(this.tsProgram);
  7260. const programDriver = new TsCreateProgramDriver(this.tsProgram, this.host, this.options, this.host.shimExtensionPrefixes);
  7261. this.incrementalStrategy = oldProgram !== void 0 ? oldProgram.incrementalStrategy.toNextBuildStrategy() : new TrackedIncrementalBuildStrategy();
  7262. const modifiedResourceFiles = /* @__PURE__ */ new Set();
  7263. if (this.host.getModifiedResourceFiles !== void 0) {
  7264. const strings = this.host.getModifiedResourceFiles();
  7265. if (strings !== void 0) {
  7266. for (const fileString of strings) {
  7267. modifiedResourceFiles.add(absoluteFrom(fileString));
  7268. }
  7269. }
  7270. }
  7271. let ticket;
  7272. if (oldProgram === void 0) {
  7273. ticket = freshCompilationTicket(
  7274. this.tsProgram,
  7275. options,
  7276. this.incrementalStrategy,
  7277. programDriver,
  7278. perfRecorder,
  7279. false,
  7280. false
  7281. );
  7282. } else {
  7283. ticket = incrementalFromCompilerTicket(oldProgram.compiler, this.tsProgram, this.incrementalStrategy, programDriver, modifiedResourceFiles, perfRecorder);
  7284. }
  7285. this.compiler = NgCompiler.fromTicket(ticket, this.host);
  7286. }
  7287. getTsProgram() {
  7288. return this.tsProgram;
  7289. }
  7290. getReuseTsProgram() {
  7291. return this.compiler.getCurrentProgram();
  7292. }
  7293. getTsOptionDiagnostics(cancellationToken) {
  7294. return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => this.tsProgram.getOptionsDiagnostics(cancellationToken));
  7295. }
  7296. getTsSyntacticDiagnostics(sourceFile, cancellationToken) {
  7297. return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
  7298. const ignoredFiles = this.compiler.ignoreForDiagnostics;
  7299. let res;
  7300. if (sourceFile !== void 0) {
  7301. if (ignoredFiles.has(sourceFile)) {
  7302. return [];
  7303. }
  7304. res = this.tsProgram.getSyntacticDiagnostics(sourceFile, cancellationToken);
  7305. } else {
  7306. const diagnostics = [];
  7307. for (const sf of this.tsProgram.getSourceFiles()) {
  7308. if (!ignoredFiles.has(sf)) {
  7309. diagnostics.push(...this.tsProgram.getSyntacticDiagnostics(sf, cancellationToken));
  7310. }
  7311. }
  7312. res = diagnostics;
  7313. }
  7314. return res;
  7315. });
  7316. }
  7317. getTsSemanticDiagnostics(sourceFile, cancellationToken) {
  7318. return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
  7319. const ignoredFiles = this.compiler.ignoreForDiagnostics;
  7320. let res;
  7321. if (sourceFile !== void 0) {
  7322. if (ignoredFiles.has(sourceFile)) {
  7323. return [];
  7324. }
  7325. res = this.tsProgram.getSemanticDiagnostics(sourceFile, cancellationToken);
  7326. } else {
  7327. const diagnostics = [];
  7328. for (const sf of this.tsProgram.getSourceFiles()) {
  7329. if (!ignoredFiles.has(sf)) {
  7330. diagnostics.push(...this.tsProgram.getSemanticDiagnostics(sf, cancellationToken));
  7331. }
  7332. }
  7333. res = diagnostics;
  7334. }
  7335. return res;
  7336. });
  7337. }
  7338. getNgOptionDiagnostics(cancellationToken) {
  7339. return this.compiler.getOptionDiagnostics();
  7340. }
  7341. getNgStructuralDiagnostics(cancellationToken) {
  7342. return [];
  7343. }
  7344. getNgSemanticDiagnostics(fileName, cancellationToken) {
  7345. let sf = void 0;
  7346. if (fileName !== void 0) {
  7347. sf = this.tsProgram.getSourceFile(fileName);
  7348. if (sf === void 0) {
  7349. return [];
  7350. }
  7351. }
  7352. if (sf === void 0) {
  7353. return this.compiler.getDiagnostics();
  7354. } else {
  7355. return this.compiler.getDiagnosticsForFile(sf, OptimizeFor.WholeProgram);
  7356. }
  7357. }
  7358. loadNgStructureAsync() {
  7359. return this.compiler.analyzeAsync();
  7360. }
  7361. listLazyRoutes(entryRoute) {
  7362. return [];
  7363. }
  7364. emitXi18n() {
  7365. var _a, _b, _c;
  7366. const ctx = new MessageBundle(new HtmlParser(), [], {}, (_a = this.options.i18nOutLocale) != null ? _a : null);
  7367. this.compiler.xi18n(ctx);
  7368. i18nExtract((_b = this.options.i18nOutFormat) != null ? _b : null, (_c = this.options.i18nOutFile) != null ? _c : null, this.host, this.options, ctx, resolve);
  7369. }
  7370. emit(opts) {
  7371. var _a;
  7372. if (opts !== void 0 && opts.emitFlags !== void 0 && opts.emitFlags & EmitFlags.I18nBundle) {
  7373. this.emitXi18n();
  7374. if (!(opts.emitFlags & EmitFlags.JS)) {
  7375. return {
  7376. diagnostics: [],
  7377. emitSkipped: true,
  7378. emittedFiles: []
  7379. };
  7380. }
  7381. }
  7382. const forceEmit = (_a = opts == null ? void 0 : opts.forceEmit) != null ? _a : false;
  7383. this.compiler.perfRecorder.memory(PerfCheckpoint.PreEmit);
  7384. const res = this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptEmit, () => {
  7385. var _a2;
  7386. const { transformers } = this.compiler.prepareEmit();
  7387. const ignoreFiles = this.compiler.ignoreForEmit;
  7388. const emitCallback = (_a2 = opts == null ? void 0 : opts.emitCallback) != null ? _a2 : defaultEmitCallback;
  7389. const writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
  7390. if (sourceFiles !== void 0) {
  7391. for (const writtenSf of sourceFiles) {
  7392. if (writtenSf.isDeclarationFile) {
  7393. continue;
  7394. }
  7395. this.compiler.incrementalCompilation.recordSuccessfulEmit(writtenSf);
  7396. }
  7397. }
  7398. this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
  7399. };
  7400. const customTransforms = opts && opts.customTransformers;
  7401. const beforeTransforms = transformers.before || [];
  7402. const afterDeclarationsTransforms = transformers.afterDeclarations;
  7403. if (customTransforms !== void 0 && customTransforms.beforeTs !== void 0) {
  7404. beforeTransforms.push(...customTransforms.beforeTs);
  7405. }
  7406. const emitResults = [];
  7407. for (const targetSourceFile of this.tsProgram.getSourceFiles()) {
  7408. if (targetSourceFile.isDeclarationFile || ignoreFiles.has(targetSourceFile)) {
  7409. continue;
  7410. }
  7411. if (!forceEmit && this.compiler.incrementalCompilation.safeToSkipEmit(targetSourceFile)) {
  7412. this.compiler.perfRecorder.eventCount(PerfEvent.EmitSkipSourceFile);
  7413. continue;
  7414. }
  7415. this.compiler.perfRecorder.eventCount(PerfEvent.EmitSourceFile);
  7416. emitResults.push(emitCallback({
  7417. targetSourceFile,
  7418. program: this.tsProgram,
  7419. host: this.host,
  7420. options: this.options,
  7421. emitOnlyDtsFiles: false,
  7422. writeFile,
  7423. customTransformers: {
  7424. before: beforeTransforms,
  7425. after: customTransforms && customTransforms.afterTs,
  7426. afterDeclarations: afterDeclarationsTransforms
  7427. }
  7428. }));
  7429. }
  7430. this.compiler.perfRecorder.memory(PerfCheckpoint.Emit);
  7431. return (opts && opts.mergeEmitResultsCallback || mergeEmitResults)(emitResults);
  7432. });
  7433. if (this.options.tracePerformance !== void 0) {
  7434. const perf = this.compiler.perfRecorder.finalize();
  7435. getFileSystem().writeFile(getFileSystem().resolve(this.options.tracePerformance), JSON.stringify(perf, null, 2));
  7436. }
  7437. return res;
  7438. }
  7439. getIndexedComponents() {
  7440. return this.compiler.getIndexedComponents();
  7441. }
  7442. getEmittedSourceFiles() {
  7443. throw new Error("Method not implemented.");
  7444. }
  7445. };
  7446. var defaultEmitCallback = ({ program, targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers }) => program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
  7447. function mergeEmitResults(emitResults) {
  7448. const diagnostics = [];
  7449. let emitSkipped = false;
  7450. const emittedFiles = [];
  7451. for (const er of emitResults) {
  7452. diagnostics.push(...er.diagnostics);
  7453. emitSkipped = emitSkipped || er.emitSkipped;
  7454. emittedFiles.push(...er.emittedFiles || []);
  7455. }
  7456. return { diagnostics, emitSkipped, emittedFiles };
  7457. }
  7458. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/transformers/program.mjs
  7459. function createProgram({ rootNames, options, host, oldProgram }) {
  7460. return new NgtscProgram(rootNames, options, host, oldProgram);
  7461. }
  7462. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/perform_compile.mjs
  7463. import ts34 from "typescript";
  7464. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/transformers/util.mjs
  7465. import ts33 from "typescript";
  7466. function createMessageDiagnostic(messageText) {
  7467. return {
  7468. file: void 0,
  7469. start: void 0,
  7470. length: void 0,
  7471. category: ts33.DiagnosticCategory.Message,
  7472. messageText,
  7473. code: DEFAULT_ERROR_CODE,
  7474. source: SOURCE
  7475. };
  7476. }
  7477. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/perform_compile.mjs
  7478. var defaultFormatHost = {
  7479. getCurrentDirectory: () => ts34.sys.getCurrentDirectory(),
  7480. getCanonicalFileName: (fileName) => fileName,
  7481. getNewLine: () => ts34.sys.newLine
  7482. };
  7483. function formatDiagnostics(diags, host = defaultFormatHost) {
  7484. if (diags && diags.length) {
  7485. return diags.map((diagnostic) => replaceTsWithNgInErrors(ts34.formatDiagnosticsWithColorAndContext([diagnostic], host))).join("");
  7486. } else {
  7487. return "";
  7488. }
  7489. }
  7490. function calcProjectFileAndBasePath(project, host = getFileSystem()) {
  7491. const absProject = host.resolve(project);
  7492. const projectIsDir = host.lstat(absProject).isDirectory();
  7493. const projectFile = projectIsDir ? host.join(absProject, "tsconfig.json") : absProject;
  7494. const projectDir = projectIsDir ? absProject : host.dirname(absProject);
  7495. const basePath = host.resolve(projectDir);
  7496. return { projectFile, basePath };
  7497. }
  7498. function readConfiguration(project, existingOptions, host = getFileSystem()) {
  7499. var _a;
  7500. try {
  7501. const fs = getFileSystem();
  7502. const readConfigFile = (configFile) => ts34.readConfigFile(configFile, (file) => host.readFile(host.resolve(file)));
  7503. const readAngularCompilerOptions = (configFile, parentOptions = {}) => {
  7504. const { config: config2, error: error2 } = readConfigFile(configFile);
  7505. if (error2) {
  7506. return parentOptions;
  7507. }
  7508. let existingNgCompilerOptions = { ...config2.angularCompilerOptions, ...parentOptions };
  7509. if (!config2.extends) {
  7510. return existingNgCompilerOptions;
  7511. }
  7512. const extendsPaths = typeof config2.extends === "string" ? [config2.extends] : config2.extends;
  7513. return [...extendsPaths].reverse().reduce((prevOptions, extendsPath) => {
  7514. const extendedConfigPath = getExtendedConfigPath(configFile, extendsPath, host, fs);
  7515. return extendedConfigPath === null ? prevOptions : readAngularCompilerOptions(extendedConfigPath, prevOptions);
  7516. }, existingNgCompilerOptions);
  7517. };
  7518. const { projectFile, basePath } = calcProjectFileAndBasePath(project, host);
  7519. const configFileName = host.resolve(host.pwd(), projectFile);
  7520. const { config, error } = readConfigFile(projectFile);
  7521. if (error) {
  7522. return {
  7523. project,
  7524. errors: [error],
  7525. rootNames: [],
  7526. options: {},
  7527. emitFlags: EmitFlags.Default
  7528. };
  7529. }
  7530. const existingCompilerOptions = {
  7531. genDir: basePath,
  7532. basePath,
  7533. ...readAngularCompilerOptions(configFileName),
  7534. ...existingOptions
  7535. };
  7536. const parseConfigHost = createParseConfigHost(host, fs);
  7537. const { options, errors, fileNames: rootNames, projectReferences } = ts34.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
  7538. let emitFlags = EmitFlags.Default;
  7539. if (!(options.skipMetadataEmit || options.flatModuleOutFile)) {
  7540. emitFlags |= EmitFlags.Metadata;
  7541. }
  7542. if (options.skipTemplateCodegen) {
  7543. emitFlags = emitFlags & ~EmitFlags.Codegen;
  7544. }
  7545. return { project: projectFile, rootNames, projectReferences, options, errors, emitFlags };
  7546. } catch (e) {
  7547. const errors = [{
  7548. category: ts34.DiagnosticCategory.Error,
  7549. messageText: (_a = e.stack) != null ? _a : e.message,
  7550. file: void 0,
  7551. start: void 0,
  7552. length: void 0,
  7553. source: "angular",
  7554. code: UNKNOWN_ERROR_CODE
  7555. }];
  7556. return { project: "", errors, rootNames: [], options: {}, emitFlags: EmitFlags.Default };
  7557. }
  7558. }
  7559. function createParseConfigHost(host, fs = getFileSystem()) {
  7560. return {
  7561. fileExists: host.exists.bind(host),
  7562. readDirectory: ts34.sys.readDirectory,
  7563. readFile: host.readFile.bind(host),
  7564. useCaseSensitiveFileNames: fs.isCaseSensitive()
  7565. };
  7566. }
  7567. function getExtendedConfigPath(configFile, extendsValue, host, fs) {
  7568. const result = getExtendedConfigPathWorker(configFile, extendsValue, host, fs);
  7569. if (result !== null) {
  7570. return result;
  7571. }
  7572. return getExtendedConfigPathWorker(configFile, `${extendsValue}.json`, host, fs);
  7573. }
  7574. function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
  7575. if (extendsValue.startsWith(".") || fs.isRooted(extendsValue)) {
  7576. const extendedConfigPath = host.resolve(host.dirname(configFile), extendsValue);
  7577. if (host.exists(extendedConfigPath)) {
  7578. return extendedConfigPath;
  7579. }
  7580. } else {
  7581. const parseConfigHost = createParseConfigHost(host, fs);
  7582. const { resolvedModule } = ts34.nodeModuleNameResolver(
  7583. extendsValue,
  7584. configFile,
  7585. { moduleResolution: 2, resolveJsonModule: true },
  7586. parseConfigHost
  7587. );
  7588. if (resolvedModule) {
  7589. return absoluteFrom(resolvedModule.resolvedFileName);
  7590. }
  7591. }
  7592. return null;
  7593. }
  7594. function exitCodeFromResult(diags) {
  7595. if (!diags)
  7596. return 0;
  7597. if (diags.every((diag) => diag.category !== ts34.DiagnosticCategory.Error)) {
  7598. return 0;
  7599. }
  7600. return diags.some((d) => d.source === "angular" && d.code === UNKNOWN_ERROR_CODE) ? 2 : 1;
  7601. }
  7602. function performCompilation({ rootNames, options, host, oldProgram, emitCallback, mergeEmitResultsCallback, gatherDiagnostics = defaultGatherDiagnostics, customTransformers, emitFlags = EmitFlags.Default, forceEmit = false, modifiedResourceFiles = null }) {
  7603. var _a;
  7604. let program;
  7605. let emitResult;
  7606. let allDiagnostics = [];
  7607. try {
  7608. if (!host) {
  7609. host = createCompilerHost({ options });
  7610. }
  7611. if (modifiedResourceFiles) {
  7612. host.getModifiedResourceFiles = () => modifiedResourceFiles;
  7613. }
  7614. program = createProgram({ rootNames, host, options, oldProgram });
  7615. const beforeDiags = Date.now();
  7616. allDiagnostics.push(...gatherDiagnostics(program));
  7617. if (options.diagnostics) {
  7618. const afterDiags = Date.now();
  7619. allDiagnostics.push(createMessageDiagnostic(`Time for diagnostics: ${afterDiags - beforeDiags}ms.`));
  7620. }
  7621. if (!hasErrors(allDiagnostics)) {
  7622. emitResult = program.emit({ emitCallback, mergeEmitResultsCallback, customTransformers, emitFlags, forceEmit });
  7623. allDiagnostics.push(...emitResult.diagnostics);
  7624. return { diagnostics: allDiagnostics, program, emitResult };
  7625. }
  7626. return { diagnostics: allDiagnostics, program };
  7627. } catch (e) {
  7628. program = void 0;
  7629. allDiagnostics.push({
  7630. category: ts34.DiagnosticCategory.Error,
  7631. messageText: (_a = e.stack) != null ? _a : e.message,
  7632. code: UNKNOWN_ERROR_CODE,
  7633. file: void 0,
  7634. start: void 0,
  7635. length: void 0
  7636. });
  7637. return { diagnostics: allDiagnostics, program };
  7638. }
  7639. }
  7640. function defaultGatherDiagnostics(program) {
  7641. const allDiagnostics = [];
  7642. function checkDiagnostics(diags) {
  7643. if (diags) {
  7644. allDiagnostics.push(...diags);
  7645. return !hasErrors(diags);
  7646. }
  7647. return true;
  7648. }
  7649. let checkOtherDiagnostics = true;
  7650. checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([...program.getTsOptionDiagnostics(), ...program.getNgOptionDiagnostics()]);
  7651. checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getTsSyntacticDiagnostics());
  7652. checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([...program.getTsSemanticDiagnostics(), ...program.getNgStructuralDiagnostics()]);
  7653. checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getNgSemanticDiagnostics());
  7654. return allDiagnostics;
  7655. }
  7656. function hasErrors(diags) {
  7657. return diags.some((d) => d.category === ts34.DiagnosticCategory.Error);
  7658. }
  7659. export {
  7660. DEFAULT_ERROR_CODE,
  7661. UNKNOWN_ERROR_CODE,
  7662. SOURCE,
  7663. isTsDiagnostic,
  7664. EmitFlags,
  7665. createCompilerHost,
  7666. untagAllTsFiles,
  7667. TsCreateProgramDriver,
  7668. PatchedProgramIncrementalBuildStrategy,
  7669. freshCompilationTicket,
  7670. incrementalFromStateTicket,
  7671. NgCompiler,
  7672. NgCompilerHost,
  7673. NgtscProgram,
  7674. createProgram,
  7675. createMessageDiagnostic,
  7676. formatDiagnostics,
  7677. calcProjectFileAndBasePath,
  7678. readConfiguration,
  7679. exitCodeFromResult,
  7680. performCompilation,
  7681. defaultGatherDiagnostics
  7682. };
  7683. /**
  7684. * @license
  7685. * Copyright Google LLC All Rights Reserved.
  7686. *
  7687. * Use of this source code is governed by an MIT-style license that can be
  7688. * found in the LICENSE file at https://angular.io/license
  7689. */
  7690. //# sourceMappingURL=chunk-QBQKEXLX.js.map