discovery.d.d.ts 273 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395
  1. /**
  2. * @license Angular v20.1.0
  3. * (c) 2010-2025 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { InjectionToken, Type, ValueProvider, ExistingProvider, FactoryProvider, ConstructorProvider, StaticClassProvider, ClassProvider, EnvironmentProviders, Injector, ProviderToken, InjectOptions, Provider, ProcessProvidersFunction, ModuleWithProviders, DestroyRef, InternalInjectFlags, WritableSignal, OutputRef, StaticProvider } from './chrome_dev_tools_performance.d.js';
  7. import { Observable, Subject, Subscription } from 'rxjs';
  8. import './event_dispatcher.d.js';
  9. import { SignalNode } from './signal.d.js';
  10. import { Injector as Injector$1, InjectionToken as InjectionToken$1, NotFound } from '@angular/core/primitives/di';
  11. import { ReactiveNode } from './graph.d.js';
  12. /**
  13. * Reactive node type for an input signal. An input signal extends a signal.
  14. * There are special properties to enable transforms and required inputs.
  15. */
  16. interface InputSignalNode<T, TransformT> extends SignalNode<T> {
  17. /**
  18. * User-configured transform that will run whenever a new value is applied
  19. * to the input signal node.
  20. */
  21. transformFn: ((value: TransformT) => T) | undefined;
  22. /**
  23. * Applies a new value to the input signal. Expects transforms to be run
  24. * manually before.
  25. *
  26. * This function is called by the framework runtime code whenever a binding
  27. * changes. The value can in practice be anything at runtime, but for typing
  28. * purposes we assume it's a valid `T` value. Type-checking will enforce that.
  29. */
  30. applyValueToInputSignal<T, TransformT>(node: InputSignalNode<T, TransformT>, value: T): void;
  31. /**
  32. * A debug name for the input signal. Used in Angular DevTools to identify the signal.
  33. */
  34. debugName?: string;
  35. }
  36. declare const enum NotificationSource {
  37. MarkAncestorsForTraversal = 0,
  38. SetInput = 1,
  39. DeferBlockStateUpdate = 2,
  40. DebugApplyChanges = 3,
  41. MarkForCheck = 4,
  42. Listener = 5,
  43. CustomElement = 6,
  44. RenderHook = 7,
  45. ViewAttached = 8,
  46. ViewDetachedFromDOM = 9,
  47. AsyncAnimationsLoaded = 10,
  48. PendingTaskRemoved = 11,
  49. RootEffect = 12,
  50. ViewEffect = 13
  51. }
  52. /**
  53. * Injectable that is notified when an `LView` is made aware of changes to application state.
  54. */
  55. declare abstract class ChangeDetectionScheduler {
  56. abstract notify(source: NotificationSource): void;
  57. abstract runningTick: boolean;
  58. }
  59. /** Token used to indicate if zoneless was enabled via provideZonelessChangeDetection(). */
  60. declare const ZONELESS_ENABLED: InjectionToken<boolean>;
  61. /**
  62. * @fileoverview
  63. * While Angular only uses Trusted Types internally for the time being,
  64. * references to Trusted Types could leak into our core.d.ts, which would force
  65. * anyone compiling against @angular/core to provide the @types/trusted-types
  66. * package in their compilation unit.
  67. *
  68. * Until https://github.com/microsoft/TypeScript/issues/30024 is resolved, we
  69. * will keep Angular's public API surface free of references to Trusted Types.
  70. * For internal and semi-private APIs that need to reference Trusted Types, the
  71. * minimal type definitions for the Trusted Types API provided by this module
  72. * should be used instead. They are marked as "declare" to prevent them from
  73. * being renamed by compiler optimization.
  74. *
  75. * Adapted from
  76. * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/trusted-types/index.d.ts
  77. * but restricted to the API surface used within Angular.
  78. */
  79. type TrustedHTML = string & {
  80. __brand__: 'TrustedHTML';
  81. };
  82. type TrustedScript = string & {
  83. __brand__: 'TrustedScript';
  84. };
  85. type TrustedScriptURL = string & {
  86. __brand__: 'TrustedScriptURL';
  87. };
  88. /**
  89. * Function used to sanitize the value before writing it into the renderer.
  90. */
  91. type SanitizerFn = (value: any, tagName?: string, propName?: string) => string | TrustedHTML | TrustedScript | TrustedScriptURL;
  92. /**
  93. * Stores a list of nodes which need to be removed.
  94. *
  95. * Numbers are indexes into the `LView`
  96. * - index > 0: `removeRNode(lView[0])`
  97. * - index < 0: `removeICU(~lView[0])`
  98. */
  99. interface I18nRemoveOpCodes extends Array<number> {
  100. __brand__: 'I18nRemoveOpCodes';
  101. }
  102. /**
  103. * Array storing OpCode for dynamically creating `i18n` blocks.
  104. *
  105. * Example:
  106. * ```ts
  107. * <I18nCreateOpCode>[
  108. * // For adding text nodes
  109. * // ---------------------
  110. * // Equivalent to:
  111. * // lView[1].appendChild(lView[0] = document.createTextNode('xyz'));
  112. * 'xyz', 0, 1 << SHIFT_PARENT | 0 << SHIFT_REF | AppendChild,
  113. *
  114. * // For adding element nodes
  115. * // ---------------------
  116. * // Equivalent to:
  117. * // lView[1].appendChild(lView[0] = document.createElement('div'));
  118. * ELEMENT_MARKER, 'div', 0, 1 << SHIFT_PARENT | 0 << SHIFT_REF | AppendChild,
  119. *
  120. * // For adding comment nodes
  121. * // ---------------------
  122. * // Equivalent to:
  123. * // lView[1].appendChild(lView[0] = document.createComment(''));
  124. * ICU_MARKER, '', 0, 1 << SHIFT_PARENT | 0 << SHIFT_REF | AppendChild,
  125. *
  126. * // For moving existing nodes to a different location
  127. * // --------------------------------------------------
  128. * // Equivalent to:
  129. * // const node = lView[1];
  130. * // lView[2].appendChild(node);
  131. * 1 << SHIFT_REF | Select, 2 << SHIFT_PARENT | 0 << SHIFT_REF | AppendChild,
  132. *
  133. * // For removing existing nodes
  134. * // --------------------------------------------------
  135. * // const node = lView[1];
  136. * // removeChild(tView.data(1), node, lView);
  137. * 1 << SHIFT_REF | Remove,
  138. *
  139. * // For writing attributes
  140. * // --------------------------------------------------
  141. * // const node = lView[1];
  142. * // node.setAttribute('attr', 'value');
  143. * 1 << SHIFT_REF | Attr, 'attr', 'value'
  144. * ];
  145. * ```
  146. */
  147. interface IcuCreateOpCodes extends Array<number | string | ELEMENT_MARKER | ICU_MARKER | null>, I18nDebug {
  148. __brand__: 'I18nCreateOpCodes';
  149. }
  150. /**
  151. * Marks that the next string is an element name.
  152. *
  153. * See `I18nMutateOpCodes` documentation.
  154. */
  155. declare const ELEMENT_MARKER: ELEMENT_MARKER;
  156. interface ELEMENT_MARKER {
  157. marker: 'element';
  158. }
  159. /**
  160. * Marks that the next string is comment text need for ICU.
  161. *
  162. * See `I18nMutateOpCodes` documentation.
  163. */
  164. declare const ICU_MARKER: ICU_MARKER;
  165. interface ICU_MARKER {
  166. marker: 'ICU';
  167. }
  168. interface I18nDebug {
  169. /**
  170. * Human readable representation of the OpCode arrays.
  171. *
  172. * NOTE: This property only exists if `ngDevMode` is set to `true` and it is not present in
  173. * production. Its presence is purely to help debug issue in development, and should not be relied
  174. * on in production application.
  175. */
  176. debug?: string[];
  177. }
  178. /**
  179. * Array storing OpCode for dynamically creating `i18n` translation DOM elements.
  180. *
  181. * This array creates a sequence of `Text` and `Comment` (as ICU anchor) DOM elements. It consists
  182. * of a pair of `number` and `string` pairs which encode the operations for the creation of the
  183. * translated block.
  184. *
  185. * The number is shifted and encoded according to `I18nCreateOpCode`
  186. *
  187. * Pseudocode:
  188. * ```ts
  189. * const i18nCreateOpCodes = [
  190. * 10 << I18nCreateOpCode.SHIFT, "Text Node add to DOM",
  191. * 11 << I18nCreateOpCode.SHIFT | I18nCreateOpCode.COMMENT, "Comment Node add to DOM",
  192. * 12 << I18nCreateOpCode.SHIFT | I18nCreateOpCode.APPEND_LATER, "Text Node added later"
  193. * ];
  194. *
  195. * for(var i=0; i<i18nCreateOpCodes.length; i++) {
  196. * const opcode = i18NCreateOpCodes[i++];
  197. * const index = opcode >> I18nCreateOpCode.SHIFT;
  198. * const text = i18NCreateOpCodes[i];
  199. * let node: Text|Comment;
  200. * if (opcode & I18nCreateOpCode.COMMENT === I18nCreateOpCode.COMMENT) {
  201. * node = lView[~index] = document.createComment(text);
  202. * } else {
  203. * node = lView[index] = document.createText(text);
  204. * }
  205. * if (opcode & I18nCreateOpCode.APPEND_EAGERLY !== I18nCreateOpCode.APPEND_EAGERLY) {
  206. * parentNode.appendChild(node);
  207. * }
  208. * }
  209. * ```
  210. */
  211. interface I18nCreateOpCodes extends Array<number | string>, I18nDebug {
  212. __brand__: 'I18nCreateOpCodes';
  213. }
  214. /**
  215. * Stores DOM operations which need to be applied to update DOM render tree due to changes in
  216. * expressions.
  217. *
  218. * The basic idea is that `i18nExp` OpCodes capture expression changes and update a change
  219. * mask bit. (Bit 1 for expression 1, bit 2 for expression 2 etc..., bit 32 for expression 32 and
  220. * higher.) The OpCodes then compare its own change mask against the expression change mask to
  221. * determine if the OpCodes should execute.
  222. *
  223. * NOTE: 32nd bit is special as it says 32nd or higher. This way if we have more than 32 bindings
  224. * the code still works, but with lower efficiency. (it is unlikely that a translation would have
  225. * more than 32 bindings.)
  226. *
  227. * These OpCodes can be used by both the i18n block as well as ICU sub-block.
  228. *
  229. * ## Example
  230. *
  231. * Assume
  232. * ```ts
  233. * if (rf & RenderFlags.Update) {
  234. * i18nExp(ctx.exp1); // If changed set mask bit 1
  235. * i18nExp(ctx.exp2); // If changed set mask bit 2
  236. * i18nExp(ctx.exp3); // If changed set mask bit 3
  237. * i18nExp(ctx.exp4); // If changed set mask bit 4
  238. * i18nApply(0); // Apply all changes by executing the OpCodes.
  239. * }
  240. * ```
  241. * We can assume that each call to `i18nExp` sets an internal `changeMask` bit depending on the
  242. * index of `i18nExp`.
  243. *
  244. * ### OpCodes
  245. * ```ts
  246. * <I18nUpdateOpCodes>[
  247. * // The following OpCodes represent: `<div i18n-title="pre{{exp1}}in{{exp2}}post">`
  248. * // If `changeMask & 0b11`
  249. * // has changed then execute update OpCodes.
  250. * // has NOT changed then skip `8` values and start processing next OpCodes.
  251. * 0b11, 8,
  252. * // Concatenate `newValue = 'pre'+lView[bindIndex-4]+'in'+lView[bindIndex-3]+'post';`.
  253. * 'pre', -4, 'in', -3, 'post',
  254. * // Update attribute: `elementAttribute(1, 'title', sanitizerFn(newValue));`
  255. * 1 << SHIFT_REF | Attr, 'title', sanitizerFn,
  256. *
  257. * // The following OpCodes represent: `<div i18n>Hello {{exp3}}!">`
  258. * // If `changeMask & 0b100`
  259. * // has changed then execute update OpCodes.
  260. * // has NOT changed then skip `4` values and start processing next OpCodes.
  261. * 0b100, 4,
  262. * // Concatenate `newValue = 'Hello ' + lView[bindIndex -2] + '!';`.
  263. * 'Hello ', -2, '!',
  264. * // Update text: `lView[1].textContent = newValue;`
  265. * 1 << SHIFT_REF | Text,
  266. *
  267. * // The following OpCodes represent: `<div i18n>{exp4, plural, ... }">`
  268. * // If `changeMask & 0b1000`
  269. * // has changed then execute update OpCodes.
  270. * // has NOT changed then skip `2` values and start processing next OpCodes.
  271. * 0b1000, 2,
  272. * // Concatenate `newValue = lView[bindIndex -1];`.
  273. * -1,
  274. * // Switch ICU: `icuSwitchCase(lView[1], 0, newValue);`
  275. * 0 << SHIFT_ICU | 1 << SHIFT_REF | IcuSwitch,
  276. *
  277. * // Note `changeMask & -1` is always true, so the IcuUpdate will always execute.
  278. * -1, 1,
  279. * // Update ICU: `icuUpdateCase(lView[1], 0);`
  280. * 0 << SHIFT_ICU | 1 << SHIFT_REF | IcuUpdate,
  281. *
  282. * ];
  283. * ```
  284. *
  285. */
  286. interface I18nUpdateOpCodes extends Array<string | number | SanitizerFn | null>, I18nDebug {
  287. __brand__: 'I18nUpdateOpCodes';
  288. }
  289. /**
  290. * Store information for the i18n translation block.
  291. */
  292. interface TI18n {
  293. /**
  294. * A set of OpCodes which will create the Text Nodes and ICU anchors for the translation blocks.
  295. *
  296. * NOTE: The ICU anchors are filled in with ICU Update OpCode.
  297. */
  298. create: I18nCreateOpCodes;
  299. /**
  300. * A set of OpCodes which will be executed on each change detection to determine if any changes to
  301. * DOM are required.
  302. */
  303. update: I18nUpdateOpCodes;
  304. /**
  305. * An AST representing the translated message. This is used for hydration (and serialization),
  306. * while the Update and Create OpCodes are used at runtime.
  307. */
  308. ast: Array<I18nNode>;
  309. /**
  310. * Index of a parent TNode, which represents a host node for this i18n block.
  311. */
  312. parentTNodeIndex: number;
  313. }
  314. /**
  315. * Defines the ICU type of `select` or `plural`
  316. */
  317. declare const enum IcuType {
  318. select = 0,
  319. plural = 1
  320. }
  321. interface TIcu {
  322. /**
  323. * Defines the ICU type of `select` or `plural`
  324. */
  325. type: IcuType;
  326. /**
  327. * Index in `LView` where the anchor node is stored. `<!-- ICU 0:0 -->`
  328. */
  329. anchorIdx: number;
  330. /**
  331. * Currently selected ICU case pointer.
  332. *
  333. * `lView[currentCaseLViewIndex]` stores the currently selected case. This is needed to know how
  334. * to clean up the current case when transitioning no the new case.
  335. *
  336. * If the value stored is:
  337. * `null`: No current case selected.
  338. * `<0`: A flag which means that the ICU just switched and that `icuUpdate` must be executed
  339. * regardless of the `mask`. (After the execution the flag is cleared)
  340. * `>=0` A currently selected case index.
  341. */
  342. currentCaseLViewIndex: number;
  343. /**
  344. * A list of case values which the current ICU will try to match.
  345. *
  346. * The last value is `other`
  347. */
  348. cases: any[];
  349. /**
  350. * A set of OpCodes to apply in order to build up the DOM render tree for the ICU
  351. */
  352. create: IcuCreateOpCodes[];
  353. /**
  354. * A set of OpCodes to apply in order to destroy the DOM render tree for the ICU.
  355. */
  356. remove: I18nRemoveOpCodes[];
  357. /**
  358. * A set of OpCodes to apply in order to update the DOM render tree for the ICU bindings.
  359. */
  360. update: I18nUpdateOpCodes[];
  361. }
  362. type I18nNode = I18nTextNode | I18nElementNode | I18nICUNode | I18nPlaceholderNode;
  363. /**
  364. * Represents a block of text in a translation, such as `Hello, {{ name }}!`.
  365. */
  366. interface I18nTextNode {
  367. /** The AST node kind */
  368. kind: I18nNodeKind.TEXT;
  369. /** The LView index */
  370. index: number;
  371. }
  372. /**
  373. * Represents a simple DOM element in a translation, such as `<div>...</div>`
  374. */
  375. interface I18nElementNode {
  376. /** The AST node kind */
  377. kind: I18nNodeKind.ELEMENT;
  378. /** The LView index */
  379. index: number;
  380. /** The child nodes */
  381. children: Array<I18nNode>;
  382. }
  383. /**
  384. * Represents an ICU in a translation.
  385. */
  386. interface I18nICUNode {
  387. /** The AST node kind */
  388. kind: I18nNodeKind.ICU;
  389. /** The LView index */
  390. index: number;
  391. /** The branching cases */
  392. cases: Array<Array<I18nNode>>;
  393. /** The LView index that stores the active case */
  394. currentCaseLViewIndex: number;
  395. }
  396. /**
  397. * Represents special content that is embedded into the translation. This can
  398. * either be a special built-in element, such as <ng-container> and <ng-content>,
  399. * or it can be a sub-template, for example, from a structural directive.
  400. */
  401. interface I18nPlaceholderNode {
  402. /** The AST node kind */
  403. kind: I18nNodeKind.PLACEHOLDER;
  404. /** The LView index */
  405. index: number;
  406. /** The child nodes */
  407. children: Array<I18nNode>;
  408. /** The placeholder type */
  409. type: I18nPlaceholderType;
  410. }
  411. declare const enum I18nPlaceholderType {
  412. ELEMENT = 0,
  413. SUBTEMPLATE = 1
  414. }
  415. declare const enum I18nNodeKind {
  416. TEXT = 0,
  417. ELEMENT = 1,
  418. PLACEHOLDER = 2,
  419. ICU = 3
  420. }
  421. /**
  422. * The goal here is to make sure that the browser DOM API is the Renderer.
  423. * We do this by defining a subset of DOM API to be the renderer and then
  424. * use that at runtime for rendering.
  425. *
  426. * At runtime we can then use the DOM api directly, in server or web-worker
  427. * it will be easy to implement such API.
  428. */
  429. /** Subset of API needed for appending elements and text nodes. */
  430. interface RNode {
  431. /**
  432. * Returns the parent Element, Document, or DocumentFragment
  433. */
  434. parentNode: RNode | null;
  435. /**
  436. * Returns the parent Element if there is one
  437. */
  438. parentElement: RElement | null;
  439. /**
  440. * Gets the Node immediately following this one in the parent's childNodes
  441. */
  442. nextSibling: RNode | null;
  443. /**
  444. * Insert a child node.
  445. *
  446. * Used exclusively for adding View root nodes into ViewAnchor location.
  447. */
  448. insertBefore(newChild: RNode, refChild: RNode | null, isViewRoot: boolean): void;
  449. /**
  450. * Append a child node.
  451. *
  452. * Used exclusively for building up DOM which are static (ie not View roots)
  453. */
  454. appendChild(newChild: RNode): RNode;
  455. }
  456. /**
  457. * Subset of API needed for writing attributes, properties, and setting up
  458. * listeners on Element.
  459. */
  460. interface RElement extends RNode {
  461. firstChild: RNode | null;
  462. style: RCssStyleDeclaration;
  463. classList: RDomTokenList;
  464. className: string;
  465. tagName: string;
  466. textContent: string | null;
  467. hasAttribute(name: string): boolean;
  468. getAttribute(name: string): string | null;
  469. setAttribute(name: string, value: string | TrustedHTML | TrustedScript | TrustedScriptURL): void;
  470. removeAttribute(name: string): void;
  471. setAttributeNS(namespaceURI: string, qualifiedName: string, value: string | TrustedHTML | TrustedScript | TrustedScriptURL): void;
  472. addEventListener(type: string, listener: EventListener, useCapture?: boolean): void;
  473. removeEventListener(type: string, listener?: EventListener, options?: boolean): void;
  474. remove(): void;
  475. setProperty?(name: string, value: any): void;
  476. }
  477. interface RCssStyleDeclaration {
  478. removeProperty(propertyName: string): string;
  479. setProperty(propertyName: string, value: string | null, priority?: string): void;
  480. }
  481. interface RDomTokenList {
  482. add(token: string): void;
  483. remove(token: string): void;
  484. }
  485. interface RText extends RNode {
  486. textContent: string | null;
  487. }
  488. interface RComment extends RNode {
  489. textContent: string | null;
  490. }
  491. /**
  492. * Keys within serialized view data structure to represent various
  493. * parts. See the `SerializedView` interface below for additional information.
  494. */
  495. declare const ELEMENT_CONTAINERS = "e";
  496. declare const TEMPLATES = "t";
  497. declare const CONTAINERS = "c";
  498. declare const MULTIPLIER = "x";
  499. declare const NUM_ROOT_NODES = "r";
  500. declare const TEMPLATE_ID = "i";
  501. declare const NODES = "n";
  502. declare const DISCONNECTED_NODES = "d";
  503. declare const I18N_DATA = "l";
  504. declare const DEFER_BLOCK_ID = "di";
  505. declare const DEFER_BLOCK_STATE = "s";
  506. /**
  507. * Represents element containers within this view, stored as key-value pairs
  508. * where key is an index of a container in an LView (also used in the
  509. * `elementContainerStart` instruction), the value is the number of root nodes
  510. * in this container. This information is needed to locate an anchor comment
  511. * node that goes after all container nodes.
  512. */
  513. interface SerializedElementContainers {
  514. [key: number]: number;
  515. }
  516. /**
  517. * Serialized data structure that contains relevant hydration
  518. * annotation information that describes a given hydration boundary
  519. * (e.g. a component).
  520. */
  521. interface SerializedView {
  522. /**
  523. * Serialized information about <ng-container>s.
  524. */
  525. [ELEMENT_CONTAINERS]?: SerializedElementContainers;
  526. /**
  527. * Serialized information about templates.
  528. * Key-value pairs where a key is an index of the corresponding
  529. * `template` instruction and the value is a unique id that can
  530. * be used during hydration to identify that template.
  531. */
  532. [TEMPLATES]?: Record<number, string>;
  533. /**
  534. * Serialized information about view containers.
  535. * Key-value pairs where a key is an index of the corresponding
  536. * LContainer entry within an LView, and the value is a list
  537. * of serialized information about views within this container.
  538. */
  539. [CONTAINERS]?: Record<number, SerializedContainerView[]>;
  540. /**
  541. * Serialized information about nodes in a template.
  542. * Key-value pairs where a key is an index of the corresponding
  543. * DOM node in an LView and the value is a path that describes
  544. * the location of this node (as a set of navigation instructions).
  545. */
  546. [NODES]?: Record<number, string>;
  547. /**
  548. * A list of ids which represents a set of nodes disconnected
  549. * from the DOM tree at the serialization time, but otherwise
  550. * present in the internal data structures.
  551. *
  552. * This information is used to avoid triggering the hydration
  553. * logic for such nodes and instead use a regular "creation mode".
  554. */
  555. [DISCONNECTED_NODES]?: number[];
  556. /**
  557. * Serialized information about i18n blocks in a template.
  558. * Key-value pairs where a key is an index of the corresponding
  559. * i18n entry within an LView, and the value is a list of
  560. * active ICU cases.
  561. */
  562. [I18N_DATA]?: Record<number, number[]>;
  563. /**
  564. * If this view represents a `@defer` block, this field contains
  565. * unique id of the block.
  566. */
  567. [DEFER_BLOCK_ID]?: string;
  568. /**
  569. * This field represents a status, based on the `DeferBlockState` enum.
  570. */
  571. [DEFER_BLOCK_STATE]?: number;
  572. }
  573. /**
  574. * Serialized data structure that contains relevant hydration
  575. * annotation information about a view that is a part of a
  576. * ViewContainer collection.
  577. */
  578. interface SerializedContainerView extends SerializedView {
  579. /**
  580. * Unique id that represents a TView that was used to create
  581. * a given instance of a view:
  582. * - TViewType.Embedded: a unique id generated during serialization on the server
  583. * - TViewType.Component: an id generated based on component properties
  584. * (see `getComponentId` function for details)
  585. */
  586. [TEMPLATE_ID]: string;
  587. /**
  588. * Number of root nodes that belong to this view.
  589. * This information is needed to effectively traverse the DOM tree
  590. * and identify segments that belong to different views.
  591. */
  592. [NUM_ROOT_NODES]: number;
  593. /**
  594. * Number of times this view is repeated.
  595. * This is used to avoid serializing and sending the same hydration
  596. * information about similar views (for example, produced by *ngFor).
  597. */
  598. [MULTIPLIER]?: number;
  599. }
  600. /**
  601. * An object that contains hydration-related information serialized
  602. * on the server, as well as the necessary references to segments of
  603. * the DOM, to facilitate the hydration process for a given hydration
  604. * boundary on the client.
  605. */
  606. interface DehydratedView {
  607. /**
  608. * The readonly hydration annotation data.
  609. */
  610. data: Readonly<SerializedView>;
  611. /**
  612. * A reference to the first child in a DOM segment associated
  613. * with a given hydration boundary.
  614. *
  615. * Once a view becomes hydrated, the value is set to `null`, which
  616. * indicates that further detaching/attaching view actions should result
  617. * in invoking corresponding DOM actions (attaching DOM nodes action is
  618. * skipped when we hydrate, since nodes are already in the DOM).
  619. */
  620. firstChild: RNode | null;
  621. /**
  622. * Stores references to first nodes in DOM segments that
  623. * represent either an <ng-container> or a view container.
  624. */
  625. segmentHeads?: {
  626. [index: number]: RNode | null;
  627. };
  628. /**
  629. * An instance of a Set that represents nodes disconnected from
  630. * the DOM tree at the serialization time, but otherwise present
  631. * in the internal data structures.
  632. *
  633. * The Set is based on the `SerializedView[DISCONNECTED_NODES]` data
  634. * and is needed to have constant-time lookups.
  635. *
  636. * If the value is `null`, it means that there were no disconnected
  637. * nodes detected in this view at serialization time.
  638. */
  639. disconnectedNodes?: Set<number> | null;
  640. /**
  641. * A mapping from a view to the first child to begin claiming nodes.
  642. *
  643. * This mapping is generated by an i18n block, and is the source of
  644. * truth for the nodes inside of it.
  645. */
  646. i18nNodes?: Map<number, RNode | null>;
  647. /**
  648. * A mapping from the index of an ICU node to dehydrated data for it.
  649. *
  650. * This information is used during the hydration process on the client.
  651. * ICU cases that were active during server-side rendering will be added
  652. * to the map. The hydration logic will "claim" matching cases, removing
  653. * them from the map. The remaining entries are "unclaimed", and will be
  654. * removed from the DOM during hydration cleanup.
  655. */
  656. dehydratedIcuData?: Map<number, DehydratedIcuData>;
  657. }
  658. /**
  659. * An object that contains hydration-related information serialized
  660. * on the server, as well as the necessary references to segments of
  661. * the DOM, to facilitate the hydration process for a given view
  662. * inside a view container (either an embedded view or a view created
  663. * for a component).
  664. */
  665. interface DehydratedContainerView extends DehydratedView {
  666. data: Readonly<SerializedContainerView>;
  667. }
  668. /**
  669. * An object that contains information about a dehydrated ICU case,
  670. * to facilitate cleaning up ICU cases that were active during
  671. * server-side rendering, but not during hydration.
  672. */
  673. interface DehydratedIcuData {
  674. /**
  675. * The case index that this data represents.
  676. */
  677. case: number;
  678. /**
  679. * A reference back to the AST for the ICU node. This allows the
  680. * AST to be used to clean up dehydrated nodes.
  681. */
  682. node: I18nICUNode;
  683. }
  684. /**
  685. * `KeyValueArray` is an array where even positions contain keys and odd positions contain values.
  686. *
  687. * `KeyValueArray` provides a very efficient way of iterating over its contents. For small
  688. * sets (~10) the cost of binary searching an `KeyValueArray` has about the same performance
  689. * characteristics that of a `Map` with significantly better memory footprint.
  690. *
  691. * If used as a `Map` the keys are stored in alphabetical order so that they can be binary searched
  692. * for retrieval.
  693. *
  694. * See: `keyValueArraySet`, `keyValueArrayGet`, `keyValueArrayIndexOf`, `keyValueArrayDelete`.
  695. */
  696. interface KeyValueArray<VALUE> extends Array<VALUE | string> {
  697. __brand__: 'array-map';
  698. }
  699. /**
  700. * Value stored in the `TData` which is needed to re-concatenate the styling.
  701. *
  702. * See: `TStylingKeyPrimitive` and `TStylingStatic`
  703. */
  704. type TStylingKey = TStylingKeyPrimitive | TStylingStatic;
  705. /**
  706. * The primitive portion (`TStylingStatic` removed) of the value stored in the `TData` which is
  707. * needed to re-concatenate the styling.
  708. *
  709. * - `string`: Stores the property name. Used with `ɵɵstyleProp`/`ɵɵclassProp` instruction.
  710. * - `null`: Represents map, so there is no name. Used with `ɵɵstyleMap`/`ɵɵclassMap`.
  711. * - `false`: Represents an ignore case. This happens when `ɵɵstyleProp`/`ɵɵclassProp` instruction
  712. * is combined with directive which shadows its input `@Input('class')`. That way the binding
  713. * should not participate in the styling resolution.
  714. */
  715. type TStylingKeyPrimitive = string | null | false;
  716. /**
  717. * Store the static values for the styling binding.
  718. *
  719. * The `TStylingStatic` is just `KeyValueArray` where key `""` (stored at location 0) contains the
  720. * `TStylingKey` (stored at location 1). In other words this wraps the `TStylingKey` such that the
  721. * `""` contains the wrapped value.
  722. *
  723. * When instructions are resolving styling they may need to look forward or backwards in the linked
  724. * list to resolve the value. For this reason we have to make sure that he linked list also contains
  725. * the static values. However the list only has space for one item per styling instruction. For this
  726. * reason we store the static values here as part of the `TStylingKey`. This means that the
  727. * resolution function when looking for a value needs to first look at the binding value, and than
  728. * at `TStylingKey` (if it exists).
  729. *
  730. * Imagine we have:
  731. *
  732. * ```angular-ts
  733. * <div class="TEMPLATE" my-dir>
  734. *
  735. * @Directive({
  736. * host: {
  737. * class: 'DIR',
  738. * '[class.dynamic]': 'exp' // ɵɵclassProp('dynamic', ctx.exp);
  739. * }
  740. * })
  741. * ```
  742. *
  743. * In the above case the linked list will contain one item:
  744. *
  745. * ```ts
  746. * // assume binding location: 10 for `ɵɵclassProp('dynamic', ctx.exp);`
  747. * tData[10] = <TStylingStatic>[
  748. * '': 'dynamic', // This is the wrapped value of `TStylingKey`
  749. * 'DIR': true, // This is the default static value of directive binding.
  750. * ];
  751. * tData[10 + 1] = 0; // We don't have prev/next.
  752. *
  753. * lView[10] = undefined; // assume `ctx.exp` is `undefined`
  754. * lView[10 + 1] = undefined; // Just normalized `lView[10]`
  755. * ```
  756. *
  757. * So when the function is resolving styling value, it first needs to look into the linked list
  758. * (there is none) and than into the static `TStylingStatic` too see if there is a default value for
  759. * `dynamic` (there is not). Therefore it is safe to remove it.
  760. *
  761. * If setting `true` case:
  762. * ```ts
  763. * lView[10] = true; // assume `ctx.exp` is `true`
  764. * lView[10 + 1] = true; // Just normalized `lView[10]`
  765. * ```
  766. * So when the function is resolving styling value, it first needs to look into the linked list
  767. * (there is none) and than into `TNode.residualClass` (TNode.residualStyle) which contains
  768. * ```ts
  769. * tNode.residualClass = [
  770. * 'TEMPLATE': true,
  771. * ];
  772. * ```
  773. *
  774. * This means that it is safe to add class.
  775. */
  776. interface TStylingStatic extends KeyValueArray<any> {
  777. }
  778. /**
  779. * This is a branded number which contains previous and next index.
  780. *
  781. * When we come across styling instructions we need to store the `TStylingKey` in the correct
  782. * order so that we can re-concatenate the styling value in the desired priority.
  783. *
  784. * The insertion can happen either at the:
  785. * - end of template as in the case of coming across additional styling instruction in the template
  786. * - in front of the template in the case of coming across additional instruction in the
  787. * `hostBindings`.
  788. *
  789. * We use `TStylingRange` to store the previous and next index into the `TData` where the template
  790. * bindings can be found.
  791. *
  792. * - bit 0 is used to mark that the previous index has a duplicate for current value.
  793. * - bit 1 is used to mark that the next index has a duplicate for the current value.
  794. * - bits 2-16 are used to encode the next/tail of the template.
  795. * - bits 17-32 are used to encode the previous/head of template.
  796. *
  797. * NODE: *duplicate* false implies that it is statically known that this binding will not collide
  798. * with other bindings and therefore there is no need to check other bindings. For example the
  799. * bindings in `<div [style.color]="exp" [style.width]="exp">` will never collide and will have
  800. * their bits set accordingly. Previous duplicate means that we may need to check previous if the
  801. * current binding is `null`. Next duplicate means that we may need to check next bindings if the
  802. * current binding is not `null`.
  803. *
  804. * NOTE: `0` has special significance and represents `null` as in no additional pointer.
  805. */
  806. type TStylingRange = number & {
  807. __brand__: 'TStylingRange';
  808. };
  809. /**
  810. * A set of marker values to be used in the attributes arrays. These markers indicate that some
  811. * items are not regular attributes and the processing should be adapted accordingly.
  812. */
  813. declare const enum AttributeMarker {
  814. /**
  815. * An implicit marker which indicates that the value in the array are of `attributeKey`,
  816. * `attributeValue` format.
  817. *
  818. * NOTE: This is implicit as it is the type when no marker is present in array. We indicate that
  819. * it should not be present at runtime by the negative number.
  820. */
  821. ImplicitAttributes = -1,
  822. /**
  823. * Marker indicates that the following 3 values in the attributes array are:
  824. * namespaceUri, attributeName, attributeValue
  825. * in that order.
  826. */
  827. NamespaceURI = 0,
  828. /**
  829. * Signals class declaration.
  830. *
  831. * Each value following `Classes` designates a class name to include on the element.
  832. * ## Example:
  833. *
  834. * Given:
  835. * ```html
  836. * <div class="foo bar baz">...</div>
  837. * ```
  838. *
  839. * the generated code is:
  840. * ```ts
  841. * var _c1 = [AttributeMarker.Classes, 'foo', 'bar', 'baz'];
  842. * ```
  843. */
  844. Classes = 1,
  845. /**
  846. * Signals style declaration.
  847. *
  848. * Each pair of values following `Styles` designates a style name and value to include on the
  849. * element.
  850. * ## Example:
  851. *
  852. * Given:
  853. * ```html
  854. * <div style="width:100px; height:200px; color:red">...</div>
  855. * ```
  856. *
  857. * the generated code is:
  858. * ```ts
  859. * var _c1 = [AttributeMarker.Styles, 'width', '100px', 'height'. '200px', 'color', 'red'];
  860. * ```
  861. */
  862. Styles = 2,
  863. /**
  864. * Signals that the following attribute names were extracted from input or output bindings.
  865. *
  866. * For example, given the following HTML:
  867. *
  868. * ```html
  869. * <div moo="car" [foo]="exp" (bar)="doSth()">
  870. * ```
  871. *
  872. * the generated code is:
  873. *
  874. * ```ts
  875. * var _c1 = ['moo', 'car', AttributeMarker.Bindings, 'foo', 'bar'];
  876. * ```
  877. */
  878. Bindings = 3,
  879. /**
  880. * Signals that the following attribute names were hoisted from an inline-template declaration.
  881. *
  882. * For example, given the following HTML:
  883. *
  884. * ```html
  885. * <div *ngFor="let value of values; trackBy:trackBy" dirA [dirB]="value">
  886. * ```
  887. *
  888. * the generated code for the `template()` instruction would include:
  889. *
  890. * ```
  891. * ['dirA', '', AttributeMarker.Bindings, 'dirB', AttributeMarker.Template, 'ngFor', 'ngForOf',
  892. * 'ngForTrackBy', 'let-value']
  893. * ```
  894. *
  895. * while the generated code for the `element()` instruction inside the template function would
  896. * include:
  897. *
  898. * ```
  899. * ['dirA', '', AttributeMarker.Bindings, 'dirB']
  900. * ```
  901. */
  902. Template = 4,
  903. /**
  904. * Signals that the following attribute is `ngProjectAs` and its value is a parsed
  905. * `CssSelector`.
  906. *
  907. * For example, given the following HTML:
  908. *
  909. * ```html
  910. * <h1 attr="value" ngProjectAs="[title]">
  911. * ```
  912. *
  913. * the generated code for the `element()` instruction would include:
  914. *
  915. * ```ts
  916. * ['attr', 'value', AttributeMarker.ProjectAs, ['', 'title', '']]
  917. * ```
  918. */
  919. ProjectAs = 5,
  920. /**
  921. * Signals that the following attribute will be translated by runtime i18n
  922. *
  923. * For example, given the following HTML:
  924. *
  925. * ```html
  926. * <div moo="car" foo="value" i18n-foo [bar]="binding" i18n-bar>
  927. * ```
  928. *
  929. * the generated code is:
  930. *
  931. * ```ts
  932. * var _c1 = ['moo', 'car', AttributeMarker.I18n, 'foo', 'bar'];
  933. * ```
  934. */
  935. I18n = 6
  936. }
  937. /**
  938. * Expresses a single CSS Selector.
  939. *
  940. * Beginning of array
  941. * - First index: element name
  942. * - Subsequent odd indices: attr keys
  943. * - Subsequent even indices: attr values
  944. *
  945. * After SelectorFlags.CLASS flag
  946. * - Class name values
  947. *
  948. * SelectorFlags.NOT flag
  949. * - Changes the mode to NOT
  950. * - Can be combined with other flags to set the element / attr / class mode
  951. *
  952. * e.g. SelectorFlags.NOT | SelectorFlags.ELEMENT
  953. *
  954. * Example:
  955. * Original: `div.foo.bar[attr1=val1][attr2]`
  956. * Parsed: ['div', 'attr1', 'val1', 'attr2', '', SelectorFlags.CLASS, 'foo', 'bar']
  957. *
  958. * Original: 'div[attr1]:not(.foo[attr2])
  959. * Parsed: [
  960. * 'div', 'attr1', '',
  961. * SelectorFlags.NOT | SelectorFlags.ATTRIBUTE 'attr2', '', SelectorFlags.CLASS, 'foo'
  962. * ]
  963. *
  964. * See more examples in node_selector_matcher_spec.ts
  965. */
  966. type CssSelector = (string | SelectorFlags)[];
  967. /**
  968. * A list of CssSelectors.
  969. *
  970. * A directive or component can have multiple selectors. This type is used for
  971. * directive defs so any of the selectors in the list will match that directive.
  972. *
  973. * Original: 'form, [ngForm]'
  974. * Parsed: [['form'], ['', 'ngForm', '']]
  975. */
  976. type CssSelectorList = CssSelector[];
  977. /**
  978. * List of slots for a projection. A slot can be either based on a parsed CSS selector
  979. * which will be used to determine nodes which are projected into that slot.
  980. *
  981. * When set to "*", the slot is reserved and can be used for multi-slot projection
  982. * using {@link ViewContainerRef#createComponent}. The last slot that specifies the
  983. * wildcard selector will retrieve all projectable nodes which do not match any selector.
  984. */
  985. type ProjectionSlots = (CssSelectorList | '*')[];
  986. /** Flags used to build up CssSelectors */
  987. declare const enum SelectorFlags {
  988. /** Indicates this is the beginning of a new negative selector */
  989. NOT = 1,
  990. /** Mode for matching attributes */
  991. ATTRIBUTE = 2,
  992. /** Mode for matching tag names */
  993. ELEMENT = 4,
  994. /** Mode for matching class names */
  995. CLASS = 8
  996. }
  997. /**
  998. * TNodeType corresponds to the {@link TNode} `type` property.
  999. *
  1000. * NOTE: type IDs are such that we use each bit to denote a type. This is done so that we can easily
  1001. * check if the `TNode` is of more than one type.
  1002. *
  1003. * `if (tNode.type === TNodeType.Text || tNode.type === TNode.Element)`
  1004. * can be written as:
  1005. * `if (tNode.type & (TNodeType.Text | TNodeType.Element))`
  1006. *
  1007. * However any given `TNode` can only be of one type.
  1008. */
  1009. declare const enum TNodeType {
  1010. /**
  1011. * The TNode contains information about a DOM element aka {@link RText}.
  1012. */
  1013. Text = 1,
  1014. /**
  1015. * The TNode contains information about a DOM element aka {@link RElement}.
  1016. */
  1017. Element = 2,
  1018. /**
  1019. * The TNode contains information about an {@link LContainer} for embedded views.
  1020. */
  1021. Container = 4,
  1022. /**
  1023. * The TNode contains information about an `<ng-container>` element {@link RNode}.
  1024. */
  1025. ElementContainer = 8,
  1026. /**
  1027. * The TNode contains information about an `<ng-content>` projection
  1028. */
  1029. Projection = 16,
  1030. /**
  1031. * The TNode contains information about an ICU comment used in `i18n`.
  1032. */
  1033. Icu = 32,
  1034. /**
  1035. * Special node type representing a placeholder for future `TNode` at this location.
  1036. *
  1037. * I18n translation blocks are created before the element nodes which they contain. (I18n blocks
  1038. * can span over many elements.) Because i18n `TNode`s (representing text) are created first they
  1039. * often may need to point to element `TNode`s which are not yet created. In such a case we create
  1040. * a `Placeholder` `TNode`. This allows the i18n to structurally link the `TNode`s together
  1041. * without knowing any information about the future nodes which will be at that location.
  1042. *
  1043. * On `firstCreatePass` When element instruction executes it will try to create a `TNode` at that
  1044. * location. Seeing a `Placeholder` `TNode` already there tells the system that it should reuse
  1045. * existing `TNode` (rather than create a new one) and just update the missing information.
  1046. */
  1047. Placeholder = 64,
  1048. /**
  1049. * The TNode contains information about a `@let` declaration.
  1050. */
  1051. LetDeclaration = 128,
  1052. AnyRNode = 3,// Text | Element
  1053. AnyContainer = 12
  1054. }
  1055. /**
  1056. * Corresponds to the TNode.flags property.
  1057. */
  1058. declare const enum TNodeFlags {
  1059. /** Bit #1 - This bit is set if the node is a host for any directive (including a component) */
  1060. isDirectiveHost = 1,
  1061. /** Bit #2 - This bit is set if the node has been projected */
  1062. isProjected = 2,
  1063. /** Bit #3 - This bit is set if any directive on this node has content queries */
  1064. hasContentQuery = 4,
  1065. /** Bit #4 - This bit is set if the node has any "class" inputs */
  1066. hasClassInput = 8,
  1067. /** Bit #5 - This bit is set if the node has any "style" inputs */
  1068. hasStyleInput = 16,
  1069. /** Bit #6 - This bit is set if the node has been detached by i18n */
  1070. isDetached = 32,
  1071. /**
  1072. * Bit #7 - This bit is set if the node has directives with host bindings.
  1073. *
  1074. * This flags allows us to guard host-binding logic and invoke it only on nodes
  1075. * that actually have directives with host bindings.
  1076. */
  1077. hasHostBindings = 64,
  1078. /**
  1079. * Bit #8 - This bit is set if the node is a located inside skip hydration block.
  1080. */
  1081. inSkipHydrationBlock = 128,
  1082. /**
  1083. * Bit #9 - This bit is set if the node is a start of a set of control flow blocks.
  1084. */
  1085. isControlFlowStart = 256,
  1086. /**
  1087. * Bit #10 - This bit is set if the node is within a set of control flow blocks.
  1088. */
  1089. isInControlFlow = 512
  1090. }
  1091. /**
  1092. * Corresponds to the TNode.providerIndexes property.
  1093. */
  1094. declare const enum TNodeProviderIndexes {
  1095. /** The index of the first provider on this node is encoded on the least significant bits. */
  1096. ProvidersStartIndexMask = 1048575,
  1097. /**
  1098. * The count of view providers from the component on this node is
  1099. * encoded on the 20 most significant bits.
  1100. */
  1101. CptViewProvidersCountShift = 20,
  1102. CptViewProvidersCountShifter = 1048576
  1103. }
  1104. /**
  1105. * A combination of:
  1106. * - Attribute names and values.
  1107. * - Special markers acting as flags to alter attributes processing.
  1108. * - Parsed ngProjectAs selectors.
  1109. */
  1110. type TAttributes = (string | AttributeMarker | CssSelector)[];
  1111. /**
  1112. * Constants that are associated with a view. Includes:
  1113. * - Attribute arrays.
  1114. * - Local definition arrays.
  1115. * - Translated messages (i18n).
  1116. */
  1117. type TConstants = (TAttributes | string)[];
  1118. /**
  1119. * Factory function that returns an array of consts. Consts can be represented as a function in
  1120. * case any additional statements are required to define consts in the list. An example is i18n
  1121. * where additional i18n calls are generated, which should be executed when consts are requested
  1122. * for the first time.
  1123. */
  1124. type TConstantsFactory = () => TConstants;
  1125. /**
  1126. * TConstants type that describes how the `consts` field is generated on ComponentDef: it can be
  1127. * either an array or a factory function that returns that array.
  1128. */
  1129. type TConstantsOrFactory = TConstants | TConstantsFactory;
  1130. /**
  1131. * Binding data (flyweight) for a particular node that is shared between all templates
  1132. * of a specific type.
  1133. *
  1134. * If a property is:
  1135. * - PropertyAliases: that property's data was generated and this is it
  1136. * - Null: that property's data was already generated and nothing was found.
  1137. * - Undefined: that property's data has not yet been generated
  1138. *
  1139. * see: https://en.wikipedia.org/wiki/Flyweight_pattern for more on the Flyweight pattern
  1140. */
  1141. interface TNode {
  1142. /** The type of the TNode. See TNodeType. */
  1143. type: TNodeType;
  1144. /**
  1145. * Index of the TNode in TView.data and corresponding native element in LView.
  1146. *
  1147. * This is necessary to get from any TNode to its corresponding native element when
  1148. * traversing the node tree.
  1149. *
  1150. * If index is -1, this is a dynamically created container node or embedded view node.
  1151. */
  1152. index: number;
  1153. /**
  1154. * Insert before existing DOM node index.
  1155. *
  1156. * When DOM nodes are being inserted, normally they are being appended as they are created.
  1157. * Under i18n case, the translated text nodes are created ahead of time as part of the
  1158. * `ɵɵi18nStart` instruction which means that this `TNode` can't just be appended and instead
  1159. * needs to be inserted using `insertBeforeIndex` semantics.
  1160. *
  1161. * Additionally sometimes it is necessary to insert new text nodes as a child of this `TNode`. In
  1162. * such a case the value stores an array of text nodes to insert.
  1163. *
  1164. * Example:
  1165. * ```html
  1166. * <div i18n>
  1167. * Hello <span>World</span>!
  1168. * </div>
  1169. * ```
  1170. * In the above example the `ɵɵi18nStart` instruction can create `Hello `, `World` and `!` text
  1171. * nodes. It can also insert `Hello ` and `!` text node as a child of `<div>`, but it can't
  1172. * insert `World` because the `<span>` node has not yet been created. In such a case the
  1173. * `<span>` `TNode` will have an array which will direct the `<span>` to not only insert
  1174. * itself in front of `!` but also to insert the `World` (created by `ɵɵi18nStart`) into
  1175. * `<span>` itself.
  1176. *
  1177. * Pseudo code:
  1178. * ```ts
  1179. * if (insertBeforeIndex === null) {
  1180. * // append as normal
  1181. * } else if (Array.isArray(insertBeforeIndex)) {
  1182. * // First insert current `TNode` at correct location
  1183. * const currentNode = lView[this.index];
  1184. * parentNode.insertBefore(currentNode, lView[this.insertBeforeIndex[0]]);
  1185. * // Now append all of the children
  1186. * for(let i=1; i<this.insertBeforeIndex; i++) {
  1187. * currentNode.appendChild(lView[this.insertBeforeIndex[i]]);
  1188. * }
  1189. * } else {
  1190. * parentNode.insertBefore(lView[this.index], lView[this.insertBeforeIndex])
  1191. * }
  1192. * ```
  1193. * - null: Append as normal using `parentNode.appendChild`
  1194. * - `number`: Append using
  1195. * `parentNode.insertBefore(lView[this.index], lView[this.insertBeforeIndex])`
  1196. *
  1197. * *Initialization*
  1198. *
  1199. * Because `ɵɵi18nStart` executes before nodes are created, on `TView.firstCreatePass` it is not
  1200. * possible for `ɵɵi18nStart` to set the `insertBeforeIndex` value as the corresponding `TNode`
  1201. * has not yet been created. For this reason the `ɵɵi18nStart` creates a `TNodeType.Placeholder`
  1202. * `TNode` at that location. See `TNodeType.Placeholder` for more information.
  1203. */
  1204. insertBeforeIndex: InsertBeforeIndex;
  1205. /**
  1206. * The index of the closest injector in this node's LView.
  1207. *
  1208. * If the index === -1, there is no injector on this node or any ancestor node in this view.
  1209. *
  1210. * If the index !== -1, it is the index of this node's injector OR the index of a parent
  1211. * injector in the same view. We pass the parent injector index down the node tree of a view so
  1212. * it's possible to find the parent injector without walking a potentially deep node tree.
  1213. * Injector indices are not set across view boundaries because there could be multiple component
  1214. * hosts.
  1215. *
  1216. * If tNode.injectorIndex === tNode.parent.injectorIndex, then the index belongs to a parent
  1217. * injector.
  1218. */
  1219. injectorIndex: number;
  1220. /** Stores starting index of the directives. */
  1221. directiveStart: number;
  1222. /**
  1223. * Stores final exclusive index of the directives.
  1224. *
  1225. * The area right behind the `directiveStart-directiveEnd` range is used to allocate the
  1226. * `HostBindingFunction` `vars` (or null if no bindings.) Therefore `directiveEnd` is used to set
  1227. * `LFrame.bindingRootIndex` before `HostBindingFunction` is executed.
  1228. */
  1229. directiveEnd: number;
  1230. /**
  1231. * Offset from the `directiveStart` at which the component (one at most) of the node is stored.
  1232. * Set to -1 if no components have been applied to the node. Component index can be found using
  1233. * `directiveStart + componentOffset`.
  1234. */
  1235. componentOffset: number;
  1236. /**
  1237. * Stores the last directive which had a styling instruction.
  1238. *
  1239. * Initial value of this is `-1` which means that no `hostBindings` styling instruction has
  1240. * executed. As `hostBindings` instructions execute they set the value to the index of the
  1241. * `DirectiveDef` which contained the last `hostBindings` styling instruction.
  1242. *
  1243. * Valid values are:
  1244. * - `-1` No `hostBindings` instruction has executed.
  1245. * - `directiveStart <= directiveStylingLast < directiveEnd`: Points to the `DirectiveDef` of
  1246. * the last styling instruction which executed in the `hostBindings`.
  1247. *
  1248. * This data is needed so that styling instructions know which static styling data needs to be
  1249. * collected from the `DirectiveDef.hostAttrs`. A styling instruction needs to collect all data
  1250. * since last styling instruction.
  1251. */
  1252. directiveStylingLast: number;
  1253. /**
  1254. * Stores indexes of property bindings. This field is only set in the ngDevMode and holds
  1255. * indexes of property bindings so TestBed can get bound property metadata for a given node.
  1256. */
  1257. propertyBindings: number[] | null;
  1258. /**
  1259. * Stores if Node isComponent, isProjected, hasContentQuery, hasClassInput and hasStyleInput
  1260. * etc.
  1261. */
  1262. flags: TNodeFlags;
  1263. /**
  1264. * This number stores two values using its bits:
  1265. *
  1266. * - the index of the first provider on that node (first 16 bits)
  1267. * - the count of view providers from the component on this node (last 16 bits)
  1268. */
  1269. providerIndexes: TNodeProviderIndexes;
  1270. /**
  1271. * The value name associated with this node.
  1272. * if type:
  1273. * `TNodeType.Text`: text value
  1274. * `TNodeType.Element`: tag name
  1275. * `TNodeType.ICUContainer`: `TIcu`
  1276. */
  1277. value: any;
  1278. /**
  1279. * Attributes associated with an element. We need to store attributes to support various
  1280. * use-cases (attribute injection, content projection with selectors, directives matching).
  1281. * Attributes are stored statically because reading them from the DOM would be way too slow for
  1282. * content projection and queries.
  1283. *
  1284. * Since attrs will always be calculated first, they will never need to be marked undefined by
  1285. * other instructions.
  1286. *
  1287. * For regular attributes a name of an attribute and its value alternate in the array.
  1288. * e.g. ['role', 'checkbox']
  1289. * This array can contain flags that will indicate "special attributes" (attributes with
  1290. * namespaces, attributes extracted from bindings and outputs).
  1291. */
  1292. attrs: TAttributes | null;
  1293. /**
  1294. * Same as `TNode.attrs` but contains merged data across all directive host bindings.
  1295. *
  1296. * We need to keep `attrs` as unmerged so that it can be used for attribute selectors.
  1297. * We merge attrs here so that it can be used in a performant way for initial rendering.
  1298. *
  1299. * The `attrs` are merged in first pass in following order:
  1300. * - Component's `hostAttrs`
  1301. * - Directives' `hostAttrs`
  1302. * - Template `TNode.attrs` associated with the current `TNode`.
  1303. */
  1304. mergedAttrs: TAttributes | null;
  1305. /**
  1306. * A set of local names under which a given element is exported in a template and
  1307. * visible to queries. An entry in this array can be created for different reasons:
  1308. * - an element itself is referenced, ex.: `<div #foo>`
  1309. * - a component is referenced, ex.: `<my-cmpt #foo>`
  1310. * - a directive is referenced, ex.: `<my-cmpt #foo="directiveExportAs">`.
  1311. *
  1312. * A given element might have different local names and those names can be associated
  1313. * with a directive. We store local names at even indexes while odd indexes are reserved
  1314. * for directive index in a view (or `-1` if there is no associated directive).
  1315. *
  1316. * Some examples:
  1317. * - `<div #foo>` => `["foo", -1]`
  1318. * - `<my-cmpt #foo>` => `["foo", myCmptIdx]`
  1319. * - `<my-cmpt #foo #bar="directiveExportAs">` => `["foo", myCmptIdx, "bar", directiveIdx]`
  1320. * - `<div #foo #bar="directiveExportAs">` => `["foo", -1, "bar", directiveIdx]`
  1321. */
  1322. localNames: (string | number)[] | null;
  1323. /** Information about input properties that need to be set once from attribute data. */
  1324. initialInputs: InitialInputData | null;
  1325. /**
  1326. * Input data for all directives on this node. `null` means that there are no directives with
  1327. * inputs on this node.
  1328. */
  1329. inputs: NodeInputBindings | null;
  1330. /**
  1331. * Input data for host directives applied to the node.
  1332. */
  1333. hostDirectiveInputs: HostDirectiveInputs | null;
  1334. /**
  1335. * Output data for all directives on this node. `null` means that there are no directives with
  1336. * outputs on this node.
  1337. */
  1338. outputs: NodeOutputBindings | null;
  1339. /**
  1340. * Input data for host directives applied to the node.
  1341. */
  1342. hostDirectiveOutputs: HostDirectiveOutputs | null;
  1343. /**
  1344. * Mapping between directive classes applied to the node and their indexes.
  1345. */
  1346. directiveToIndex: DirectiveIndexMap | null;
  1347. /**
  1348. * The TView attached to this node.
  1349. *
  1350. * If this TNode corresponds to an LContainer with a template (e.g. structural
  1351. * directive), the template's TView will be stored here.
  1352. *
  1353. * If this TNode corresponds to an element, tView will be `null`.
  1354. */
  1355. tView: TView | null;
  1356. /**
  1357. * The next sibling node. Necessary so we can propagate through the root nodes of a view
  1358. * to insert them or remove them from the DOM.
  1359. */
  1360. next: TNode | null;
  1361. /**
  1362. * The previous sibling node.
  1363. * This simplifies operations when we need a pointer to the previous node.
  1364. */
  1365. prev: TNode | null;
  1366. /**
  1367. * The next projected sibling. Since in Angular content projection works on the node-by-node
  1368. * basis the act of projecting nodes might change nodes relationship at the insertion point
  1369. * (target view). At the same time we need to keep initial relationship between nodes as
  1370. * expressed in content view.
  1371. */
  1372. projectionNext: TNode | null;
  1373. /**
  1374. * First child of the current node.
  1375. *
  1376. * For component nodes, the child will always be a ContentChild (in same view).
  1377. * For embedded view nodes, the child will be in their child view.
  1378. */
  1379. child: TNode | null;
  1380. /**
  1381. * Parent node (in the same view only).
  1382. *
  1383. * We need a reference to a node's parent so we can append the node to its parent's native
  1384. * element at the appropriate time.
  1385. *
  1386. * If the parent would be in a different view (e.g. component host), this property will be null.
  1387. * It's important that we don't try to cross component boundaries when retrieving the parent
  1388. * because the parent will change (e.g. index, attrs) depending on where the component was
  1389. * used (and thus shouldn't be stored on TNode). In these cases, we retrieve the parent through
  1390. * LView.node instead (which will be instance-specific).
  1391. *
  1392. * If this is an inline view node (V), the parent will be its container.
  1393. */
  1394. parent: TElementNode | TContainerNode | null;
  1395. /**
  1396. * List of projected TNodes for a given component host element OR index into the said nodes.
  1397. *
  1398. * For easier discussion assume this example:
  1399. * `<parent>`'s view definition:
  1400. * ```html
  1401. * <child id="c1">content1</child>
  1402. * <child id="c2"><span>content2</span></child>
  1403. * ```
  1404. * `<child>`'s view definition:
  1405. * ```html
  1406. * <ng-content id="cont1"></ng-content>
  1407. * ```
  1408. *
  1409. * If `Array.isArray(projection)` then `TNode` is a host element:
  1410. * - `projection` stores the content nodes which are to be projected.
  1411. * - The nodes represent categories defined by the selector: For example:
  1412. * `<ng-content/><ng-content select="abc"/>` would represent the heads for `<ng-content/>`
  1413. * and `<ng-content select="abc"/>` respectively.
  1414. * - The nodes we store in `projection` are heads only, we used `.next` to get their
  1415. * siblings.
  1416. * - The nodes `.next` is sorted/rewritten as part of the projection setup.
  1417. * - `projection` size is equal to the number of projections `<ng-content>`. The size of
  1418. * `c1` will be `1` because `<child>` has only one `<ng-content>`.
  1419. * - we store `projection` with the host (`c1`, `c2`) rather than the `<ng-content>` (`cont1`)
  1420. * because the same component (`<child>`) can be used in multiple locations (`c1`, `c2`) and
  1421. * as a result have different set of nodes to project.
  1422. * - without `projection` it would be difficult to efficiently traverse nodes to be projected.
  1423. *
  1424. * If `typeof projection == 'number'` then `TNode` is a `<ng-content>` element:
  1425. * - `projection` is an index of the host's `projection`Nodes.
  1426. * - This would return the first head node to project:
  1427. * `getHost(currentTNode).projection[currentTNode.projection]`.
  1428. * - When projecting nodes the parent node retrieved may be a `<ng-content>` node, in which case
  1429. * the process is recursive in nature.
  1430. *
  1431. * If `projection` is of type `RNode[][]` than we have a collection of native nodes passed as
  1432. * projectable nodes during dynamic component creation.
  1433. */
  1434. projection: (TNode | RNode[])[] | number | null;
  1435. /**
  1436. * A collection of all `style` static values for an element (including from host).
  1437. *
  1438. * This field will be populated if and when:
  1439. *
  1440. * - There are one or more initial `style`s on an element (e.g. `<div style="width:200px;">`)
  1441. * - There are one or more initial `style`s on a directive/component host
  1442. * (e.g. `@Directive({host: {style: "width:200px;" } }`)
  1443. */
  1444. styles: string | null;
  1445. /**
  1446. * A collection of all `style` static values for an element excluding host sources.
  1447. *
  1448. * Populated when there are one or more initial `style`s on an element
  1449. * (e.g. `<div style="width:200px;">`)
  1450. * Must be stored separately from `tNode.styles` to facilitate setting directive
  1451. * inputs that shadow the `style` property. If we used `tNode.styles` as is for shadowed inputs,
  1452. * we would feed host styles back into directives as "inputs". If we used `tNode.attrs`, we
  1453. * would have to concatenate the attributes on every template pass. Instead, we process once on
  1454. * first create pass and store here.
  1455. */
  1456. stylesWithoutHost: string | null;
  1457. /**
  1458. * A `KeyValueArray` version of residual `styles`.
  1459. *
  1460. * When there are styling instructions than each instruction stores the static styling
  1461. * which is of lower priority than itself. This means that there may be a higher priority
  1462. * styling than the instruction.
  1463. *
  1464. * Imagine:
  1465. * ```angular-ts
  1466. * <div style="color: highest;" my-dir>
  1467. *
  1468. * @Directive({
  1469. * host: {
  1470. * style: 'color: lowest; ',
  1471. * '[styles.color]': 'exp' // ɵɵstyleProp('color', ctx.exp);
  1472. * }
  1473. * })
  1474. * ```
  1475. *
  1476. * In the above case:
  1477. * - `color: lowest` is stored with `ɵɵstyleProp('color', ctx.exp);` instruction
  1478. * - `color: highest` is the residual and is stored here.
  1479. *
  1480. * - `undefined': not initialized.
  1481. * - `null`: initialized but `styles` is `null`
  1482. * - `KeyValueArray`: parsed version of `styles`.
  1483. */
  1484. residualStyles: KeyValueArray<any> | undefined | null;
  1485. /**
  1486. * A collection of all class static values for an element (including from host).
  1487. *
  1488. * This field will be populated if and when:
  1489. *
  1490. * - There are one or more initial classes on an element (e.g. `<div class="one two three">`)
  1491. * - There are one or more initial classes on an directive/component host
  1492. * (e.g. `@Directive({host: {class: "SOME_CLASS" } }`)
  1493. */
  1494. classes: string | null;
  1495. /**
  1496. * A collection of all class static values for an element excluding host sources.
  1497. *
  1498. * Populated when there are one or more initial classes on an element
  1499. * (e.g. `<div class="SOME_CLASS">`)
  1500. * Must be stored separately from `tNode.classes` to facilitate setting directive
  1501. * inputs that shadow the `class` property. If we used `tNode.classes` as is for shadowed
  1502. * inputs, we would feed host classes back into directives as "inputs". If we used
  1503. * `tNode.attrs`, we would have to concatenate the attributes on every template pass. Instead,
  1504. * we process once on first create pass and store here.
  1505. */
  1506. classesWithoutHost: string | null;
  1507. /**
  1508. * A `KeyValueArray` version of residual `classes`.
  1509. *
  1510. * Same as `TNode.residualStyles` but for classes.
  1511. *
  1512. * - `undefined': not initialized.
  1513. * - `null`: initialized but `classes` is `null`
  1514. * - `KeyValueArray`: parsed version of `classes`.
  1515. */
  1516. residualClasses: KeyValueArray<any> | undefined | null;
  1517. /**
  1518. * Stores the head/tail index of the class bindings.
  1519. *
  1520. * - If no bindings, the head and tail will both be 0.
  1521. * - If there are template bindings, stores the head/tail of the class bindings in the template.
  1522. * - If no template bindings but there are host bindings, the head value will point to the last
  1523. * host binding for "class" (not the head of the linked list), tail will be 0.
  1524. *
  1525. * See: `style_binding_list.ts` for details.
  1526. *
  1527. * This is used by `insertTStylingBinding` to know where the next styling binding should be
  1528. * inserted so that they can be sorted in priority order.
  1529. */
  1530. classBindings: TStylingRange;
  1531. /**
  1532. * Stores the head/tail index of the class bindings.
  1533. *
  1534. * - If no bindings, the head and tail will both be 0.
  1535. * - If there are template bindings, stores the head/tail of the style bindings in the template.
  1536. * - If no template bindings but there are host bindings, the head value will point to the last
  1537. * host binding for "style" (not the head of the linked list), tail will be 0.
  1538. *
  1539. * See: `style_binding_list.ts` for details.
  1540. *
  1541. * This is used by `insertTStylingBinding` to know where the next styling binding should be
  1542. * inserted so that they can be sorted in priority order.
  1543. */
  1544. styleBindings: TStylingRange;
  1545. }
  1546. /**
  1547. * See `TNode.insertBeforeIndex`
  1548. */
  1549. type InsertBeforeIndex = null | number | number[];
  1550. /** Static data for an element */
  1551. interface TElementNode extends TNode {
  1552. /** Index in the data[] array */
  1553. index: number;
  1554. child: TElementNode | TTextNode | TElementContainerNode | TContainerNode | TProjectionNode | null;
  1555. /**
  1556. * Element nodes will have parents unless they are the first node of a component or
  1557. * embedded view (which means their parent is in a different view and must be
  1558. * retrieved using viewData[HOST_NODE]).
  1559. */
  1560. parent: TElementNode | TElementContainerNode | null;
  1561. tView: null;
  1562. /**
  1563. * If this is a component TNode with projection, this will be an array of projected
  1564. * TNodes or native nodes (see TNode.projection for more info). If it's a regular element node
  1565. * or a component without projection, it will be null.
  1566. */
  1567. projection: (TNode | RNode[])[] | null;
  1568. /**
  1569. * Stores TagName
  1570. */
  1571. value: string;
  1572. }
  1573. /** Static data for a text node */
  1574. interface TTextNode extends TNode {
  1575. /** Index in the data[] array */
  1576. index: number;
  1577. child: null;
  1578. /**
  1579. * Text nodes will have parents unless they are the first node of a component or
  1580. * embedded view (which means their parent is in a different view and must be
  1581. * retrieved using LView.node).
  1582. */
  1583. parent: TElementNode | TElementContainerNode | null;
  1584. tView: null;
  1585. projection: null;
  1586. }
  1587. /** Static data for an LContainer */
  1588. interface TContainerNode extends TNode {
  1589. /**
  1590. * Index in the data[] array.
  1591. *
  1592. * If it's -1, this is a dynamically created container node that isn't stored in
  1593. * data[] (e.g. when you inject ViewContainerRef) .
  1594. */
  1595. index: number;
  1596. child: null;
  1597. /**
  1598. * Container nodes will have parents unless:
  1599. *
  1600. * - They are the first node of a component or embedded view
  1601. * - They are dynamically created
  1602. */
  1603. parent: TElementNode | TElementContainerNode | null;
  1604. tView: TView | null;
  1605. projection: null;
  1606. value: null;
  1607. }
  1608. /** Static data for an <ng-container> */
  1609. interface TElementContainerNode extends TNode {
  1610. /** Index in the LView[] array. */
  1611. index: number;
  1612. child: TElementNode | TTextNode | TContainerNode | TElementContainerNode | TProjectionNode | null;
  1613. parent: TElementNode | TElementContainerNode | null;
  1614. tView: null;
  1615. projection: null;
  1616. }
  1617. /** Static data for an LProjectionNode */
  1618. interface TProjectionNode extends TNode {
  1619. /** Index in the data[] array */
  1620. child: null;
  1621. /**
  1622. * Projection nodes will have parents unless they are the first node of a component
  1623. * or embedded view (which means their parent is in a different view and must be
  1624. * retrieved using LView.node).
  1625. */
  1626. parent: TElementNode | TElementContainerNode | null;
  1627. tView: null;
  1628. /** Index of the projection node. (See TNode.projection for more info.) */
  1629. projection: number;
  1630. value: null;
  1631. }
  1632. /**
  1633. * Maps the public names of outputs available on a specific node to the index
  1634. * of the directive instance that defines the output, for example:
  1635. *
  1636. * ```
  1637. * {
  1638. * "publicName": [0, 5]
  1639. * }
  1640. * ```
  1641. */
  1642. type NodeOutputBindings = Record<string, number[]>;
  1643. /**
  1644. * Maps the public names of inputs applied to a specific node to the index of the
  1645. * directive instance to which the input value should be written, for example:
  1646. *
  1647. * ```
  1648. * {
  1649. * "publicName": [0, 5]
  1650. * }
  1651. * ```
  1652. */
  1653. type NodeInputBindings = Record<string, number[]>;
  1654. /**
  1655. * This array contains information about input properties that
  1656. * need to be set once from attribute data. It's ordered by
  1657. * directive index (relative to element) so it's simple to
  1658. * look up a specific directive's initial input data.
  1659. *
  1660. * Within each sub-array:
  1661. *
  1662. * i+0: public name
  1663. * i+1: initial value
  1664. *
  1665. * If a directive on a node does not have any input properties
  1666. * that should be set from attributes, its index is set to null
  1667. * to avoid a sparse array.
  1668. *
  1669. * e.g. [null, ['role-min', 'minified-input', 'button']]
  1670. */
  1671. type InitialInputData = (InitialInputs | null)[];
  1672. /**
  1673. * Used by InitialInputData to store input properties
  1674. * that should be set once from attributes.
  1675. *
  1676. * i+0: attribute name
  1677. * i+1: minified/internal input name
  1678. * i+2: input flags
  1679. * i+3: initial value
  1680. *
  1681. * e.g. ['role-min', 'minified-input', 'button']
  1682. */
  1683. type InitialInputs = string[];
  1684. /**
  1685. * Represents inputs coming from a host directive and exposed on a TNode.
  1686. *
  1687. * - The key is the public name of an input as it is exposed on the specific node.
  1688. * - The value is an array where:
  1689. * - i+0: Index of the host directive that should be written to.
  1690. * - i+1: Public name of the input as it was defined on the host directive before aliasing.
  1691. */
  1692. type HostDirectiveInputs = Record<string, (number | string)[]>;
  1693. /**
  1694. * Represents outputs coming from a host directive and exposed on a TNode.
  1695. *
  1696. * - The key is the public name of an output as it is exposed on the specific node.
  1697. * - The value is an array where:
  1698. * - i+0: Index of the host directive on which the output is defined..
  1699. * - i+1: Public name of the output as it was defined on the host directive before aliasing.
  1700. */
  1701. type HostDirectiveOutputs = Record<string, (number | string)[]>;
  1702. /**
  1703. * Represents a map between a class reference and the index at which its directive is available on
  1704. * a specific TNode. The value can be either:
  1705. * 1. A number means that there's only one selector-matched directive on the node and it
  1706. * doesn't have any host directives.
  1707. * 2. An array means that there's a selector-matched directive and it has host directives.
  1708. * The array is structured as follows:
  1709. * - 0: Index of the selector-matched directive.
  1710. * - 1: Start index of the range within which the host directives are defined.
  1711. * - 2: End of the host directive range.
  1712. *
  1713. * Example:
  1714. * ```
  1715. * Map {
  1716. * [NoHostDirectives]: 5,
  1717. * [HasHostDirectives]: [10, 6, 8],
  1718. * }
  1719. * ```
  1720. */
  1721. type DirectiveIndexMap = Map<Type<unknown>, number | [directiveIndex: number, hostDirectivesStart: number, hostDirectivesEnd: number]>;
  1722. /**
  1723. * Type representing a set of TNodes that can have local refs (`#foo`) placed on them.
  1724. */
  1725. type TNodeWithLocalRefs = TContainerNode | TElementNode | TElementContainerNode;
  1726. /**
  1727. * Type for a function that extracts a value for a local refs.
  1728. * Example:
  1729. * - `<div #nativeDivEl>` - `nativeDivEl` should point to the native `<div>` element;
  1730. * - `<ng-template #tplRef>` - `tplRef` should point to the `TemplateRef` instance;
  1731. */
  1732. type LocalRefExtractor = (tNode: TNodeWithLocalRefs, currentView: LView) => any;
  1733. /**
  1734. * Special location which allows easy identification of type. If we have an array which was
  1735. * retrieved from the `LView` and that array has `true` at `TYPE` location, we know it is
  1736. * `LContainer`.
  1737. */
  1738. declare const TYPE = 1;
  1739. /**
  1740. * Below are constants for LContainer indices to help us look up LContainer members
  1741. * without having to remember the specific indices.
  1742. * Uglify will inline these when minifying so there shouldn't be a cost.
  1743. */
  1744. declare const DEHYDRATED_VIEWS = 6;
  1745. declare const NATIVE = 7;
  1746. declare const VIEW_REFS = 8;
  1747. declare const MOVED_VIEWS = 9;
  1748. /**
  1749. * Size of LContainer's header. Represents the index after which all views in the
  1750. * container will be inserted. We need to keep a record of current views so we know
  1751. * which views are already in the DOM (and don't need to be re-added) and so we can
  1752. * remove views from the DOM when they are no longer required.
  1753. */
  1754. declare const CONTAINER_HEADER_OFFSET = 10;
  1755. /**
  1756. * The state associated with a container.
  1757. *
  1758. * This is an array so that its structure is closer to LView. This helps
  1759. * when traversing the view tree (which is a mix of containers and component
  1760. * views), so we can jump to viewOrContainer[NEXT] in the same way regardless
  1761. * of type.
  1762. */
  1763. interface LContainer extends Array<any> {
  1764. /**
  1765. * The host element of this LContainer.
  1766. *
  1767. * The host could be an LView if this container is on a component node.
  1768. * In that case, the component LView is its HOST.
  1769. */
  1770. readonly [HOST]: RElement | RComment | LView;
  1771. /**
  1772. * This is a type field which allows us to differentiate `LContainer` from `StylingContext` in an
  1773. * efficient way. The value is always set to `true`
  1774. */
  1775. [TYPE]: true;
  1776. /** Flags for this container. See LContainerFlags for more info. */
  1777. [FLAGS]: LContainerFlags;
  1778. /**
  1779. * Access to the parent view is necessary so we can propagate back
  1780. * up from inside a container to parent[NEXT].
  1781. */
  1782. [PARENT]: LView;
  1783. /**
  1784. * This allows us to jump from a container to a sibling container or component
  1785. * view with the same parent, so we can remove listeners efficiently.
  1786. */
  1787. [NEXT]: LView | LContainer | null;
  1788. /**
  1789. * A collection of views created based on the underlying `<ng-template>` element but inserted into
  1790. * a different `LContainer`. We need to track views created from a given declaration point since
  1791. * queries collect matches from the embedded view declaration point and _not_ the insertion point.
  1792. */
  1793. [MOVED_VIEWS]: LView[] | null;
  1794. /**
  1795. * Pointer to the `TNode` which represents the host of the container.
  1796. */
  1797. [T_HOST]: TNode;
  1798. /** The comment element that serves as an anchor for this LContainer. */
  1799. [NATIVE]: RComment;
  1800. /**
  1801. * Array of `ViewRef`s used by any `ViewContainerRef`s that point to this container.
  1802. *
  1803. * This is lazily initialized by `ViewContainerRef` when the first view is inserted.
  1804. *
  1805. * NOTE: This is stored as `any[]` because render3 should really not be aware of `ViewRef` and
  1806. * doing so creates circular dependency.
  1807. */
  1808. [VIEW_REFS]: unknown[] | null;
  1809. /**
  1810. * Array of dehydrated views within this container.
  1811. *
  1812. * This information is used during the hydration process on the client.
  1813. * The hydration logic tries to find a matching dehydrated view, "claim" it
  1814. * and use this information to do further matching. After that, this "claimed"
  1815. * view is removed from the list. The remaining "unclaimed" views are
  1816. * "garbage-collected" later on, i.e. removed from the DOM once the hydration
  1817. * logic finishes.
  1818. */
  1819. [DEHYDRATED_VIEWS]: DehydratedContainerView[] | null;
  1820. }
  1821. /** Flags associated with an LContainer (saved in LContainer[FLAGS]) */
  1822. declare const enum LContainerFlags {
  1823. None = 0,
  1824. /**
  1825. * Flag to signify that this `LContainer` may have transplanted views which need to be change
  1826. * detected. (see: `LView[DECLARATION_COMPONENT_VIEW])`.
  1827. *
  1828. * This flag, once set, is never unset for the `LContainer`.
  1829. */
  1830. HasTransplantedViews = 2
  1831. }
  1832. /**
  1833. * Information about how a type or `InjectionToken` interfaces with the DI system.
  1834. *
  1835. * At a minimum, this includes a `factory` which defines how to create the given type `T`, possibly
  1836. * requesting injection of other types if necessary.
  1837. *
  1838. * Optionally, a `providedIn` parameter specifies that the given type belongs to a particular
  1839. * `Injector`, `NgModule`, or a special scope (e.g. `'root'`). A value of `null` indicates
  1840. * that the injectable does not belong to any scope.
  1841. *
  1842. * @codeGenApi
  1843. * @publicApi The ViewEngine compiler emits code with this type for injectables. This code is
  1844. * deployed to npm, and should be treated as public api.
  1845. */
  1846. interface ɵɵInjectableDeclaration<T> {
  1847. /**
  1848. * Specifies that the given type belongs to a particular injector:
  1849. * - `InjectorType` such as `NgModule`,
  1850. * - `'root'` the root injector
  1851. * - `'any'` all injectors.
  1852. * - `null`, does not belong to any injector. Must be explicitly listed in the injector
  1853. * `providers`.
  1854. */
  1855. providedIn: InjectorType<any> | 'root' | 'platform' | 'any' | 'environment' | null;
  1856. /**
  1857. * The token to which this definition belongs.
  1858. *
  1859. * Note that this may not be the same as the type that the `factory` will create.
  1860. */
  1861. token: unknown;
  1862. /**
  1863. * Factory method to execute to create an instance of the injectable.
  1864. */
  1865. factory: (t?: Type<any>) => T;
  1866. /**
  1867. * In a case of no explicit injector, a location where the instance of the injectable is stored.
  1868. */
  1869. value: T | undefined;
  1870. }
  1871. /**
  1872. * Information about the providers to be included in an `Injector` as well as how the given type
  1873. * which carries the information should be created by the DI system.
  1874. *
  1875. * An `InjectorDef` can import other types which have `InjectorDefs`, forming a deep nested
  1876. * structure of providers with a defined priority (identically to how `NgModule`s also have
  1877. * an import/dependency structure).
  1878. *
  1879. * NOTE: This is a private type and should not be exported
  1880. *
  1881. * @codeGenApi
  1882. */
  1883. interface ɵɵInjectorDef<T> {
  1884. providers: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | EnvironmentProviders | any[])[];
  1885. imports: (InjectorType<any> | InjectorTypeWithProviders<any>)[];
  1886. }
  1887. /**
  1888. * A `Type` which has a `ɵprov: ɵɵInjectableDeclaration` static field.
  1889. *
  1890. * `InjectableType`s contain their own Dependency Injection metadata and are usable in an
  1891. * `InjectorDef`-based `StaticInjector`.
  1892. *
  1893. * @publicApi
  1894. */
  1895. interface InjectableType<T> extends Type<T> {
  1896. /**
  1897. * Opaque type whose structure is highly version dependent. Do not rely on any properties.
  1898. */
  1899. ɵprov: unknown;
  1900. }
  1901. /**
  1902. * A type which has an `InjectorDef` static field.
  1903. *
  1904. * `InjectorTypes` can be used to configure a `StaticInjector`.
  1905. *
  1906. * This is an opaque type whose structure is highly version dependent. Do not rely on any
  1907. * properties.
  1908. *
  1909. * @publicApi
  1910. */
  1911. interface InjectorType<T> extends Type<T> {
  1912. ɵfac?: unknown;
  1913. ɵinj: unknown;
  1914. }
  1915. /**
  1916. * Describes the `InjectorDef` equivalent of a `ModuleWithProviders`, an `InjectorType` with an
  1917. * associated array of providers.
  1918. *
  1919. * Objects of this type can be listed in the imports section of an `InjectorDef`.
  1920. *
  1921. * NOTE: This is a private type and should not be exported
  1922. */
  1923. interface InjectorTypeWithProviders<T> {
  1924. ngModule: InjectorType<T>;
  1925. providers?: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | EnvironmentProviders | any[])[];
  1926. }
  1927. /**
  1928. * Construct an injectable definition which defines how a token will be constructed by the DI
  1929. * system, and in which injectors (if any) it will be available.
  1930. *
  1931. * This should be assigned to a static `ɵprov` field on a type, which will then be an
  1932. * `InjectableType`.
  1933. *
  1934. * Options:
  1935. * * `providedIn` determines which injectors will include the injectable, by either associating it
  1936. * with an `@NgModule` or other `InjectorType`, or by specifying that this injectable should be
  1937. * provided in the `'root'` injector, which will be the application-level injector in most apps.
  1938. * * `factory` gives the zero argument function which will create an instance of the injectable.
  1939. * The factory can call [`inject`](api/core/inject) to access the `Injector` and request injection
  1940. * of dependencies.
  1941. *
  1942. * @codeGenApi
  1943. * @publicApi This instruction has been emitted by ViewEngine for some time and is deployed to npm.
  1944. */
  1945. declare function ɵɵdefineInjectable<T>(opts: {
  1946. token: unknown;
  1947. providedIn?: Type<any> | 'root' | 'platform' | 'any' | 'environment' | null;
  1948. factory: () => T;
  1949. }): unknown;
  1950. /**
  1951. * @deprecated in v8, delete after v10. This API should be used only by generated code, and that
  1952. * code should now use ɵɵdefineInjectable instead.
  1953. * @publicApi
  1954. */
  1955. declare const defineInjectable: typeof ɵɵdefineInjectable;
  1956. /**
  1957. * Construct an `InjectorDef` which configures an injector.
  1958. *
  1959. * This should be assigned to a static injector def (`ɵinj`) field on a type, which will then be an
  1960. * `InjectorType`.
  1961. *
  1962. * Options:
  1963. *
  1964. * * `providers`: an optional array of providers to add to the injector. Each provider must
  1965. * either have a factory or point to a type which has a `ɵprov` static property (the
  1966. * type must be an `InjectableType`).
  1967. * * `imports`: an optional array of imports of other `InjectorType`s or `InjectorTypeWithModule`s
  1968. * whose providers will also be added to the injector. Locally provided types will override
  1969. * providers from imports.
  1970. *
  1971. * @codeGenApi
  1972. */
  1973. declare function ɵɵdefineInjector(options: {
  1974. providers?: any[];
  1975. imports?: any[];
  1976. }): unknown;
  1977. /**
  1978. * Read the injectable def (`ɵprov`) for `type` in a way which is immune to accidentally reading
  1979. * inherited value.
  1980. *
  1981. * @param type A type which may have its own (non-inherited) `ɵprov`.
  1982. */
  1983. declare function getInjectableDef<T>(type: any): ɵɵInjectableDeclaration<T> | null;
  1984. declare function isInjectable(type: any): boolean;
  1985. declare const NG_PROV_DEF: string;
  1986. declare const NG_INJ_DEF: string;
  1987. type InjectorScope = 'root' | 'platform' | 'environment';
  1988. /**
  1989. * An internal token whose presence in an injector indicates that the injector should treat itself
  1990. * as a root scoped injector when processing requests for unknown tokens which may indicate
  1991. * they are provided in the root scope.
  1992. */
  1993. declare const INJECTOR_SCOPE: InjectionToken<InjectorScope | null>;
  1994. /**
  1995. * An `Injector` that's part of the environment injector hierarchy, which exists outside of the
  1996. * component tree.
  1997. *
  1998. * @publicApi
  1999. */
  2000. declare abstract class EnvironmentInjector implements Injector {
  2001. /**
  2002. * Retrieves an instance from the injector based on the provided token.
  2003. * @returns The instance from the injector if defined, otherwise the `notFoundValue`.
  2004. * @throws When the `notFoundValue` is `undefined` or `Injector.THROW_IF_NOT_FOUND`.
  2005. */
  2006. abstract get<T>(token: ProviderToken<T>, notFoundValue: undefined, options: InjectOptions & {
  2007. optional?: false;
  2008. }): T;
  2009. /**
  2010. * Retrieves an instance from the injector based on the provided token.
  2011. * @returns The instance from the injector if defined, otherwise the `notFoundValue`.
  2012. * @throws When the `notFoundValue` is `undefined` or `Injector.THROW_IF_NOT_FOUND`.
  2013. */
  2014. abstract get<T>(token: ProviderToken<T>, notFoundValue: null | undefined, options: InjectOptions): T | null;
  2015. /**
  2016. * Retrieves an instance from the injector based on the provided token.
  2017. * @returns The instance from the injector if defined, otherwise the `notFoundValue`.
  2018. * @throws When the `notFoundValue` is `undefined` or `Injector.THROW_IF_NOT_FOUND`.
  2019. */
  2020. abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, options?: InjectOptions): T;
  2021. /**
  2022. * @deprecated from v4.0.0 use ProviderToken<T>
  2023. * @suppress {duplicate}
  2024. */
  2025. abstract get<T>(token: string | ProviderToken<T>, notFoundValue?: any): any;
  2026. /**
  2027. * Runs the given function in the context of this `EnvironmentInjector`.
  2028. *
  2029. * Within the function's stack frame, [`inject`](api/core/inject) can be used to inject
  2030. * dependencies from this injector. Note that `inject` is only usable synchronously, and cannot be
  2031. * used in any asynchronous callbacks or after any `await` points.
  2032. *
  2033. * @param fn the closure to be run in the context of this injector
  2034. * @returns the return value of the function, if any
  2035. * @deprecated use the standalone function `runInInjectionContext` instead
  2036. */
  2037. abstract runInContext<ReturnT>(fn: () => ReturnT): ReturnT;
  2038. abstract destroy(): void;
  2039. /**
  2040. * Indicates whether the instance has already been destroyed.
  2041. */
  2042. abstract get destroyed(): boolean;
  2043. }
  2044. declare class R3Injector extends EnvironmentInjector implements Injector$1 {
  2045. readonly parent: Injector;
  2046. readonly source: string | null;
  2047. readonly scopes: Set<InjectorScope>;
  2048. /**
  2049. * Map of tokens to records which contain the instances of those tokens.
  2050. * - `null` value implies that we don't have the record. Used by tree-shakable injectors
  2051. * to prevent further searches.
  2052. */
  2053. private records;
  2054. /**
  2055. * Set of values instantiated by this injector which contain `ngOnDestroy` lifecycle hooks.
  2056. */
  2057. private _ngOnDestroyHooks;
  2058. private _onDestroyHooks;
  2059. /**
  2060. * Flag indicating that this injector was previously destroyed.
  2061. */
  2062. get destroyed(): boolean;
  2063. private _destroyed;
  2064. private injectorDefTypes;
  2065. constructor(providers: Array<Provider | EnvironmentProviders>, parent: Injector, source: string | null, scopes: Set<InjectorScope>);
  2066. retrieve<T>(token: InjectionToken$1<T>, options?: unknown): T | NotFound;
  2067. /**
  2068. * Destroy the injector and release references to every instance or provider associated with it.
  2069. *
  2070. * Also calls the `OnDestroy` lifecycle hooks of every instance that was created for which a
  2071. * hook was found.
  2072. */
  2073. destroy(): void;
  2074. onDestroy(callback: () => void): () => void;
  2075. runInContext<ReturnT>(fn: () => ReturnT): ReturnT;
  2076. get<T>(token: ProviderToken<T>, notFoundValue?: any, options?: InjectOptions): T;
  2077. toString(): string;
  2078. /**
  2079. * Process a `SingleProvider` and add it.
  2080. */
  2081. private processProvider;
  2082. private hydrate;
  2083. private injectableDefInScope;
  2084. private removeOnDestroy;
  2085. }
  2086. /**
  2087. * A schema definition associated with a component or an NgModule.
  2088. *
  2089. * @see {@link NgModule}
  2090. * @see {@link CUSTOM_ELEMENTS_SCHEMA}
  2091. * @see {@link NO_ERRORS_SCHEMA}
  2092. *
  2093. * @param name The name of a defined schema.
  2094. *
  2095. * @publicApi
  2096. */
  2097. interface SchemaMetadata {
  2098. name: string;
  2099. }
  2100. /**
  2101. * Defines a schema that allows an NgModule to contain the following:
  2102. * - Non-Angular elements named with dash case (`-`).
  2103. * - Element properties named with dash case (`-`).
  2104. * Dash case is the naming convention for custom elements.
  2105. *
  2106. * @publicApi
  2107. */
  2108. declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata;
  2109. /**
  2110. * Defines a schema that allows any property on any element.
  2111. *
  2112. * This schema allows you to ignore the errors related to any unknown elements or properties in a
  2113. * template. The usage of this schema is generally discouraged because it prevents useful validation
  2114. * and may hide real errors in your template. Consider using the `CUSTOM_ELEMENTS_SCHEMA` instead.
  2115. *
  2116. * @publicApi
  2117. */
  2118. declare const NO_ERRORS_SCHEMA: SchemaMetadata;
  2119. /**
  2120. * Defines the CSS styles encapsulation policies for the {@link /api/core/Component Component} decorator's
  2121. * `encapsulation` option.
  2122. *
  2123. * See {@link Component#encapsulation encapsulation}.
  2124. *
  2125. * @usageNotes
  2126. * ### Example
  2127. *
  2128. * {@example core/ts/metadata/encapsulation.ts region='longform'}
  2129. *
  2130. * @publicApi
  2131. */
  2132. declare enum ViewEncapsulation {
  2133. /**
  2134. * Emulates a native Shadow DOM encapsulation behavior by adding a specific attribute to the
  2135. * component's host element and applying the same attribute to all the CSS selectors provided
  2136. * via {@link Component#styles styles} or {@link Component#styleUrls styleUrls}.
  2137. *
  2138. * This is the default option.
  2139. */
  2140. Emulated = 0,
  2141. /**
  2142. * Doesn't provide any sort of CSS style encapsulation, meaning that all the styles provided
  2143. * via {@link Component#styles styles} or {@link Component#styleUrls styleUrls} are applicable
  2144. * to any HTML element of the application regardless of their host Component.
  2145. */
  2146. None = 2,
  2147. /**
  2148. * Uses the browser's native Shadow DOM API to encapsulate CSS styles, meaning that it creates
  2149. * a ShadowRoot for the component's host element which is then used to encapsulate
  2150. * all the Component's styling.
  2151. */
  2152. ShadowDom = 3
  2153. }
  2154. /**
  2155. * Definition of what a factory function should look like.
  2156. */
  2157. type FactoryFn<T> = {
  2158. /**
  2159. * Subclasses without an explicit constructor call through to the factory of their base
  2160. * definition, providing it with their own constructor to instantiate.
  2161. */
  2162. <U extends T>(t?: Type<U>): U;
  2163. /**
  2164. * If no constructor to instantiate is provided, an instance of type T itself is created.
  2165. */
  2166. (t?: undefined): T;
  2167. };
  2168. /** Flags describing an input for a directive. */
  2169. declare enum InputFlags {
  2170. None = 0,
  2171. SignalBased = 1,
  2172. HasDecoratorInputTransform = 2
  2173. }
  2174. /**
  2175. * Definition of what a template rendering function should look like for a component.
  2176. */
  2177. type ComponentTemplate<T> = {
  2178. <U extends T>(rf: RenderFlags, ctx: T | U): void;
  2179. };
  2180. /**
  2181. * Definition of what a view queries function should look like.
  2182. */
  2183. type ViewQueriesFunction<T> = <U extends T>(rf: RenderFlags, ctx: U) => void;
  2184. /**
  2185. * Definition of what a content queries function should look like.
  2186. */
  2187. type ContentQueriesFunction<T> = <U extends T>(rf: RenderFlags, ctx: U, directiveIndex: number) => void;
  2188. interface ClassDebugInfo {
  2189. className: string;
  2190. filePath?: string;
  2191. lineNumber?: number;
  2192. forbidOrphanRendering?: boolean;
  2193. }
  2194. /**
  2195. * Flags passed into template functions to determine which blocks (i.e. creation, update)
  2196. * should be executed.
  2197. *
  2198. * Typically, a template runs both the creation block and the update block on initialization and
  2199. * subsequent runs only execute the update block. However, dynamically created views require that
  2200. * the creation block be executed separately from the update block (for backwards compat).
  2201. */
  2202. declare const enum RenderFlags {
  2203. Create = 1,
  2204. Update = 2
  2205. }
  2206. /**
  2207. * A subclass of `Type` which has a static `ɵcmp`:`ComponentDef` field making it
  2208. * consumable for rendering.
  2209. */
  2210. interface ComponentType<T> extends Type<T> {
  2211. ɵcmp: unknown;
  2212. }
  2213. /**
  2214. * A subclass of `Type` which has a static `ɵdir`:`DirectiveDef` field making it
  2215. * consumable for rendering.
  2216. */
  2217. interface DirectiveType<T> extends Type<T> {
  2218. ɵdir: unknown;
  2219. ɵfac: unknown;
  2220. }
  2221. /**
  2222. * A subclass of `Type` which has a static `ɵpipe`:`PipeDef` field making it
  2223. * consumable for rendering.
  2224. */
  2225. interface PipeType<T> extends Type<T> {
  2226. ɵpipe: unknown;
  2227. }
  2228. /**
  2229. * Runtime link information for Directives.
  2230. *
  2231. * This is an internal data structure used by the render to link
  2232. * directives into templates.
  2233. *
  2234. * NOTE: Always use `defineDirective` function to create this object,
  2235. * never create the object directly since the shape of this object
  2236. * can change between versions.
  2237. *
  2238. * @param Selector type metadata specifying the selector of the directive or component
  2239. *
  2240. * See: {@link defineDirective}
  2241. */
  2242. interface DirectiveDef<T> {
  2243. /**
  2244. * A dictionary mapping the inputs' public name to their minified property names
  2245. * (along with flags if there are any).
  2246. */
  2247. readonly inputs: Record<string, [
  2248. minifiedName: string,
  2249. flags: InputFlags,
  2250. transform: InputTransformFunction | null
  2251. ]>;
  2252. /**
  2253. * Contains the raw input information produced by the compiler. Can be
  2254. * used to do further processing after the `inputs` have been inverted.
  2255. */
  2256. readonly inputConfig: {
  2257. [P in keyof T]?: string | [InputFlags, string, string?, InputTransformFunction?];
  2258. };
  2259. /**
  2260. * @deprecated This is only here because `NgOnChanges` incorrectly uses declared name instead of
  2261. * public or minified name.
  2262. */
  2263. readonly declaredInputs: Record<string, string>;
  2264. /**
  2265. * A dictionary mapping the outputs' minified property names to their public API names, which
  2266. * are their aliases if any, or their original unminified property names
  2267. * (as in `@Output('alias') propertyName: any;`).
  2268. */
  2269. readonly outputs: Record<string, string>;
  2270. /**
  2271. * Function to create and refresh content queries associated with a given directive.
  2272. */
  2273. contentQueries: ContentQueriesFunction<T> | null;
  2274. /**
  2275. * Query-related instructions for a directive. Note that while directives don't have a
  2276. * view and as such view queries won't necessarily do anything, there might be
  2277. * components that extend the directive.
  2278. */
  2279. viewQuery: ViewQueriesFunction<T> | null;
  2280. /**
  2281. * Refreshes host bindings on the associated directive.
  2282. */
  2283. readonly hostBindings: HostBindingsFunction<T> | null;
  2284. /**
  2285. * The number of bindings in this directive `hostBindings` (including pure fn bindings).
  2286. *
  2287. * Used to calculate the length of the component's LView array, so we
  2288. * can pre-fill the array and set the host binding start index.
  2289. */
  2290. readonly hostVars: number;
  2291. /**
  2292. * Assign static attribute values to a host element.
  2293. *
  2294. * This property will assign static attribute values as well as class and style
  2295. * values to a host element. Since attribute values can consist of different types of values, the
  2296. * `hostAttrs` array must include the values in the following format:
  2297. *
  2298. * attrs = [
  2299. * // static attributes (like `title`, `name`, `id`...)
  2300. * attr1, value1, attr2, value,
  2301. *
  2302. * // a single namespace value (like `x:id`)
  2303. * NAMESPACE_MARKER, namespaceUri1, name1, value1,
  2304. *
  2305. * // another single namespace value (like `x:name`)
  2306. * NAMESPACE_MARKER, namespaceUri2, name2, value2,
  2307. *
  2308. * // a series of CSS classes that will be applied to the element (no spaces)
  2309. * CLASSES_MARKER, class1, class2, class3,
  2310. *
  2311. * // a series of CSS styles (property + value) that will be applied to the element
  2312. * STYLES_MARKER, prop1, value1, prop2, value2
  2313. * ]
  2314. *
  2315. * All non-class and non-style attributes must be defined at the start of the list
  2316. * first before all class and style values are set. When there is a change in value
  2317. * type (like when classes and styles are introduced) a marker must be used to separate
  2318. * the entries. The marker values themselves are set via entries found in the
  2319. * [AttributeMarker] enum.
  2320. */
  2321. readonly hostAttrs: TAttributes | null;
  2322. /** Token representing the directive. Used by DI. */
  2323. readonly type: Type<T>;
  2324. /** Function that resolves providers and publishes them into the DI system. */
  2325. providersResolver: (<U extends T>(def: DirectiveDef<U>, processProvidersFn?: ProcessProvidersFunction) => void) | null;
  2326. /** The selectors that will be used to match nodes to this directive. */
  2327. readonly selectors: CssSelectorList;
  2328. /**
  2329. * Name under which the directive is exported (for use with local references in template)
  2330. */
  2331. readonly exportAs: string[] | null;
  2332. /**
  2333. * Whether this directive (or component) is standalone.
  2334. */
  2335. readonly standalone: boolean;
  2336. /**
  2337. * Whether this directive (or component) uses the signals authoring experience.
  2338. */
  2339. readonly signals: boolean;
  2340. /**
  2341. * Factory function used to create a new directive instance. Will be null initially.
  2342. * Populated when the factory is first requested by directive instantiation logic.
  2343. */
  2344. readonly factory: FactoryFn<T> | null;
  2345. /**
  2346. * The features applied to this directive
  2347. */
  2348. readonly features: DirectiveDefFeature[] | null;
  2349. /**
  2350. * Info related to debugging/troubleshooting for this component. This info is only available in
  2351. * dev mode.
  2352. */
  2353. debugInfo: ClassDebugInfo | null;
  2354. /**
  2355. * Function inteded to be called after template selector matching is done
  2356. * in order to resolve information about their host directives. Patched
  2357. * onto the definition by the `ɵɵHostDirectivesFeature`.
  2358. */
  2359. resolveHostDirectives: ((matches: DirectiveDef<unknown>[]) => HostDirectiveResolution) | null;
  2360. /**
  2361. * Additional directives to be applied whenever the directive has been matched.
  2362. *
  2363. * `HostDirectiveConfig` objects represent a host directive that can be resolved eagerly and were
  2364. * already pre-processed when the definition was created. A function needs to be resolved lazily
  2365. * during directive matching, because it's a forward reference.
  2366. *
  2367. * **Note:** we can't use `HostDirectiveConfig` in the array, because there's no way to
  2368. * distinguish if a function in the array is a `Type` or a `() => HostDirectiveConfig[]`.
  2369. */
  2370. hostDirectives: (HostDirectiveDef | (() => HostDirectiveConfig[]))[] | null;
  2371. setInput: (<U extends T>(this: DirectiveDef<U>, instance: U, inputSignalNode: null | InputSignalNode<unknown, unknown>, value: any, publicName: string, privateName: string) => void) | null;
  2372. }
  2373. /**
  2374. * Runtime link information for Components.
  2375. *
  2376. * This is an internal data structure used by the render to link
  2377. * components into templates.
  2378. *
  2379. * NOTE: Always use `defineComponent` function to create this object,
  2380. * never create the object directly since the shape of this object
  2381. * can change between versions.
  2382. *
  2383. * See: {@link defineComponent}
  2384. */
  2385. interface ComponentDef<T> extends DirectiveDef<T> {
  2386. /**
  2387. * Unique ID for the component. Used in view encapsulation and
  2388. * to keep track of the injector in standalone components.
  2389. */
  2390. readonly id: string;
  2391. /**
  2392. * The View template of the component.
  2393. */
  2394. readonly template: ComponentTemplate<T>;
  2395. /** Constants associated with the component's view. */
  2396. readonly consts: TConstantsOrFactory | null;
  2397. /**
  2398. * An array of `ngContent[selector]` values that were found in the template.
  2399. */
  2400. readonly ngContentSelectors?: string[];
  2401. /**
  2402. * A set of styles that the component needs to be present for component to render correctly.
  2403. */
  2404. readonly styles: string[];
  2405. /**
  2406. * The number of nodes, local refs, and pipes in this component template.
  2407. *
  2408. * Used to calculate the length of the component's LView array, so we
  2409. * can pre-fill the array and set the binding start index.
  2410. */
  2411. readonly decls: number;
  2412. /**
  2413. * The number of bindings in this component template (including pure fn bindings).
  2414. *
  2415. * Used to calculate the length of the component's LView array, so we
  2416. * can pre-fill the array and set the host binding start index.
  2417. */
  2418. readonly vars: number;
  2419. /**
  2420. * Query-related instructions for a component.
  2421. */
  2422. viewQuery: ViewQueriesFunction<T> | null;
  2423. /**
  2424. * The view encapsulation type, which determines how styles are applied to
  2425. * DOM elements. One of
  2426. * - `Emulated` (default): Emulate native scoping of styles.
  2427. * - `Native`: Use the native encapsulation mechanism of the renderer.
  2428. * - `ShadowDom`: Use modern [ShadowDOM](https://w3c.github.io/webcomponents/spec/shadow/) and
  2429. * create a ShadowRoot for component's host element.
  2430. * - `None`: Do not provide any template or style encapsulation.
  2431. */
  2432. readonly encapsulation: ViewEncapsulation;
  2433. /**
  2434. * Defines arbitrary developer-defined data to be stored on a renderer instance.
  2435. * This is useful for renderers that delegate to other renderers.
  2436. */
  2437. readonly data: {
  2438. [kind: string]: any;
  2439. animation?: any[];
  2440. };
  2441. /** Whether or not this component's ChangeDetectionStrategy is OnPush */
  2442. readonly onPush: boolean;
  2443. /** Whether or not this component is signal-based. */
  2444. readonly signals: boolean;
  2445. /**
  2446. * Registry of directives and components that may be found in this view.
  2447. *
  2448. * The property is either an array of `DirectiveDef`s or a function which returns the array of
  2449. * `DirectiveDef`s. The function is necessary to be able to support forward declarations.
  2450. */
  2451. directiveDefs: DirectiveDefListOrFactory | null;
  2452. /**
  2453. * Registry of pipes that may be found in this view.
  2454. *
  2455. * The property is either an array of `PipeDefs`s or a function which returns the array of
  2456. * `PipeDefs`s. The function is necessary to be able to support forward declarations.
  2457. */
  2458. pipeDefs: PipeDefListOrFactory | null;
  2459. /**
  2460. * Unfiltered list of all dependencies of a component, or `null` if none.
  2461. */
  2462. dependencies: TypeOrFactory<DependencyTypeList> | null;
  2463. /**
  2464. * The set of schemas that declare elements to be allowed in the component's template.
  2465. */
  2466. schemas: SchemaMetadata[] | null;
  2467. /**
  2468. * Ivy runtime uses this place to store the computed tView for the component. This gets filled on
  2469. * the first run of component.
  2470. */
  2471. tView: TView | null;
  2472. /**
  2473. * A function used by the framework to create standalone injectors.
  2474. */
  2475. getStandaloneInjector: ((parentInjector: EnvironmentInjector) => EnvironmentInjector | null) | null;
  2476. /**
  2477. * A function used by the framework to create the list of external runtime style URLs.
  2478. */
  2479. getExternalStyles: ((encapsulationId?: string) => string[]) | null;
  2480. /**
  2481. * Used to store the result of `noSideEffects` function so that it is not removed by closure
  2482. * compiler. The property should never be read.
  2483. */
  2484. readonly _?: unknown;
  2485. }
  2486. /**
  2487. * Runtime link information for Pipes.
  2488. *
  2489. * This is an internal data structure used by the renderer to link
  2490. * pipes into templates.
  2491. *
  2492. * NOTE: Always use `definePipe` function to create this object,
  2493. * never create the object directly since the shape of this object
  2494. * can change between versions.
  2495. *
  2496. * See: {@link definePipe}
  2497. */
  2498. interface PipeDef<T> {
  2499. /** Token representing the pipe. */
  2500. type: Type<T>;
  2501. /**
  2502. * Pipe name.
  2503. *
  2504. * Used to resolve pipe in templates.
  2505. */
  2506. readonly name: string;
  2507. /**
  2508. * Factory function used to create a new pipe instance. Will be null initially.
  2509. * Populated when the factory is first requested by pipe instantiation logic.
  2510. */
  2511. factory: FactoryFn<T> | null;
  2512. /**
  2513. * Whether or not the pipe is pure.
  2514. *
  2515. * Pure pipes result only depends on the pipe input and not on internal
  2516. * state of the pipe.
  2517. */
  2518. readonly pure: boolean;
  2519. /**
  2520. * Whether this pipe is standalone.
  2521. */
  2522. readonly standalone: boolean;
  2523. onDestroy: (() => void) | null;
  2524. }
  2525. interface DirectiveDefFeature {
  2526. <T>(directiveDef: DirectiveDef<T>): void;
  2527. /**
  2528. * Marks a feature as something that {@link InheritDefinitionFeature} will execute
  2529. * during inheritance.
  2530. *
  2531. * NOTE: DO NOT SET IN ROOT OF MODULE! Doing so will result in tree-shakers/bundlers
  2532. * identifying the change as a side effect, and the feature will be included in
  2533. * every bundle.
  2534. */
  2535. ngInherit?: true;
  2536. }
  2537. /** Data produced after host directives are resolved for a node. */
  2538. type HostDirectiveResolution = [
  2539. matches: DirectiveDef<unknown>[],
  2540. hostDirectiveDefs: HostDirectiveDefs | null,
  2541. hostDirectiveRanges: HostDirectiveRanges | null
  2542. ];
  2543. /**
  2544. * Map that tracks a selector-matched directive to the range within which its host directives
  2545. * are declared. Host directives for a specific directive are always contiguous within the runtime.
  2546. * Note that both the start and end are inclusive and they're both **after** `tNode.directiveStart`.
  2547. */
  2548. type HostDirectiveRanges = Map<DirectiveDef<unknown>, [start: number, end: number]>;
  2549. /** Runtime information used to configure a host directive. */
  2550. interface HostDirectiveDef<T = unknown> {
  2551. /** Class representing the host directive. */
  2552. directive: Type<T>;
  2553. /** Directive inputs that have been exposed. */
  2554. inputs: HostDirectiveBindingMap;
  2555. /** Directive outputs that have been exposed. */
  2556. outputs: HostDirectiveBindingMap;
  2557. }
  2558. /**
  2559. * Mapping between the public aliases of directive bindings and the underlying inputs/outputs that
  2560. * they represent. Also serves as an allowlist of the inputs/outputs from the host directive that
  2561. * the author has decided to expose.
  2562. */
  2563. type HostDirectiveBindingMap = {
  2564. [publicName: string]: string;
  2565. };
  2566. /**
  2567. * Mapping between a directive that was used as a host directive
  2568. * and the configuration that was used to define it as such.
  2569. */
  2570. type HostDirectiveDefs = Map<DirectiveDef<unknown>, HostDirectiveDef>;
  2571. /** Value that can be used to configure a host directive. */
  2572. type HostDirectiveConfig = Type<unknown> | {
  2573. directive: Type<unknown>;
  2574. inputs?: string[];
  2575. outputs?: string[];
  2576. };
  2577. interface ComponentDefFeature {
  2578. <T>(componentDef: ComponentDef<T>): void;
  2579. /**
  2580. * Marks a feature as something that {@link InheritDefinitionFeature} will execute
  2581. * during inheritance.
  2582. *
  2583. * NOTE: DO NOT SET IN ROOT OF MODULE! Doing so will result in tree-shakers/bundlers
  2584. * identifying the change as a side effect, and the feature will be included in
  2585. * every bundle.
  2586. */
  2587. ngInherit?: true;
  2588. }
  2589. /** Function that can be used to transform incoming input values. */
  2590. type InputTransformFunction = (value: any) => any;
  2591. /**
  2592. * Type used for directiveDefs on component definition.
  2593. *
  2594. * The function is necessary to be able to support forward declarations.
  2595. */
  2596. type DirectiveDefListOrFactory = (() => DirectiveDefList) | DirectiveDefList;
  2597. type DirectiveDefList = (DirectiveDef<any> | ComponentDef<any>)[];
  2598. type DependencyType = DirectiveType<any> | ComponentType<any> | PipeType<any> | Type<any>;
  2599. type DependencyTypeList = Array<DependencyType>;
  2600. type TypeOrFactory<T> = T | (() => T);
  2601. type HostBindingsFunction<T> = <U extends T>(rf: RenderFlags, ctx: U) => void;
  2602. /**
  2603. * Type used for PipeDefs on component definition.
  2604. *
  2605. * The function is necessary to be able to support forward declarations.
  2606. */
  2607. type PipeDefListOrFactory = (() => PipeDefList) | PipeDefList;
  2608. type PipeDefList = PipeDef<any>[];
  2609. /**
  2610. * NgModule scope info as provided by AoT compiler
  2611. *
  2612. * In full compilation Ivy resolved all the "module with providers" and forward refs the whole array
  2613. * if at least one element is forward refed. So we end up with type `Type<any>[]|(() =>
  2614. * Type<any>[])`.
  2615. *
  2616. * In local mode the compiler passes the raw info as they are to the runtime functions as it is not
  2617. * possible to resolve them any further due to limited info at compile time. So we end up with type
  2618. * `RawScopeInfoFromDecorator[]`.
  2619. */
  2620. interface NgModuleScopeInfoFromDecorator {
  2621. /** List of components, directives, and pipes declared by this module. */
  2622. declarations?: Type<any>[] | (() => Type<any>[]) | RawScopeInfoFromDecorator[];
  2623. /** List of modules or `ModuleWithProviders` or standalone components imported by this module. */
  2624. imports?: Type<any>[] | (() => Type<any>[]) | RawScopeInfoFromDecorator[];
  2625. /**
  2626. * List of modules, `ModuleWithProviders`, components, directives, or pipes exported by this
  2627. * module.
  2628. */
  2629. exports?: Type<any>[] | (() => Type<any>[]) | RawScopeInfoFromDecorator[];
  2630. /**
  2631. * The set of components that are bootstrapped when this module is bootstrapped. This field is
  2632. * only available in local compilation mode. In full compilation mode bootstrap info is passed
  2633. * directly to the module def runtime after statically analyzed and resolved.
  2634. */
  2635. bootstrap?: Type<any>[] | (() => Type<any>[]) | RawScopeInfoFromDecorator[];
  2636. }
  2637. /**
  2638. * The array element type passed to:
  2639. * - NgModule's annotation imports/exports/declarations fields
  2640. * - standalone component annotation imports field
  2641. */
  2642. type RawScopeInfoFromDecorator = Type<any> | ModuleWithProviders<any> | (() => Type<any>) | (() => ModuleWithProviders<any>) | any[];
  2643. /**
  2644. * Basic set of data structures used for identifying a defer block
  2645. * and triggering defer blocks
  2646. */
  2647. interface DehydratedDeferBlock {
  2648. lView: LView;
  2649. tNode: TNode;
  2650. lContainer: LContainer;
  2651. }
  2652. /**
  2653. * Describes the shape of a function generated by the compiler
  2654. * to download dependencies that can be defer-loaded.
  2655. */
  2656. type DependencyResolverFn = () => Array<Promise<DependencyType>>;
  2657. /**
  2658. * Describes the state of defer block dependency loading.
  2659. */
  2660. declare enum DeferDependenciesLoadingState {
  2661. /** Initial state, dependency loading is not yet triggered */
  2662. NOT_STARTED = 0,
  2663. /** Dependency loading is in progress */
  2664. IN_PROGRESS = 1,
  2665. /** Dependency loading has completed successfully */
  2666. COMPLETE = 2,
  2667. /** Dependency loading has failed */
  2668. FAILED = 3
  2669. }
  2670. /** Configuration object for a loading block as it is stored in the component constants. */
  2671. type DeferredLoadingBlockConfig = [minimumTime: number | null, afterTime: number | null];
  2672. /** Configuration object for a placeholder block as it is stored in the component constants. */
  2673. type DeferredPlaceholderBlockConfig = [minimumTime: number | null];
  2674. /**
  2675. * Describes the data shared across all instances of a defer block.
  2676. */
  2677. interface TDeferBlockDetails {
  2678. /**
  2679. * Index in an LView and TData arrays where a template for the primary content
  2680. * can be found.
  2681. */
  2682. primaryTmplIndex: number;
  2683. /**
  2684. * Index in an LView and TData arrays where a template for the loading block can be found.
  2685. */
  2686. loadingTmplIndex: number | null;
  2687. /**
  2688. * Extra configuration parameters (such as `after` and `minimum`) for the loading block.
  2689. */
  2690. loadingBlockConfig: DeferredLoadingBlockConfig | null;
  2691. /**
  2692. * Index in an LView and TData arrays where a template for the placeholder block can be found.
  2693. */
  2694. placeholderTmplIndex: number | null;
  2695. /**
  2696. * Extra configuration parameters (such as `after` and `minimum`) for the placeholder block.
  2697. */
  2698. placeholderBlockConfig: DeferredPlaceholderBlockConfig | null;
  2699. /**
  2700. * Index in an LView and TData arrays where a template for the error block can be found.
  2701. */
  2702. errorTmplIndex: number | null;
  2703. /**
  2704. * Compiler-generated function that loads all dependencies for a defer block.
  2705. */
  2706. dependencyResolverFn: DependencyResolverFn | null;
  2707. /**
  2708. * Keeps track of the current loading state of defer block dependencies.
  2709. */
  2710. loadingState: DeferDependenciesLoadingState;
  2711. /**
  2712. * Dependency loading Promise. This Promise is helpful for cases when there
  2713. * are multiple instances of a defer block (e.g. if it was used inside of an *ngFor),
  2714. * which all await the same set of dependencies.
  2715. */
  2716. loadingPromise: Promise<unknown> | null;
  2717. /**
  2718. * List of providers collected from all NgModules that were imported by
  2719. * standalone components used within this defer block.
  2720. */
  2721. providers: Provider[] | null;
  2722. /**
  2723. * List of hydrate triggers for a given block
  2724. */
  2725. hydrateTriggers: Map<DeferBlockTrigger, HydrateTriggerDetails | null> | null;
  2726. /**
  2727. * Defer block flags, which should be used for all
  2728. * instances of a given defer block (the flags that should be
  2729. * placed into the `TDeferDetails` at runtime).
  2730. */
  2731. flags: TDeferDetailsFlags;
  2732. /**
  2733. * Tracks debugging information about the deferred block.
  2734. */
  2735. debug: {
  2736. /** Text representations of the block's triggers. */
  2737. triggers?: Set<string>;
  2738. } | null;
  2739. }
  2740. /**
  2741. * Specifies defer block flags, which should be used for all
  2742. * instances of a given defer block (the flags that should be
  2743. * placed into the `TDeferDetails` at runtime).
  2744. */
  2745. declare const enum TDeferDetailsFlags {
  2746. Default = 0,
  2747. /**
  2748. * Whether or not the defer block has hydrate triggers.
  2749. */
  2750. HasHydrateTriggers = 1
  2751. }
  2752. /**
  2753. * Describes the current state of this defer block instance.
  2754. *
  2755. * @publicApi
  2756. */
  2757. declare enum DeferBlockState {
  2758. /** The placeholder block content is rendered */
  2759. Placeholder = 0,
  2760. /** The loading block content is rendered */
  2761. Loading = 1,
  2762. /** The main content block content is rendered */
  2763. Complete = 2,
  2764. /** The error block content is rendered */
  2765. Error = 3
  2766. }
  2767. /**
  2768. * Represents defer trigger types.
  2769. */
  2770. declare const enum DeferBlockTrigger {
  2771. Idle = 0,
  2772. Immediate = 1,
  2773. Viewport = 2,
  2774. Interaction = 3,
  2775. Hover = 4,
  2776. Timer = 5,
  2777. When = 6,
  2778. Never = 7
  2779. }
  2780. /** * Describes specified delay (in ms) in the `hydrate on timer()` trigger. */
  2781. interface HydrateTimerTriggerDetails {
  2782. delay: number;
  2783. }
  2784. /** * Describes all possible hydration trigger details specified in a template. */
  2785. type HydrateTriggerDetails = HydrateTimerTriggerDetails;
  2786. /**
  2787. * Internal structure used for configuration of defer block behavior.
  2788. * */
  2789. interface DeferBlockConfig {
  2790. behavior: DeferBlockBehavior;
  2791. }
  2792. /**
  2793. * Options for configuring defer blocks behavior.
  2794. * @publicApi
  2795. */
  2796. declare enum DeferBlockBehavior {
  2797. /**
  2798. * Manual triggering mode for defer blocks. Provides control over when defer blocks render
  2799. * and which state they render.
  2800. */
  2801. Manual = 0,
  2802. /**
  2803. * Playthrough mode for defer blocks. This mode behaves like defer blocks would in a browser.
  2804. * This is the default behavior in test environments.
  2805. */
  2806. Playthrough = 1
  2807. }
  2808. /**
  2809. * **INTERNAL**, avoid referencing it in application code.
  2810. *
  2811. * Describes a helper class that allows to intercept a call to retrieve current
  2812. * dependency loading function and replace it with a different implementation.
  2813. * This interceptor class is needed to allow testing blocks in different states
  2814. * by simulating loading response.
  2815. */
  2816. interface DeferBlockDependencyInterceptor {
  2817. /**
  2818. * Invoked for each defer block when dependency loading function is accessed.
  2819. */
  2820. intercept(dependencyFn: DependencyResolverFn | null): DependencyResolverFn | null;
  2821. /**
  2822. * Allows to configure an interceptor function.
  2823. */
  2824. setInterceptor(interceptorFn: (current: DependencyResolverFn) => DependencyResolverFn): void;
  2825. }
  2826. /**
  2827. * A SecurityContext marks a location that has dangerous security implications, e.g. a DOM property
  2828. * like `innerHTML` that could cause Cross Site Scripting (XSS) security bugs when improperly
  2829. * handled.
  2830. *
  2831. * See DomSanitizer for more details on security in Angular applications.
  2832. *
  2833. * @publicApi
  2834. */
  2835. declare enum SecurityContext {
  2836. NONE = 0,
  2837. HTML = 1,
  2838. STYLE = 2,
  2839. SCRIPT = 3,
  2840. URL = 4,
  2841. RESOURCE_URL = 5
  2842. }
  2843. /**
  2844. * Sanitizer is used by the views to sanitize potentially dangerous values.
  2845. *
  2846. * @publicApi
  2847. */
  2848. declare abstract class Sanitizer {
  2849. abstract sanitize(context: SecurityContext, value: {} | string | null): string | null;
  2850. /** @nocollapse */
  2851. static ɵprov: unknown;
  2852. }
  2853. /** Actions that are supported by the tracing framework. */
  2854. declare enum TracingAction {
  2855. CHANGE_DETECTION = 0,
  2856. AFTER_NEXT_RENDER = 1
  2857. }
  2858. /** A single tracing snapshot. */
  2859. interface TracingSnapshot {
  2860. run<T>(action: TracingAction, fn: () => T): T;
  2861. /** Disposes of the tracing snapshot. Must be run exactly once per TracingSnapshot. */
  2862. dispose(): void;
  2863. }
  2864. /**
  2865. * Injection token for a `TracingService`, optionally provided.
  2866. */
  2867. declare const TracingService: InjectionToken<TracingService<TracingSnapshot>>;
  2868. /**
  2869. * Tracing mechanism which can associate causes (snapshots) with runs of
  2870. * subsequent operations.
  2871. *
  2872. * Not defined by Angular directly, but defined in contexts where tracing is
  2873. * desired.
  2874. */
  2875. interface TracingService<T extends TracingSnapshot> {
  2876. /**
  2877. * Take a snapshot of the current context which will be stored by Angular and
  2878. * used when additional work is performed that was scheduled in this context.
  2879. *
  2880. * @param linkedSnapshot Optional snapshot to use link to the current context.
  2881. * The caller is no longer responsible for calling dispose on the linkedSnapshot.
  2882. *
  2883. * @return The tracing snapshot. The caller is responsible for diposing of the
  2884. * snapshot.
  2885. */
  2886. snapshot(linkedSnapshot: T | null): T;
  2887. /**
  2888. * Wrap an event listener bound by the framework for tracing.
  2889. * @param element Element on which the event is bound.
  2890. * @param eventName Name of the event.
  2891. * @param handler Event handler.
  2892. * @return A new event handler to be bound instead of the original one.
  2893. */
  2894. wrapEventListener?<T extends Function>(element: HTMLElement, eventName: string, handler: T): T;
  2895. }
  2896. /**
  2897. * A callback that runs after render.
  2898. *
  2899. * @publicApi
  2900. */
  2901. interface AfterRenderRef {
  2902. /**
  2903. * Shut down the callback, preventing it from being called again.
  2904. */
  2905. destroy(): void;
  2906. }
  2907. declare class AfterRenderManager {
  2908. impl: AfterRenderImpl | null;
  2909. execute(): void;
  2910. /** @nocollapse */
  2911. static ɵprov: unknown;
  2912. }
  2913. declare class AfterRenderImpl {
  2914. private readonly ngZone;
  2915. private readonly scheduler;
  2916. private readonly errorHandler;
  2917. /** Current set of active sequences. */
  2918. private readonly sequences;
  2919. /** Tracks registrations made during the current set of executions. */
  2920. private readonly deferredRegistrations;
  2921. /** Whether the `AfterRenderManager` is currently executing hooks. */
  2922. executing: boolean;
  2923. constructor();
  2924. /**
  2925. * Run the sequence of phases of hooks, once through. As a result of executing some hooks, more
  2926. * might be scheduled.
  2927. */
  2928. execute(): void;
  2929. register(sequence: AfterRenderSequence): void;
  2930. addSequence(sequence: AfterRenderSequence): void;
  2931. unregister(sequence: AfterRenderSequence): void;
  2932. protected maybeTrace<T>(fn: () => T, snapshot: TracingSnapshot | null): T;
  2933. /** @nocollapse */
  2934. static ɵprov: unknown;
  2935. }
  2936. type AfterRenderHook = (value?: unknown) => unknown;
  2937. type AfterRenderHooks = [
  2938. AfterRenderHook | undefined,
  2939. AfterRenderHook | undefined,
  2940. AfterRenderHook | undefined,
  2941. AfterRenderHook | undefined
  2942. ];
  2943. declare class AfterRenderSequence implements AfterRenderRef {
  2944. readonly impl: AfterRenderImpl;
  2945. readonly hooks: AfterRenderHooks;
  2946. readonly view: LView | undefined;
  2947. once: boolean;
  2948. snapshot: TracingSnapshot | null;
  2949. /**
  2950. * Whether this sequence errored or was destroyed during this execution, and hooks should no
  2951. * longer run for it.
  2952. */
  2953. erroredOrDestroyed: boolean;
  2954. /**
  2955. * The value returned by the last hook execution (if any), ready to be pipelined into the next
  2956. * one.
  2957. */
  2958. pipelinedValue: unknown;
  2959. private unregisterOnDestroy;
  2960. constructor(impl: AfterRenderImpl, hooks: AfterRenderHooks, view: LView | undefined, once: boolean, destroyRef: DestroyRef | null, snapshot?: TracingSnapshot | null);
  2961. afterRun(): void;
  2962. destroy(): void;
  2963. }
  2964. interface ReactiveLViewConsumer extends ReactiveNode {
  2965. lView: LView | null;
  2966. }
  2967. /**
  2968. * Abstraction that encompasses any kind of effect that can be scheduled.
  2969. */
  2970. interface SchedulableEffect {
  2971. run(): void;
  2972. zone: {
  2973. run<T>(fn: () => T): T;
  2974. } | null;
  2975. dirty: boolean;
  2976. }
  2977. /**
  2978. * A scheduler which manages the execution of effects.
  2979. */
  2980. declare abstract class EffectScheduler {
  2981. abstract add(e: SchedulableEffect): void;
  2982. /**
  2983. * Schedule the given effect to be executed at a later time.
  2984. *
  2985. * It is an error to attempt to execute any effects synchronously during a scheduling operation.
  2986. */
  2987. abstract schedule(e: SchedulableEffect): void;
  2988. /**
  2989. * Run any scheduled effects.
  2990. */
  2991. abstract flush(): void;
  2992. /** Remove a scheduled effect */
  2993. abstract remove(e: SchedulableEffect): void;
  2994. /** @nocollapse */
  2995. static ɵprov: unknown;
  2996. }
  2997. /**
  2998. * A global reactive effect, which can be manually destroyed.
  2999. *
  3000. * @publicApi 20.0
  3001. */
  3002. interface EffectRef {
  3003. /**
  3004. * Shut down the effect, removing it from any upcoming scheduled executions.
  3005. */
  3006. destroy(): void;
  3007. }
  3008. /**
  3009. * Options passed to the `effect` function.
  3010. *
  3011. * @publicApi 20.0
  3012. */
  3013. interface CreateEffectOptions {
  3014. /**
  3015. * The `Injector` in which to create the effect.
  3016. *
  3017. * If this is not provided, the current [injection context](guide/di/dependency-injection-context)
  3018. * will be used instead (via `inject`).
  3019. */
  3020. injector?: Injector;
  3021. /**
  3022. * Whether the `effect` should require manual cleanup.
  3023. *
  3024. * If this is `false` (the default) the effect will automatically register itself to be cleaned up
  3025. * with the current `DestroyRef`.
  3026. *
  3027. * If this is `true` and you want to use the effect outside an injection context, you still
  3028. * need to provide an `Injector` to the effect.
  3029. */
  3030. manualCleanup?: boolean;
  3031. /**
  3032. * @deprecated no longer required, signal writes are allowed by default.
  3033. */
  3034. allowSignalWrites?: boolean;
  3035. /**
  3036. * A debug name for the effect. Used in Angular DevTools to identify the effect.
  3037. */
  3038. debugName?: string;
  3039. }
  3040. /**
  3041. * An effect can, optionally, register a cleanup function. If registered, the cleanup is executed
  3042. * before the next effect run. The cleanup function makes it possible to "cancel" any work that the
  3043. * previous effect run might have started.
  3044. *
  3045. * @publicApi 20.0
  3046. */
  3047. type EffectCleanupFn = () => void;
  3048. /**
  3049. * A callback passed to the effect function that makes it possible to register cleanup logic.
  3050. *
  3051. * @publicApi 20.0
  3052. */
  3053. type EffectCleanupRegisterFn = (cleanupFn: EffectCleanupFn) => void;
  3054. /**
  3055. * Registers an "effect" that will be scheduled & executed whenever the signals that it reads
  3056. * changes.
  3057. *
  3058. * Angular has two different kinds of effect: component effects and root effects. Component effects
  3059. * are created when `effect()` is called from a component, directive, or within a service of a
  3060. * component/directive. Root effects are created when `effect()` is called from outside the
  3061. * component tree, such as in a root service.
  3062. *
  3063. * The two effect types differ in their timing. Component effects run as a component lifecycle
  3064. * event during Angular's synchronization (change detection) process, and can safely read input
  3065. * signals or create/destroy views that depend on component state. Root effects run as microtasks
  3066. * and have no connection to the component tree or change detection.
  3067. *
  3068. * `effect()` must be run in injection context, unless the `injector` option is manually specified.
  3069. *
  3070. * @publicApi 20.0
  3071. */
  3072. declare function effect(effectFn: (onCleanup: EffectCleanupRegisterFn) => void, options?: CreateEffectOptions): EffectRef;
  3073. interface EffectNode extends ReactiveNode, SchedulableEffect {
  3074. hasRun: boolean;
  3075. cleanupFns: EffectCleanupFn[] | undefined;
  3076. injector: Injector;
  3077. notifier: ChangeDetectionScheduler;
  3078. onDestroyFn: () => void;
  3079. fn: (cleanupFn: EffectCleanupRegisterFn) => void;
  3080. run(): void;
  3081. destroy(): void;
  3082. maybeCleanup(): void;
  3083. }
  3084. interface ViewEffectNode extends EffectNode {
  3085. view: LView;
  3086. }
  3087. /**
  3088. * An unmodifiable list of items that Angular keeps up to date when the state
  3089. * of the application changes.
  3090. *
  3091. * The type of object that {@link ViewChildren}, {@link ContentChildren}, and {@link QueryList}
  3092. * provide.
  3093. *
  3094. * Implements an iterable interface, therefore it can be used in both ES6
  3095. * javascript `for (var i of items)` loops as well as in Angular templates with
  3096. * `@for(i of myList; track $index)`.
  3097. *
  3098. * Changes can be observed by subscribing to the `changes` `Observable`.
  3099. * *
  3100. * @usageNotes
  3101. * ### Example
  3102. * ```ts
  3103. * @Component({...})
  3104. * class Container {
  3105. * @ViewChildren(Item) items:QueryList<Item>;
  3106. * }
  3107. * ```
  3108. *
  3109. * @publicApi
  3110. */
  3111. declare class QueryList<T> implements Iterable<T> {
  3112. private _emitDistinctChangesOnly;
  3113. readonly dirty = true;
  3114. private _onDirty?;
  3115. private _results;
  3116. private _changesDetected;
  3117. private _changes;
  3118. readonly length: number;
  3119. readonly first: T;
  3120. readonly last: T;
  3121. /**
  3122. * Returns `Observable` of `QueryList` notifying the subscriber of changes.
  3123. */
  3124. get changes(): Observable<any>;
  3125. /**
  3126. * @param emitDistinctChangesOnly Whether `QueryList.changes` should fire only when actual change
  3127. * has occurred. Or if it should fire when query is recomputed. (recomputing could resolve in
  3128. * the same result)
  3129. */
  3130. constructor(_emitDistinctChangesOnly?: boolean);
  3131. /**
  3132. * Returns the QueryList entry at `index`.
  3133. */
  3134. get(index: number): T | undefined;
  3135. /**
  3136. * See
  3137. * [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
  3138. */
  3139. map<U>(fn: (item: T, index: number, array: T[]) => U): U[];
  3140. /**
  3141. * See
  3142. * [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
  3143. */
  3144. filter<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S): S[];
  3145. filter(predicate: (value: T, index: number, array: readonly T[]) => unknown): T[];
  3146. /**
  3147. * See
  3148. * [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
  3149. */
  3150. find(fn: (item: T, index: number, array: T[]) => boolean): T | undefined;
  3151. /**
  3152. * See
  3153. * [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
  3154. */
  3155. reduce<U>(fn: (prevValue: U, curValue: T, curIndex: number, array: T[]) => U, init: U): U;
  3156. /**
  3157. * See
  3158. * [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
  3159. */
  3160. forEach(fn: (item: T, index: number, array: T[]) => void): void;
  3161. /**
  3162. * See
  3163. * [Array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
  3164. */
  3165. some(fn: (value: T, index: number, array: T[]) => boolean): boolean;
  3166. /**
  3167. * Returns a copy of the internal results list as an Array.
  3168. */
  3169. toArray(): T[];
  3170. toString(): string;
  3171. /**
  3172. * Updates the stored data of the query list, and resets the `dirty` flag to `false`, so that
  3173. * on change detection, it will not notify of changes to the queries, unless a new change
  3174. * occurs.
  3175. *
  3176. * @param resultsTree The query results to store
  3177. * @param identityAccessor Optional function for extracting stable object identity from a value
  3178. * in the array. This function is executed for each element of the query result list while
  3179. * comparing current query list with the new one (provided as a first argument of the `reset`
  3180. * function) to detect if the lists are different. If the function is not provided, elements
  3181. * are compared as is (without any pre-processing).
  3182. */
  3183. reset(resultsTree: Array<T | any[]>, identityAccessor?: (value: T) => unknown): void;
  3184. /**
  3185. * Triggers a change event by emitting on the `changes` {@link EventEmitter}.
  3186. */
  3187. notifyOnChanges(): void;
  3188. /** internal */
  3189. setDirty(): void;
  3190. /** internal */
  3191. destroy(): void;
  3192. [Symbol.iterator]: () => Iterator<T>;
  3193. }
  3194. /**
  3195. * An object representing query metadata extracted from query annotations.
  3196. */
  3197. interface TQueryMetadata {
  3198. predicate: ProviderToken<unknown> | string[];
  3199. read: any;
  3200. flags: QueryFlags;
  3201. }
  3202. /**
  3203. * A set of flags to be used with Queries.
  3204. *
  3205. * NOTE: Ensure changes here are reflected in `packages/compiler/src/render3/view/compiler.ts`
  3206. */
  3207. declare const enum QueryFlags {
  3208. /**
  3209. * No flags
  3210. */
  3211. none = 0,
  3212. /**
  3213. * Whether or not the query should descend into children.
  3214. */
  3215. descendants = 1,
  3216. /**
  3217. * The query can be computed statically and hence can be assigned eagerly.
  3218. *
  3219. * NOTE: Backwards compatibility with ViewEngine.
  3220. */
  3221. isStatic = 2,
  3222. /**
  3223. * If the `QueryList` should fire change event only if actual change to query was computed (vs old
  3224. * behavior where the change was fired whenever the query was recomputed, even if the recomputed
  3225. * query resulted in the same list.)
  3226. */
  3227. emitDistinctChangesOnly = 4
  3228. }
  3229. /**
  3230. * TQuery objects represent all the query-related data that remain the same from one view instance
  3231. * to another and can be determined on the very first template pass. Most notably TQuery holds all
  3232. * the matches for a given view.
  3233. */
  3234. interface TQuery {
  3235. /**
  3236. * Query metadata extracted from query annotations.
  3237. */
  3238. metadata: TQueryMetadata;
  3239. /**
  3240. * Index of a query in a declaration view in case of queries propagated to en embedded view, -1
  3241. * for queries declared in a given view. We are storing this index so we can find a parent query
  3242. * to clone for an embedded view (when an embedded view is created).
  3243. */
  3244. indexInDeclarationView: number;
  3245. /**
  3246. * Matches collected on the first template pass. Each match is a pair of:
  3247. * - TNode index;
  3248. * - match index;
  3249. *
  3250. * A TNode index can be either:
  3251. * - a positive number (the most common case) to indicate a matching TNode;
  3252. * - a negative number to indicate that a given query is crossing a <ng-template> element and
  3253. * results from views created based on TemplateRef should be inserted at this place.
  3254. *
  3255. * A match index is a number used to find an actual value (for a given node) when query results
  3256. * are materialized. This index can have one of the following values:
  3257. * - -2 - indicates that we need to read a special token (TemplateRef, ViewContainerRef etc.);
  3258. * - -1 - indicates that we need to read a default value based on the node type (TemplateRef for
  3259. * ng-template and ElementRef for other elements);
  3260. * - a positive number - index of an injectable to be read from the element injector.
  3261. */
  3262. matches: number[] | null;
  3263. /**
  3264. * A flag indicating if a given query crosses an <ng-template> element. This flag exists for
  3265. * performance reasons: we can notice that queries not crossing any <ng-template> elements will
  3266. * have matches from a given view only (and adapt processing accordingly).
  3267. */
  3268. crossesNgTemplate: boolean;
  3269. /**
  3270. * A method call when a given query is crossing an element (or element container). This is where a
  3271. * given TNode is matched against a query predicate.
  3272. * @param tView
  3273. * @param tNode
  3274. */
  3275. elementStart(tView: TView, tNode: TNode): void;
  3276. /**
  3277. * A method called when processing the elementEnd instruction - this is mostly useful to determine
  3278. * if a given content query should match any nodes past this point.
  3279. * @param tNode
  3280. */
  3281. elementEnd(tNode: TNode): void;
  3282. /**
  3283. * A method called when processing the template instruction. This is where a
  3284. * given TContainerNode is matched against a query predicate.
  3285. * @param tView
  3286. * @param tNode
  3287. */
  3288. template(tView: TView, tNode: TNode): void;
  3289. /**
  3290. * A query-related method called when an embedded TView is created based on the content of a
  3291. * <ng-template> element. We call this method to determine if a given query should be propagated
  3292. * to the embedded view and if so - return a cloned TQuery for this embedded view.
  3293. * @param tNode
  3294. * @param childQueryIndex
  3295. */
  3296. embeddedTView(tNode: TNode, childQueryIndex: number): TQuery | null;
  3297. }
  3298. /**
  3299. * TQueries represent a collection of individual TQuery objects tracked in a given view. Most of the
  3300. * methods on this interface are simple proxy methods to the corresponding functionality on TQuery.
  3301. */
  3302. interface TQueries {
  3303. /**
  3304. * Adds a new TQuery to a collection of queries tracked in a given view.
  3305. * @param tQuery
  3306. */
  3307. track(tQuery: TQuery): void;
  3308. /**
  3309. * Returns a TQuery instance for at the given index in the queries array.
  3310. * @param index
  3311. */
  3312. getByIndex(index: number): TQuery;
  3313. /**
  3314. * Returns the number of queries tracked in a given view.
  3315. */
  3316. length: number;
  3317. /**
  3318. * A proxy method that iterates over all the TQueries in a given TView and calls the corresponding
  3319. * `elementStart` on each and every TQuery.
  3320. * @param tView
  3321. * @param tNode
  3322. */
  3323. elementStart(tView: TView, tNode: TNode): void;
  3324. /**
  3325. * A proxy method that iterates over all the TQueries in a given TView and calls the corresponding
  3326. * `elementEnd` on each and every TQuery.
  3327. * @param tNode
  3328. */
  3329. elementEnd(tNode: TNode): void;
  3330. /**
  3331. * A proxy method that iterates over all the TQueries in a given TView and calls the corresponding
  3332. * `template` on each and every TQuery.
  3333. * @param tView
  3334. * @param tNode
  3335. */
  3336. template(tView: TView, tNode: TNode): void;
  3337. /**
  3338. * A proxy method that iterates over all the TQueries in a given TView and calls the corresponding
  3339. * `embeddedTView` on each and every TQuery.
  3340. * @param tNode
  3341. */
  3342. embeddedTView(tNode: TNode): TQueries | null;
  3343. }
  3344. /**
  3345. * An interface that represents query-related information specific to a view instance. Most notably
  3346. * it contains:
  3347. * - materialized query matches;
  3348. * - a pointer to a QueryList where materialized query results should be reported.
  3349. */
  3350. interface LQuery<T> {
  3351. /**
  3352. * Materialized query matches for a given view only (!). Results are initialized lazily so the
  3353. * array of matches is set to `null` initially.
  3354. */
  3355. matches: (T | null)[] | null;
  3356. /**
  3357. * A QueryList where materialized query results should be reported.
  3358. */
  3359. queryList: QueryList<T>;
  3360. /**
  3361. * Clones an LQuery for an embedded view. A cloned query shares the same `QueryList` but has a
  3362. * separate collection of materialized matches.
  3363. */
  3364. clone(): LQuery<T>;
  3365. /**
  3366. * Called when an embedded view, impacting results of this query, is inserted or removed.
  3367. */
  3368. setDirty(): void;
  3369. }
  3370. /**
  3371. * lQueries represent a collection of individual LQuery objects tracked in a given view.
  3372. */
  3373. interface LQueries {
  3374. /**
  3375. * A collection of queries tracked in a given view.
  3376. */
  3377. queries: LQuery<any>[];
  3378. /**
  3379. * A method called when a new embedded view is created. As a result a set of LQueries applicable
  3380. * for a new embedded view is instantiated (cloned) from the declaration view.
  3381. * @param tView
  3382. */
  3383. createEmbeddedView(tView: TView): LQueries | null;
  3384. /**
  3385. * A method called when an embedded view is inserted into a container. As a result all impacted
  3386. * `LQuery` objects (and associated `QueryList`) are marked as dirty.
  3387. * @param tView
  3388. */
  3389. insertView(tView: TView): void;
  3390. /**
  3391. * A method called when an embedded view is detached from a container. As a result all impacted
  3392. * `LQuery` objects (and associated `QueryList`) are marked as dirty.
  3393. * @param tView
  3394. */
  3395. detachView(tView: TView): void;
  3396. /**
  3397. * A method called when a view finishes its creation pass. As a result all impacted
  3398. * `LQuery` objects (and associated `QueryList`) are marked as dirty. This additional dirty
  3399. * marking gives us a precise point in time where we can collect results for a given view in an
  3400. * atomic way.
  3401. * @param tView
  3402. */
  3403. finishViewCreation(tView: TView): void;
  3404. }
  3405. /**
  3406. * Used by `RendererFactory2` to associate custom rendering data and styles
  3407. * with a rendering implementation.
  3408. * @publicApi
  3409. */
  3410. interface RendererType2 {
  3411. /**
  3412. * A unique identifying string for the new renderer, used when creating
  3413. * unique styles for encapsulation.
  3414. */
  3415. id: string;
  3416. /**
  3417. * The view encapsulation type, which determines how styles are applied to
  3418. * DOM elements. One of
  3419. * - `Emulated` (default): Emulate native scoping of styles.
  3420. * - `Native`: Use the native encapsulation mechanism of the renderer.
  3421. * - `ShadowDom`: Use modern [Shadow
  3422. * DOM](https://w3c.github.io/webcomponents/spec/shadow/) and
  3423. * create a ShadowRoot for component's host element.
  3424. * - `None`: Do not provide any template or style encapsulation.
  3425. */
  3426. encapsulation: ViewEncapsulation;
  3427. /**
  3428. * Defines CSS styles to be stored on a renderer instance.
  3429. */
  3430. styles: string[];
  3431. /**
  3432. * Defines arbitrary developer-defined data to be stored on a renderer instance.
  3433. * This is useful for renderers that delegate to other renderers.
  3434. */
  3435. data: {
  3436. [kind: string]: any;
  3437. };
  3438. /**
  3439. * A function used by the framework to create the list of external runtime style URLs.
  3440. */
  3441. getExternalStyles?: ((encapsulationId?: string) => string[]) | null;
  3442. }
  3443. /**
  3444. * Flags for renderer-specific style modifiers.
  3445. * @publicApi
  3446. */
  3447. declare enum RendererStyleFlags2 {
  3448. /**
  3449. * Marks a style as important.
  3450. */
  3451. Important = 1,
  3452. /**
  3453. * Marks a style as using dash case naming (this-is-dash-case).
  3454. */
  3455. DashCase = 2
  3456. }
  3457. /**
  3458. * Creates and initializes a custom renderer that implements the `Renderer2` base class.
  3459. *
  3460. * @publicApi
  3461. */
  3462. declare abstract class RendererFactory2 {
  3463. /**
  3464. * Creates and initializes a custom renderer for a host DOM element.
  3465. * @param hostElement The element to render.
  3466. * @param type The base class to implement.
  3467. * @returns The new custom renderer instance.
  3468. */
  3469. abstract createRenderer(hostElement: any, type: RendererType2 | null): Renderer2;
  3470. /**
  3471. * A callback invoked when rendering has begun.
  3472. */
  3473. abstract begin?(): void;
  3474. /**
  3475. * A callback invoked when rendering has completed.
  3476. */
  3477. abstract end?(): void;
  3478. /**
  3479. * Use with animations test-only mode. Notifies the test when rendering has completed.
  3480. * @returns The asynchronous result of the developer-defined function.
  3481. */
  3482. abstract whenRenderingDone?(): Promise<any>;
  3483. }
  3484. /**
  3485. * Extend this base class to implement custom rendering. By default, Angular
  3486. * renders a template into DOM. You can use custom rendering to intercept
  3487. * rendering calls, or to render to something other than DOM.
  3488. *
  3489. * <div class="docs-alert docs-alert-important">
  3490. * <p>
  3491. * Please be aware that usage of `Renderer2`, in context of accessing DOM elements, provides no
  3492. * extra security which makes it equivalent to
  3493. * {@link /best-practices/security#direct-use-of-the-dom-apis-and-explicit-sanitization-calls Security vulnerabilities}.
  3494. * </p>
  3495. * </div>
  3496. *
  3497. * Create your custom renderer using `RendererFactory2`.
  3498. *
  3499. * Use a custom renderer to bypass Angular's templating and
  3500. * make custom UI changes that can't be expressed declaratively.
  3501. * For example if you need to set a property or an attribute whose name is
  3502. * not statically known, use the `setProperty()` or
  3503. * `setAttribute()` method.
  3504. *
  3505. * @publicApi
  3506. */
  3507. declare abstract class Renderer2 {
  3508. /**
  3509. * Use to store arbitrary developer-defined data on a renderer instance,
  3510. * as an object containing key-value pairs.
  3511. * This is useful for renderers that delegate to other renderers.
  3512. */
  3513. abstract get data(): {
  3514. [key: string]: any;
  3515. };
  3516. /**
  3517. * Implement this callback to destroy the renderer or the host element.
  3518. */
  3519. abstract destroy(): void;
  3520. /**
  3521. * Implement this callback to create an instance of the host element.
  3522. * @param name An identifying name for the new element, unique within the namespace.
  3523. * @param namespace The namespace for the new element.
  3524. * @returns The new element.
  3525. */
  3526. abstract createElement(name: string, namespace?: string | null): any;
  3527. /**
  3528. * Implement this callback to add a comment to the DOM of the host element.
  3529. * @param value The comment text.
  3530. * @returns The modified element.
  3531. */
  3532. abstract createComment(value: string): any;
  3533. /**
  3534. * Implement this callback to add text to the DOM of the host element.
  3535. * @param value The text string.
  3536. * @returns The modified element.
  3537. */
  3538. abstract createText(value: string): any;
  3539. /**
  3540. * If null or undefined, the view engine won't call it.
  3541. * This is used as a performance optimization for production mode.
  3542. */
  3543. destroyNode: ((node: any) => void) | null;
  3544. /**
  3545. * Appends a child to a given parent node in the host element DOM.
  3546. * @param parent The parent node.
  3547. * @param newChild The new child node.
  3548. */
  3549. abstract appendChild(parent: any, newChild: any): void;
  3550. /**
  3551. * Implement this callback to insert a child node at a given position in a parent node
  3552. * in the host element DOM.
  3553. * @param parent The parent node.
  3554. * @param newChild The new child nodes.
  3555. * @param refChild The existing child node before which `newChild` is inserted.
  3556. * @param isMove Optional argument which signifies if the current `insertBefore` is a result of a
  3557. * move. Animation uses this information to trigger move animations. In the past the Animation
  3558. * would always assume that any `insertBefore` is a move. This is not strictly true because
  3559. * with runtime i18n it is possible to invoke `insertBefore` as a result of i18n and it should
  3560. * not trigger an animation move.
  3561. */
  3562. abstract insertBefore(parent: any, newChild: any, refChild: any, isMove?: boolean): void;
  3563. /**
  3564. * Implement this callback to remove a child node from the host element's DOM.
  3565. * @param parent The parent node.
  3566. * @param oldChild The child node to remove.
  3567. * @param isHostElement Optionally signal to the renderer whether this element is a host element
  3568. * or not
  3569. */
  3570. abstract removeChild(parent: any, oldChild: any, isHostElement?: boolean): void;
  3571. /**
  3572. * Implement this callback to prepare an element to be bootstrapped
  3573. * as a root element, and return the element instance.
  3574. * @param selectorOrNode The DOM element.
  3575. * @param preserveContent Whether the contents of the root element
  3576. * should be preserved, or cleared upon bootstrap (default behavior).
  3577. * Use with `ViewEncapsulation.ShadowDom` to allow simple native
  3578. * content projection via `<slot>` elements.
  3579. * @returns The root element.
  3580. */
  3581. abstract selectRootElement(selectorOrNode: string | any, preserveContent?: boolean): any;
  3582. /**
  3583. * Implement this callback to get the parent of a given node
  3584. * in the host element's DOM.
  3585. * @param node The child node to query.
  3586. * @returns The parent node, or null if there is no parent.
  3587. * This is because the check is synchronous,
  3588. * and the caller can't rely on checking for null.
  3589. */
  3590. abstract parentNode(node: any): any;
  3591. /**
  3592. * Implement this callback to get the next sibling node of a given node
  3593. * in the host element's DOM.
  3594. * @returns The sibling node, or null if there is no sibling.
  3595. * This is because the check is synchronous,
  3596. * and the caller can't rely on checking for null.
  3597. */
  3598. abstract nextSibling(node: any): any;
  3599. /**
  3600. * Implement this callback to set an attribute value for an element in the DOM.
  3601. * @param el The element.
  3602. * @param name The attribute name.
  3603. * @param value The new value.
  3604. * @param namespace The namespace.
  3605. */
  3606. abstract setAttribute(el: any, name: string, value: string, namespace?: string | null): void;
  3607. /**
  3608. * Implement this callback to remove an attribute from an element in the DOM.
  3609. * @param el The element.
  3610. * @param name The attribute name.
  3611. * @param namespace The namespace.
  3612. */
  3613. abstract removeAttribute(el: any, name: string, namespace?: string | null): void;
  3614. /**
  3615. * Implement this callback to add a class to an element in the DOM.
  3616. * @param el The element.
  3617. * @param name The class name.
  3618. */
  3619. abstract addClass(el: any, name: string): void;
  3620. /**
  3621. * Implement this callback to remove a class from an element in the DOM.
  3622. * @param el The element.
  3623. * @param name The class name.
  3624. */
  3625. abstract removeClass(el: any, name: string): void;
  3626. /**
  3627. * Implement this callback to set a CSS style for an element in the DOM.
  3628. * @param el The element.
  3629. * @param style The name of the style.
  3630. * @param value The new value.
  3631. * @param flags Flags for style variations. No flags are set by default.
  3632. */
  3633. abstract setStyle(el: any, style: string, value: any, flags?: RendererStyleFlags2): void;
  3634. /**
  3635. * Implement this callback to remove the value from a CSS style for an element in the DOM.
  3636. * @param el The element.
  3637. * @param style The name of the style.
  3638. * @param flags Flags for style variations to remove, if set. ???
  3639. */
  3640. abstract removeStyle(el: any, style: string, flags?: RendererStyleFlags2): void;
  3641. /**
  3642. * Implement this callback to set the value of a property of an element in the DOM.
  3643. * @param el The element.
  3644. * @param name The property name.
  3645. * @param value The new value.
  3646. */
  3647. abstract setProperty(el: any, name: string, value: any): void;
  3648. /**
  3649. * Implement this callback to set the value of a node in the host element.
  3650. * @param node The node.
  3651. * @param value The new value.
  3652. */
  3653. abstract setValue(node: any, value: string): void;
  3654. /**
  3655. * Implement this callback to start an event listener.
  3656. * @param target The context in which to listen for events. Can be
  3657. * the entire window or document, the body of the document, or a specific
  3658. * DOM element.
  3659. * @param eventName The event to listen for.
  3660. * @param callback A handler function to invoke when the event occurs.
  3661. * @param options Options that configure how the event listener is bound.
  3662. * @returns An "unlisten" function for disposing of this handler.
  3663. */
  3664. abstract listen(target: 'window' | 'document' | 'body' | any, eventName: string, callback: (event: any) => boolean | void, options?: ListenerOptions): () => void;
  3665. }
  3666. /**
  3667. * This enum is meant to be used by `ɵtype` properties of the different renderers implemented
  3668. * by the framework
  3669. *
  3670. * We choose to not add `ɵtype` to `Renderer2` to no expose it to the public API.
  3671. */
  3672. declare const enum AnimationRendererType {
  3673. Regular = 0,
  3674. Delegated = 1
  3675. }
  3676. /**
  3677. * Options that can be used to configure an event listener.
  3678. * @publicApi
  3679. */
  3680. interface ListenerOptions {
  3681. capture?: boolean;
  3682. once?: boolean;
  3683. passive?: boolean;
  3684. }
  3685. /**
  3686. * The goal here is to make sure that the browser DOM API is the Renderer.
  3687. * We do this by defining a subset of DOM API to be the renderer and then
  3688. * use that at runtime for rendering.
  3689. *
  3690. * At runtime we can then use the DOM api directly, in server or web-worker
  3691. * it will be easy to implement such API.
  3692. */
  3693. type GlobalTargetName = 'document' | 'window' | 'body';
  3694. type GlobalTargetResolver = (element: any) => EventTarget;
  3695. /**
  3696. * Procedural style of API needed to create elements and text nodes.
  3697. *
  3698. * In non-native browser environments (e.g. platforms such as web-workers), this is the
  3699. * facade that enables element manipulation. In practice, this is implemented by `Renderer2`.
  3700. */
  3701. interface Renderer {
  3702. destroy(): void;
  3703. createComment(value: string): RComment;
  3704. createElement(name: string, namespace?: string | null): RElement;
  3705. createText(value: string): RText;
  3706. /**
  3707. * This property is allowed to be null / undefined,
  3708. * in which case the view engine won't call it.
  3709. * This is used as a performance optimization for production mode.
  3710. */
  3711. destroyNode?: ((node: RNode) => void) | null;
  3712. appendChild(parent: RElement, newChild: RNode): void;
  3713. insertBefore(parent: RNode, newChild: RNode, refChild: RNode | null, isMove?: boolean): void;
  3714. removeChild(parent: RElement | null, oldChild: RNode, isHostElement?: boolean): void;
  3715. selectRootElement(selectorOrNode: string | any, preserveContent?: boolean): RElement;
  3716. parentNode(node: RNode): RElement | null;
  3717. nextSibling(node: RNode): RNode | null;
  3718. setAttribute(el: RElement, name: string, value: string | TrustedHTML | TrustedScript | TrustedScriptURL, namespace?: string | null): void;
  3719. removeAttribute(el: RElement, name: string, namespace?: string | null): void;
  3720. addClass(el: RElement, name: string): void;
  3721. removeClass(el: RElement, name: string): void;
  3722. setStyle(el: RElement, style: string, value: any, flags?: RendererStyleFlags2): void;
  3723. removeStyle(el: RElement, style: string, flags?: RendererStyleFlags2): void;
  3724. setProperty(el: RElement, name: string, value: any): void;
  3725. setValue(node: RText | RComment, value: string): void;
  3726. listen(target: GlobalTargetName | RNode, eventName: string, callback: (event: any) => boolean | void, options?: ListenerOptions): () => void;
  3727. }
  3728. interface RendererFactory {
  3729. createRenderer(hostElement: RElement | null, rendererType: RendererType2 | null): Renderer;
  3730. begin?(): void;
  3731. end?(): void;
  3732. }
  3733. declare const HOST = 0;
  3734. declare const TVIEW = 1;
  3735. declare const FLAGS = 2;
  3736. declare const PARENT = 3;
  3737. declare const NEXT = 4;
  3738. declare const T_HOST = 5;
  3739. declare const HYDRATION = 6;
  3740. declare const CLEANUP = 7;
  3741. declare const CONTEXT = 8;
  3742. declare const INJECTOR = 9;
  3743. declare const ENVIRONMENT = 10;
  3744. declare const RENDERER = 11;
  3745. declare const CHILD_HEAD = 12;
  3746. declare const CHILD_TAIL = 13;
  3747. declare const DECLARATION_VIEW = 14;
  3748. declare const DECLARATION_COMPONENT_VIEW = 15;
  3749. declare const DECLARATION_LCONTAINER = 16;
  3750. declare const PREORDER_HOOK_FLAGS = 17;
  3751. declare const QUERIES = 18;
  3752. declare const ID = 19;
  3753. declare const EMBEDDED_VIEW_INJECTOR = 20;
  3754. declare const ON_DESTROY_HOOKS = 21;
  3755. declare const EFFECTS_TO_SCHEDULE = 22;
  3756. declare const EFFECTS = 23;
  3757. declare const REACTIVE_TEMPLATE_CONSUMER = 24;
  3758. declare const AFTER_RENDER_SEQUENCES_TO_ADD = 25;
  3759. interface OpaqueViewState {
  3760. '__brand__': 'Brand for OpaqueViewState that nothing will match';
  3761. }
  3762. /**
  3763. * `LView` stores all of the information needed to process the instructions as
  3764. * they are invoked from the template. Each embedded view and component view has its
  3765. * own `LView`. When processing a particular view, we set the `viewData` to that
  3766. * `LView`. When that view is done processing, the `viewData` is set back to
  3767. * whatever the original `viewData` was before (the parent `LView`).
  3768. *
  3769. * Keeping separate state for each view facilities view insertion / deletion, so we
  3770. * don't have to edit the data array based on which views are present.
  3771. */
  3772. interface LView<T = unknown> extends Array<any> {
  3773. /**
  3774. * The node into which this `LView` is inserted.
  3775. */
  3776. [HOST]: RElement | null;
  3777. /**
  3778. * The static data for this view. We need a reference to this so we can easily walk up the
  3779. * node tree in DI and get the TView.data array associated with a node (where the
  3780. * directive defs are stored).
  3781. */
  3782. readonly [TVIEW]: TView;
  3783. /** Flags for this view. See LViewFlags for more info. */
  3784. [FLAGS]: LViewFlags;
  3785. /**
  3786. * This may store an {@link LView} or {@link LContainer}.
  3787. *
  3788. * `LView` - The parent view. This is needed when we exit the view and must restore the previous
  3789. * LView. Without this, the render method would have to keep a stack of
  3790. * views as it is recursively rendering templates.
  3791. *
  3792. * `LContainer` - The current view is part of a container, and is an embedded view.
  3793. */
  3794. [PARENT]: LView | LContainer | null;
  3795. /**
  3796. *
  3797. * The next sibling LView or LContainer.
  3798. *
  3799. * Allows us to propagate between sibling view states that aren't in the same
  3800. * container. Embedded views already have a node.next, but it is only set for
  3801. * views in the same container. We need a way to link component views and views
  3802. * across containers as well.
  3803. */
  3804. [NEXT]: LView | LContainer | null;
  3805. /** Queries active for this view - nodes from a view are reported to those queries. */
  3806. [QUERIES]: LQueries | null;
  3807. /**
  3808. * Store the `TNode` of the location where the current `LView` is inserted into.
  3809. *
  3810. * Given:
  3811. * ```html
  3812. * <div>
  3813. * <ng-template><span></span></ng-template>
  3814. * </div>
  3815. * ```
  3816. *
  3817. * We end up with two `TView`s.
  3818. * - `parent` `TView` which contains `<div><!-- anchor --></div>`
  3819. * - `child` `TView` which contains `<span></span>`
  3820. *
  3821. * Typically the `child` is inserted into the declaration location of the `parent`, but it can be
  3822. * inserted anywhere. Because it can be inserted anywhere it is not possible to store the
  3823. * insertion information in the `TView` and instead we must store it in the `LView[T_HOST]`.
  3824. *
  3825. * So to determine where is our insertion parent we would execute:
  3826. * ```ts
  3827. * const parentLView = lView[PARENT];
  3828. * const parentTNode = lView[T_HOST];
  3829. * const insertionParent = parentLView[parentTNode.index];
  3830. * ```
  3831. *
  3832. *
  3833. * If `null`, this is the root view of an application (root component is in this view) and it has
  3834. * no parents.
  3835. */
  3836. [T_HOST]: TNode | null;
  3837. /**
  3838. * When a view is destroyed, listeners need to be released and outputs need to be
  3839. * unsubscribed. This context array stores both listener functions wrapped with
  3840. * their context and output subscription instances for a particular view.
  3841. *
  3842. * These change per LView instance, so they cannot be stored on TView. Instead,
  3843. * TView.cleanup saves an index to the necessary context in this array.
  3844. *
  3845. * After `LView` is created it is possible to attach additional instance specific functions at the
  3846. * end of the `lView[CLEANUP]` because we know that no more `T` level cleanup functions will be
  3847. * added here.
  3848. */
  3849. [CLEANUP]: any[] | null;
  3850. /**
  3851. * - For dynamic views, this is the context with which to render the template (e.g.
  3852. * `NgForContext`), or `{}` if not defined explicitly.
  3853. * - For root view of the root component it's a reference to the component instance itself.
  3854. * - For components, the context is a reference to the component instance itself.
  3855. * - For inline views, the context is null.
  3856. */
  3857. [CONTEXT]: T;
  3858. /** A Module Injector to be used as fall back after Element Injectors are consulted. */
  3859. readonly [INJECTOR]: Injector;
  3860. /**
  3861. * Contextual data that is shared across multiple instances of `LView` in the same application.
  3862. */
  3863. [ENVIRONMENT]: LViewEnvironment;
  3864. /** Renderer to be used for this view. */
  3865. [RENDERER]: Renderer;
  3866. /**
  3867. * Reference to the first LView or LContainer beneath this LView in
  3868. * the hierarchy.
  3869. *
  3870. * Necessary to store this so views can traverse through their nested views
  3871. * to remove listeners and call onDestroy callbacks.
  3872. */
  3873. [CHILD_HEAD]: LView | LContainer | null;
  3874. /**
  3875. * The last LView or LContainer beneath this LView in the hierarchy.
  3876. *
  3877. * The tail allows us to quickly add a new state to the end of the view list
  3878. * without having to propagate starting from the first child.
  3879. */
  3880. [CHILD_TAIL]: LView | LContainer | null;
  3881. /**
  3882. * View where this view's template was declared.
  3883. *
  3884. * The template for a dynamically created view may be declared in a different view than
  3885. * it is inserted. We already track the "insertion view" (view where the template was
  3886. * inserted) in LView[PARENT], but we also need access to the "declaration view"
  3887. * (view where the template was declared). Otherwise, we wouldn't be able to call the
  3888. * view's template function with the proper contexts. Context should be inherited from
  3889. * the declaration view tree, not the insertion view tree.
  3890. *
  3891. * Example (AppComponent template):
  3892. *
  3893. * <ng-template #foo></ng-template> <-- declared here -->
  3894. * <some-comp [tpl]="foo"></some-comp> <-- inserted inside this component -->
  3895. *
  3896. * The <ng-template> above is declared in the AppComponent template, but it will be passed into
  3897. * SomeComp and inserted there. In this case, the declaration view would be the AppComponent,
  3898. * but the insertion view would be SomeComp. When we are removing views, we would want to
  3899. * traverse through the insertion view to clean up listeners. When we are calling the
  3900. * template function during change detection, we need the declaration view to get inherited
  3901. * context.
  3902. */
  3903. [DECLARATION_VIEW]: LView | null;
  3904. /**
  3905. * Points to the declaration component view, used to track transplanted `LView`s.
  3906. *
  3907. * See: `DECLARATION_VIEW` which points to the actual `LView` where it was declared, whereas
  3908. * `DECLARATION_COMPONENT_VIEW` points to the component which may not be same as
  3909. * `DECLARATION_VIEW`.
  3910. *
  3911. * Example:
  3912. * ```html
  3913. * <#VIEW #myComp>
  3914. * <div *ngIf="true">
  3915. * <ng-template #myTmpl>...</ng-template>
  3916. * </div>
  3917. * </#VIEW>
  3918. * ```
  3919. * In the above case `DECLARATION_VIEW` for `myTmpl` points to the `LView` of `ngIf` whereas
  3920. * `DECLARATION_COMPONENT_VIEW` points to `LView` of the `myComp` which owns the template.
  3921. *
  3922. * The reason for this is that all embedded views are always check-always whereas the component
  3923. * view can be check-always or on-push. When we have a transplanted view it is important to
  3924. * determine if we have transplanted a view from check-always declaration to on-push insertion
  3925. * point. In such a case the transplanted view needs to be added to the `LContainer` in the
  3926. * declared `LView` and CD during the declared view CD (in addition to the CD at the insertion
  3927. * point.) (Any transplanted views which are intra Component are of no interest because the CD
  3928. * strategy of declaration and insertion will always be the same, because it is the same
  3929. * component.)
  3930. *
  3931. * Queries already track moved views in `LView[DECLARATION_LCONTAINER]` and
  3932. * `LContainer[MOVED_VIEWS]`. However the queries also track `LView`s which moved within the same
  3933. * component `LView`. Transplanted views are a subset of moved views, and we use
  3934. * `DECLARATION_COMPONENT_VIEW` to differentiate them. As in this example.
  3935. *
  3936. * Example showing intra component `LView` movement.
  3937. * ```html
  3938. * <#VIEW #myComp>
  3939. * <div *ngIf="condition; then thenBlock else elseBlock"></div>
  3940. * <ng-template #thenBlock>Content to render when condition is true.</ng-template>
  3941. * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
  3942. * </#VIEW>
  3943. * ```
  3944. * The `thenBlock` and `elseBlock` is moved but not transplanted.
  3945. *
  3946. * Example showing inter component `LView` movement (transplanted view).
  3947. * ```html
  3948. * <#VIEW #myComp>
  3949. * <ng-template #myTmpl>...</ng-template>
  3950. * <insertion-component [template]="myTmpl"></insertion-component>
  3951. * </#VIEW>
  3952. * ```
  3953. * In the above example `myTmpl` is passed into a different component. If `insertion-component`
  3954. * instantiates `myTmpl` and `insertion-component` is on-push then the `LContainer` needs to be
  3955. * marked as containing transplanted views and those views need to be CD as part of the
  3956. * declaration CD.
  3957. *
  3958. *
  3959. * When change detection runs, it iterates over `[MOVED_VIEWS]` and CDs any child `LView`s where
  3960. * the `DECLARATION_COMPONENT_VIEW` of the current component and the child `LView` does not match
  3961. * (it has been transplanted across components.)
  3962. *
  3963. * Note: `[DECLARATION_COMPONENT_VIEW]` points to itself if the LView is a component view (the
  3964. * simplest / most common case).
  3965. *
  3966. * see also:
  3967. * - https://hackmd.io/@mhevery/rJUJsvv9H write up of the problem
  3968. * - `LContainer[HAS_TRANSPLANTED_VIEWS]` which marks which `LContainer` has transplanted views.
  3969. * - `LContainer[TRANSPLANT_HEAD]` and `LContainer[TRANSPLANT_TAIL]` storage for transplanted
  3970. * - `LView[DECLARATION_LCONTAINER]` similar problem for queries
  3971. * - `LContainer[MOVED_VIEWS]` similar problem for queries
  3972. */
  3973. [DECLARATION_COMPONENT_VIEW]: LView;
  3974. /**
  3975. * A declaration point of embedded views (ones instantiated based on the content of a
  3976. * <ng-template>), null for other types of views.
  3977. *
  3978. * We need to track all embedded views created from a given declaration point so we can prepare
  3979. * query matches in a proper order (query matches are ordered based on their declaration point and
  3980. * _not_ the insertion point).
  3981. */
  3982. [DECLARATION_LCONTAINER]: LContainer | null;
  3983. /**
  3984. * More flags for this view. See PreOrderHookFlags for more info.
  3985. */
  3986. [PREORDER_HOOK_FLAGS]: PreOrderHookFlags;
  3987. /** Unique ID of the view. Used for `__ngContext__` lookups in the `LView` registry. */
  3988. [ID]: number;
  3989. /**
  3990. * A container related to hydration annotation information that's associated with this LView.
  3991. */
  3992. [HYDRATION]: DehydratedView | null;
  3993. /**
  3994. * Optional injector assigned to embedded views that takes
  3995. * precedence over the element and module injectors.
  3996. */
  3997. readonly [EMBEDDED_VIEW_INJECTOR]: Injector | null;
  3998. /**
  3999. * Effect scheduling operations that need to run during this views's update pass.
  4000. */
  4001. [EFFECTS_TO_SCHEDULE]: Array<() => void> | null;
  4002. [EFFECTS]: Set<ViewEffectNode> | null;
  4003. /**
  4004. * A collection of callbacks functions that are executed when a given LView is destroyed. Those
  4005. * are user defined, LView-specific destroy callbacks that don't have any corresponding TView
  4006. * entries.
  4007. */
  4008. [ON_DESTROY_HOOKS]: Array<() => void> | null;
  4009. /**
  4010. * The `Consumer` for this `LView`'s template so that signal reads can be tracked.
  4011. *
  4012. * This is initially `null` and gets assigned a consumer after template execution
  4013. * if any signals were read.
  4014. */
  4015. [REACTIVE_TEMPLATE_CONSUMER]: ReactiveLViewConsumer | null;
  4016. [AFTER_RENDER_SEQUENCES_TO_ADD]: AfterRenderSequence[] | null;
  4017. }
  4018. /**
  4019. * Contextual data that is shared across multiple instances of `LView` in the same application.
  4020. */
  4021. interface LViewEnvironment {
  4022. /** Factory to be used for creating Renderer. */
  4023. rendererFactory: RendererFactory;
  4024. /** An optional custom sanitizer. */
  4025. sanitizer: Sanitizer | null;
  4026. /** Scheduler for change detection to notify when application state changes. */
  4027. changeDetectionScheduler: ChangeDetectionScheduler | null;
  4028. /**
  4029. * Whether `ng-reflect-*` attributes should be produced in dev mode
  4030. * (always disabled in prod mode).
  4031. */
  4032. ngReflect: boolean;
  4033. }
  4034. /** Flags associated with an LView (saved in LView[FLAGS]) */
  4035. declare const enum LViewFlags {
  4036. /** The state of the init phase on the first 2 bits */
  4037. InitPhaseStateIncrementer = 1,
  4038. InitPhaseStateMask = 3,
  4039. /**
  4040. * Whether or not the view is in creationMode.
  4041. *
  4042. * This must be stored in the view rather than using `data` as a marker so that
  4043. * we can properly support embedded views. Otherwise, when exiting a child view
  4044. * back into the parent view, `data` will be defined and `creationMode` will be
  4045. * improperly reported as false.
  4046. */
  4047. CreationMode = 4,
  4048. /**
  4049. * Whether or not this LView instance is on its first processing pass.
  4050. *
  4051. * An LView instance is considered to be on its "first pass" until it
  4052. * has completed one creation mode run and one update mode run. At this
  4053. * time, the flag is turned off.
  4054. */
  4055. FirstLViewPass = 8,
  4056. /** Whether this view has default change detection strategy (checks always) or onPush */
  4057. CheckAlways = 16,
  4058. /** Whether there are any i18n blocks inside this LView. */
  4059. HasI18n = 32,
  4060. /** Whether or not this view is currently dirty (needing check) */
  4061. Dirty = 64,
  4062. /** Whether or not this view is currently attached to change detection tree. */
  4063. Attached = 128,
  4064. /** Whether or not this view is destroyed. */
  4065. Destroyed = 256,
  4066. /** Whether or not this view is the root view */
  4067. IsRoot = 512,
  4068. /**
  4069. * Whether this moved LView needs to be refreshed. Similar to the Dirty flag, but used for
  4070. * transplanted and signal views where the parent/ancestor views are not marked dirty as well.
  4071. * i.e. "Refresh just this view". Used in conjunction with the HAS_CHILD_VIEWS_TO_REFRESH
  4072. * flag.
  4073. */
  4074. RefreshView = 1024,
  4075. /** Indicates that the view **or any of its ancestors** have an embedded view injector. */
  4076. HasEmbeddedViewInjector = 2048,
  4077. /** Indicates that the view was created with `signals: true`. */
  4078. SignalView = 4096,
  4079. /**
  4080. * Indicates that this LView has a view underneath it that needs to be refreshed during change
  4081. * detection. This flag indicates that even if this view is not dirty itself, we still need to
  4082. * traverse its children during change detection.
  4083. */
  4084. HasChildViewsToRefresh = 8192,
  4085. /**
  4086. * This is the count of the bits the 1 was shifted above (base 10)
  4087. */
  4088. IndexWithinInitPhaseShift = 14,
  4089. /**
  4090. * Index of the current init phase on last 21 bits
  4091. */
  4092. IndexWithinInitPhaseIncrementer = 16384,
  4093. IndexWithinInitPhaseReset = 16383
  4094. }
  4095. /** More flags associated with an LView (saved in LView[PREORDER_HOOK_FLAGS]) */
  4096. declare const enum PreOrderHookFlags {
  4097. /**
  4098. The index of the next pre-order hook to be called in the hooks array, on the first 16
  4099. bits
  4100. */
  4101. IndexOfTheNextPreOrderHookMaskMask = 65535,
  4102. /**
  4103. * The number of init hooks that have already been called, on the last 16 bits
  4104. */
  4105. NumberOfInitHooksCalledIncrementer = 65536,
  4106. NumberOfInitHooksCalledShift = 16,
  4107. NumberOfInitHooksCalledMask = 4294901760
  4108. }
  4109. /**
  4110. * Stores a set of OpCodes to process `HostBindingsFunction` associated with a current view.
  4111. *
  4112. * In order to invoke `HostBindingsFunction` we need:
  4113. * 1. 'elementIdx`: Index to the element associated with the `HostBindingsFunction`.
  4114. * 2. 'directiveIdx`: Index to the directive associated with the `HostBindingsFunction`. (This will
  4115. * become the context for the `HostBindingsFunction` invocation.)
  4116. * 3. `bindingRootIdx`: Location where the bindings for the `HostBindingsFunction` start. Internally
  4117. * `HostBindingsFunction` binding indexes start from `0` so we need to add `bindingRootIdx` to
  4118. * it.
  4119. * 4. `HostBindingsFunction`: A host binding function to execute.
  4120. *
  4121. * The above information needs to be encoded into the `HostBindingOpCodes` in an efficient manner.
  4122. *
  4123. * 1. `elementIdx` is encoded into the `HostBindingOpCodes` as `~elementIdx` (so a negative number);
  4124. * 2. `directiveIdx`
  4125. * 3. `bindingRootIdx`
  4126. * 4. `HostBindingsFunction` is passed in as is.
  4127. *
  4128. * The `HostBindingOpCodes` array contains:
  4129. * - negative number to select the element index.
  4130. * - followed by 1 or more of:
  4131. * - a number to select the directive index
  4132. * - a number to select the bindingRoot index
  4133. * - and a function to invoke.
  4134. *
  4135. * ## Example
  4136. *
  4137. * ```ts
  4138. * const hostBindingOpCodes = [
  4139. * ~30, // Select element 30
  4140. * 40, 45, MyDir.ɵdir.hostBindings // Invoke host bindings on MyDir on element 30;
  4141. * // directiveIdx = 40; bindingRootIdx = 45;
  4142. * 50, 55, OtherDir.ɵdir.hostBindings // Invoke host bindings on OtherDire on element 30
  4143. * // directiveIdx = 50; bindingRootIdx = 55;
  4144. * ]
  4145. * ```
  4146. *
  4147. * ## Pseudocode
  4148. * ```ts
  4149. * const hostBindingOpCodes = tView.hostBindingOpCodes;
  4150. * if (hostBindingOpCodes === null) return;
  4151. * for (let i = 0; i < hostBindingOpCodes.length; i++) {
  4152. * const opCode = hostBindingOpCodes[i] as number;
  4153. * if (opCode < 0) {
  4154. * // Negative numbers are element indexes.
  4155. * setSelectedIndex(~opCode);
  4156. * } else {
  4157. * // Positive numbers are NumberTuple which store bindingRootIndex and directiveIndex.
  4158. * const directiveIdx = opCode;
  4159. * const bindingRootIndx = hostBindingOpCodes[++i] as number;
  4160. * const hostBindingFn = hostBindingOpCodes[++i] as HostBindingsFunction<any>;
  4161. * setBindingRootForHostBindings(bindingRootIndx, directiveIdx);
  4162. * const context = lView[directiveIdx];
  4163. * hostBindingFn(RenderFlags.Update, context);
  4164. * }
  4165. * }
  4166. * ```
  4167. *
  4168. */
  4169. interface HostBindingOpCodes extends Array<number | HostBindingsFunction<any>> {
  4170. __brand__: 'HostBindingOpCodes';
  4171. debug?: string[];
  4172. }
  4173. /**
  4174. * Explicitly marks `TView` as a specific type in `ngDevMode`
  4175. *
  4176. * It is useful to know conceptually what time of `TView` we are dealing with when
  4177. * debugging an application (even if the runtime does not need it.) For this reason
  4178. * we store this information in the `ngDevMode` `TView` and than use it for
  4179. * better debugging experience.
  4180. */
  4181. declare const enum TViewType {
  4182. /**
  4183. * Root `TView` is the used to bootstrap components into. It is used in conjunction with
  4184. * `LView` which takes an existing DOM node not owned by Angular and wraps it in `TView`/`LView`
  4185. * so that other components can be loaded into it.
  4186. */
  4187. Root = 0,
  4188. /**
  4189. * `TView` associated with a Component. This would be the `TView` directly associated with the
  4190. * component view (as opposed an `Embedded` `TView` which would be a child of `Component` `TView`)
  4191. */
  4192. Component = 1,
  4193. /**
  4194. * `TView` associated with a template. Such as `*ngIf`, `<ng-template>` etc... A `Component`
  4195. * can have zero or more `Embedded` `TView`s.
  4196. */
  4197. Embedded = 2
  4198. }
  4199. /**
  4200. * The static data for an LView (shared between all templates of a
  4201. * given type).
  4202. *
  4203. * Stored on the `ComponentDef.tView`.
  4204. */
  4205. interface TView {
  4206. /**
  4207. * Type of `TView` (`Root`|`Component`|`Embedded`).
  4208. */
  4209. type: TViewType;
  4210. /**
  4211. * This is a blueprint used to generate LView instances for this TView. Copying this
  4212. * blueprint is faster than creating a new LView from scratch.
  4213. */
  4214. blueprint: LView;
  4215. /**
  4216. * The template function used to refresh the view of dynamically created views
  4217. * and components. Will be null for inline views.
  4218. */
  4219. template: ComponentTemplate<{}> | null;
  4220. /**
  4221. * A function containing query-related instructions.
  4222. */
  4223. viewQuery: ViewQueriesFunction<{}> | null;
  4224. /**
  4225. * A `TNode` representing the declaration location of this `TView` (not part of this TView).
  4226. */
  4227. declTNode: TNode | null;
  4228. /** Whether or not this template has been processed in creation mode. */
  4229. firstCreatePass: boolean;
  4230. /**
  4231. * Whether or not this template has been processed in update mode (e.g. change detected)
  4232. *
  4233. * `firstUpdatePass` is used by styling to set up `TData` to contain metadata about the styling
  4234. * instructions. (Mainly to build up a linked list of styling priority order.)
  4235. *
  4236. * Typically this function gets cleared after first execution. If exception is thrown then this
  4237. * flag can remain turned un until there is first successful (no exception) pass. This means that
  4238. * individual styling instructions keep track of if they have already been added to the linked
  4239. * list to prevent double adding.
  4240. */
  4241. firstUpdatePass: boolean;
  4242. /** Static data equivalent of LView.data[]. Contains TNodes, PipeDefInternal or TI18n. */
  4243. data: TData;
  4244. /**
  4245. * The binding start index is the index at which the data array
  4246. * starts to store bindings only. Saving this value ensures that we
  4247. * will begin reading bindings at the correct point in the array when
  4248. * we are in update mode.
  4249. *
  4250. * -1 means that it has not been initialized.
  4251. */
  4252. bindingStartIndex: number;
  4253. /**
  4254. * The index where the "expando" section of `LView` begins. The expando
  4255. * section contains injectors, directive instances, and host binding values.
  4256. * Unlike the "decls" and "vars" sections of `LView`, the length of this
  4257. * section cannot be calculated at compile-time because directives are matched
  4258. * at runtime to preserve locality.
  4259. *
  4260. * We store this start index so we know where to start checking host bindings
  4261. * in `setHostBindings`.
  4262. */
  4263. expandoStartIndex: number;
  4264. /**
  4265. * Whether or not there are any static view queries tracked on this view.
  4266. *
  4267. * We store this so we know whether or not we should do a view query
  4268. * refresh after creation mode to collect static query results.
  4269. */
  4270. staticViewQueries: boolean;
  4271. /**
  4272. * Whether or not there are any static content queries tracked on this view.
  4273. *
  4274. * We store this so we know whether or not we should do a content query
  4275. * refresh after creation mode to collect static query results.
  4276. */
  4277. staticContentQueries: boolean;
  4278. /**
  4279. * A reference to the first child node located in the view.
  4280. */
  4281. firstChild: TNode | null;
  4282. /**
  4283. * Stores the OpCodes to be replayed during change-detection to process the `HostBindings`
  4284. *
  4285. * See `HostBindingOpCodes` for encoding details.
  4286. */
  4287. hostBindingOpCodes: HostBindingOpCodes | null;
  4288. /**
  4289. * Full registry of directives and components that may be found in this view.
  4290. *
  4291. * It's necessary to keep a copy of the full def list on the TView so it's possible
  4292. * to render template functions without a host component.
  4293. */
  4294. directiveRegistry: DirectiveDefList | null;
  4295. /**
  4296. * Full registry of pipes that may be found in this view.
  4297. *
  4298. * The property is either an array of `PipeDefs`s or a function which returns the array of
  4299. * `PipeDefs`s. The function is necessary to be able to support forward declarations.
  4300. *
  4301. * It's necessary to keep a copy of the full def list on the TView so it's possible
  4302. * to render template functions without a host component.
  4303. */
  4304. pipeRegistry: PipeDefList | null;
  4305. /**
  4306. * Array of ngOnInit, ngOnChanges and ngDoCheck hooks that should be executed for this view in
  4307. * creation mode.
  4308. *
  4309. * This array has a flat structure and contains TNode indices, directive indices (where an
  4310. * instance can be found in `LView`) and hook functions. TNode index is followed by the directive
  4311. * index and a hook function. If there are multiple hooks for a given TNode, the TNode index is
  4312. * not repeated and the next lifecycle hook information is stored right after the previous hook
  4313. * function. This is done so that at runtime the system can efficiently iterate over all of the
  4314. * functions to invoke without having to make any decisions/lookups.
  4315. */
  4316. preOrderHooks: HookData | null;
  4317. /**
  4318. * Array of ngOnChanges and ngDoCheck hooks that should be executed for this view in update mode.
  4319. *
  4320. * This array has the same structure as the `preOrderHooks` one.
  4321. */
  4322. preOrderCheckHooks: HookData | null;
  4323. /**
  4324. * Array of ngAfterContentInit and ngAfterContentChecked hooks that should be executed
  4325. * for this view in creation mode.
  4326. *
  4327. * Even indices: Directive index
  4328. * Odd indices: Hook function
  4329. */
  4330. contentHooks: HookData | null;
  4331. /**
  4332. * Array of ngAfterContentChecked hooks that should be executed for this view in update
  4333. * mode.
  4334. *
  4335. * Even indices: Directive index
  4336. * Odd indices: Hook function
  4337. */
  4338. contentCheckHooks: HookData | null;
  4339. /**
  4340. * Array of ngAfterViewInit and ngAfterViewChecked hooks that should be executed for
  4341. * this view in creation mode.
  4342. *
  4343. * Even indices: Directive index
  4344. * Odd indices: Hook function
  4345. */
  4346. viewHooks: HookData | null;
  4347. /**
  4348. * Array of ngAfterViewChecked hooks that should be executed for this view in
  4349. * update mode.
  4350. *
  4351. * Even indices: Directive index
  4352. * Odd indices: Hook function
  4353. */
  4354. viewCheckHooks: HookData | null;
  4355. /**
  4356. * Array of ngOnDestroy hooks that should be executed when this view is destroyed.
  4357. *
  4358. * Even indices: Directive index
  4359. * Odd indices: Hook function
  4360. */
  4361. destroyHooks: DestroyHookData | null;
  4362. /**
  4363. * When a view is destroyed, listeners need to be released and outputs need to be
  4364. * unsubscribed. This cleanup array stores both listener data (in chunks of 4)
  4365. * and output data (in chunks of 2) for a particular view. Combining the arrays
  4366. * saves on memory (70 bytes per array) and on a few bytes of code size (for two
  4367. * separate for loops).
  4368. *
  4369. * If it's a native DOM listener or output subscription being stored:
  4370. * 1st index is: event name `name = tView.cleanup[i+0]`
  4371. * 2nd index is: index of native element or a function that retrieves global target (window,
  4372. * document or body) reference based on the native element:
  4373. * `typeof idxOrTargetGetter === 'function'`: global target getter function
  4374. * `typeof idxOrTargetGetter === 'number'`: index of native element
  4375. *
  4376. * 3rd index is: index of listener function `listener = lView[CLEANUP][tView.cleanup[i+2]]`
  4377. * 4th index is: `useCaptureOrIndx = tView.cleanup[i+3]`
  4378. * `typeof useCaptureOrIndx == 'boolean' : useCapture boolean
  4379. * `typeof useCaptureOrIndx == 'number':
  4380. * `useCaptureOrIndx >= 0` `removeListener = LView[CLEANUP][useCaptureOrIndx]`
  4381. * `useCaptureOrIndx < 0` `subscription = LView[CLEANUP][-useCaptureOrIndx]`
  4382. *
  4383. * If it's an output subscription or query list destroy hook:
  4384. * 1st index is: output unsubscribe function / query list destroy function
  4385. * 2nd index is: index of function context in LView.cleanupInstances[]
  4386. * `tView.cleanup[i+0].call(lView[CLEANUP][tView.cleanup[i+1]])`
  4387. */
  4388. cleanup: any[] | null;
  4389. /**
  4390. * A list of element indices for child components that will need to be
  4391. * refreshed when the current view has finished its check. These indices have
  4392. * already been adjusted for the HEADER_OFFSET.
  4393. *
  4394. */
  4395. components: number[] | null;
  4396. /**
  4397. * A collection of queries tracked in a given view.
  4398. */
  4399. queries: TQueries | null;
  4400. /**
  4401. * An array of indices pointing to directives with content queries alongside with the
  4402. * corresponding query index. Each entry in this array is a tuple of:
  4403. * - index of the first content query index declared by a given directive;
  4404. * - index of a directive.
  4405. *
  4406. * We are storing those indexes so we can refresh content queries as part of a view refresh
  4407. * process.
  4408. */
  4409. contentQueries: number[] | null;
  4410. /**
  4411. * Set of schemas that declare elements to be allowed inside the view.
  4412. */
  4413. schemas: SchemaMetadata[] | null;
  4414. /**
  4415. * Array of constants for the view. Includes attribute arrays, local definition arrays etc.
  4416. * Used for directive matching, attribute bindings, local definitions and more.
  4417. */
  4418. consts: TConstants | null;
  4419. /**
  4420. * Indicates that there was an error before we managed to complete the first create pass of the
  4421. * view. This means that the view is likely corrupted and we should try to recover it.
  4422. */
  4423. incompleteFirstPass: boolean;
  4424. /**
  4425. * Unique id of this TView for hydration purposes:
  4426. * - TViewType.Embedded: a unique id generated during serialization on the server
  4427. * - TViewType.Component: an id generated based on component properties
  4428. * (see `getComponentId` function for details)
  4429. */
  4430. ssrId: string | null;
  4431. }
  4432. /** Single hook callback function. */
  4433. type HookFn = () => void;
  4434. /**
  4435. * Information necessary to call a hook. E.g. the callback that
  4436. * needs to invoked and the index at which to find its context.
  4437. */
  4438. type HookEntry = number | HookFn;
  4439. /**
  4440. * Array of hooks that should be executed for a view and their directive indices.
  4441. *
  4442. * For each node of the view, the following data is stored:
  4443. * 1) Node index (optional)
  4444. * 2) A series of number/function pairs where:
  4445. * - even indices are directive indices
  4446. * - odd indices are hook functions
  4447. *
  4448. * Special cases:
  4449. * - a negative directive index flags an init hook (ngOnInit, ngAfterContentInit, ngAfterViewInit)
  4450. */
  4451. type HookData = HookEntry[];
  4452. /**
  4453. * Array of destroy hooks that should be executed for a view and their directive indices.
  4454. *
  4455. * The array is set up as a series of number/function or number/(number|function)[]:
  4456. * - Even indices represent the context with which hooks should be called.
  4457. * - Odd indices are the hook functions themselves. If a value at an odd index is an array,
  4458. * it represents the destroy hooks of a `multi` provider where:
  4459. * - Even indices represent the index of the provider for which we've registered a destroy hook,
  4460. * inside of the `multi` provider array.
  4461. * - Odd indices are the destroy hook functions.
  4462. * For example:
  4463. * LView: `[0, 1, 2, AService, 4, [BService, CService, DService]]`
  4464. * destroyHooks: `[3, AService.ngOnDestroy, 5, [0, BService.ngOnDestroy, 2, DService.ngOnDestroy]]`
  4465. *
  4466. * In the example above `AService` is a type provider with an `ngOnDestroy`, whereas `BService`,
  4467. * `CService` and `DService` are part of a `multi` provider where only `BService` and `DService`
  4468. * have an `ngOnDestroy` hook.
  4469. */
  4470. type DestroyHookData = (HookEntry | HookData)[];
  4471. /**
  4472. * Static data that corresponds to the instance-specific data array on an LView.
  4473. *
  4474. * Each node's static data is stored in tData at the same index that it's stored
  4475. * in the data array. Any nodes that do not have static data store a null value in
  4476. * tData to avoid a sparse array.
  4477. *
  4478. * Each pipe's definition is stored here at the same index as its pipe instance in
  4479. * the data array.
  4480. *
  4481. * Each host property's name is stored here at the same index as its value in the
  4482. * data array.
  4483. *
  4484. * Each property binding name is stored here at the same index as its value in
  4485. * the data array. If the binding is an interpolation, the static string values
  4486. * are stored parallel to the dynamic values. Example:
  4487. *
  4488. * id="prefix {{ v0 }} a {{ v1 }} b {{ v2 }} suffix"
  4489. *
  4490. * LView | TView.data
  4491. *------------------------
  4492. * v0 value | 'a'
  4493. * v1 value | 'b'
  4494. * v2 value | id � prefix � suffix
  4495. *
  4496. * Injector bloom filters are also stored here.
  4497. */
  4498. type TData = (TNode | PipeDef<any> | DirectiveDef<any> | ComponentDef<any> | number | TStylingRange | TStylingKey | ProviderToken<any> | TI18n | I18nUpdateOpCodes | TIcu | null | string | TDeferBlockDetails)[];
  4499. /**
  4500. * The strategy that the default change detector uses to detect changes.
  4501. * When set, takes effect the next time change detection is triggered.
  4502. *
  4503. * @see {@link /api/core/ChangeDetectorRef?tab=usage-notes Change detection usage}
  4504. * @see {@link /best-practices/skipping-subtrees Skipping component subtrees}
  4505. *
  4506. * @publicApi
  4507. */
  4508. declare enum ChangeDetectionStrategy {
  4509. /**
  4510. * Use the `CheckOnce` strategy, meaning that automatic change detection is deactivated
  4511. * until reactivated by setting the strategy to `Default` (`CheckAlways`).
  4512. * Change detection can still be explicitly invoked.
  4513. * This strategy applies to all child directives and cannot be overridden.
  4514. */
  4515. OnPush = 0,
  4516. /**
  4517. * Use the default `CheckAlways` strategy, in which change detection is automatic until
  4518. * explicitly deactivated.
  4519. */
  4520. Default = 1
  4521. }
  4522. /**
  4523. * An interface implemented by all Angular type decorators, which allows them to be used as
  4524. * decorators as well as Angular syntax.
  4525. *
  4526. * ```ts
  4527. * @ng.Component({...})
  4528. * class MyClass {...}
  4529. * ```
  4530. *
  4531. * @publicApi
  4532. */
  4533. interface TypeDecorator {
  4534. /**
  4535. * Invoke as decorator.
  4536. */
  4537. <T extends Type<any>>(type: T): T;
  4538. (target: Object, propertyKey?: string | symbol, parameterIndex?: number): void;
  4539. (target: unknown, context: unknown): void;
  4540. }
  4541. /**
  4542. * Type of the Directive decorator / constructor function.
  4543. * @publicApi
  4544. */
  4545. interface DirectiveDecorator {
  4546. /**
  4547. * Decorator that marks a class as an Angular directive.
  4548. * You can define your own directives to attach custom behavior to elements in the DOM.
  4549. *
  4550. * The options provide configuration metadata that determines
  4551. * how the directive should be processed, instantiated and used at
  4552. * runtime.
  4553. *
  4554. * Directive classes, like component classes, can implement
  4555. * [life-cycle hooks](guide/components/lifecycle) to influence their configuration and behavior.
  4556. *
  4557. *
  4558. * @usageNotes
  4559. * To define a directive, mark the class with the decorator and provide metadata.
  4560. *
  4561. * ```ts
  4562. * import {Directive} from '@angular/core';
  4563. *
  4564. * @Directive({
  4565. * selector: 'my-directive',
  4566. * })
  4567. * export class MyDirective {
  4568. * ...
  4569. * }
  4570. * ```
  4571. *
  4572. * ### Declaring directives
  4573. *
  4574. * In order to make a directive available to other components in your application, you should do
  4575. * one of the following:
  4576. * - either mark the directive as [standalone](guide/components/importing),
  4577. * - or declare it in an NgModule by adding it to the `declarations` and `exports` fields.
  4578. *
  4579. * ** Marking a directive as standalone **
  4580. *
  4581. * You can add the `standalone: true` flag to the Directive decorator metadata to declare it as
  4582. * [standalone](guide/components/importing):
  4583. *
  4584. * ```ts
  4585. * @Directive({
  4586. * standalone: true,
  4587. * selector: 'my-directive',
  4588. * })
  4589. * class MyDirective {}
  4590. * ```
  4591. *
  4592. * When marking a directive as standalone, please make sure that the directive is not already
  4593. * declared in an NgModule.
  4594. *
  4595. *
  4596. * ** Declaring a directive in an NgModule **
  4597. *
  4598. * Another approach is to declare a directive in an NgModule:
  4599. *
  4600. * ```ts
  4601. * @Directive({
  4602. * selector: 'my-directive',
  4603. * })
  4604. * class MyDirective {}
  4605. *
  4606. * @NgModule({
  4607. * declarations: [MyDirective, SomeComponent],
  4608. * exports: [MyDirective], // making it available outside of this module
  4609. * })
  4610. * class SomeNgModule {}
  4611. * ```
  4612. *
  4613. * When declaring a directive in an NgModule, please make sure that:
  4614. * - the directive is declared in exactly one NgModule.
  4615. * - the directive is not standalone.
  4616. * - you do not re-declare a directive imported from another module.
  4617. * - the directive is included into the `exports` field as well if you want this directive to be
  4618. * accessible for components outside of the NgModule.
  4619. *
  4620. *
  4621. * @Annotation
  4622. */
  4623. (obj?: Directive): TypeDecorator;
  4624. /**
  4625. * See the `Directive` decorator.
  4626. */
  4627. new (obj?: Directive): Directive;
  4628. }
  4629. /**
  4630. * Directive decorator and metadata.
  4631. *
  4632. * @Annotation
  4633. * @publicApi
  4634. */
  4635. interface Directive {
  4636. /**
  4637. * The CSS selector that identifies this directive in a template
  4638. * and triggers instantiation of the directive.
  4639. *
  4640. * Declare as one of the following:
  4641. *
  4642. * - `element-name`: Select by element name.
  4643. * - `.class`: Select by class name.
  4644. * - `[attribute]`: Select by attribute name.
  4645. * - `[attribute=value]`: Select by attribute name and value.
  4646. * - `:not(sub_selector)`: Select only if the element does not match the `sub_selector`.
  4647. * - `selector1, selector2`: Select if either `selector1` or `selector2` matches.
  4648. *
  4649. * Angular only allows directives to apply on CSS selectors that do not cross
  4650. * element boundaries.
  4651. *
  4652. * For the following template HTML, a directive with an `input[type=text]` selector,
  4653. * would be instantiated only on the `<input type="text">` element.
  4654. *
  4655. * ```html
  4656. * <form>
  4657. * <input type="text">
  4658. * <input type="radio">
  4659. * <form>
  4660. * ```
  4661. *
  4662. */
  4663. selector?: string;
  4664. /**
  4665. * Enumerates the set of data-bound input properties for a directive
  4666. *
  4667. * Angular automatically updates input properties during change detection.
  4668. * The `inputs` property accepts either strings or object literals that configure the directive
  4669. * properties that should be exposed as inputs.
  4670. *
  4671. * When an object literal is passed in, the `name` property indicates which property on the
  4672. * class the input should write to, while the `alias` determines the name under
  4673. * which the input will be available in template bindings. The `required` property indicates that
  4674. * the input is required which will trigger a compile-time error if it isn't passed in when the
  4675. * directive is used.
  4676. *
  4677. * When a string is passed into the `inputs` array, it can have a format of `'name'` or
  4678. * `'name: alias'` where `name` is the property on the class that the directive should write
  4679. * to, while the `alias` determines the name under which the input will be available in
  4680. * template bindings. String-based input definitions are assumed to be optional.
  4681. *
  4682. * @usageNotes
  4683. *
  4684. * The following example creates a component with two data-bound properties.
  4685. *
  4686. * ```ts
  4687. * @Component({
  4688. * selector: 'bank-account',
  4689. * inputs: ['bankName', {name: 'id', alias: 'account-id'}],
  4690. * template: `
  4691. * Bank Name: {{bankName}}
  4692. * Account Id: {{id}}
  4693. * `
  4694. * })
  4695. * class BankAccount {
  4696. * bankName: string;
  4697. * id: string;
  4698. * }
  4699. * ```
  4700. *
  4701. */
  4702. inputs?: ({
  4703. name: string;
  4704. alias?: string;
  4705. required?: boolean;
  4706. transform?: (value: any) => any;
  4707. } | string)[];
  4708. /**
  4709. * Enumerates the set of event-bound output properties.
  4710. *
  4711. * When an output property emits an event, an event handler attached to that event
  4712. * in the template is invoked.
  4713. *
  4714. * The `outputs` property defines a set of `directiveProperty` to `alias`
  4715. * configuration:
  4716. *
  4717. * - `directiveProperty` specifies the component property that emits events.
  4718. * - `alias` specifies the DOM property the event handler is attached to.
  4719. *
  4720. * @usageNotes
  4721. *
  4722. * ```ts
  4723. * @Component({
  4724. * selector: 'child-dir',
  4725. * outputs: [ 'bankNameChange' ],
  4726. * template: `<input (input)="bankNameChange.emit($event.target.value)" />`
  4727. * })
  4728. * class ChildDir {
  4729. * bankNameChange: EventEmitter<string> = new EventEmitter<string>();
  4730. * }
  4731. *
  4732. * @Component({
  4733. * selector: 'main',
  4734. * template: `
  4735. * {{ bankName }} <child-dir (bankNameChange)="onBankNameChange($event)"></child-dir>
  4736. * `
  4737. * })
  4738. * class MainComponent {
  4739. * bankName: string;
  4740. *
  4741. * onBankNameChange(bankName: string) {
  4742. * this.bankName = bankName;
  4743. * }
  4744. * }
  4745. * ```
  4746. *
  4747. */
  4748. outputs?: string[];
  4749. /**
  4750. * Configures the injector of this
  4751. * directive or component with a token
  4752. * that maps to a provider of a dependency.
  4753. */
  4754. providers?: Provider[];
  4755. /**
  4756. * Defines the name that can be used in the template to assign this directive to a variable.
  4757. *
  4758. * @usageNotes
  4759. *
  4760. * ```ts
  4761. * @Directive({
  4762. * selector: 'child-dir',
  4763. * exportAs: 'child'
  4764. * })
  4765. * class ChildDir {
  4766. * }
  4767. *
  4768. * @Component({
  4769. * selector: 'main',
  4770. * template: `<child-dir #c="child"></child-dir>`
  4771. * })
  4772. * class MainComponent {
  4773. * }
  4774. * ```
  4775. *
  4776. */
  4777. exportAs?: string;
  4778. /**
  4779. * Configures the queries that will be injected into the directive.
  4780. *
  4781. * Content queries are set before the `ngAfterContentInit` callback is called.
  4782. * View queries are set before the `ngAfterViewInit` callback is called.
  4783. *
  4784. * @usageNotes
  4785. *
  4786. * The following example shows how queries are defined
  4787. * and when their results are available in lifecycle hooks:
  4788. *
  4789. * ```ts
  4790. * @Component({
  4791. * selector: 'someDir',
  4792. * queries: {
  4793. * contentChildren: new ContentChildren(ChildDirective),
  4794. * viewChildren: new ViewChildren(ChildDirective)
  4795. * },
  4796. * template: '<child-directive></child-directive>'
  4797. * })
  4798. * class SomeDir {
  4799. * contentChildren: QueryList<ChildDirective>,
  4800. * viewChildren: QueryList<ChildDirective>
  4801. *
  4802. * ngAfterContentInit() {
  4803. * // contentChildren is set
  4804. * }
  4805. *
  4806. * ngAfterViewInit() {
  4807. * // viewChildren is set
  4808. * }
  4809. * }
  4810. * ```
  4811. *
  4812. * @Annotation
  4813. */
  4814. queries?: {
  4815. [key: string]: any;
  4816. };
  4817. /**
  4818. * Maps class properties to host element bindings for properties,
  4819. * attributes, and events, using a set of key-value pairs.
  4820. *
  4821. * Angular automatically checks host property bindings during change detection.
  4822. * If a binding changes, Angular updates the directive's host element.
  4823. *
  4824. * When the key is a property of the host element, the property value is
  4825. * propagated to the specified DOM property.
  4826. *
  4827. * When the key is a static attribute in the DOM, the attribute value
  4828. * is propagated to the specified property in the host element.
  4829. *
  4830. * For event handling:
  4831. * - The key is the DOM event that the directive listens to.
  4832. * To listen to global events, add the target to the event name.
  4833. * The target can be `window`, `document` or `body`.
  4834. * - The value is the statement to execute when the event occurs. If the
  4835. * statement evaluates to `false`, then `preventDefault` is applied on the DOM
  4836. * event. A handler method can refer to the `$event` local variable.
  4837. *
  4838. */
  4839. host?: {
  4840. [key: string]: string;
  4841. };
  4842. /**
  4843. * When present, this directive/component is ignored by the AOT compiler.
  4844. * It remains in distributed code, and the JIT compiler attempts to compile it
  4845. * at run time, in the browser.
  4846. * To ensure the correct behavior, the app must import `@angular/compiler`.
  4847. */
  4848. jit?: true;
  4849. /**
  4850. * Angular directives marked as `standalone` do not need to be declared in an NgModule. Such
  4851. * directives don't depend on any "intermediate context" of an NgModule (ex. configured
  4852. * providers).
  4853. *
  4854. * More information about standalone components, directives, and pipes can be found in [this
  4855. * guide](guide/components/importing).
  4856. */
  4857. standalone?: boolean;
  4858. /**
  4859. * Standalone directives that should be applied to the host whenever the directive is matched.
  4860. * By default, none of the inputs or outputs of the host directives will be available on the host,
  4861. * unless they are specified in the `inputs` or `outputs` properties.
  4862. *
  4863. * You can additionally alias inputs and outputs by putting a colon and the alias after the
  4864. * original input or output name. For example, if a directive applied via `hostDirectives`
  4865. * defines an input named `menuDisabled`, you can alias this to `disabled` by adding
  4866. * `'menuDisabled: disabled'` as an entry to `inputs`.
  4867. */
  4868. hostDirectives?: (Type<unknown> | {
  4869. directive: Type<unknown>;
  4870. inputs?: string[];
  4871. outputs?: string[];
  4872. })[];
  4873. }
  4874. /**
  4875. * Type of the Directive metadata.
  4876. *
  4877. * @publicApi
  4878. */
  4879. declare const Directive: DirectiveDecorator;
  4880. /**
  4881. * Component decorator interface
  4882. *
  4883. * @publicApi
  4884. */
  4885. interface ComponentDecorator {
  4886. /**
  4887. * Decorator that marks a class as an Angular component and provides configuration
  4888. * metadata that determines how the component should be processed,
  4889. * instantiated, and used at runtime.
  4890. *
  4891. * Components are the most basic UI building block of an Angular app.
  4892. * An Angular app contains a tree of Angular components.
  4893. *
  4894. * Angular components are a subset of directives, always associated with a template.
  4895. * Unlike other directives, only one component can be instantiated for a given element in a
  4896. * template.
  4897. *
  4898. * Standalone components can be directly imported in any other standalone component or NgModule.
  4899. * NgModule based apps on the other hand require components to belong to an NgModule in
  4900. * order for them to be available to another component or application. To make a component a
  4901. * member of an NgModule, list it in the `declarations` field of the `NgModule` metadata.
  4902. *
  4903. * Note that, in addition to these options for configuring a directive,
  4904. * you can control a component's runtime behavior by implementing
  4905. * life-cycle hooks. For more information, see the
  4906. * [Lifecycle Hooks](guide/components/lifecycle) guide.
  4907. *
  4908. * @usageNotes
  4909. *
  4910. * ### Setting component inputs
  4911. *
  4912. * The following example creates a component with two data-bound properties,
  4913. * specified by the `inputs` value.
  4914. *
  4915. * {@example core/ts/metadata/directives.ts region='component-input'}
  4916. *
  4917. *
  4918. * ### Setting component outputs
  4919. *
  4920. * The following example shows two output function that emit on an interval. One
  4921. * emits an output every second, while the other emits every five seconds.
  4922. *
  4923. * {@example core/ts/metadata/directives.ts region='component-output-interval'}
  4924. *
  4925. * ### Injecting a class with a view provider
  4926. *
  4927. * The following simple example injects a class into a component
  4928. * using the view provider specified in component metadata:
  4929. *
  4930. * ```ts
  4931. * class Greeter {
  4932. * greet(name:string) {
  4933. * return 'Hello ' + name + '!';
  4934. * }
  4935. * }
  4936. *
  4937. * @Directive({
  4938. * selector: 'needs-greeter'
  4939. * })
  4940. * class NeedsGreeter {
  4941. * greeter:Greeter;
  4942. *
  4943. * constructor(greeter:Greeter) {
  4944. * this.greeter = greeter;
  4945. * }
  4946. * }
  4947. *
  4948. * @Component({
  4949. * selector: 'greet',
  4950. * viewProviders: [
  4951. * Greeter
  4952. * ],
  4953. * template: `<needs-greeter></needs-greeter>`
  4954. * })
  4955. * class HelloWorld {
  4956. * }
  4957. *
  4958. * ```
  4959. *
  4960. * ### Preserving whitespace
  4961. *
  4962. * Removing whitespace can greatly reduce AOT-generated code size and speed up view creation.
  4963. * As of Angular 6, the default for `preserveWhitespaces` is false (whitespace is removed).
  4964. * To change the default setting for all components in your application, set
  4965. * the `preserveWhitespaces` option of the AOT compiler.
  4966. *
  4967. * By default, the AOT compiler removes whitespace characters as follows:
  4968. * * Trims all whitespaces at the beginning and the end of a template.
  4969. * * Removes whitespace-only text nodes. For example,
  4970. *
  4971. * ```html
  4972. * <button>Action 1</button> <button>Action 2</button>
  4973. * ```
  4974. *
  4975. * becomes:
  4976. *
  4977. * ```html
  4978. * <button>Action 1</button><button>Action 2</button>
  4979. * ```
  4980. *
  4981. * * Replaces a series of whitespace characters in text nodes with a single space.
  4982. * For example, `<span>\n some text\n</span>` becomes `<span> some text </span>`.
  4983. * * Does NOT alter text nodes inside HTML tags such as `<pre>` or `<textarea>`,
  4984. * where whitespace characters are significant.
  4985. *
  4986. * Note that these transformations can influence DOM nodes layout, although impact
  4987. * should be minimal.
  4988. *
  4989. * You can override the default behavior to preserve whitespace characters
  4990. * in certain fragments of a template. For example, you can exclude an entire
  4991. * DOM sub-tree by using the `ngPreserveWhitespaces` attribute:
  4992. *
  4993. * ```html
  4994. * <div ngPreserveWhitespaces>
  4995. * whitespaces are preserved here
  4996. * <span> and here </span>
  4997. * </div>
  4998. * ```
  4999. *
  5000. * You can force a single space to be preserved in a text node by using `&ngsp;`,
  5001. * which is replaced with a space character by Angular's template
  5002. * compiler:
  5003. *
  5004. * ```html
  5005. * <a>Spaces</a>&ngsp;<a>between</a>&ngsp;<a>links.</a>
  5006. * <!-- compiled to be equivalent to:
  5007. * <a>Spaces</a> <a>between</a> <a>links.</a> -->
  5008. * ```
  5009. *
  5010. * Note that sequences of `&ngsp;` are still collapsed to just one space character when
  5011. * the `preserveWhitespaces` option is set to `false`.
  5012. *
  5013. * ```html
  5014. * <a>before</a>&ngsp;&ngsp;&ngsp;<a>after</a>
  5015. * <!-- compiled to be equivalent to:
  5016. * <a>before</a> <a>after</a> -->
  5017. * ```
  5018. *
  5019. * To preserve sequences of whitespace characters, use the
  5020. * `ngPreserveWhitespaces` attribute.
  5021. *
  5022. * @Annotation
  5023. */
  5024. (obj: Component): TypeDecorator;
  5025. /**
  5026. * See the `Component` decorator.
  5027. */
  5028. new (obj: Component): Component;
  5029. }
  5030. /**
  5031. * Supplies configuration metadata for an Angular component.
  5032. *
  5033. * @publicApi
  5034. */
  5035. interface Component extends Directive {
  5036. /**
  5037. * The change-detection strategy to use for this component.
  5038. *
  5039. * When a component is instantiated, Angular creates a change detector,
  5040. * which is responsible for propagating the component's bindings.
  5041. * The strategy is one of:
  5042. * - `ChangeDetectionStrategy#OnPush` sets the strategy to `CheckOnce` (on demand).
  5043. * - `ChangeDetectionStrategy#Default` sets the strategy to `CheckAlways`.
  5044. */
  5045. changeDetection?: ChangeDetectionStrategy;
  5046. /**
  5047. * Defines the set of injectable objects that are visible to its view DOM children.
  5048. * See [example](#injecting-a-class-with-a-view-provider).
  5049. *
  5050. */
  5051. viewProviders?: Provider[];
  5052. /**
  5053. * The module ID of the module that contains the component.
  5054. * The component must be able to resolve relative URLs for templates and styles.
  5055. * SystemJS exposes the `__moduleName` variable within each module.
  5056. * In CommonJS, this can be set to `module.id`.
  5057. *
  5058. * @deprecated This option does not have any effect. Will be removed in Angular v17.
  5059. */
  5060. moduleId?: string;
  5061. /**
  5062. * The relative path or absolute URL of a template file for an Angular component.
  5063. * If provided, do not supply an inline template using `template`.
  5064. *
  5065. */
  5066. templateUrl?: string;
  5067. /**
  5068. * An inline template for an Angular component. If provided,
  5069. * do not supply a template file using `templateUrl`.
  5070. *
  5071. */
  5072. template?: string;
  5073. /**
  5074. * One relative path or an absolute URL for file containing a CSS stylesheet to use
  5075. * in this component.
  5076. */
  5077. styleUrl?: string;
  5078. /**
  5079. * Relative paths or absolute URLs for files containing CSS stylesheets to use in this component.
  5080. */
  5081. styleUrls?: string[];
  5082. /**
  5083. * One or more inline CSS stylesheets to use
  5084. * in this component.
  5085. */
  5086. styles?: string | string[];
  5087. /**
  5088. * One or more animation `trigger()` calls, containing
  5089. * [`state()`](api/animations/state) and `transition()` definitions.
  5090. * See the [Animations guide](guide/animations) and animations API documentation.
  5091. *
  5092. */
  5093. animations?: any[];
  5094. /**
  5095. * An encapsulation policy for the component's styling.
  5096. * Possible values:
  5097. * - `ViewEncapsulation.Emulated`: Apply modified component styles in order to emulate
  5098. * a native Shadow DOM CSS encapsulation behavior.
  5099. * - `ViewEncapsulation.None`: Apply component styles globally without any sort of encapsulation.
  5100. * - `ViewEncapsulation.ShadowDom`: Use the browser's native Shadow DOM API to encapsulate styles.
  5101. *
  5102. * If not supplied, the value is taken from the `CompilerOptions`
  5103. * which defaults to `ViewEncapsulation.Emulated`.
  5104. *
  5105. * If the policy is `ViewEncapsulation.Emulated` and the component has no
  5106. * {@link Component#styles styles} nor {@link Component#styleUrls styleUrls},
  5107. * the policy is automatically switched to `ViewEncapsulation.None`.
  5108. */
  5109. encapsulation?: ViewEncapsulation;
  5110. /**
  5111. * Overrides the default interpolation start and end delimiters (`{{` and `}}`).
  5112. *
  5113. * @deprecated use Angular's default interpolation delimiters instead.
  5114. */
  5115. interpolation?: [string, string];
  5116. /**
  5117. * True to preserve or false to remove potentially superfluous whitespace characters
  5118. * from the compiled template. Whitespace characters are those matching the `\s`
  5119. * character class in JavaScript regular expressions. Default is false, unless
  5120. * overridden in compiler options.
  5121. */
  5122. preserveWhitespaces?: boolean;
  5123. /**
  5124. * Angular components marked as `standalone` do not need to be declared in an NgModule. Such
  5125. * components directly manage their own template dependencies (components, directives, and pipes
  5126. * used in a template) via the imports property.
  5127. *
  5128. * More information about standalone components, directives, and pipes can be found in [this
  5129. * guide](guide/components/importing).
  5130. */
  5131. standalone?: boolean;
  5132. /**
  5133. * The imports property specifies the standalone component's template dependencies — those
  5134. * directives, components, and pipes that can be used within its template. Standalone components
  5135. * can import other standalone components, directives, and pipes as well as existing NgModules.
  5136. *
  5137. * This property is only available for standalone components - specifying it for components
  5138. * declared in an NgModule generates a compilation error.
  5139. *
  5140. * More information about standalone components, directives, and pipes can be found in [this
  5141. * guide](guide/components/importing).
  5142. */
  5143. imports?: (Type<any> | ReadonlyArray<any>)[];
  5144. /**
  5145. * The set of schemas that declare elements to be allowed in a standalone component. Elements and
  5146. * properties that are neither Angular components nor directives must be declared in a schema.
  5147. *
  5148. * This property is only available for standalone components - specifying it for components
  5149. * declared in an NgModule generates a compilation error.
  5150. *
  5151. * More information about standalone components, directives, and pipes can be found in [this
  5152. * guide](guide/components/importing).
  5153. */
  5154. schemas?: SchemaMetadata[];
  5155. }
  5156. /**
  5157. * Component decorator and metadata.
  5158. *
  5159. * @Annotation
  5160. * @publicApi
  5161. */
  5162. declare const Component: ComponentDecorator;
  5163. /**
  5164. * Type of the Pipe decorator / constructor function.
  5165. *
  5166. * @publicApi
  5167. */
  5168. interface PipeDecorator {
  5169. /**
  5170. *
  5171. * Decorator that marks a class as pipe and supplies configuration metadata.
  5172. *
  5173. * A pipe class must implement the `PipeTransform` interface.
  5174. * For example, if the name is "myPipe", use a template binding expression
  5175. * such as the following:
  5176. *
  5177. * ```html
  5178. * {{ exp | myPipe }}
  5179. * ```
  5180. *
  5181. * The result of the expression is passed to the pipe's `transform()` method.
  5182. *
  5183. * A pipe must belong to an NgModule in order for it to be available
  5184. * to a template. To make it a member of an NgModule,
  5185. * list it in the `declarations` field of the `NgModule` metadata.
  5186. *
  5187. * @see [Style Guide: Pipe Names](style-guide#02-09)
  5188. *
  5189. */
  5190. (obj: Pipe): TypeDecorator;
  5191. /**
  5192. * See the `Pipe` decorator.
  5193. */
  5194. new (obj: Pipe): Pipe;
  5195. }
  5196. /**
  5197. * Type of the Pipe metadata.
  5198. *
  5199. * @publicApi
  5200. */
  5201. interface Pipe {
  5202. /**
  5203. * The pipe name to use in template bindings.
  5204. * Typically uses lowerCamelCase
  5205. * because the name cannot contain hyphens.
  5206. */
  5207. name: string;
  5208. /**
  5209. * When true, the pipe is pure, meaning that the
  5210. * `transform()` method is invoked only when its input arguments
  5211. * change. Pipes are pure by default.
  5212. *
  5213. * If the pipe has internal state (that is, the result
  5214. * depends on state other than its arguments), set `pure` to false.
  5215. * In this case, the pipe is invoked on each change-detection cycle,
  5216. * even if the arguments have not changed.
  5217. */
  5218. pure?: boolean;
  5219. /**
  5220. * Angular pipes marked as `standalone` do not need to be declared in an NgModule. Such
  5221. * pipes don't depend on any "intermediate context" of an NgModule (ex. configured providers).
  5222. *
  5223. * More information about standalone components, directives, and pipes can be found in [this
  5224. * guide](guide/components/importing).
  5225. */
  5226. standalone?: boolean;
  5227. }
  5228. /**
  5229. * @Annotation
  5230. * @publicApi
  5231. */
  5232. declare const Pipe: PipeDecorator;
  5233. /**
  5234. * @publicApi
  5235. */
  5236. interface InputDecorator {
  5237. /**
  5238. * Decorator that marks a class field as an input property and supplies configuration metadata.
  5239. * The input property is bound to a DOM property in the template. During change detection,
  5240. * Angular automatically updates the data property with the DOM property's value.
  5241. *
  5242. * @usageNotes
  5243. *
  5244. * You can supply an optional name to use in templates when the
  5245. * component is instantiated, that maps to the
  5246. * name of the bound property. By default, the original
  5247. * name of the bound property is used for input binding.
  5248. *
  5249. * The following example creates a component with two input properties,
  5250. * one of which is given a special binding name.
  5251. *
  5252. * ```ts
  5253. * import { Component, Input, numberAttribute, booleanAttribute } from '@angular/core';
  5254. * @Component({
  5255. * selector: 'bank-account',
  5256. * template: `
  5257. * Bank Name: {{bankName}}
  5258. * Account Id: {{id}}
  5259. * Account Status: {{status ? 'Active' : 'InActive'}}
  5260. * `
  5261. * })
  5262. * class BankAccount {
  5263. * // This property is bound using its original name.
  5264. * // Defining argument required as true inside the Input Decorator
  5265. * // makes this property deceleration as mandatory
  5266. * @Input({ required: true }) bankName!: string;
  5267. * // Argument alias makes this property value is bound to a different property name
  5268. * // when this component is instantiated in a template.
  5269. * // Argument transform convert the input value from string to number
  5270. * @Input({ alias:'account-id', transform: numberAttribute }) id: number;
  5271. * // Argument transform the input value from string to boolean
  5272. * @Input({ transform: booleanAttribute }) status: boolean;
  5273. * // this property is not bound, and is not automatically updated by Angular
  5274. * normalizedBankName: string;
  5275. * }
  5276. *
  5277. * @Component({
  5278. * selector: 'app',
  5279. * template: `
  5280. * <bank-account bankName="RBC" account-id="4747" status="true"></bank-account>
  5281. * `
  5282. * })
  5283. * class App {}
  5284. * ```
  5285. *
  5286. * @see [Input properties](guide/components/inputs)
  5287. * @see [Output properties](guide/components/outputs)
  5288. */
  5289. (arg?: string | Input): any;
  5290. new (arg?: string | Input): any;
  5291. }
  5292. /**
  5293. * Type of metadata for an `Input` property.
  5294. *
  5295. * @publicApi
  5296. */
  5297. interface Input {
  5298. /**
  5299. * The name of the DOM property to which the input property is bound.
  5300. */
  5301. alias?: string;
  5302. /**
  5303. * Whether the input is required for the directive to function.
  5304. */
  5305. required?: boolean;
  5306. /**
  5307. * Function with which to transform the input value before assigning it to the directive instance.
  5308. */
  5309. transform?: (value: any) => any;
  5310. }
  5311. /**
  5312. * @Annotation
  5313. * @publicApi
  5314. */
  5315. declare const Input: InputDecorator;
  5316. /**
  5317. * Type of the Output decorator / constructor function.
  5318. *
  5319. * @publicApi
  5320. */
  5321. interface OutputDecorator {
  5322. /**
  5323. * Decorator that marks a class field as an output property and supplies configuration metadata.
  5324. * The DOM property bound to the output property is automatically updated during change detection.
  5325. *
  5326. * @usageNotes
  5327. *
  5328. * You can supply an optional name to use in templates when the
  5329. * component is instantiated, that maps to the
  5330. * name of the bound property. By default, the original
  5331. * name of the bound property is used for output binding.
  5332. *
  5333. * See `Input` decorator for an example of providing a binding name.
  5334. *
  5335. * @see [Input properties](guide/components/inputs)
  5336. * @see [Output properties](guide/components/outputs)
  5337. *
  5338. */
  5339. (alias?: string): any;
  5340. new (alias?: string): any;
  5341. }
  5342. /**
  5343. * Type of the Output metadata.
  5344. *
  5345. * @publicApi
  5346. */
  5347. interface Output {
  5348. /**
  5349. * The name of the DOM property to which the output property is bound.
  5350. */
  5351. alias?: string;
  5352. }
  5353. /**
  5354. * @Annotation
  5355. * @publicApi
  5356. */
  5357. declare const Output: OutputDecorator;
  5358. /**
  5359. * Type of the HostBinding decorator / constructor function.
  5360. *
  5361. * @publicApi
  5362. */
  5363. interface HostBindingDecorator {
  5364. /**
  5365. * Decorator that marks a DOM property or an element class, style or attribute as a host-binding
  5366. * property and supplies configuration metadata. Angular automatically checks host bindings during
  5367. * change detection, and if a binding changes it updates the host element of the directive.
  5368. *
  5369. * @usageNotes
  5370. *
  5371. * The following example creates a directive that sets the `valid` and `invalid`
  5372. * class, a style color, and an id on the DOM element that has an `ngModel` directive on it.
  5373. *
  5374. * ```ts
  5375. * @Directive({selector: '[ngModel]'})
  5376. * class NgModelStatus {
  5377. * constructor(public control: NgModel) {}
  5378. * // class bindings
  5379. * @HostBinding('class.valid') get valid() { return this.control.valid; }
  5380. * @HostBinding('class.invalid') get invalid() { return this.control.invalid; }
  5381. *
  5382. * // style binding
  5383. * @HostBinding('style.color') get color() { return this.control.valid ? 'green': 'red'; }
  5384. *
  5385. * // style binding also supports a style unit extension
  5386. * @HostBinding('style.width.px') @Input() width: number = 500;
  5387. *
  5388. * // attribute binding
  5389. * @HostBinding('attr.aria-required')
  5390. * @Input() required: boolean = false;
  5391. *
  5392. * // property binding
  5393. * @HostBinding('id') get id() { return this.control.value?.length ? 'odd': 'even'; }
  5394. *
  5395. * @Component({
  5396. * selector: 'app',
  5397. * template: `<input [(ngModel)]="prop">`,
  5398. * })
  5399. * class App {
  5400. * prop;
  5401. * }
  5402. * ```
  5403. *
  5404. */
  5405. (hostPropertyName?: string): any;
  5406. new (hostPropertyName?: string): any;
  5407. }
  5408. /**
  5409. * Type of the HostBinding metadata.
  5410. *
  5411. * @publicApi
  5412. */
  5413. interface HostBinding {
  5414. /**
  5415. * The DOM property that is bound to a data property.
  5416. * This field also accepts:
  5417. * * classes, prefixed by `class.`
  5418. * * styles, prefixed by `style.`
  5419. * * attributes, prefixed by `attr.`
  5420. */
  5421. hostPropertyName?: string;
  5422. }
  5423. /**
  5424. * @Annotation
  5425. * @publicApi
  5426. */
  5427. declare const HostBinding: HostBindingDecorator;
  5428. /**
  5429. * Type of the HostListener decorator / constructor function.
  5430. *
  5431. * @publicApi
  5432. */
  5433. interface HostListenerDecorator {
  5434. /**
  5435. * Decorator that declares a DOM event to listen for,
  5436. * and provides a handler method to run when that event occurs.
  5437. *
  5438. * Angular invokes the supplied handler method when the host element emits the specified event,
  5439. * and updates the bound element with the result.
  5440. *
  5441. * If the handler method returns false, applies `preventDefault` on the bound element.
  5442. *
  5443. * @usageNotes
  5444. *
  5445. * The following example declares a directive
  5446. * that attaches a click listener to a button and counts clicks.
  5447. *
  5448. * ```ts
  5449. * @Directive({selector: 'button[counting]'})
  5450. * class CountClicks {
  5451. * numberOfClicks = 0;
  5452. *
  5453. * @HostListener('click', ['$event.target'])
  5454. * onClick(btn) {
  5455. * console.log('button', btn, 'number of clicks:', this.numberOfClicks++);
  5456. * }
  5457. * }
  5458. *
  5459. * @Component({
  5460. * selector: 'app',
  5461. * template: '<button counting>Increment</button>',
  5462. * })
  5463. * class App {}
  5464. * ```
  5465. *
  5466. * The following example registers another DOM event handler that listens for `Enter` key-press
  5467. * events on the global `window`.
  5468. * ```ts
  5469. * import { HostListener, Component } from "@angular/core";
  5470. *
  5471. * @Component({
  5472. * selector: 'app',
  5473. * template: `<h1>Hello, you have pressed enter {{counter}} number of times!</h1> Press enter
  5474. * key to increment the counter. <button (click)="resetCounter()">Reset Counter</button>`
  5475. * })
  5476. * class AppComponent {
  5477. * counter = 0;
  5478. * @HostListener('window:keydown.enter', ['$event'])
  5479. * handleKeyDown(event: KeyboardEvent) {
  5480. * this.counter++;
  5481. * }
  5482. * resetCounter() {
  5483. * this.counter = 0;
  5484. * }
  5485. * }
  5486. * ```
  5487. * The list of valid key names for `keydown` and `keyup` events
  5488. * can be found here:
  5489. * https://www.w3.org/TR/DOM-Level-3-Events-key/#named-key-attribute-values
  5490. *
  5491. * Note that keys can also be combined, e.g. `@HostListener('keydown.shift.a')`.
  5492. *
  5493. * The global target names that can be used to prefix an event name are
  5494. * `document:`, `window:` and `body:`.
  5495. *
  5496. */
  5497. (eventName: string, args?: string[]): any;
  5498. new (eventName: string, args?: string[]): any;
  5499. }
  5500. /**
  5501. * Type of the HostListener metadata.
  5502. *
  5503. * @publicApi
  5504. */
  5505. interface HostListener {
  5506. /**
  5507. * The DOM event to listen for.
  5508. */
  5509. eventName?: string;
  5510. /**
  5511. * A set of arguments to pass to the handler method when the event occurs.
  5512. */
  5513. args?: string[];
  5514. }
  5515. /**
  5516. * @Annotation
  5517. * @publicApi
  5518. */
  5519. declare const HostListener: HostListenerDecorator;
  5520. /**
  5521. * Base class that provides change detection functionality.
  5522. * A change-detection tree collects all views that are to be checked for changes.
  5523. * Use the methods to add and remove views from the tree, initiate change-detection,
  5524. * and explicitly mark views as _dirty_, meaning that they have changed and need to be re-rendered.
  5525. *
  5526. * @see [Using change detection hooks](guide/components/lifecycle#using-change-detection-hooks)
  5527. * @see [Defining custom change detection](guide/components/lifecycle#defining-custom-change-detection)
  5528. *
  5529. * @usageNotes
  5530. *
  5531. * The following examples demonstrate how to modify default change-detection behavior
  5532. * to perform explicit detection when needed.
  5533. *
  5534. * ### Use `markForCheck()` with `CheckOnce` strategy
  5535. *
  5536. * The following example sets the `OnPush` change-detection strategy for a component
  5537. * (`CheckOnce`, rather than the default `CheckAlways`), then forces a second check
  5538. * after an interval.
  5539. *
  5540. * {@example core/ts/change_detect/change-detection.ts region='mark-for-check'}
  5541. *
  5542. * ### Detach change detector to limit how often check occurs
  5543. *
  5544. * The following example defines a component with a large list of read-only data
  5545. * that is expected to change constantly, many times per second.
  5546. * To improve performance, we want to check and update the list
  5547. * less often than the changes actually occur. To do that, we detach
  5548. * the component's change detector and perform an explicit local check every five seconds.
  5549. *
  5550. * {@example core/ts/change_detect/change-detection.ts region='detach'}
  5551. *
  5552. *
  5553. * ### Reattaching a detached component
  5554. *
  5555. * The following example creates a component displaying live data.
  5556. * The component detaches its change detector from the main change detector tree
  5557. * when the `live` property is set to false, and reattaches it when the property
  5558. * becomes true.
  5559. *
  5560. * {@example core/ts/change_detect/change-detection.ts region='reattach'}
  5561. *
  5562. * @publicApi
  5563. */
  5564. declare abstract class ChangeDetectorRef {
  5565. /**
  5566. * When a view uses the {@link ChangeDetectionStrategy#OnPush} (checkOnce)
  5567. * change detection strategy, explicitly marks the view as changed so that
  5568. * it can be checked again.
  5569. *
  5570. * Components are normally marked as dirty (in need of rerendering) when inputs
  5571. * have changed or events have fired in the view. Call this method to ensure that
  5572. * a component is checked even if these triggers have not occurred.
  5573. *
  5574. * <!-- TODO: Add a link to a chapter on OnPush components -->
  5575. *
  5576. */
  5577. abstract markForCheck(): void;
  5578. /**
  5579. * Detaches this view from the change-detection tree.
  5580. * A detached view is not checked until it is reattached.
  5581. * Use in combination with `detectChanges()` to implement local change detection checks.
  5582. *
  5583. * Detached views are not checked during change detection runs until they are
  5584. * re-attached, even if they are marked as dirty.
  5585. *
  5586. * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
  5587. * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
  5588. *
  5589. */
  5590. abstract detach(): void;
  5591. /**
  5592. * Checks this view and its children. Use in combination with {@link ChangeDetectorRef#detach}
  5593. * to implement local change detection checks.
  5594. *
  5595. * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
  5596. * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
  5597. *
  5598. */
  5599. abstract detectChanges(): void;
  5600. /**
  5601. * Checks the change detector and its children, and throws if any changes are detected.
  5602. *
  5603. * Use in development mode to verify that running change detection doesn't introduce
  5604. * other changes. Calling it in production mode is a noop.
  5605. *
  5606. * @deprecated This is a test-only API that does not have a place in production interface.
  5607. * `checkNoChanges` is already part of an `ApplicationRef` tick when the app is running in dev
  5608. * mode. For more granular `checkNoChanges` validation, use `ComponentFixture`.
  5609. */
  5610. abstract checkNoChanges(): void;
  5611. /**
  5612. * Re-attaches the previously detached view to the change detection tree.
  5613. * Views are attached to the tree by default.
  5614. *
  5615. * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
  5616. *
  5617. */
  5618. abstract reattach(): void;
  5619. }
  5620. /** Returns a ChangeDetectorRef (a.k.a. a ViewRef) */
  5621. declare function injectChangeDetectorRef(flags: InternalInjectFlags): ChangeDetectorRef;
  5622. /*!
  5623. * @license
  5624. * Copyright Google LLC All Rights Reserved.
  5625. *
  5626. * Use of this source code is governed by an MIT-style license that can be
  5627. * found in the LICENSE file at https://angular.dev/license
  5628. */
  5629. /** Symbol used to store and retrieve metadata about a binding. */
  5630. declare const BINDING: unique symbol;
  5631. /**
  5632. * A dynamically-defined binding targeting.
  5633. * For example, `inputBinding('value', () => 123)` creates an input binding.
  5634. */
  5635. interface Binding {
  5636. readonly [BINDING]: unknown;
  5637. }
  5638. /**
  5639. * Represents a dynamically-created directive with bindings targeting it specifically.
  5640. */
  5641. interface DirectiveWithBindings<T> {
  5642. /** Directive type that should be created. */
  5643. type: Type<T>;
  5644. /** Bindings that should be applied to the specific directive. */
  5645. bindings: Binding[];
  5646. }
  5647. /**
  5648. * Creates an input binding.
  5649. * @param publicName Public name of the input to bind to.
  5650. * @param value Callback that returns the current value for the binding. Can be either a signal or
  5651. * a plain getter function.
  5652. *
  5653. * ### Usage Example
  5654. * In this example we create an instance of the `MyButton` component and bind the value of
  5655. * the `isDisabled` signal to its `disabled` input.
  5656. *
  5657. * ```
  5658. * const isDisabled = signal(false);
  5659. *
  5660. * createComponent(MyButton, {
  5661. * bindings: [inputBinding('disabled', isDisabled)]
  5662. * });
  5663. * ```
  5664. */
  5665. declare function inputBinding(publicName: string, value: () => unknown): Binding;
  5666. /**
  5667. * Creates an output binding.
  5668. * @param eventName Public name of the output to listen to.
  5669. * @param listener Function to be called when the output emits.
  5670. *
  5671. * ### Usage example
  5672. * In this example we create an instance of the `MyCheckbox` component and listen
  5673. * to its `onChange` event.
  5674. *
  5675. * ```
  5676. * interface CheckboxChange {
  5677. * value: string;
  5678. * }
  5679. *
  5680. * createComponent(MyCheckbox, {
  5681. * bindings: [
  5682. * outputBinding<CheckboxChange>('onChange', event => console.log(event.value))
  5683. * ],
  5684. * });
  5685. * ```
  5686. */
  5687. declare function outputBinding<T>(eventName: string, listener: (event: T) => unknown): Binding;
  5688. /**
  5689. * Creates a two-way binding.
  5690. * @param eventName Public name of the two-way compatible input.
  5691. * @param value Writable signal from which to get the current value and to which to write new
  5692. * values.
  5693. *
  5694. * ### Usage example
  5695. * In this example we create an instance of the `MyCheckbox` component and bind to its `value`
  5696. * input using a two-way binding.
  5697. *
  5698. * ```
  5699. * const checkboxValue = signal('');
  5700. *
  5701. * createComponent(MyCheckbox, {
  5702. * bindings: [
  5703. * twoWayBinding('value', checkboxValue),
  5704. * ],
  5705. * });
  5706. * ```
  5707. */
  5708. declare function twoWayBinding(publicName: string, value: WritableSignal<unknown>): Binding;
  5709. /**
  5710. * A wrapper around a native element inside of a View.
  5711. *
  5712. * An `ElementRef` is backed by a render-specific element. In the browser, this is usually a DOM
  5713. * element.
  5714. *
  5715. * @security Permitting direct access to the DOM can make your application more vulnerable to
  5716. * XSS attacks. Carefully review any use of `ElementRef` in your code. For more detail, see the
  5717. * [Security Guide](https://g.co/ng/security).
  5718. *
  5719. * @publicApi
  5720. */
  5721. declare class ElementRef<T = any> {
  5722. /**
  5723. * <div class="docs-alert docs-alert-important">
  5724. * <header>Use with caution</header>
  5725. * <p>
  5726. * Use this API as the last resort when direct access to DOM is needed. Use templating and
  5727. * data-binding provided by Angular instead. If used, it is recommended in combination with
  5728. * {@link /best-practices/security#direct-use-of-the-dom-apis-and-explicit-sanitization-calls DomSanitizer}
  5729. * for maxiumum security;
  5730. * </p>
  5731. * </div>
  5732. */
  5733. nativeElement: T;
  5734. constructor(nativeElement: T);
  5735. }
  5736. /**
  5737. * A simple registry that maps `Components` to generated `ComponentFactory` classes
  5738. * that can be used to create instances of components.
  5739. * Use to obtain the factory for a given component type,
  5740. * then use the factory's `create()` method to create a component of that type.
  5741. *
  5742. * Note: since v13, dynamic component creation via
  5743. * [`ViewContainerRef.createComponent`](api/core/ViewContainerRef#createComponent)
  5744. * does **not** require resolving component factory: component class can be used directly.
  5745. *
  5746. * @publicApi
  5747. *
  5748. * @deprecated Angular no longer requires Component factories. Please use other APIs where
  5749. * Component class can be used directly.
  5750. */
  5751. declare abstract class ComponentFactoryResolver {
  5752. static NULL: ComponentFactoryResolver;
  5753. /**
  5754. * Retrieves the factory object that creates a component of the given type.
  5755. * @param component The component type.
  5756. */
  5757. abstract resolveComponentFactory<T>(component: Type<T>): ComponentFactory<T>;
  5758. }
  5759. /**
  5760. * Represents an instance of an `NgModule` created by an `NgModuleFactory`.
  5761. * Provides access to the `NgModule` instance and related objects.
  5762. *
  5763. * @publicApi
  5764. */
  5765. declare abstract class NgModuleRef<T> {
  5766. /**
  5767. * The injector that contains all of the providers of the `NgModule`.
  5768. */
  5769. abstract get injector(): EnvironmentInjector;
  5770. /**
  5771. * The resolver that can retrieve component factories in a context of this module.
  5772. *
  5773. * Note: since v13, dynamic component creation via
  5774. * [`ViewContainerRef.createComponent`](api/core/ViewContainerRef#createComponent)
  5775. * does **not** require resolving component factory: component class can be used directly.
  5776. *
  5777. * @deprecated Angular no longer requires Component factories. Please use other APIs where
  5778. * Component class can be used directly.
  5779. */
  5780. abstract get componentFactoryResolver(): ComponentFactoryResolver;
  5781. /**
  5782. * The `NgModule` instance.
  5783. */
  5784. abstract get instance(): T;
  5785. /**
  5786. * Destroys the module instance and all of the data structures associated with it.
  5787. */
  5788. abstract destroy(): void;
  5789. /**
  5790. * Registers a callback to be executed when the module is destroyed.
  5791. */
  5792. abstract onDestroy(callback: () => void): void;
  5793. }
  5794. interface InternalNgModuleRef<T> extends NgModuleRef<T> {
  5795. _bootstrapComponents: Type<any>[];
  5796. resolveInjectorInitializers(): void;
  5797. }
  5798. /**
  5799. * @publicApi
  5800. *
  5801. * @deprecated
  5802. * This class was mostly used as a part of ViewEngine-based JIT API and is no longer needed in Ivy
  5803. * JIT mode. Angular provides APIs that accept NgModule classes directly (such as
  5804. * [PlatformRef.bootstrapModule](api/core/PlatformRef#bootstrapModule) and
  5805. * [createNgModule](api/core/createNgModule)), consider switching to those APIs instead of
  5806. * using factory-based ones.
  5807. */
  5808. declare abstract class NgModuleFactory<T> {
  5809. abstract get moduleType(): Type<T>;
  5810. abstract create(parentInjector: Injector | null): NgModuleRef<T>;
  5811. }
  5812. /**
  5813. * Represents an Angular view.
  5814. *
  5815. * @see {@link /api/core/ChangeDetectorRef?tab=usage-notes Change detection usage}
  5816. *
  5817. * @publicApi
  5818. */
  5819. declare abstract class ViewRef extends ChangeDetectorRef {
  5820. /**
  5821. * Destroys this view and all of the data structures associated with it.
  5822. */
  5823. abstract destroy(): void;
  5824. /**
  5825. * Reports whether this view has been destroyed.
  5826. * @returns True after the `destroy()` method has been called, false otherwise.
  5827. */
  5828. abstract get destroyed(): boolean;
  5829. /**
  5830. * A lifecycle hook that provides additional developer-defined cleanup
  5831. * functionality for views.
  5832. * @param callback A handler function that cleans up developer-defined data
  5833. * associated with a view. Called when the `destroy()` method is invoked.
  5834. */
  5835. abstract onDestroy(callback: Function): void;
  5836. }
  5837. /**
  5838. * Represents an Angular view in a view container.
  5839. * An embedded view can be referenced from a component
  5840. * other than the hosting component whose template defines it, or it can be defined
  5841. * independently by a `TemplateRef`.
  5842. *
  5843. * Properties of elements in a view can change, but the structure (number and order) of elements in
  5844. * a view cannot. Change the structure of elements by inserting, moving, or
  5845. * removing nested views in a view container.
  5846. *
  5847. * @see {@link ViewContainerRef}
  5848. *
  5849. * @usageNotes
  5850. *
  5851. * The following template breaks down into two separate `TemplateRef` instances,
  5852. * an outer one and an inner one.
  5853. *
  5854. * ```html
  5855. * Count: {{items.length}}
  5856. * <ul>
  5857. * <li *ngFor="let item of items">{{item}}</li>
  5858. * </ul>
  5859. * ```
  5860. *
  5861. * This is the outer `TemplateRef`:
  5862. *
  5863. * ```html
  5864. * Count: {{items.length}}
  5865. * <ul>
  5866. * <ng-template ngFor let-item [ngForOf]="items"></ng-template>
  5867. * </ul>
  5868. * ```
  5869. *
  5870. * This is the inner `TemplateRef`:
  5871. *
  5872. * ```html
  5873. * <li>{{item}}</li>
  5874. * ```
  5875. *
  5876. * The outer and inner `TemplateRef` instances are assembled into views as follows:
  5877. *
  5878. * ```html
  5879. * <!-- ViewRef: outer-0 -->
  5880. * Count: 2
  5881. * <ul>
  5882. * <ng-template view-container-ref></ng-template>
  5883. * <!-- ViewRef: inner-1 --><li>first</li><!-- /ViewRef: inner-1 -->
  5884. * <!-- ViewRef: inner-2 --><li>second</li><!-- /ViewRef: inner-2 -->
  5885. * </ul>
  5886. * <!-- /ViewRef: outer-0 -->
  5887. * ```
  5888. * @publicApi
  5889. */
  5890. declare abstract class EmbeddedViewRef<C> extends ViewRef {
  5891. /**
  5892. * The context for this view, inherited from the anchor element.
  5893. */
  5894. abstract context: C;
  5895. /**
  5896. * The root nodes for this embedded view.
  5897. */
  5898. abstract get rootNodes(): any[];
  5899. }
  5900. /**
  5901. * Represents a component created by a `ComponentFactory`.
  5902. * Provides access to the component instance and related objects,
  5903. * and provides the means of destroying the instance.
  5904. *
  5905. * @publicApi
  5906. */
  5907. declare abstract class ComponentRef<C> {
  5908. /**
  5909. * Updates a specified input name to a new value. Using this method will properly mark for check
  5910. * component using the `OnPush` change detection strategy. It will also assure that the
  5911. * `OnChanges` lifecycle hook runs when a dynamically created component is change-detected.
  5912. *
  5913. * @param name The name of an input.
  5914. * @param value The new value of an input.
  5915. */
  5916. abstract setInput(name: string, value: unknown): void;
  5917. /**
  5918. * The host or anchor element for this component instance.
  5919. */
  5920. abstract get location(): ElementRef;
  5921. /**
  5922. * The dependency injector for this component instance.
  5923. */
  5924. abstract get injector(): Injector;
  5925. /**
  5926. * This component instance.
  5927. */
  5928. abstract get instance(): C;
  5929. /**
  5930. * The host view defined by the template
  5931. * for this component instance.
  5932. */
  5933. abstract get hostView(): ViewRef;
  5934. /**
  5935. * The change detector for this component instance.
  5936. */
  5937. abstract get changeDetectorRef(): ChangeDetectorRef;
  5938. /**
  5939. * The type of this component (as created by a `ComponentFactory` class).
  5940. */
  5941. abstract get componentType(): Type<any>;
  5942. /**
  5943. * Destroys the component instance and all of the data structures associated with it.
  5944. */
  5945. abstract destroy(): void;
  5946. /**
  5947. * A lifecycle hook that provides additional developer-defined cleanup
  5948. * functionality for the component.
  5949. * @param callback A handler function that cleans up developer-defined data
  5950. * associated with this component. Called when the `destroy()` method is invoked.
  5951. */
  5952. abstract onDestroy(callback: Function): void;
  5953. }
  5954. /**
  5955. * Base class for a factory that can create a component dynamically.
  5956. * Instantiate a factory for a given type of component with `resolveComponentFactory()`.
  5957. * Use the resulting `ComponentFactory.create()` method to create a component of that type.
  5958. *
  5959. * @publicApi
  5960. *
  5961. * @deprecated Angular no longer requires Component factories. Please use other APIs where
  5962. * Component class can be used directly.
  5963. */
  5964. declare abstract class ComponentFactory<C> {
  5965. /**
  5966. * The component's HTML selector.
  5967. */
  5968. abstract get selector(): string;
  5969. /**
  5970. * The type of component the factory will create.
  5971. */
  5972. abstract get componentType(): Type<any>;
  5973. /**
  5974. * Selector for all <ng-content> elements in the component.
  5975. */
  5976. abstract get ngContentSelectors(): string[];
  5977. /**
  5978. * The inputs of the component.
  5979. */
  5980. abstract get inputs(): {
  5981. propName: string;
  5982. templateName: string;
  5983. transform?: (value: any) => any;
  5984. isSignal: boolean;
  5985. }[];
  5986. /**
  5987. * The outputs of the component.
  5988. */
  5989. abstract get outputs(): {
  5990. propName: string;
  5991. templateName: string;
  5992. }[];
  5993. /**
  5994. * Creates a new component.
  5995. */
  5996. abstract create(injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string | any, environmentInjector?: EnvironmentInjector | NgModuleRef<any>, directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[], bindings?: Binding[]): ComponentRef<C>;
  5997. }
  5998. /**
  5999. * Use in components with the `@Output` directive to emit custom events
  6000. * synchronously or asynchronously, and register handlers for those events
  6001. * by subscribing to an instance.
  6002. *
  6003. * @usageNotes
  6004. *
  6005. * Extends
  6006. * [RxJS `Subject`](https://rxjs.dev/api/index/class/Subject)
  6007. * for Angular by adding the `emit()` method.
  6008. *
  6009. * In the following example, a component defines two output properties
  6010. * that create event emitters. When the title is clicked, the emitter
  6011. * emits an open or close event to toggle the current visibility state.
  6012. *
  6013. * ```angular-ts
  6014. * @Component({
  6015. * selector: 'zippy',
  6016. * template: `
  6017. * <div class="zippy">
  6018. * <div (click)="toggle()">Toggle</div>
  6019. * <div [hidden]="!visible">
  6020. * <ng-content></ng-content>
  6021. * </div>
  6022. * </div>`})
  6023. * export class Zippy {
  6024. * visible: boolean = true;
  6025. * @Output() open: EventEmitter<any> = new EventEmitter();
  6026. * @Output() close: EventEmitter<any> = new EventEmitter();
  6027. *
  6028. * toggle() {
  6029. * this.visible = !this.visible;
  6030. * if (this.visible) {
  6031. * this.open.emit(null);
  6032. * } else {
  6033. * this.close.emit(null);
  6034. * }
  6035. * }
  6036. * }
  6037. * ```
  6038. *
  6039. * Access the event object with the `$event` argument passed to the output event
  6040. * handler:
  6041. *
  6042. * ```html
  6043. * <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
  6044. * ```
  6045. *
  6046. * @publicApi
  6047. */
  6048. interface EventEmitter<T> extends Subject<T>, OutputRef<T> {
  6049. /**
  6050. * Creates an instance of this class that can
  6051. * deliver events synchronously or asynchronously.
  6052. *
  6053. * @param [isAsync=false] When true, deliver events asynchronously.
  6054. *
  6055. */
  6056. new (isAsync?: boolean): EventEmitter<T>;
  6057. /**
  6058. * Emits an event containing a given value.
  6059. * @param value The value to emit.
  6060. */
  6061. emit(value?: T): void;
  6062. /**
  6063. * Registers handlers for events emitted by this instance.
  6064. * @param next When supplied, a custom handler for emitted events.
  6065. * @param error When supplied, a custom handler for an error notification from this emitter.
  6066. * @param complete When supplied, a custom handler for a completion notification from this
  6067. * emitter.
  6068. */
  6069. subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Subscription;
  6070. /**
  6071. * Registers handlers for events emitted by this instance.
  6072. * @param observerOrNext When supplied, a custom handler for emitted events, or an observer
  6073. * object.
  6074. * @param error When supplied, a custom handler for an error notification from this emitter.
  6075. * @param complete When supplied, a custom handler for a completion notification from this
  6076. * emitter.
  6077. */
  6078. subscribe(observerOrNext?: any, error?: any, complete?: any): Subscription;
  6079. }
  6080. /**
  6081. * @publicApi
  6082. */
  6083. declare const EventEmitter: {
  6084. new (isAsync?: boolean): EventEmitter<any>;
  6085. new <T>(isAsync?: boolean): EventEmitter<T>;
  6086. readonly prototype: EventEmitter<any>;
  6087. };
  6088. /**
  6089. * An injectable service for executing work inside or outside of the Angular zone.
  6090. *
  6091. * The most common use of this service is to optimize performance when starting a work consisting of
  6092. * one or more asynchronous tasks that don't require UI updates or error handling to be handled by
  6093. * Angular. Such tasks can be kicked off via {@link #runOutsideAngular} and if needed, these tasks
  6094. * can reenter the Angular zone via {@link #run}.
  6095. *
  6096. * <!-- TODO: add/fix links to:
  6097. * - docs explaining zones and the use of zones in Angular and change-detection
  6098. * - link to runOutsideAngular/run (throughout this file!)
  6099. * -->
  6100. *
  6101. * @usageNotes
  6102. * ### Example
  6103. *
  6104. * ```ts
  6105. * import {Component, NgZone} from '@angular/core';
  6106. *
  6107. * @Component({
  6108. * selector: 'ng-zone-demo',
  6109. * template: `
  6110. * <h2>Demo: NgZone</h2>
  6111. *
  6112. * <p>Progress: {{progress}}%</p>
  6113. * @if(progress >= 100) {
  6114. * <p>Done processing {{label}} of Angular zone!</p>
  6115. * }
  6116. *
  6117. * <button (click)="processWithinAngularZone()">Process within Angular zone</button>
  6118. * <button (click)="processOutsideOfAngularZone()">Process outside of Angular zone</button>
  6119. * `,
  6120. * })
  6121. * export class NgZoneDemo {
  6122. * progress: number = 0;
  6123. * label: string;
  6124. *
  6125. * constructor(private _ngZone: NgZone) {}
  6126. *
  6127. * // Loop inside the Angular zone
  6128. * // so the UI DOES refresh after each setTimeout cycle
  6129. * processWithinAngularZone() {
  6130. * this.label = 'inside';
  6131. * this.progress = 0;
  6132. * this._increaseProgress(() => console.log('Inside Done!'));
  6133. * }
  6134. *
  6135. * // Loop outside of the Angular zone
  6136. * // so the UI DOES NOT refresh after each setTimeout cycle
  6137. * processOutsideOfAngularZone() {
  6138. * this.label = 'outside';
  6139. * this.progress = 0;
  6140. * this._ngZone.runOutsideAngular(() => {
  6141. * this._increaseProgress(() => {
  6142. * // reenter the Angular zone and display done
  6143. * this._ngZone.run(() => { console.log('Outside Done!'); });
  6144. * });
  6145. * });
  6146. * }
  6147. *
  6148. * _increaseProgress(doneCallback: () => void) {
  6149. * this.progress += 1;
  6150. * console.log(`Current progress: ${this.progress}%`);
  6151. *
  6152. * if (this.progress < 100) {
  6153. * window.setTimeout(() => this._increaseProgress(doneCallback), 10);
  6154. * } else {
  6155. * doneCallback();
  6156. * }
  6157. * }
  6158. * }
  6159. * ```
  6160. *
  6161. * @publicApi
  6162. */
  6163. declare class NgZone {
  6164. readonly hasPendingMacrotasks: boolean;
  6165. readonly hasPendingMicrotasks: boolean;
  6166. /**
  6167. * Whether there are no outstanding microtasks or macrotasks.
  6168. */
  6169. readonly isStable: boolean;
  6170. /**
  6171. * Notifies when code enters Angular Zone. This gets fired first on VM Turn.
  6172. */
  6173. readonly onUnstable: EventEmitter<any>;
  6174. /**
  6175. * Notifies when there is no more microtasks enqueued in the current VM Turn.
  6176. * This is a hint for Angular to do change detection, which may enqueue more microtasks.
  6177. * For this reason this event can fire multiple times per VM Turn.
  6178. */
  6179. readonly onMicrotaskEmpty: EventEmitter<any>;
  6180. /**
  6181. * Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
  6182. * implies we are about to relinquish VM turn.
  6183. * This event gets called just once.
  6184. */
  6185. readonly onStable: EventEmitter<any>;
  6186. /**
  6187. * Notifies that an error has been delivered.
  6188. */
  6189. readonly onError: EventEmitter<any>;
  6190. constructor(options: {
  6191. enableLongStackTrace?: boolean;
  6192. shouldCoalesceEventChangeDetection?: boolean;
  6193. shouldCoalesceRunChangeDetection?: boolean;
  6194. });
  6195. /**
  6196. This method checks whether the method call happens within an Angular Zone instance.
  6197. */
  6198. static isInAngularZone(): boolean;
  6199. /**
  6200. Assures that the method is called within the Angular Zone, otherwise throws an error.
  6201. */
  6202. static assertInAngularZone(): void;
  6203. /**
  6204. Assures that the method is called outside of the Angular Zone, otherwise throws an error.
  6205. */
  6206. static assertNotInAngularZone(): void;
  6207. /**
  6208. * Executes the `fn` function synchronously within the Angular zone and returns value returned by
  6209. * the function.
  6210. *
  6211. * Running functions via `run` allows you to reenter Angular zone from a task that was executed
  6212. * outside of the Angular zone (typically started via {@link #runOutsideAngular}).
  6213. *
  6214. * Any future tasks or microtasks scheduled from within this function will continue executing from
  6215. * within the Angular zone.
  6216. *
  6217. * If a synchronous error happens it will be rethrown and not reported via `onError`.
  6218. */
  6219. run<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[]): T;
  6220. /**
  6221. * Executes the `fn` function synchronously within the Angular zone as a task and returns value
  6222. * returned by the function.
  6223. *
  6224. * Running functions via `runTask` allows you to reenter Angular zone from a task that was executed
  6225. * outside of the Angular zone (typically started via {@link #runOutsideAngular}).
  6226. *
  6227. * Any future tasks or microtasks scheduled from within this function will continue executing from
  6228. * within the Angular zone.
  6229. *
  6230. * If a synchronous error happens it will be rethrown and not reported via `onError`.
  6231. */
  6232. runTask<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[], name?: string): T;
  6233. /**
  6234. * Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
  6235. * rethrown.
  6236. */
  6237. runGuarded<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[]): T;
  6238. /**
  6239. * Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
  6240. * the function.
  6241. *
  6242. * Running functions via {@link #runOutsideAngular} allows you to escape Angular's zone and do
  6243. * work that
  6244. * doesn't trigger Angular change-detection or is subject to Angular's error handling.
  6245. *
  6246. * Any future tasks or microtasks scheduled from within this function will continue executing from
  6247. * outside of the Angular zone.
  6248. *
  6249. * Use {@link #run} to reenter the Angular zone and do work that updates the application model.
  6250. */
  6251. runOutsideAngular<T>(fn: (...args: any[]) => T): T;
  6252. }
  6253. /**
  6254. * Provides a noop implementation of `NgZone` which does nothing. This zone requires explicit calls
  6255. * to framework to perform rendering.
  6256. */
  6257. declare class NoopNgZone implements NgZone {
  6258. readonly hasPendingMicrotasks = false;
  6259. readonly hasPendingMacrotasks = false;
  6260. readonly isStable = true;
  6261. readonly onUnstable: EventEmitter<any>;
  6262. readonly onMicrotaskEmpty: EventEmitter<any>;
  6263. readonly onStable: EventEmitter<any>;
  6264. readonly onError: EventEmitter<any>;
  6265. run<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any): T;
  6266. runGuarded<T>(fn: (...args: any[]) => any, applyThis?: any, applyArgs?: any): T;
  6267. runOutsideAngular<T>(fn: (...args: any[]) => T): T;
  6268. runTask<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any, name?: string): T;
  6269. }
  6270. /**
  6271. * @publicApi
  6272. */
  6273. type ɵɵDirectiveDeclaration<T, Selector extends string, ExportAs extends string[], InputMap extends {
  6274. [key: string]: string | {
  6275. alias: string | null;
  6276. required: boolean;
  6277. isSignal?: boolean;
  6278. };
  6279. }, OutputMap extends {
  6280. [key: string]: string;
  6281. }, QueryFields extends string[], NgContentSelectors extends never = never, IsStandalone extends boolean = false, HostDirectives = never, IsSignal extends boolean = false> = unknown;
  6282. /**
  6283. * @publicApi
  6284. */
  6285. type ɵɵComponentDeclaration<T, Selector extends String, ExportAs extends string[], InputMap extends {
  6286. [key: string]: string | {
  6287. alias: string | null;
  6288. required: boolean;
  6289. };
  6290. }, OutputMap extends {
  6291. [key: string]: string;
  6292. }, QueryFields extends string[], NgContentSelectors extends string[], IsStandalone extends boolean = false, HostDirectives = never, IsSignal extends boolean = false> = unknown;
  6293. /**
  6294. * @publicApi
  6295. */
  6296. type ɵɵNgModuleDeclaration<T, Declarations, Imports, Exports> = unknown;
  6297. /**
  6298. * @publicApi
  6299. */
  6300. type ɵɵPipeDeclaration<T, Name extends string, IsStandalone extends boolean = false> = unknown;
  6301. /**
  6302. * @publicApi
  6303. */
  6304. type ɵɵInjectorDeclaration<T> = unknown;
  6305. /**
  6306. * @publicApi
  6307. */
  6308. type ɵɵFactoryDeclaration<T, CtorDependencies extends CtorDependency[]> = unknown;
  6309. /**
  6310. * An object literal of this type is used to represent the metadata of a constructor dependency.
  6311. * The type itself is never referred to from generated code.
  6312. *
  6313. * @publicApi
  6314. */
  6315. type CtorDependency = {
  6316. /**
  6317. * If an `@Attribute` decorator is used, this represents the injected attribute's name. If the
  6318. * attribute name is a dynamic expression instead of a string literal, this will be the unknown
  6319. * type.
  6320. */
  6321. attribute?: string | unknown;
  6322. /**
  6323. * If `@Optional()` is used, this key is set to true.
  6324. */
  6325. optional?: true;
  6326. /**
  6327. * If `@Host` is used, this key is set to true.
  6328. */
  6329. host?: true;
  6330. /**
  6331. * If `@Self` is used, this key is set to true.
  6332. */
  6333. self?: true;
  6334. /**
  6335. * If `@SkipSelf` is used, this key is set to true.
  6336. */
  6337. skipSelf?: true;
  6338. } | null;
  6339. /**
  6340. * A DI token that provides a set of callbacks to
  6341. * be called for every component that is bootstrapped.
  6342. *
  6343. * Each callback must take a `ComponentRef` instance and return nothing.
  6344. *
  6345. * `(componentRef: ComponentRef) => void`
  6346. *
  6347. * @publicApi
  6348. */
  6349. declare const APP_BOOTSTRAP_LISTENER: InjectionToken<readonly ((compRef: ComponentRef<any>) => void)[]>;
  6350. declare function isBoundToModule<C>(cf: ComponentFactory<C>): boolean;
  6351. /**
  6352. * A token for third-party components that can register themselves with NgProbe.
  6353. *
  6354. * @deprecated
  6355. * @publicApi
  6356. */
  6357. declare class NgProbeToken {
  6358. name: string;
  6359. token: any;
  6360. constructor(name: string, token: any);
  6361. }
  6362. /**
  6363. * Provides additional options to the bootstrapping process.
  6364. *
  6365. * @publicApi
  6366. */
  6367. interface BootstrapOptions {
  6368. /**
  6369. * Optionally specify which `NgZone` should be used when not configured in the providers.
  6370. *
  6371. * - Provide your own `NgZone` instance.
  6372. * - `zone.js` - Use default `NgZone` which requires `Zone.js`.
  6373. * - `noop` - Use `NoopNgZone` which does nothing.
  6374. */
  6375. ngZone?: NgZone | 'zone.js' | 'noop';
  6376. /**
  6377. * Optionally specify coalescing event change detections or not.
  6378. * Consider the following case.
  6379. *
  6380. * ```html
  6381. * <div (click)="doSomething()">
  6382. * <button (click)="doSomethingElse()"></button>
  6383. * </div>
  6384. * ```
  6385. *
  6386. * When button is clicked, because of the event bubbling, both
  6387. * event handlers will be called and 2 change detections will be
  6388. * triggered. We can coalesce such kind of events to only trigger
  6389. * change detection only once.
  6390. *
  6391. * By default, this option will be false. So the events will not be
  6392. * coalesced and the change detection will be triggered multiple times.
  6393. * And if this option be set to true, the change detection will be
  6394. * triggered async by scheduling a animation frame. So in the case above,
  6395. * the change detection will only be triggered once.
  6396. */
  6397. ngZoneEventCoalescing?: boolean;
  6398. /**
  6399. * Optionally specify if `NgZone#run()` method invocations should be coalesced
  6400. * into a single change detection.
  6401. *
  6402. * Consider the following case.
  6403. * ```ts
  6404. * for (let i = 0; i < 10; i ++) {
  6405. * ngZone.run(() => {
  6406. * // do something
  6407. * });
  6408. * }
  6409. * ```
  6410. *
  6411. * This case triggers the change detection multiple times.
  6412. * With ngZoneRunCoalescing options, all change detections in an event loop trigger only once.
  6413. * In addition, the change detection executes in requestAnimation.
  6414. *
  6415. */
  6416. ngZoneRunCoalescing?: boolean;
  6417. /**
  6418. * When false, change detection is scheduled when Angular receives
  6419. * a clear indication that templates need to be refreshed. This includes:
  6420. *
  6421. * - calling `ChangeDetectorRef.markForCheck`
  6422. * - calling `ComponentRef.setInput`
  6423. * - updating a signal that is read in a template
  6424. * - attaching a view that is marked dirty
  6425. * - removing a view
  6426. * - registering a render hook (templates are only refreshed if render hooks do one of the above)
  6427. *
  6428. * @deprecated This option was introduced out of caution as a way for developers to opt out of the
  6429. * new behavior in v18 which schedule change detection for the above events when they occur
  6430. * outside the Zone. After monitoring the results post-release, we have determined that this
  6431. * feature is working as desired and do not believe it should ever be disabled by setting
  6432. * this option to `true`.
  6433. */
  6434. ignoreChangesOutsideZone?: boolean;
  6435. }
  6436. /**
  6437. * A reference to an Angular application running on a page.
  6438. *
  6439. * @usageNotes
  6440. * ### isStable examples and caveats
  6441. *
  6442. * Note two important points about `isStable`, demonstrated in the examples below:
  6443. * - the application will never be stable if you start any kind
  6444. * of recurrent asynchronous task when the application starts
  6445. * (for example for a polling process, started with a `setInterval`, a `setTimeout`
  6446. * or using RxJS operators like `interval`);
  6447. * - the `isStable` Observable runs outside of the Angular zone.
  6448. *
  6449. * Let's imagine that you start a recurrent task
  6450. * (here incrementing a counter, using RxJS `interval`),
  6451. * and at the same time subscribe to `isStable`.
  6452. *
  6453. * ```ts
  6454. * constructor(appRef: ApplicationRef) {
  6455. * appRef.isStable.pipe(
  6456. * filter(stable => stable)
  6457. * ).subscribe(() => console.log('App is stable now');
  6458. * interval(1000).subscribe(counter => console.log(counter));
  6459. * }
  6460. * ```
  6461. * In this example, `isStable` will never emit `true`,
  6462. * and the trace "App is stable now" will never get logged.
  6463. *
  6464. * If you want to execute something when the app is stable,
  6465. * you have to wait for the application to be stable
  6466. * before starting your polling process.
  6467. *
  6468. * ```ts
  6469. * constructor(appRef: ApplicationRef) {
  6470. * appRef.isStable.pipe(
  6471. * first(stable => stable),
  6472. * tap(stable => console.log('App is stable now')),
  6473. * switchMap(() => interval(1000))
  6474. * ).subscribe(counter => console.log(counter));
  6475. * }
  6476. * ```
  6477. * In this example, the trace "App is stable now" will be logged
  6478. * and then the counter starts incrementing every second.
  6479. *
  6480. * Note also that this Observable runs outside of the Angular zone,
  6481. * which means that the code in the subscription
  6482. * to this Observable will not trigger the change detection.
  6483. *
  6484. * Let's imagine that instead of logging the counter value,
  6485. * you update a field of your component
  6486. * and display it in its template.
  6487. *
  6488. * ```ts
  6489. * constructor(appRef: ApplicationRef) {
  6490. * appRef.isStable.pipe(
  6491. * first(stable => stable),
  6492. * switchMap(() => interval(1000))
  6493. * ).subscribe(counter => this.value = counter);
  6494. * }
  6495. * ```
  6496. * As the `isStable` Observable runs outside the zone,
  6497. * the `value` field will be updated properly,
  6498. * but the template will not be refreshed!
  6499. *
  6500. * You'll have to manually trigger the change detection to update the template.
  6501. *
  6502. * ```ts
  6503. * constructor(appRef: ApplicationRef, cd: ChangeDetectorRef) {
  6504. * appRef.isStable.pipe(
  6505. * first(stable => stable),
  6506. * switchMap(() => interval(1000))
  6507. * ).subscribe(counter => {
  6508. * this.value = counter;
  6509. * cd.detectChanges();
  6510. * });
  6511. * }
  6512. * ```
  6513. *
  6514. * Or make the subscription callback run inside the zone.
  6515. *
  6516. * ```ts
  6517. * constructor(appRef: ApplicationRef, zone: NgZone) {
  6518. * appRef.isStable.pipe(
  6519. * first(stable => stable),
  6520. * switchMap(() => interval(1000))
  6521. * ).subscribe(counter => zone.run(() => this.value = counter));
  6522. * }
  6523. * ```
  6524. *
  6525. * @publicApi
  6526. */
  6527. declare class ApplicationRef {
  6528. private _destroyed;
  6529. private _destroyListeners;
  6530. private readonly internalErrorHandler;
  6531. private readonly afterRenderManager;
  6532. private readonly zonelessEnabled;
  6533. private readonly rootEffectScheduler;
  6534. private allTestViews;
  6535. private autoDetectTestViews;
  6536. private includeAllTestViews;
  6537. /**
  6538. * Indicates whether this instance was destroyed.
  6539. */
  6540. get destroyed(): boolean;
  6541. /**
  6542. * Get a list of component types registered to this application.
  6543. * This list is populated even before the component is created.
  6544. */
  6545. readonly componentTypes: Type<any>[];
  6546. /**
  6547. * Get a list of components registered to this application.
  6548. */
  6549. readonly components: ComponentRef<any>[];
  6550. private internalPendingTask;
  6551. /**
  6552. * Returns an Observable that indicates when the application is stable or unstable.
  6553. */
  6554. get isStable(): Observable<boolean>;
  6555. constructor();
  6556. /**
  6557. * @returns A promise that resolves when the application becomes stable
  6558. */
  6559. whenStable(): Promise<void>;
  6560. private readonly _injector;
  6561. private _rendererFactory;
  6562. /**
  6563. * The `EnvironmentInjector` used to create this application.
  6564. */
  6565. get injector(): EnvironmentInjector;
  6566. /**
  6567. * Bootstrap a component onto the element identified by its selector or, optionally, to a
  6568. * specified element.
  6569. *
  6570. * @usageNotes
  6571. * ### Bootstrap process
  6572. *
  6573. * When bootstrapping a component, Angular mounts it onto a target DOM element
  6574. * and kicks off automatic change detection. The target DOM element can be
  6575. * provided using the `rootSelectorOrNode` argument.
  6576. *
  6577. * If the target DOM element is not provided, Angular tries to find one on a page
  6578. * using the `selector` of the component that is being bootstrapped
  6579. * (first matched element is used).
  6580. *
  6581. * ### Example
  6582. *
  6583. * Generally, we define the component to bootstrap in the `bootstrap` array of `NgModule`,
  6584. * but it requires us to know the component while writing the application code.
  6585. *
  6586. * Imagine a situation where we have to wait for an API call to decide about the component to
  6587. * bootstrap. We can use the `ngDoBootstrap` hook of the `NgModule` and call this method to
  6588. * dynamically bootstrap a component.
  6589. *
  6590. * {@example core/ts/platform/platform.ts region='componentSelector'}
  6591. *
  6592. * Optionally, a component can be mounted onto a DOM element that does not match the
  6593. * selector of the bootstrapped component.
  6594. *
  6595. * In the following example, we are providing a CSS selector to match the target element.
  6596. *
  6597. * {@example core/ts/platform/platform.ts region='cssSelector'}
  6598. *
  6599. * While in this example, we are providing reference to a DOM node.
  6600. *
  6601. * {@example core/ts/platform/platform.ts region='domNode'}
  6602. */
  6603. bootstrap<C>(component: Type<C>, rootSelectorOrNode?: string | any): ComponentRef<C>;
  6604. /**
  6605. * Bootstrap a component onto the element identified by its selector or, optionally, to a
  6606. * specified element.
  6607. *
  6608. * @usageNotes
  6609. * ### Bootstrap process
  6610. *
  6611. * When bootstrapping a component, Angular mounts it onto a target DOM element
  6612. * and kicks off automatic change detection. The target DOM element can be
  6613. * provided using the `rootSelectorOrNode` argument.
  6614. *
  6615. * If the target DOM element is not provided, Angular tries to find one on a page
  6616. * using the `selector` of the component that is being bootstrapped
  6617. * (first matched element is used).
  6618. *
  6619. * ### Example
  6620. *
  6621. * Generally, we define the component to bootstrap in the `bootstrap` array of `NgModule`,
  6622. * but it requires us to know the component while writing the application code.
  6623. *
  6624. * Imagine a situation where we have to wait for an API call to decide about the component to
  6625. * bootstrap. We can use the `ngDoBootstrap` hook of the `NgModule` and call this method to
  6626. * dynamically bootstrap a component.
  6627. *
  6628. * {@example core/ts/platform/platform.ts region='componentSelector'}
  6629. *
  6630. * Optionally, a component can be mounted onto a DOM element that does not match the
  6631. * selector of the bootstrapped component.
  6632. *
  6633. * In the following example, we are providing a CSS selector to match the target element.
  6634. *
  6635. * {@example core/ts/platform/platform.ts region='cssSelector'}
  6636. *
  6637. * While in this example, we are providing reference to a DOM node.
  6638. *
  6639. * {@example core/ts/platform/platform.ts region='domNode'}
  6640. *
  6641. * @deprecated Passing Component factories as the `Application.bootstrap` function argument is
  6642. * deprecated. Pass Component Types instead.
  6643. */
  6644. bootstrap<C>(componentFactory: ComponentFactory<C>, rootSelectorOrNode?: string | any): ComponentRef<C>;
  6645. private bootstrapImpl;
  6646. /**
  6647. * Invoke this method to explicitly process change detection and its side-effects.
  6648. *
  6649. * In development mode, `tick()` also performs a second change detection cycle to ensure that no
  6650. * further changes are detected. If additional changes are picked up during this second cycle,
  6651. * bindings in the app have side-effects that cannot be resolved in a single change detection
  6652. * pass.
  6653. * In this case, Angular throws an error, since an Angular application can only have one change
  6654. * detection pass during which all change detection must complete.
  6655. */
  6656. tick(): void;
  6657. private tickImpl;
  6658. /**
  6659. * Performs the core work of synchronizing the application state with the UI, resolving any
  6660. * pending dirtiness (potentially in a loop).
  6661. */
  6662. private synchronize;
  6663. /**
  6664. * Perform a single synchronization pass.
  6665. */
  6666. private synchronizeOnce;
  6667. /**
  6668. * Checks `allViews` for views which require refresh/traversal, and updates `dirtyFlags`
  6669. * accordingly, with two potential behaviors:
  6670. *
  6671. * 1. If any of our views require updating, then this adds the `ViewTreeTraversal` dirty flag.
  6672. * This _should_ be a no-op, since the scheduler should've added the flag at the same time the
  6673. * view was marked as needing updating.
  6674. *
  6675. * TODO(alxhub): figure out if this behavior is still needed for edge cases.
  6676. *
  6677. * 2. If none of our views require updating, then clear the view-related `dirtyFlag`s. This
  6678. * happens when the scheduler is notified of a view becoming dirty, but the view itself isn't
  6679. * reachable through traversal from our roots (e.g. it's detached from the CD tree).
  6680. */
  6681. private syncDirtyFlagsWithViews;
  6682. /**
  6683. * Attaches a view so that it will be dirty checked.
  6684. * The view will be automatically detached when it is destroyed.
  6685. * This will throw if the view is already attached to a ViewContainer.
  6686. */
  6687. attachView(viewRef: ViewRef): void;
  6688. /**
  6689. * Detaches a view from dirty checking again.
  6690. */
  6691. detachView(viewRef: ViewRef): void;
  6692. private _loadComponent;
  6693. /**
  6694. * Registers a listener to be called when an instance is destroyed.
  6695. *
  6696. * @param callback A callback function to add as a listener.
  6697. * @returns A function which unregisters a listener.
  6698. */
  6699. onDestroy(callback: () => void): VoidFunction;
  6700. /**
  6701. * Destroys an Angular application represented by this `ApplicationRef`. Calling this function
  6702. * will destroy the associated environment injectors as well as all the bootstrapped components
  6703. * with their views.
  6704. */
  6705. destroy(): void;
  6706. /**
  6707. * Returns the number of attached views.
  6708. */
  6709. get viewCount(): number;
  6710. static ɵfac: ɵɵFactoryDeclaration<ApplicationRef, never>;
  6711. static ɵprov: ɵɵInjectableDeclaration<ApplicationRef>;
  6712. }
  6713. /**
  6714. * Type of the NgModule decorator / constructor function.
  6715. *
  6716. * @publicApi
  6717. */
  6718. interface NgModuleDecorator {
  6719. /**
  6720. * Decorator that marks a class as an NgModule and supplies configuration metadata.
  6721. */
  6722. (obj?: NgModule): TypeDecorator;
  6723. new (obj?: NgModule): NgModule;
  6724. }
  6725. /**
  6726. * Type of the NgModule metadata.
  6727. *
  6728. * @publicApi
  6729. */
  6730. interface NgModule {
  6731. /**
  6732. * The set of injectable objects that are available in the injector
  6733. * of this module.
  6734. *
  6735. * @see [Dependency Injection guide](guide/di/dependency-injection
  6736. * @see [NgModule guide](guide/ngmodules/providers)
  6737. *
  6738. * @usageNotes
  6739. *
  6740. * Dependencies whose providers are listed here become available for injection
  6741. * into any component, directive, pipe or service that is a child of this injector.
  6742. * The NgModule used for bootstrapping uses the root injector, and can provide dependencies
  6743. * to any part of the app.
  6744. *
  6745. * A lazy-loaded module has its own injector, typically a child of the app root injector.
  6746. * Lazy-loaded services are scoped to the lazy-loaded module's injector.
  6747. * If a lazy-loaded module also provides the `UserService`, any component created
  6748. * within that module's context (such as by router navigation) gets the local instance
  6749. * of the service, not the instance in the root injector.
  6750. * Components in external modules continue to receive the instance provided by their injectors.
  6751. *
  6752. * ### Example
  6753. *
  6754. * The following example defines a class that is injected in
  6755. * the HelloWorld NgModule:
  6756. *
  6757. * ```ts
  6758. * class Greeter {
  6759. * greet(name:string) {
  6760. * return 'Hello ' + name + '!';
  6761. * }
  6762. * }
  6763. *
  6764. * @NgModule({
  6765. * providers: [
  6766. * Greeter
  6767. * ]
  6768. * })
  6769. * class HelloWorld {
  6770. * greeter:Greeter;
  6771. *
  6772. * constructor(greeter:Greeter) {
  6773. * this.greeter = greeter;
  6774. * }
  6775. * }
  6776. * ```
  6777. */
  6778. providers?: Array<Provider | EnvironmentProviders>;
  6779. /**
  6780. * The set of components, directives, and pipes (declarables
  6781. * that belong to this module.
  6782. *
  6783. * @usageNotes
  6784. *
  6785. * The set of selectors that are available to a template include those declared here, and
  6786. * those that are exported from imported NgModules.
  6787. *
  6788. * Declarables must belong to exactly one module.
  6789. * The compiler emits an error if you try to declare the same class in more than one module.
  6790. * Be careful not to declare a class that is imported from another module.
  6791. *
  6792. * ### Example
  6793. *
  6794. * The following example allows the CommonModule to use the `NgFor`
  6795. * directive.
  6796. *
  6797. * ```javascript
  6798. * @NgModule({
  6799. * declarations: [NgFor]
  6800. * })
  6801. * class CommonModule {
  6802. * }
  6803. * ```
  6804. */
  6805. declarations?: Array<Type<any> | any[]>;
  6806. /**
  6807. * The set of NgModules whose exported declarables
  6808. * are available to templates in this module.
  6809. *
  6810. * @usageNotes
  6811. *
  6812. * A template can use exported declarables from any
  6813. * imported module, including those from modules that are imported indirectly
  6814. * and re-exported.
  6815. * For example, `ModuleA` imports `ModuleB`, and also exports
  6816. * it, which makes the declarables from `ModuleB` available
  6817. * wherever `ModuleA` is imported.
  6818. *
  6819. * ### Example
  6820. *
  6821. * The following example allows MainModule to use anything exported by
  6822. * `CommonModule`:
  6823. *
  6824. * ```javascript
  6825. * @NgModule({
  6826. * imports: [CommonModule]
  6827. * })
  6828. * class MainModule {
  6829. * }
  6830. * ```
  6831. *
  6832. */
  6833. imports?: Array<Type<any> | ModuleWithProviders<{}> | any[]>;
  6834. /**
  6835. * The set of components, directives, and pipes declared in this
  6836. * NgModule that can be used in the template of any component that is part of an
  6837. * NgModule that imports this NgModule. Exported declarations are the module's public API.
  6838. *
  6839. * A declarable belongs to one and only one NgModule.
  6840. * A module can list another module among its exports, in which case all of that module's
  6841. * public declaration are exported.
  6842. *
  6843. * @usageNotes
  6844. *
  6845. * Declarations are private by default.
  6846. * If this ModuleA does not export UserComponent, then only the components within this
  6847. * ModuleA can use UserComponent.
  6848. *
  6849. * ModuleA can import ModuleB and also export it, making exports from ModuleB
  6850. * available to an NgModule that imports ModuleA.
  6851. *
  6852. * ### Example
  6853. *
  6854. * The following example exports the `NgFor` directive from CommonModule.
  6855. *
  6856. * ```javascript
  6857. * @NgModule({
  6858. * exports: [NgFor]
  6859. * })
  6860. * class CommonModule {
  6861. * }
  6862. * ```
  6863. */
  6864. exports?: Array<Type<any> | any[]>;
  6865. /**
  6866. * The set of components that are bootstrapped when this module is bootstrapped.
  6867. */
  6868. bootstrap?: Array<Type<any> | any[]>;
  6869. /**
  6870. * The set of schemas that declare elements to be allowed in the NgModule.
  6871. * Elements and properties that are neither Angular components nor directives
  6872. * must be declared in a schema.
  6873. *
  6874. * Allowed value are `NO_ERRORS_SCHEMA` and `CUSTOM_ELEMENTS_SCHEMA`.
  6875. *
  6876. * @security When using one of `NO_ERRORS_SCHEMA` or `CUSTOM_ELEMENTS_SCHEMA`
  6877. * you must ensure that allowed elements and properties securely escape inputs.
  6878. */
  6879. schemas?: Array<SchemaMetadata | any[]>;
  6880. /**
  6881. * A name or path that uniquely identifies this NgModule in `getNgModuleById`.
  6882. * If left `undefined`, the NgModule is not registered with `getNgModuleById`.
  6883. */
  6884. id?: string;
  6885. /**
  6886. * When present, this module is ignored by the AOT compiler.
  6887. * It remains in distributed code, and the JIT compiler attempts to compile it
  6888. * at run time, in the browser.
  6889. * To ensure the correct behavior, the app must import `@angular/compiler`.
  6890. */
  6891. jit?: true;
  6892. }
  6893. /**
  6894. * @Annotation
  6895. */
  6896. declare const NgModule: NgModuleDecorator;
  6897. /**
  6898. * Combination of NgModuleFactory and ComponentFactories.
  6899. *
  6900. * @publicApi
  6901. *
  6902. * @deprecated
  6903. * Ivy JIT mode doesn't require accessing this symbol.
  6904. */
  6905. declare class ModuleWithComponentFactories<T> {
  6906. ngModuleFactory: NgModuleFactory<T>;
  6907. componentFactories: ComponentFactory<any>[];
  6908. constructor(ngModuleFactory: NgModuleFactory<T>, componentFactories: ComponentFactory<any>[]);
  6909. }
  6910. /**
  6911. * Low-level service for running the angular compiler during runtime
  6912. * to create {@link ComponentFactory}s, which
  6913. * can later be used to create and render a Component instance.
  6914. *
  6915. * Each `@NgModule` provides an own `Compiler` to its injector,
  6916. * that will use the directives/pipes of the ng module for compilation
  6917. * of components.
  6918. *
  6919. * @publicApi
  6920. *
  6921. * @deprecated
  6922. * Ivy JIT mode doesn't require accessing this symbol.
  6923. */
  6924. declare class Compiler {
  6925. /**
  6926. * Compiles the given NgModule and all of its components. All templates of the components
  6927. * have to be inlined.
  6928. */
  6929. compileModuleSync<T>(moduleType: Type<T>): NgModuleFactory<T>;
  6930. /**
  6931. * Compiles the given NgModule and all of its components
  6932. */
  6933. compileModuleAsync<T>(moduleType: Type<T>): Promise<NgModuleFactory<T>>;
  6934. /**
  6935. * Same as {@link Compiler#compileModuleSync compileModuleSync} but also creates ComponentFactories for all components.
  6936. */
  6937. compileModuleAndAllComponentsSync<T>(moduleType: Type<T>): ModuleWithComponentFactories<T>;
  6938. /**
  6939. * Same as {@link Compiler#compileModuleAsync compileModuleAsync} but also creates ComponentFactories for all components.
  6940. */
  6941. compileModuleAndAllComponentsAsync<T>(moduleType: Type<T>): Promise<ModuleWithComponentFactories<T>>;
  6942. /**
  6943. * Clears all caches.
  6944. */
  6945. clearCache(): void;
  6946. /**
  6947. * Clears the cache for the given component/ngModule.
  6948. */
  6949. clearCacheFor(type: Type<any>): void;
  6950. /**
  6951. * Returns the id for a given NgModule, if one is defined and known to the compiler.
  6952. */
  6953. getModuleId(moduleType: Type<any>): string | undefined;
  6954. static ɵfac: ɵɵFactoryDeclaration<Compiler, never>;
  6955. static ɵprov: ɵɵInjectableDeclaration<Compiler>;
  6956. }
  6957. /**
  6958. * Options for creating a compiler.
  6959. *
  6960. * @publicApi
  6961. */
  6962. type CompilerOptions = {
  6963. defaultEncapsulation?: ViewEncapsulation;
  6964. providers?: StaticProvider[];
  6965. preserveWhitespaces?: boolean;
  6966. };
  6967. /**
  6968. * Token to provide CompilerOptions in the platform injector.
  6969. *
  6970. * @publicApi
  6971. */
  6972. declare const COMPILER_OPTIONS: InjectionToken<CompilerOptions[]>;
  6973. /**
  6974. * A factory for creating a Compiler
  6975. *
  6976. * @publicApi
  6977. *
  6978. * @deprecated
  6979. * Ivy JIT mode doesn't require accessing this symbol.
  6980. */
  6981. declare abstract class CompilerFactory {
  6982. abstract createCompiler(options?: CompilerOptions[]): Compiler;
  6983. }
  6984. /**
  6985. * The Angular platform is the entry point for Angular on a web page.
  6986. * Each page has exactly one platform. Services (such as reflection) which are common
  6987. * to every Angular application running on the page are bound in its scope.
  6988. * A page's platform is initialized implicitly when a platform is created using a platform
  6989. * factory such as `PlatformBrowser`, or explicitly by calling the `createPlatform()` function.
  6990. *
  6991. * @publicApi
  6992. */
  6993. declare class PlatformRef {
  6994. private _injector;
  6995. private _modules;
  6996. private _destroyListeners;
  6997. private _destroyed;
  6998. /**
  6999. * Creates an instance of an `@NgModule` for the given platform.
  7000. *
  7001. * @deprecated Passing NgModule factories as the `PlatformRef.bootstrapModuleFactory` function
  7002. * argument is deprecated. Use the `PlatformRef.bootstrapModule` API instead.
  7003. */
  7004. bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>, options?: BootstrapOptions): Promise<NgModuleRef<M>>;
  7005. /**
  7006. * Creates an instance of an `@NgModule` for a given platform.
  7007. *
  7008. * @usageNotes
  7009. * ### Simple Example
  7010. *
  7011. * ```ts
  7012. * @NgModule({
  7013. * imports: [BrowserModule]
  7014. * })
  7015. * class MyModule {}
  7016. *
  7017. * let moduleRef = platformBrowser().bootstrapModule(MyModule);
  7018. * ```
  7019. *
  7020. */
  7021. bootstrapModule<M>(moduleType: Type<M>, compilerOptions?: (CompilerOptions & BootstrapOptions) | Array<CompilerOptions & BootstrapOptions>): Promise<NgModuleRef<M>>;
  7022. /**
  7023. * Registers a listener to be called when the platform is destroyed.
  7024. */
  7025. onDestroy(callback: () => void): void;
  7026. /**
  7027. * Retrieves the platform {@link Injector}, which is the parent injector for
  7028. * every Angular application on the page and provides singleton providers.
  7029. */
  7030. get injector(): Injector;
  7031. /**
  7032. * Destroys the current Angular platform and all Angular applications on the page.
  7033. * Destroys all modules and listeners registered with the platform.
  7034. */
  7035. destroy(): void;
  7036. /**
  7037. * Indicates whether this instance was destroyed.
  7038. */
  7039. get destroyed(): boolean;
  7040. static ɵfac: ɵɵFactoryDeclaration<PlatformRef, never>;
  7041. static ɵprov: ɵɵInjectableDeclaration<PlatformRef>;
  7042. }
  7043. /**
  7044. * @publicApi
  7045. */
  7046. declare class DebugEventListener {
  7047. name: string;
  7048. callback: Function;
  7049. constructor(name: string, callback: Function);
  7050. }
  7051. /**
  7052. * @publicApi
  7053. */
  7054. declare function asNativeElements(debugEls: DebugElement[]): any;
  7055. /**
  7056. * @publicApi
  7057. */
  7058. declare class DebugNode {
  7059. /**
  7060. * The underlying DOM node.
  7061. */
  7062. readonly nativeNode: any;
  7063. constructor(nativeNode: Node);
  7064. /**
  7065. * The `DebugElement` parent. Will be `null` if this is the root element.
  7066. */
  7067. get parent(): DebugElement | null;
  7068. /**
  7069. * The host dependency injector. For example, the root element's component instance injector.
  7070. */
  7071. get injector(): Injector;
  7072. /**
  7073. * The element's own component instance, if it has one.
  7074. */
  7075. get componentInstance(): any;
  7076. /**
  7077. * An object that provides parent context for this element. Often an ancestor component instance
  7078. * that governs this element.
  7079. *
  7080. * When an element is repeated within *ngFor, the context is an `NgForOf` whose `$implicit`
  7081. * property is the value of the row instance value. For example, the `hero` in `*ngFor="let hero
  7082. * of heroes"`.
  7083. */
  7084. get context(): any;
  7085. /**
  7086. * The callbacks attached to the component's @Output properties and/or the element's event
  7087. * properties.
  7088. */
  7089. get listeners(): DebugEventListener[];
  7090. /**
  7091. * Dictionary of objects associated with template local variables (e.g. #foo), keyed by the local
  7092. * variable name.
  7093. */
  7094. get references(): {
  7095. [key: string]: any;
  7096. };
  7097. /**
  7098. * This component's injector lookup tokens. Includes the component itself plus the tokens that the
  7099. * component lists in its providers metadata.
  7100. */
  7101. get providerTokens(): any[];
  7102. }
  7103. /**
  7104. * @publicApi
  7105. *
  7106. * @see [Component testing scenarios](guide/testing/components-scenarios)
  7107. * @see [Basics of testing components](guide/testing/components-basics)
  7108. * @see [Testing utility APIs](guide/testing/utility-apis)
  7109. */
  7110. declare class DebugElement extends DebugNode {
  7111. constructor(nativeNode: Element);
  7112. /**
  7113. * The underlying DOM element at the root of the component.
  7114. */
  7115. get nativeElement(): any;
  7116. /**
  7117. * The element tag name, if it is an element.
  7118. */
  7119. get name(): string;
  7120. /**
  7121. * Gets a map of property names to property values for an element.
  7122. *
  7123. * This map includes:
  7124. * - Regular property bindings (e.g. `[id]="id"`)
  7125. * - Host property bindings (e.g. `host: { '[id]': "id" }`)
  7126. * - Interpolated property bindings (e.g. `id="{{ value }}")
  7127. *
  7128. * It does not include:
  7129. * - input property bindings (e.g. `[myCustomInput]="value"`)
  7130. * - attribute bindings (e.g. `[attr.role]="menu"`)
  7131. */
  7132. get properties(): {
  7133. [key: string]: any;
  7134. };
  7135. /**
  7136. * A map of attribute names to attribute values for an element.
  7137. */
  7138. get attributes(): {
  7139. [key: string]: string | null;
  7140. };
  7141. /**
  7142. * The inline styles of the DOM element.
  7143. */
  7144. get styles(): {
  7145. [key: string]: string | null;
  7146. };
  7147. /**
  7148. * A map containing the class names on the element as keys.
  7149. *
  7150. * This map is derived from the `className` property of the DOM element.
  7151. *
  7152. * Note: The values of this object will always be `true`. The class key will not appear in the KV
  7153. * object if it does not exist on the element.
  7154. *
  7155. * @see [Element.className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className)
  7156. */
  7157. get classes(): {
  7158. [key: string]: boolean;
  7159. };
  7160. /**
  7161. * The `childNodes` of the DOM element as a `DebugNode` array.
  7162. *
  7163. * @see [Node.childNodes](https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes)
  7164. */
  7165. get childNodes(): DebugNode[];
  7166. /**
  7167. * The immediate `DebugElement` children. Walk the tree by descending through `children`.
  7168. */
  7169. get children(): DebugElement[];
  7170. /**
  7171. * @returns the first `DebugElement` that matches the predicate at any depth in the subtree.
  7172. */
  7173. query(predicate: Predicate<DebugElement>): DebugElement;
  7174. /**
  7175. * @returns All `DebugElement` matches for the predicate at any depth in the subtree.
  7176. */
  7177. queryAll(predicate: Predicate<DebugElement>): DebugElement[];
  7178. /**
  7179. * @returns All `DebugNode` matches for the predicate at any depth in the subtree.
  7180. */
  7181. queryAllNodes(predicate: Predicate<DebugNode>): DebugNode[];
  7182. /**
  7183. * Triggers the event by its name if there is a corresponding listener in the element's
  7184. * `listeners` collection.
  7185. *
  7186. * If the event lacks a listener or there's some other problem, consider
  7187. * calling `nativeElement.dispatchEvent(eventObject)`.
  7188. *
  7189. * @param eventName The name of the event to trigger
  7190. * @param eventObj The _event object_ expected by the handler
  7191. *
  7192. * @see [Testing components scenarios](guide/testing/components-scenarios#trigger-event-handler)
  7193. */
  7194. triggerEventHandler(eventName: string, eventObj?: any): void;
  7195. }
  7196. /**
  7197. * @publicApi
  7198. */
  7199. declare function getDebugNode(nativeNode: any): DebugNode | null;
  7200. /**
  7201. * A boolean-valued function over a value, possibly including context information
  7202. * regarding that value's position in an array.
  7203. *
  7204. * @publicApi
  7205. */
  7206. type Predicate<T> = (value: T) => boolean;
  7207. interface NavigationEventMap {
  7208. navigate: NavigateEvent;
  7209. navigatesuccess: Event;
  7210. navigateerror: ErrorEvent;
  7211. currententrychange: NavigationCurrentEntryChangeEvent;
  7212. }
  7213. interface NavigationResult {
  7214. committed: Promise<NavigationHistoryEntry>;
  7215. finished: Promise<NavigationHistoryEntry>;
  7216. }
  7217. declare class Navigation extends EventTarget {
  7218. entries(): NavigationHistoryEntry[];
  7219. readonly currentEntry: NavigationHistoryEntry | null;
  7220. updateCurrentEntry(options: NavigationUpdateCurrentEntryOptions): void;
  7221. readonly transition: NavigationTransition | null;
  7222. readonly canGoBack: boolean;
  7223. readonly canGoForward: boolean;
  7224. navigate(url: string, options?: NavigationNavigateOptions): NavigationResult;
  7225. reload(options?: NavigationReloadOptions): NavigationResult;
  7226. traverseTo(key: string, options?: NavigationOptions): NavigationResult;
  7227. back(options?: NavigationOptions): NavigationResult;
  7228. forward(options?: NavigationOptions): NavigationResult;
  7229. onnavigate: ((this: Navigation, ev: NavigateEvent) => any) | null;
  7230. onnavigatesuccess: ((this: Navigation, ev: Event) => any) | null;
  7231. onnavigateerror: ((this: Navigation, ev: ErrorEvent) => any) | null;
  7232. oncurrententrychange: ((this: Navigation, ev: NavigationCurrentEntryChangeEvent) => any) | null;
  7233. addEventListener<K extends keyof NavigationEventMap>(type: K, listener: (this: Navigation, ev: NavigationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  7234. addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
  7235. removeEventListener<K extends keyof NavigationEventMap>(type: K, listener: (this: Navigation, ev: NavigationEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  7236. removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
  7237. }
  7238. declare class NavigationTransition {
  7239. readonly navigationType: NavigationTypeString;
  7240. readonly from: NavigationHistoryEntry;
  7241. readonly finished: Promise<void>;
  7242. readonly committed: Promise<void>;
  7243. }
  7244. interface NavigationHistoryEntryEventMap {
  7245. dispose: Event;
  7246. }
  7247. declare class NavigationHistoryEntry extends EventTarget {
  7248. readonly key: string;
  7249. readonly id: string;
  7250. readonly url: string | null;
  7251. readonly index: number;
  7252. readonly sameDocument: boolean;
  7253. getState(): unknown;
  7254. ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null;
  7255. addEventListener<K extends keyof NavigationHistoryEntryEventMap>(type: K, listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  7256. addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
  7257. removeEventListener<K extends keyof NavigationHistoryEntryEventMap>(type: K, listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  7258. removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
  7259. }
  7260. type NavigationTypeString = 'reload' | 'push' | 'replace' | 'traverse';
  7261. interface NavigationUpdateCurrentEntryOptions {
  7262. state: unknown;
  7263. }
  7264. interface NavigationOptions {
  7265. info?: unknown;
  7266. }
  7267. interface NavigationNavigateOptions extends NavigationOptions {
  7268. state?: unknown;
  7269. history?: 'auto' | 'push' | 'replace';
  7270. }
  7271. interface NavigationReloadOptions extends NavigationOptions {
  7272. state?: unknown;
  7273. }
  7274. declare class NavigationCurrentEntryChangeEvent extends Event {
  7275. constructor(type: string, eventInit?: NavigationCurrentEntryChangeEventInit);
  7276. readonly navigationType: NavigationTypeString | null;
  7277. readonly from: NavigationHistoryEntry;
  7278. }
  7279. interface NavigationCurrentEntryChangeEventInit extends EventInit {
  7280. navigationType?: NavigationTypeString | null;
  7281. from: NavigationHistoryEntry;
  7282. }
  7283. declare class NavigateEvent extends Event {
  7284. constructor(type: string, eventInit?: NavigateEventInit);
  7285. readonly navigationType: NavigationTypeString;
  7286. readonly canIntercept: boolean;
  7287. readonly userInitiated: boolean;
  7288. readonly hashChange: boolean;
  7289. readonly destination: NavigationDestination;
  7290. readonly signal: AbortSignal;
  7291. readonly formData: FormData | null;
  7292. readonly downloadRequest: string | null;
  7293. readonly info?: unknown;
  7294. intercept(options?: NavigationInterceptOptions): void;
  7295. scroll(): void;
  7296. }
  7297. interface NavigateEventInit extends EventInit {
  7298. navigationType?: NavigationTypeString;
  7299. canIntercept?: boolean;
  7300. userInitiated?: boolean;
  7301. hashChange?: boolean;
  7302. destination: NavigationDestination;
  7303. signal: AbortSignal;
  7304. formData?: FormData | null;
  7305. downloadRequest?: string | null;
  7306. info?: unknown;
  7307. }
  7308. interface NavigationInterceptOptions {
  7309. handler?: () => Promise<void>;
  7310. focusReset?: 'after-transition' | 'manual';
  7311. scroll?: 'after-transition' | 'manual';
  7312. }
  7313. declare class NavigationDestination {
  7314. readonly url: string;
  7315. readonly key: string | null;
  7316. readonly id: string | null;
  7317. readonly index: number;
  7318. readonly sameDocument: boolean;
  7319. getState(): unknown;
  7320. }
  7321. /**
  7322. * Defer block instance for testing.
  7323. */
  7324. interface DeferBlockDetails extends DehydratedDeferBlock {
  7325. tDetails: TDeferBlockDetails;
  7326. }
  7327. /**
  7328. * Retrieves all defer blocks in a given LView.
  7329. *
  7330. * @param lView lView with defer blocks
  7331. * @param deferBlocks defer block aggregator array
  7332. */
  7333. declare function getDeferBlocks(lView: LView, deferBlocks: DeferBlockDetails[]): void;
  7334. export { APP_BOOTSTRAP_LISTENER, AfterRenderManager, AnimationRendererType, ApplicationRef, AttributeMarker, COMPILER_OPTIONS, CONTAINER_HEADER_OFFSET, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionScheduler, ChangeDetectionStrategy, ChangeDetectorRef, Compiler, CompilerFactory, Component, ComponentFactory, ComponentFactoryResolver, ComponentRef, DebugElement, DebugEventListener, DebugNode, DeferBlockBehavior, DeferBlockState, Directive, EffectScheduler, ElementRef, EmbeddedViewRef, EnvironmentInjector, EventEmitter, HostBinding, HostListener, INJECTOR_SCOPE, Input, InputFlags, ModuleWithComponentFactories, NG_INJ_DEF, NG_PROV_DEF, NO_ERRORS_SCHEMA, NavigateEvent, Navigation, NavigationCurrentEntryChangeEvent, NavigationDestination, NavigationHistoryEntry, NavigationTransition, NgModule, NgModuleFactory, NgModuleRef, NgProbeToken, NgZone, NoopNgZone, NotificationSource, Output, Pipe, PlatformRef, QueryFlags, QueryList, R3Injector, RenderFlags, Renderer2, RendererFactory2, RendererStyleFlags2, Sanitizer, SecurityContext, TDeferDetailsFlags, TracingAction, TracingService, ViewEncapsulation, ViewRef, ZONELESS_ENABLED, asNativeElements, defineInjectable, effect, getDebugNode, getDeferBlocks, getInjectableDef, injectChangeDetectorRef, inputBinding, isBoundToModule, isInjectable, outputBinding, twoWayBinding, ɵɵdefineInjectable, ɵɵdefineInjector };
  7335. export type { AfterRenderRef, Binding, BootstrapOptions, ClassDebugInfo, CompilerOptions, ComponentDecorator, ComponentDef, ComponentDefFeature, ComponentTemplate, ComponentType, ContentQueriesFunction, CreateEffectOptions, CssSelectorList, DeferBlockConfig, DeferBlockDependencyInterceptor, DeferBlockDetails, DehydratedDeferBlock, DependencyResolverFn, DependencyTypeList, DirectiveDecorator, DirectiveDef, DirectiveDefFeature, DirectiveType, DirectiveWithBindings, EffectCleanupFn, EffectCleanupRegisterFn, EffectRef, GlobalTargetResolver, HostBindingDecorator, HostBindingsFunction, HostDirectiveConfig, HostListenerDecorator, InjectableType, InjectorType, InputDecorator, InputSignalNode, InputTransformFunction, InternalNgModuleRef, LContainer, LView, ListenerOptions, LocalRefExtractor, NavigationInterceptOptions, NavigationNavigateOptions, NavigationOptions, NavigationReloadOptions, NavigationResult, NavigationTypeString, NavigationUpdateCurrentEntryOptions, NgModuleDecorator, NgModuleScopeInfoFromDecorator, OpaqueViewState, OutputDecorator, PipeDecorator, PipeDef, PipeType, Predicate, ProjectionSlots, RElement, RNode, RawScopeInfoFromDecorator, RendererType2, SanitizerFn, SchemaMetadata, TAttributes, TConstantsOrFactory, TDeferBlockDetails, TNode, TView, TracingSnapshot, TrustedHTML, TrustedScript, TrustedScriptURL, TypeDecorator, TypeOrFactory, ViewQueriesFunction, ɵɵComponentDeclaration, ɵɵDirectiveDeclaration, ɵɵFactoryDeclaration, ɵɵInjectableDeclaration, ɵɵInjectorDeclaration, ɵɵInjectorDef, ɵɵNgModuleDeclaration, ɵɵPipeDeclaration };