angular-ui-router.js 352 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364
  1. /*
  2. * Password Management Servlets (PWM)
  3. * http://www.pwm-project.org
  4. *
  5. * Copyright (c) 2006-2009 Novell, Inc.
  6. * Copyright (c) 2009-2021 The PWM Project
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. /*!
  21. * State-based routing for AngularJS
  22. * @version v1.0.0-beta.3
  23. * @link https://ui-router.github.io
  24. * @license MIT License, http://www.opensource.org/licenses/MIT
  25. */
  26. (function webpackUniversalModuleDefinition(root, factory) {
  27. if(typeof exports === 'object' && typeof module === 'object')
  28. module.exports = factory(require("angular"));
  29. else if(typeof define === 'function' && define.amd)
  30. define("angular-ui-router", ["angular"], factory);
  31. else if(typeof exports === 'object')
  32. exports["angular-ui-router"] = factory(require("angular"));
  33. else
  34. root["angular-ui-router"] = factory(root["angular"]);
  35. })(this, function(__WEBPACK_EXTERNAL_MODULE_57__) {
  36. return /******/ (function(modules) { // webpackBootstrap
  37. /******/ // The module cache
  38. /******/ var installedModules = {};
  39. /******/
  40. /******/ // The require function
  41. /******/ function __webpack_require__(moduleId) {
  42. /******/
  43. /******/ // Check if module is in cache
  44. /******/ if(installedModules[moduleId])
  45. /******/ return installedModules[moduleId].exports;
  46. /******/
  47. /******/ // Create a new module (and put it into the cache)
  48. /******/ var module = installedModules[moduleId] = {
  49. /******/ exports: {},
  50. /******/ id: moduleId,
  51. /******/ loaded: false
  52. /******/ };
  53. /******/
  54. /******/ // Execute the module function
  55. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  56. /******/
  57. /******/ // Flag the module as loaded
  58. /******/ module.loaded = true;
  59. /******/
  60. /******/ // Return the exports of the module
  61. /******/ return module.exports;
  62. /******/ }
  63. /******/
  64. /******/
  65. /******/ // expose the modules object (__webpack_modules__)
  66. /******/ __webpack_require__.m = modules;
  67. /******/
  68. /******/ // expose the module cache
  69. /******/ __webpack_require__.c = installedModules;
  70. /******/
  71. /******/ // __webpack_public_path__
  72. /******/ __webpack_require__.p = "";
  73. /******/
  74. /******/ // Load entry module and return exports
  75. /******/ return __webpack_require__(0);
  76. /******/ })
  77. /************************************************************************/
  78. /******/ ([
  79. /* 0 */
  80. /***/ function(module, exports, __webpack_require__) {
  81. /**
  82. * Main entry point for angular 1.x build
  83. * @module ng1
  84. */
  85. /** for typedoc */
  86. "use strict";
  87. function __export(m) {
  88. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  89. }
  90. __export(__webpack_require__(1));
  91. __export(__webpack_require__(53));
  92. __export(__webpack_require__(55));
  93. __export(__webpack_require__(58));
  94. __webpack_require__(60);
  95. __webpack_require__(61);
  96. __webpack_require__(62);
  97. __webpack_require__(63);
  98. Object.defineProperty(exports, "__esModule", { value: true });
  99. exports.default = "ui.router";
  100. /***/ },
  101. /* 1 */
  102. /***/ function(module, exports, __webpack_require__) {
  103. /** @module common */ /** */
  104. "use strict";
  105. function __export(m) {
  106. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  107. }
  108. __export(__webpack_require__(2));
  109. __export(__webpack_require__(46));
  110. __export(__webpack_require__(47));
  111. __export(__webpack_require__(48));
  112. __export(__webpack_require__(49));
  113. __export(__webpack_require__(50));
  114. __export(__webpack_require__(51));
  115. __export(__webpack_require__(52));
  116. __export(__webpack_require__(44));
  117. var router_1 = __webpack_require__(25);
  118. exports.UIRouter = router_1.UIRouter;
  119. /***/ },
  120. /* 2 */
  121. /***/ function(module, exports, __webpack_require__) {
  122. "use strict";
  123. function __export(m) {
  124. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  125. }
  126. /** @module common */ /** for typedoc */
  127. __export(__webpack_require__(3));
  128. __export(__webpack_require__(6));
  129. __export(__webpack_require__(7));
  130. __export(__webpack_require__(5));
  131. __export(__webpack_require__(4));
  132. __export(__webpack_require__(8));
  133. __export(__webpack_require__(9));
  134. __export(__webpack_require__(12));
  135. /***/ },
  136. /* 3 */
  137. /***/ function(module, exports, __webpack_require__) {
  138. /**
  139. * Random utility functions used in the UI-Router code
  140. *
  141. * @preferred @module common
  142. */ /** for typedoc */
  143. "use strict";
  144. var predicates_1 = __webpack_require__(4);
  145. var hof_1 = __webpack_require__(5);
  146. var coreservices_1 = __webpack_require__(6);
  147. var w = typeof window === 'undefined' ? {} : window;
  148. var angular = w.angular || {};
  149. exports.fromJson = angular.fromJson || JSON.parse.bind(JSON);
  150. exports.toJson = angular.toJson || JSON.stringify.bind(JSON);
  151. exports.copy = angular.copy || _copy;
  152. exports.forEach = angular.forEach || _forEach;
  153. exports.extend = angular.extend || _extend;
  154. exports.equals = angular.equals || _equals;
  155. exports.identity = function (x) { return x; };
  156. exports.noop = function () { return undefined; };
  157. /**
  158. * Binds and copies functions onto an object
  159. *
  160. * Takes functions from the 'from' object, binds those functions to the _this object, and puts the bound functions
  161. * on the 'to' object.
  162. *
  163. * This example creates an new class instance whose functions are prebound to the new'd object.
  164. * @example
  165. * ```
  166. *
  167. * class Foo {
  168. * constructor(data) {
  169. * // Binds all functions from Foo.prototype to 'this',
  170. * // then copies them to 'this'
  171. * bindFunctions(Foo.prototype, this, this);
  172. * this.data = data;
  173. * }
  174. *
  175. * log() {
  176. * console.log(this.data);
  177. * }
  178. * }
  179. *
  180. * let myFoo = new Foo([1,2,3]);
  181. * var logit = myFoo.log;
  182. * logit(); // logs [1, 2, 3] from the myFoo 'this' instance
  183. * ```
  184. *
  185. * This example creates a bound version of a service function, and copies it to another object
  186. * @example
  187. * ```
  188. *
  189. * var SomeService = {
  190. * this.data = [3, 4, 5];
  191. * this.log = function() {
  192. * console.log(this.data);
  193. * }
  194. * }
  195. *
  196. * // Constructor fn
  197. * function OtherThing() {
  198. * // Binds all functions from SomeService to SomeService,
  199. * // then copies them to 'this'
  200. * bindFunctions(SomeService, this, SomeService);
  201. * }
  202. *
  203. * let myOtherThing = new OtherThing();
  204. * myOtherThing.log(); // logs [3, 4, 5] from SomeService's 'this'
  205. * ```
  206. *
  207. * @param from The object which contains the functions to be bound
  208. * @param to The object which will receive the bound functions
  209. * @param bindTo The object which the functions will be bound to
  210. * @param fnNames The function names which will be bound (Defaults to all the functions found on the 'from' object)
  211. */
  212. function bindFunctions(from, to, bindTo, fnNames) {
  213. if (fnNames === void 0) { fnNames = Object.keys(from); }
  214. return fnNames.filter(function (name) { return typeof from[name] === 'function'; })
  215. .forEach(function (name) { return to[name] = from[name].bind(bindTo); });
  216. }
  217. exports.bindFunctions = bindFunctions;
  218. /**
  219. * prototypal inheritance helper.
  220. * Creates a new object which has `parent` object as its prototype, and then copies the properties from `extra` onto it
  221. */
  222. exports.inherit = function (parent, extra) {
  223. return exports.extend(new (exports.extend(function () { }, { prototype: parent }))(), extra);
  224. };
  225. /**
  226. * Given an arguments object, converts the arguments at index idx and above to an array.
  227. * This is similar to es6 rest parameters.
  228. *
  229. * Optionally, the argument at index idx may itself already be an array.
  230. *
  231. * For example,
  232. * given either:
  233. * arguments = [ obj, "foo", "bar" ]
  234. * or:
  235. * arguments = [ obj, ["foo", "bar"] ]
  236. * then:
  237. * restArgs(arguments, 1) == ["foo", "bar"]
  238. *
  239. * This allows functions like pick() to be implemented such that it allows either a bunch
  240. * of string arguments (like es6 rest parameters), or a single array of strings:
  241. *
  242. * given:
  243. * var obj = { foo: 1, bar: 2, baz: 3 };
  244. * then:
  245. * pick(obj, "foo", "bar"); // returns { foo: 1, bar: 2 }
  246. * pick(obj, ["foo", "bar"]); // returns { foo: 1, bar: 2 }
  247. */
  248. var restArgs = function (args, idx) {
  249. if (idx === void 0) { idx = 0; }
  250. return Array.prototype.concat.apply(Array.prototype, Array.prototype.slice.call(args, idx));
  251. };
  252. /** Given an array, returns true if the object is found in the array, (using indexOf) */
  253. exports.inArray = function (array, obj) {
  254. return array.indexOf(obj) !== -1;
  255. };
  256. /** Given an array, and an item, if the item is found in the array, it removes it (in-place). The same array is returned */
  257. exports.removeFrom = hof_1.curry(function (array, obj) {
  258. var idx = array.indexOf(obj);
  259. if (idx >= 0)
  260. array.splice(idx, 1);
  261. return array;
  262. });
  263. /**
  264. * Applies a set of defaults to an options object. The options object is filtered
  265. * to only those properties of the objects in the defaultsList.
  266. * Earlier objects in the defaultsList take precedence when applying defaults.
  267. */
  268. function defaults(opts) {
  269. if (opts === void 0) { opts = {}; }
  270. var defaultsList = [];
  271. for (var _i = 1; _i < arguments.length; _i++) {
  272. defaultsList[_i - 1] = arguments[_i];
  273. }
  274. var defaults = merge.apply(null, [{}].concat(defaultsList));
  275. return exports.extend({}, defaults, pick(opts || {}, Object.keys(defaults)));
  276. }
  277. exports.defaults = defaults;
  278. /**
  279. * Merges properties from the list of objects to the destination object.
  280. * If a property already exists in the destination object, then it is not overwritten.
  281. */
  282. function merge(dst) {
  283. var objs = [];
  284. for (var _i = 1; _i < arguments.length; _i++) {
  285. objs[_i - 1] = arguments[_i];
  286. }
  287. exports.forEach(objs, function (obj) {
  288. exports.forEach(obj, function (value, key) {
  289. if (!dst.hasOwnProperty(key))
  290. dst[key] = value;
  291. });
  292. });
  293. return dst;
  294. }
  295. exports.merge = merge;
  296. /** Reduce function that merges each element of the list into a single object, using extend */
  297. exports.mergeR = function (memo, item) { return exports.extend(memo, item); };
  298. /**
  299. * Finds the common ancestor path between two states.
  300. *
  301. * @param {Object} first The first state.
  302. * @param {Object} second The second state.
  303. * @return {Array} Returns an array of state names in descending order, not including the root.
  304. */
  305. function ancestors(first, second) {
  306. var path = [];
  307. for (var n in first.path) {
  308. if (first.path[n] !== second.path[n])
  309. break;
  310. path.push(first.path[n]);
  311. }
  312. return path;
  313. }
  314. exports.ancestors = ancestors;
  315. /**
  316. * Performs a non-strict comparison of the subset of two objects, defined by a list of keys.
  317. *
  318. * @param {Object} a The first object.
  319. * @param {Object} b The second object.
  320. * @param {Array} keys The list of keys within each object to compare. If the list is empty or not specified,
  321. * it defaults to the list of keys in `a`.
  322. * @return {Boolean} Returns `true` if the keys match, otherwise `false`.
  323. */
  324. function equalForKeys(a, b, keys) {
  325. if (keys === void 0) { keys = Object.keys(a); }
  326. for (var i = 0; i < keys.length; i++) {
  327. var k = keys[i];
  328. if (a[k] != b[k])
  329. return false; // Not '===', values aren't necessarily normalized
  330. }
  331. return true;
  332. }
  333. exports.equalForKeys = equalForKeys;
  334. function pickOmitImpl(predicate, obj) {
  335. var keys = [];
  336. for (var _i = 2; _i < arguments.length; _i++) {
  337. keys[_i - 2] = arguments[_i];
  338. }
  339. var objCopy = {};
  340. for (var key in obj) {
  341. if (predicate(keys, key))
  342. objCopy[key] = obj[key];
  343. }
  344. return objCopy;
  345. }
  346. /** Return a copy of the object only containing the whitelisted properties. */
  347. function pick(obj) {
  348. return pickOmitImpl.apply(null, [exports.inArray].concat(restArgs(arguments)));
  349. }
  350. exports.pick = pick;
  351. /** Return a copy of the object omitting the blacklisted properties. */
  352. function omit(obj) {
  353. var notInArray = function (array, item) { return !exports.inArray(array, item); };
  354. return pickOmitImpl.apply(null, [notInArray].concat(restArgs(arguments)));
  355. }
  356. exports.omit = omit;
  357. /**
  358. * Maps an array, or object to a property (by name)
  359. */
  360. function pluck(collection, propName) {
  361. return map(collection, hof_1.prop(propName));
  362. }
  363. exports.pluck = pluck;
  364. /** Filters an Array or an Object's properties based on a predicate */
  365. function filter(collection, callback) {
  366. var arr = predicates_1.isArray(collection), result = arr ? [] : {};
  367. var accept = arr ? function (x) { return result.push(x); } : function (x, key) { return result[key] = x; };
  368. exports.forEach(collection, function (item, i) {
  369. if (callback(item, i))
  370. accept(item, i);
  371. });
  372. return result;
  373. }
  374. exports.filter = filter;
  375. /** Finds an object from an array, or a property of an object, that matches a predicate */
  376. function find(collection, callback) {
  377. var result;
  378. exports.forEach(collection, function (item, i) {
  379. if (result)
  380. return;
  381. if (callback(item, i))
  382. result = item;
  383. });
  384. return result;
  385. }
  386. exports.find = find;
  387. /** Given an object, returns a new object, where each property is transformed by the callback function */
  388. exports.mapObj = map;
  389. /** Maps an array or object properties using a callback function */
  390. function map(collection, callback) {
  391. var result = predicates_1.isArray(collection) ? [] : {};
  392. exports.forEach(collection, function (item, i) { return result[i] = callback(item, i); });
  393. return result;
  394. }
  395. exports.map = map;
  396. /**
  397. * Given an object, return its enumerable property values
  398. *
  399. * @example
  400. * ```
  401. *
  402. * let foo = { a: 1, b: 2, c: 3 }
  403. * let vals = values(foo); // [ 1, 2, 3 ]
  404. * ```
  405. */
  406. exports.values = function (obj) {
  407. return Object.keys(obj).map(function (key) { return obj[key]; });
  408. };
  409. /**
  410. * Reduce function that returns true if all of the values are truthy.
  411. *
  412. * @example
  413. * ```
  414. *
  415. * let vals = [ 1, true, {}, "hello world"];
  416. * vals.reduce(allTrueR, true); // true
  417. *
  418. * vals.push(0);
  419. * vals.reduce(allTrueR, true); // false
  420. * ```
  421. */
  422. exports.allTrueR = function (memo, elem) { return memo && elem; };
  423. /**
  424. * Reduce function that returns true if any of the values are truthy.
  425. *
  426. * * @example
  427. * ```
  428. *
  429. * let vals = [ 0, null, undefined ];
  430. * vals.reduce(anyTrueR, true); // false
  431. *
  432. * vals.push("hello world");
  433. * vals.reduce(anyTrueR, true); // true
  434. * ```
  435. */
  436. exports.anyTrueR = function (memo, elem) { return memo || elem; };
  437. /**
  438. * Reduce function which un-nests a single level of arrays
  439. * @example
  440. * ```
  441. *
  442. * let input = [ [ "a", "b" ], [ "c", "d" ], [ [ "double", "nested" ] ] ];
  443. * input.reduce(unnestR, []) // [ "a", "b", "c", "d", [ "double, "nested" ] ]
  444. * ```
  445. */
  446. exports.unnestR = function (memo, elem) { return memo.concat(elem); };
  447. /**
  448. * Reduce function which recursively un-nests all arrays
  449. *
  450. * @example
  451. * ```
  452. *
  453. * let input = [ [ "a", "b" ], [ "c", "d" ], [ [ "double", "nested" ] ] ];
  454. * input.reduce(unnestR, []) // [ "a", "b", "c", "d", "double, "nested" ]
  455. * ```
  456. */
  457. exports.flattenR = function (memo, elem) {
  458. return predicates_1.isArray(elem) ? memo.concat(elem.reduce(exports.flattenR, [])) : pushR(memo, elem);
  459. };
  460. /**
  461. * Reduce function that pushes an object to an array, then returns the array.
  462. * Mostly just for [[flattenR]] and [[uniqR]]
  463. */
  464. function pushR(arr, obj) {
  465. arr.push(obj);
  466. return arr;
  467. }
  468. exports.pushR = pushR;
  469. /** Reduce function that filters out duplicates */
  470. exports.uniqR = function (acc, token) {
  471. return exports.inArray(acc, token) ? acc : pushR(acc, token);
  472. };
  473. /**
  474. * Return a new array with a single level of arrays unnested.
  475. *
  476. * @example
  477. * ```
  478. *
  479. * let input = [ [ "a", "b" ], [ "c", "d" ], [ [ "double", "nested" ] ] ];
  480. * unnest(input) // [ "a", "b", "c", "d", [ "double, "nested" ] ]
  481. * ```
  482. */
  483. exports.unnest = function (arr) { return arr.reduce(exports.unnestR, []); };
  484. /**
  485. * Return a completely flattened version of an array.
  486. *
  487. * @example
  488. * ```
  489. *
  490. * let input = [ [ "a", "b" ], [ "c", "d" ], [ [ "double", "nested" ] ] ];
  491. * flatten(input) // [ "a", "b", "c", "d", "double, "nested" ]
  492. * ```
  493. */
  494. exports.flatten = function (arr) { return arr.reduce(exports.flattenR, []); };
  495. /**
  496. * Given a .filter Predicate, builds a .filter Predicate which throws an error if any elements do not pass.
  497. * @example
  498. * ```
  499. *
  500. * let isNumber = (obj) => typeof(obj) === 'number';
  501. * let allNumbers = [ 1, 2, 3, 4, 5 ];
  502. * allNumbers.filter(assertPredicate(isNumber)); //OK
  503. *
  504. * let oneString = [ 1, 2, 3, 4, "5" ];
  505. * oneString.filter(assertPredicate(isNumber, "Not all numbers")); // throws Error(""Not all numbers"");
  506. * ```
  507. */
  508. function assertPredicate(predicate, errMsg) {
  509. if (errMsg === void 0) { errMsg = "assert failure"; }
  510. return function (obj) {
  511. if (!predicate(obj)) {
  512. throw new Error(predicates_1.isFunction(errMsg) ? errMsg(obj) : errMsg);
  513. }
  514. return true;
  515. };
  516. }
  517. exports.assertPredicate = assertPredicate;
  518. /**
  519. * Like _.pairs: Given an object, returns an array of key/value pairs
  520. *
  521. * @example
  522. * ```
  523. *
  524. * pairs({ foo: "FOO", bar: "BAR }) // [ [ "foo", "FOO" ], [ "bar": "BAR" ] ]
  525. * ```
  526. */
  527. exports.pairs = function (obj) {
  528. return Object.keys(obj).map(function (key) { return [key, obj[key]]; });
  529. };
  530. /**
  531. * Given two or more parallel arrays, returns an array of tuples where
  532. * each tuple is composed of [ a[i], b[i], ... z[i] ]
  533. *
  534. * @example
  535. * ```
  536. *
  537. * let foo = [ 0, 2, 4, 6 ];
  538. * let bar = [ 1, 3, 5, 7 ];
  539. * let baz = [ 10, 30, 50, 70 ];
  540. * arrayTuples(foo, bar); // [ [0, 1], [2, 3], [4, 5], [6, 7] ]
  541. * arrayTuples(foo, bar, baz); // [ [0, 1, 10], [2, 3, 30], [4, 5, 50], [6, 7, 70] ]
  542. * ```
  543. */
  544. function arrayTuples() {
  545. var arrayArgs = [];
  546. for (var _i = 0; _i < arguments.length; _i++) {
  547. arrayArgs[_i - 0] = arguments[_i];
  548. }
  549. if (arrayArgs.length === 0)
  550. return [];
  551. var length = arrayArgs.reduce(function (min, arr) { return Math.min(arr.length, min); }, 9007199254740991); // aka 2^53 − 1 aka Number.MAX_SAFE_INTEGER
  552. return Array.apply(null, Array(length)).map(function (ignored, idx) { return arrayArgs.map(function (arr) { return arr[idx]; }); });
  553. }
  554. exports.arrayTuples = arrayTuples;
  555. /**
  556. * Reduce function which builds an object from an array of [key, value] pairs.
  557. *
  558. * Each iteration sets the key/val pair on the memo object, then returns the memo for the next iteration.
  559. *
  560. * Each keyValueTuple should be an array with values [ key: string, value: any ]
  561. *
  562. * @example
  563. * ```
  564. *
  565. * var pairs = [ ["fookey", "fooval"], ["barkey", "barval"] ]
  566. *
  567. * var pairsToObj = pairs.reduce((memo, pair) => applyPairs(memo, pair), {})
  568. * // pairsToObj == { fookey: "fooval", barkey: "barval" }
  569. *
  570. * // Or, more simply:
  571. * var pairsToObj = pairs.reduce(applyPairs, {})
  572. * // pairsToObj == { fookey: "fooval", barkey: "barval" }
  573. * ```
  574. */
  575. function applyPairs(memo, keyValTuple) {
  576. var key, value;
  577. if (predicates_1.isArray(keyValTuple))
  578. key = keyValTuple[0], value = keyValTuple[1];
  579. if (!predicates_1.isString(key))
  580. throw new Error("invalid parameters to applyPairs");
  581. memo[key] = value;
  582. return memo;
  583. }
  584. exports.applyPairs = applyPairs;
  585. /** Get the last element of an array */
  586. function tail(arr) {
  587. return arr.length && arr[arr.length - 1] || undefined;
  588. }
  589. exports.tail = tail;
  590. /**
  591. * shallow copy from src to dest
  592. *
  593. * note: This is a shallow copy, while angular.copy is a deep copy.
  594. * ui-router uses `copy` only to make copies of state parameters.
  595. */
  596. function _copy(src, dest) {
  597. if (dest)
  598. Object.keys(dest).forEach(function (key) { return delete dest[key]; });
  599. if (!dest)
  600. dest = {};
  601. return exports.extend(dest, src);
  602. }
  603. /** Naive forEach implementation works with Objects or Arrays */
  604. function _forEach(obj, cb, _this) {
  605. if (predicates_1.isArray(obj))
  606. return obj.forEach(cb, _this);
  607. Object.keys(obj).forEach(function (key) { return cb(obj[key], key); });
  608. }
  609. function _copyProps(to, from) {
  610. Object.keys(from).forEach(function (key) { return to[key] = from[key]; });
  611. return to;
  612. }
  613. function _extend(toObj) {
  614. return restArgs(arguments, 1).filter(exports.identity).reduce(_copyProps, toObj);
  615. }
  616. function _equals(o1, o2) {
  617. if (o1 === o2)
  618. return true;
  619. if (o1 === null || o2 === null)
  620. return false;
  621. if (o1 !== o1 && o2 !== o2)
  622. return true; // NaN === NaN
  623. var t1 = typeof o1, t2 = typeof o2;
  624. if (t1 !== t2 || t1 !== 'object')
  625. return false;
  626. var tup = [o1, o2];
  627. if (hof_1.all(predicates_1.isArray)(tup))
  628. return _arraysEq(o1, o2);
  629. if (hof_1.all(predicates_1.isDate)(tup))
  630. return o1.getTime() === o2.getTime();
  631. if (hof_1.all(predicates_1.isRegExp)(tup))
  632. return o1.toString() === o2.toString();
  633. if (hof_1.all(predicates_1.isFunction)(tup))
  634. return true; // meh
  635. var predicates = [predicates_1.isFunction, predicates_1.isArray, predicates_1.isDate, predicates_1.isRegExp];
  636. if (predicates.map(hof_1.any).reduce(function (b, fn) { return b || !!fn(tup); }, false))
  637. return false;
  638. var key, keys = {};
  639. for (key in o1) {
  640. if (!_equals(o1[key], o2[key]))
  641. return false;
  642. keys[key] = true;
  643. }
  644. for (key in o2) {
  645. if (!keys[key])
  646. return false;
  647. }
  648. return true;
  649. }
  650. function _arraysEq(a1, a2) {
  651. if (a1.length !== a2.length)
  652. return false;
  653. return arrayTuples(a1, a2).reduce(function (b, t) { return b && _equals(t[0], t[1]); }, true);
  654. }
  655. // issue #2676
  656. exports.silenceUncaughtInPromise = function (promise) {
  657. return promise.catch(function (e) { return 0; }) && promise;
  658. };
  659. exports.silentRejection = function (error) {
  660. return exports.silenceUncaughtInPromise(coreservices_1.services.$q.reject(error));
  661. };
  662. /***/ },
  663. /* 4 */
  664. /***/ function(module, exports, __webpack_require__) {
  665. "use strict";
  666. /** Predicates @module common_predicates */ /** */
  667. var hof_1 = __webpack_require__(5);
  668. var toStr = Object.prototype.toString;
  669. var tis = function (t) { return function (x) { return typeof (x) === t; }; };
  670. exports.isUndefined = tis('undefined');
  671. exports.isDefined = hof_1.not(exports.isUndefined);
  672. exports.isNull = function (o) { return o === null; };
  673. exports.isFunction = tis('function');
  674. exports.isNumber = tis('number');
  675. exports.isString = tis('string');
  676. exports.isObject = function (x) { return x !== null && typeof x === 'object'; };
  677. exports.isArray = Array.isArray;
  678. exports.isDate = (function (x) { return toStr.call(x) === '[object Date]'; });
  679. exports.isRegExp = (function (x) { return toStr.call(x) === '[object RegExp]'; });
  680. /**
  681. * Predicate which checks if a value is injectable
  682. *
  683. * A value is "injectable" if it is a function, or if it is an ng1 array-notation-style array
  684. * where all the elements in the array are Strings, except the last one, which is a Function
  685. */
  686. function isInjectable(val) {
  687. if (exports.isArray(val) && val.length) {
  688. var head = val.slice(0, -1), tail = val.slice(-1);
  689. return !(head.filter(hof_1.not(exports.isString)).length || tail.filter(hof_1.not(exports.isFunction)).length);
  690. }
  691. return exports.isFunction(val);
  692. }
  693. exports.isInjectable = isInjectable;
  694. /**
  695. * Predicate which checks if a value looks like a Promise
  696. *
  697. * It is probably a Promise if it's an object, and it has a `then` property which is a Function
  698. */
  699. exports.isPromise = hof_1.and(exports.isObject, hof_1.pipe(hof_1.prop('then'), exports.isFunction));
  700. /***/ },
  701. /* 5 */
  702. /***/ function(module, exports) {
  703. /**
  704. * Higher order functions
  705. *
  706. * @module common_hof
  707. */ /** */
  708. "use strict";
  709. /**
  710. * Returns a new function for [Partial Application](https://en.wikipedia.org/wiki/Partial_application) of the original function.
  711. *
  712. * Given a function with N parameters, returns a new function that supports partial application.
  713. * The new function accepts anywhere from 1 to N parameters. When that function is called with M parameters,
  714. * where M is less than N, it returns a new function that accepts the remaining parameters. It continues to
  715. * accept more parameters until all N parameters have been supplied.
  716. *
  717. *
  718. * This contrived example uses a partially applied function as an predicate, which returns true
  719. * if an object is found in both arrays.
  720. * @example
  721. * ```
  722. * // returns true if an object is in both of the two arrays
  723. * function inBoth(array1, array2, object) {
  724. * return array1.indexOf(object) !== -1 &&
  725. * array2.indexOf(object) !== 1;
  726. * }
  727. * let obj1, obj2, obj3, obj4, obj5, obj6, obj7
  728. * let foos = [obj1, obj3]
  729. * let bars = [obj3, obj4, obj5]
  730. *
  731. * // A curried "copy" of inBoth
  732. * let curriedInBoth = curry(inBoth);
  733. * // Partially apply both the array1 and array2
  734. * let inFoosAndBars = curriedInBoth(foos, bars);
  735. *
  736. * // Supply the final argument; since all arguments are
  737. * // supplied, the original inBoth function is then called.
  738. * let obj1InBoth = inFoosAndBars(obj1); // false
  739. *
  740. * // Use the inFoosAndBars as a predicate.
  741. * // Filter, on each iteration, supplies the final argument
  742. * let allObjs = [ obj1, obj2, obj3, obj4, obj5, obj6, obj7 ];
  743. * let foundInBoth = allObjs.filter(inFoosAndBars); // [ obj3 ]
  744. *
  745. * ```
  746. *
  747. * Stolen from: http://stackoverflow.com/questions/4394747/javascript-curry-function
  748. *
  749. * @param fn
  750. * @returns {*|function(): (*|any)}
  751. */
  752. function curry(fn) {
  753. var initial_args = [].slice.apply(arguments, [1]);
  754. var func_args_length = fn.length;
  755. function curried(args) {
  756. if (args.length >= func_args_length)
  757. return fn.apply(null, args);
  758. return function () {
  759. return curried(args.concat([].slice.apply(arguments)));
  760. };
  761. }
  762. return curried(initial_args);
  763. }
  764. exports.curry = curry;
  765. /**
  766. * Given a varargs list of functions, returns a function that composes the argument functions, right-to-left
  767. * given: f(x), g(x), h(x)
  768. * let composed = compose(f,g,h)
  769. * then, composed is: f(g(h(x)))
  770. */
  771. function compose() {
  772. var args = arguments;
  773. var start = args.length - 1;
  774. return function () {
  775. var i = start, result = args[start].apply(this, arguments);
  776. while (i--)
  777. result = args[i].call(this, result);
  778. return result;
  779. };
  780. }
  781. exports.compose = compose;
  782. /**
  783. * Given a varargs list of functions, returns a function that is composes the argument functions, left-to-right
  784. * given: f(x), g(x), h(x)
  785. * let piped = pipe(f,g,h);
  786. * then, piped is: h(g(f(x)))
  787. */
  788. function pipe() {
  789. var funcs = [];
  790. for (var _i = 0; _i < arguments.length; _i++) {
  791. funcs[_i - 0] = arguments[_i];
  792. }
  793. return compose.apply(null, [].slice.call(arguments).reverse());
  794. }
  795. exports.pipe = pipe;
  796. /**
  797. * Given a property name, returns a function that returns that property from an object
  798. * let obj = { foo: 1, name: "blarg" };
  799. * let getName = prop("name");
  800. * getName(obj) === "blarg"
  801. */
  802. exports.prop = function (name) {
  803. return function (obj) { return obj && obj[name]; };
  804. };
  805. /**
  806. * Given a property name and a value, returns a function that returns a boolean based on whether
  807. * the passed object has a property that matches the value
  808. * let obj = { foo: 1, name: "blarg" };
  809. * let getName = propEq("name", "blarg");
  810. * getName(obj) === true
  811. */
  812. exports.propEq = curry(function (name, val, obj) { return obj && obj[name] === val; });
  813. /**
  814. * Given a dotted property name, returns a function that returns a nested property from an object, or undefined
  815. * let obj = { id: 1, nestedObj: { foo: 1, name: "blarg" }, };
  816. * let getName = prop("nestedObj.name");
  817. * getName(obj) === "blarg"
  818. * let propNotFound = prop("this.property.doesnt.exist");
  819. * propNotFound(obj) === undefined
  820. */
  821. exports.parse = function (name) {
  822. return pipe.apply(null, name.split(".").map(exports.prop));
  823. };
  824. /**
  825. * Given a function that returns a truthy or falsey value, returns a
  826. * function that returns the opposite (falsey or truthy) value given the same inputs
  827. */
  828. exports.not = function (fn) {
  829. return function () {
  830. var args = [];
  831. for (var _i = 0; _i < arguments.length; _i++) {
  832. args[_i - 0] = arguments[_i];
  833. }
  834. return !fn.apply(null, args);
  835. };
  836. };
  837. /**
  838. * Given two functions that return truthy or falsey values, returns a function that returns truthy
  839. * if both functions return truthy for the given arguments
  840. */
  841. function and(fn1, fn2) {
  842. return function () {
  843. var args = [];
  844. for (var _i = 0; _i < arguments.length; _i++) {
  845. args[_i - 0] = arguments[_i];
  846. }
  847. return fn1.apply(null, args) && fn2.apply(null, args);
  848. };
  849. }
  850. exports.and = and;
  851. /**
  852. * Given two functions that return truthy or falsey values, returns a function that returns truthy
  853. * if at least one of the functions returns truthy for the given arguments
  854. */
  855. function or(fn1, fn2) {
  856. return function () {
  857. var args = [];
  858. for (var _i = 0; _i < arguments.length; _i++) {
  859. args[_i - 0] = arguments[_i];
  860. }
  861. return fn1.apply(null, args) || fn2.apply(null, args);
  862. };
  863. }
  864. exports.or = or;
  865. /**
  866. * Check if all the elements of an array match a predicate function
  867. *
  868. * @param fn1 a predicate function `fn1`
  869. * @returns a function which takes an array and returns true if `fn1` is true for all elements of the array
  870. */
  871. exports.all = function (fn1) {
  872. return function (arr) { return arr.reduce(function (b, x) { return b && !!fn1(x); }, true); };
  873. };
  874. exports.any = function (fn1) {
  875. return function (arr) { return arr.reduce(function (b, x) { return b || !!fn1(x); }, false); };
  876. };
  877. /** Given a class, returns a Predicate function that returns true if the object is of that class */
  878. exports.is = function (ctor) { return function (obj) {
  879. return (obj != null && obj.constructor === ctor || obj instanceof ctor);
  880. }; };
  881. /** Given a value, returns a Predicate function that returns true if another value is === equal to the original value */
  882. exports.eq = function (val) { return function (other) {
  883. return val === other;
  884. }; };
  885. /** Given a value, returns a function which returns the value */
  886. exports.val = function (v) { return function () { return v; }; };
  887. function invoke(fnName, args) {
  888. return function (obj) {
  889. return obj[fnName].apply(obj, args);
  890. };
  891. }
  892. exports.invoke = invoke;
  893. /**
  894. * Sorta like Pattern Matching (a functional programming conditional construct)
  895. *
  896. * See http://c2.com/cgi/wiki?PatternMatching
  897. *
  898. * This is a conditional construct which allows a series of predicates and output functions
  899. * to be checked and then applied. Each predicate receives the input. If the predicate
  900. * returns truthy, then its matching output function (mapping function) is provided with
  901. * the input and, then the result is returned.
  902. *
  903. * Each combination (2-tuple) of predicate + output function should be placed in an array
  904. * of size 2: [ predicate, mapFn ]
  905. *
  906. * These 2-tuples should be put in an outer array.
  907. *
  908. * @example
  909. * ```
  910. *
  911. * // Here's a 2-tuple where the first element is the isString predicate
  912. * // and the second element is a function that returns a description of the input
  913. * let firstTuple = [ angular.isString, (input) => `Heres your string ${input}` ];
  914. *
  915. * // Second tuple: predicate "isNumber", mapfn returns a description
  916. * let secondTuple = [ angular.isNumber, (input) => `(${input}) That's a number!` ];
  917. *
  918. * let third = [ (input) => input === null, (input) => `Oh, null...` ];
  919. *
  920. * let fourth = [ (input) => input === undefined, (input) => `notdefined` ];
  921. *
  922. * let descriptionOf = pattern([ firstTuple, secondTuple, third, fourth ]);
  923. *
  924. * console.log(descriptionOf(undefined)); // 'notdefined'
  925. * console.log(descriptionOf(55)); // '(55) That's a number!'
  926. * console.log(descriptionOf("foo")); // 'Here's your string foo'
  927. * ```
  928. *
  929. * @param struct A 2D array. Each element of the array should be an array, a 2-tuple,
  930. * with a Predicate and a mapping/output function
  931. * @returns {function(any): *}
  932. */
  933. function pattern(struct) {
  934. return function (x) {
  935. for (var i = 0; i < struct.length; i++) {
  936. if (struct[i][0](x))
  937. return struct[i][1](x);
  938. }
  939. };
  940. }
  941. exports.pattern = pattern;
  942. /***/ },
  943. /* 6 */
  944. /***/ function(module, exports) {
  945. "use strict";
  946. var notImplemented = function (fnname) { return function () {
  947. throw new Error(fnname + "(): No coreservices implementation for UI-Router is loaded. You should include one of: ['angular1.js']");
  948. }; };
  949. var services = {
  950. $q: undefined,
  951. $injector: undefined,
  952. location: {},
  953. locationConfig: {},
  954. template: {}
  955. };
  956. exports.services = services;
  957. ["setUrl", "path", "search", "hash", "onChange"]
  958. .forEach(function (key) { return services.location[key] = notImplemented(key); });
  959. ["port", "protocol", "host", "baseHref", "html5Mode", "hashPrefix"]
  960. .forEach(function (key) { return services.locationConfig[key] = notImplemented(key); });
  961. /***/ },
  962. /* 7 */
  963. /***/ function(module, exports) {
  964. "use strict";
  965. /** @module common */
  966. /**
  967. * Matches state names using glob-like pattern strings.
  968. *
  969. * Globs can be used in specific APIs including:
  970. *
  971. * - [[StateService.is]]
  972. * - [[StateService.includes]]
  973. * - [[HookMatchCriteria.to]]
  974. * - [[HookMatchCriteria.from]]
  975. * - [[HookMatchCriteria.exiting]]
  976. * - [[HookMatchCriteria.retained]]
  977. * - [[HookMatchCriteria.entering]]
  978. *
  979. * A `Glob` string is a pattern which matches state names.
  980. * Nested state names are split into segments (separated by a dot) when processing.
  981. * The state named `foo.bar.baz` is split into three segments ['foo', 'bar', 'baz']
  982. *
  983. * Globs work according to the following rules:
  984. *
  985. * ### Exact match:
  986. *
  987. * The glob `'A.B'` matches the state named exactly `'A.B'`.
  988. *
  989. * | Glob |Matches states named|Does not match state named|
  990. * |:------------|:--------------------|:---------------------|
  991. * | `'A'` | `'A'` | `'B'` , `'A.C'` |
  992. * | `'A.B'` | `'A.B'` | `'A'` , `'A.B.C'` |
  993. * | `'foo'` | `'foo'` | `'FOO'` , `'foo.bar'`|
  994. *
  995. * ### Single star (`*`)
  996. *
  997. * A single star (`*`) is a wildcard that matches exactly one segment.
  998. *
  999. * | Glob |Matches states named |Does not match state named |
  1000. * |:------------|:---------------------|:--------------------------|
  1001. * | `'*'` | `'A'` , `'Z'` | `'A.B'` , `'Z.Y.X'` |
  1002. * | `'A.*'` | `'A.B'` , `'A.C'` | `'A'` , `'A.B.C'` |
  1003. * | `'A.*.*'` | `'A.B.C'` , `'A.X.Y'`| `'A'`, `'A.B'` , `'Z.Y.X'`|
  1004. *
  1005. * ### Double star (`**`)
  1006. *
  1007. * A double star (`'**'`) is a wildcard that matches *zero or more segments*
  1008. *
  1009. * | Glob |Matches states named |Does not match state named |
  1010. * |:------------|:----------------------------------------------|:----------------------------------|
  1011. * | `'**'` | `'A'` , `'A.B'`, `'Z.Y.X'` | (matches all states) |
  1012. * | `'A.**'` | `'A'` , `'A.B'` , `'A.C.X'` | `'Z.Y.X'` |
  1013. * | `'**.X'` | `'X'` , `'A.X'` , `'Z.Y.X'` | `'A'` , `'A.login.Z'` |
  1014. * | `'A.**.X'` | `'A.X'` , `'A.B.X'` , `'A.B.C.X'` | `'A'` , `'A.B.C'` |
  1015. *
  1016. */
  1017. var Glob = (function () {
  1018. function Glob(text) {
  1019. this.text = text;
  1020. this.glob = text.split('.');
  1021. var regexpString = this.text.split('.')
  1022. .map(function (seg) {
  1023. if (seg === '**')
  1024. return '(?:|(?:\\.[^.]*)*)';
  1025. if (seg === '*')
  1026. return '\\.[^.]*';
  1027. return '\\.' + seg;
  1028. }).join('');
  1029. this.regexp = new RegExp("^" + regexpString + "$");
  1030. }
  1031. Glob.prototype.matches = function (name) {
  1032. return this.regexp.test('.' + name);
  1033. };
  1034. /** @deprecated whats the point? */
  1035. Glob.is = function (text) {
  1036. return text.indexOf('*') > -1;
  1037. };
  1038. /** @deprecated whats the point? */
  1039. Glob.fromString = function (text) {
  1040. if (!this.is(text))
  1041. return null;
  1042. return new Glob(text);
  1043. };
  1044. return Glob;
  1045. }());
  1046. exports.Glob = Glob;
  1047. /***/ },
  1048. /* 8 */
  1049. /***/ function(module, exports) {
  1050. /** @module common */ /** for typedoc */
  1051. "use strict";
  1052. var Queue = (function () {
  1053. function Queue(_items, _limit) {
  1054. if (_items === void 0) { _items = []; }
  1055. if (_limit === void 0) { _limit = null; }
  1056. this._items = _items;
  1057. this._limit = _limit;
  1058. }
  1059. Queue.prototype.enqueue = function (item) {
  1060. var items = this._items;
  1061. items.push(item);
  1062. if (this._limit && items.length > this._limit)
  1063. items.shift();
  1064. return item;
  1065. };
  1066. Queue.prototype.dequeue = function () {
  1067. if (this.size())
  1068. return this._items.splice(0, 1)[0];
  1069. };
  1070. Queue.prototype.clear = function () {
  1071. var current = this._items;
  1072. this._items = [];
  1073. return current;
  1074. };
  1075. Queue.prototype.size = function () {
  1076. return this._items.length;
  1077. };
  1078. Queue.prototype.remove = function (item) {
  1079. var idx = this._items.indexOf(item);
  1080. return idx > -1 && this._items.splice(idx, 1)[0];
  1081. };
  1082. Queue.prototype.peekTail = function () {
  1083. return this._items[this._items.length - 1];
  1084. };
  1085. Queue.prototype.peekHead = function () {
  1086. if (this.size())
  1087. return this._items[0];
  1088. };
  1089. return Queue;
  1090. }());
  1091. exports.Queue = Queue;
  1092. /***/ },
  1093. /* 9 */
  1094. /***/ function(module, exports, __webpack_require__) {
  1095. /** @module common_strings */ /** */
  1096. "use strict";
  1097. var predicates_1 = __webpack_require__(4);
  1098. var rejectFactory_1 = __webpack_require__(10);
  1099. var common_1 = __webpack_require__(3);
  1100. var hof_1 = __webpack_require__(5);
  1101. var transition_1 = __webpack_require__(11);
  1102. var resolvable_1 = __webpack_require__(19);
  1103. /**
  1104. * Returns a string shortened to a maximum length
  1105. *
  1106. * If the string is already less than the `max` length, return the string.
  1107. * Else return the string, shortened to `max - 3` and append three dots ("...").
  1108. *
  1109. * @param max the maximum length of the string to return
  1110. * @param str the input string
  1111. */
  1112. function maxLength(max, str) {
  1113. if (str.length <= max)
  1114. return str;
  1115. return str.substr(0, max - 3) + "...";
  1116. }
  1117. exports.maxLength = maxLength;
  1118. /**
  1119. * Returns a string, with spaces added to the end, up to a desired str length
  1120. *
  1121. * If the string is already longer than the desired length, return the string.
  1122. * Else returns the string, with extra spaces on the end, such that it reaches `length` characters.
  1123. *
  1124. * @param length the desired length of the string to return
  1125. * @param str the input string
  1126. */
  1127. function padString(length, str) {
  1128. while (str.length < length)
  1129. str += " ";
  1130. return str;
  1131. }
  1132. exports.padString = padString;
  1133. function kebobString(camelCase) {
  1134. return camelCase
  1135. .replace(/^([A-Z])/, function ($1) { return $1.toLowerCase(); }) // replace first char
  1136. .replace(/([A-Z])/g, function ($1) { return "-" + $1.toLowerCase(); }); // replace rest
  1137. }
  1138. exports.kebobString = kebobString;
  1139. function _toJson(obj) {
  1140. return JSON.stringify(obj);
  1141. }
  1142. function _fromJson(json) {
  1143. return predicates_1.isString(json) ? JSON.parse(json) : json;
  1144. }
  1145. function promiseToString(p) {
  1146. return "Promise(" + JSON.stringify(p) + ")";
  1147. }
  1148. function functionToString(fn) {
  1149. var fnStr = fnToString(fn);
  1150. var namedFunctionMatch = fnStr.match(/^(function [^ ]+\([^)]*\))/);
  1151. var toStr = namedFunctionMatch ? namedFunctionMatch[1] : fnStr;
  1152. var fnName = fn['name'] || "";
  1153. if (fnName && toStr.match(/function \(/)) {
  1154. return 'function ' + fnName + toStr.substr(9);
  1155. }
  1156. return toStr;
  1157. }
  1158. exports.functionToString = functionToString;
  1159. function fnToString(fn) {
  1160. var _fn = predicates_1.isArray(fn) ? fn.slice(-1)[0] : fn;
  1161. return _fn && _fn.toString() || "undefined";
  1162. }
  1163. exports.fnToString = fnToString;
  1164. var stringifyPatternFn = null;
  1165. var stringifyPattern = function (value) {
  1166. var isTransitionRejectionPromise = rejectFactory_1.Rejection.isTransitionRejectionPromise;
  1167. stringifyPatternFn = stringifyPatternFn || hof_1.pattern([
  1168. [hof_1.not(predicates_1.isDefined), hof_1.val("undefined")],
  1169. [predicates_1.isNull, hof_1.val("null")],
  1170. [predicates_1.isPromise, hof_1.val("[Promise]")],
  1171. [isTransitionRejectionPromise, function (x) { return x._transitionRejection.toString(); }],
  1172. [hof_1.is(rejectFactory_1.Rejection), hof_1.invoke("toString")],
  1173. [hof_1.is(transition_1.Transition), hof_1.invoke("toString")],
  1174. [hof_1.is(resolvable_1.Resolvable), hof_1.invoke("toString")],
  1175. [predicates_1.isInjectable, functionToString],
  1176. [hof_1.val(true), common_1.identity]
  1177. ]);
  1178. return stringifyPatternFn(value);
  1179. };
  1180. function stringify(o) {
  1181. var seen = [];
  1182. function format(val) {
  1183. if (predicates_1.isObject(val)) {
  1184. if (seen.indexOf(val) !== -1)
  1185. return '[circular ref]';
  1186. seen.push(val);
  1187. }
  1188. return stringifyPattern(val);
  1189. }
  1190. return JSON.stringify(o, function (key, val) { return format(val); }).replace(/\\"/g, '"');
  1191. }
  1192. exports.stringify = stringify;
  1193. /** Returns a function that splits a string on a character or substring */
  1194. exports.beforeAfterSubstr = function (char) { return function (str) {
  1195. if (!str)
  1196. return ["", ""];
  1197. var idx = str.indexOf(char);
  1198. if (idx === -1)
  1199. return [str, ""];
  1200. return [str.substr(0, idx), str.substr(idx + 1)];
  1201. }; };
  1202. /***/ },
  1203. /* 10 */
  1204. /***/ function(module, exports, __webpack_require__) {
  1205. /** @module transition */ /** for typedoc */
  1206. "use strict";
  1207. var common_1 = __webpack_require__(3);
  1208. var strings_1 = __webpack_require__(9);
  1209. (function (RejectType) {
  1210. RejectType[RejectType["SUPERSEDED"] = 2] = "SUPERSEDED";
  1211. RejectType[RejectType["ABORTED"] = 3] = "ABORTED";
  1212. RejectType[RejectType["INVALID"] = 4] = "INVALID";
  1213. RejectType[RejectType["IGNORED"] = 5] = "IGNORED";
  1214. RejectType[RejectType["ERROR"] = 6] = "ERROR";
  1215. })(exports.RejectType || (exports.RejectType = {}));
  1216. var RejectType = exports.RejectType;
  1217. var Rejection = (function () {
  1218. function Rejection(type, message, detail) {
  1219. this.type = type;
  1220. this.message = message;
  1221. this.detail = detail;
  1222. }
  1223. Rejection.prototype.toString = function () {
  1224. var detailString = function (d) {
  1225. return d && d.toString !== Object.prototype.toString ? d.toString() : strings_1.stringify(d);
  1226. };
  1227. var type = this.type, message = this.message, detail = detailString(this.detail);
  1228. return "TransitionRejection(type: " + type + ", message: " + message + ", detail: " + detail + ")";
  1229. };
  1230. Rejection.prototype.toPromise = function () {
  1231. return common_1.extend(common_1.silentRejection(this), { _transitionRejection: this });
  1232. };
  1233. /** Returns true if the obj is a rejected promise created from the `asPromise` factory */
  1234. Rejection.isTransitionRejectionPromise = function (obj) {
  1235. return obj && (typeof obj.then === 'function') && obj._transitionRejection instanceof Rejection;
  1236. };
  1237. /** Returns a TransitionRejection due to transition superseded */
  1238. Rejection.superseded = function (detail, options) {
  1239. var message = "The transition has been superseded by a different transition";
  1240. var rejection = new Rejection(RejectType.SUPERSEDED, message, detail);
  1241. if (options && options.redirected) {
  1242. rejection.redirected = true;
  1243. }
  1244. return rejection;
  1245. };
  1246. /** Returns a TransitionRejection due to redirected transition */
  1247. Rejection.redirected = function (detail) {
  1248. return Rejection.superseded(detail, { redirected: true });
  1249. };
  1250. /** Returns a TransitionRejection due to invalid transition */
  1251. Rejection.invalid = function (detail) {
  1252. var message = "This transition is invalid";
  1253. return new Rejection(RejectType.INVALID, message, detail);
  1254. };
  1255. /** Returns a TransitionRejection due to ignored transition */
  1256. Rejection.ignored = function (detail) {
  1257. var message = "The transition was ignored";
  1258. return new Rejection(RejectType.IGNORED, message, detail);
  1259. };
  1260. /** Returns a TransitionRejection due to aborted transition */
  1261. Rejection.aborted = function (detail) {
  1262. // TODO think about how to encapsulate an Error() object
  1263. var message = "The transition has been aborted";
  1264. return new Rejection(RejectType.ABORTED, message, detail);
  1265. };
  1266. /** Returns a TransitionRejection due to aborted transition */
  1267. Rejection.errored = function (detail) {
  1268. // TODO think about how to encapsulate an Error() object
  1269. var message = "The transition errored";
  1270. return new Rejection(RejectType.ERROR, message, detail);
  1271. };
  1272. return Rejection;
  1273. }());
  1274. exports.Rejection = Rejection;
  1275. /***/ },
  1276. /* 11 */
  1277. /***/ function(module, exports, __webpack_require__) {
  1278. "use strict";
  1279. /** @module transition */ /** for typedoc */
  1280. var strings_1 = __webpack_require__(9);
  1281. var trace_1 = __webpack_require__(12);
  1282. var coreservices_1 = __webpack_require__(6);
  1283. var common_1 = __webpack_require__(3);
  1284. var predicates_1 = __webpack_require__(4);
  1285. var hof_1 = __webpack_require__(5);
  1286. var transitionHook_1 = __webpack_require__(13);
  1287. var hookRegistry_1 = __webpack_require__(15);
  1288. var hookBuilder_1 = __webpack_require__(16);
  1289. var node_1 = __webpack_require__(21);
  1290. var pathFactory_1 = __webpack_require__(20);
  1291. var targetState_1 = __webpack_require__(14);
  1292. var param_1 = __webpack_require__(22);
  1293. var resolvable_1 = __webpack_require__(19);
  1294. var rejectFactory_1 = __webpack_require__(10);
  1295. var resolveContext_1 = __webpack_require__(17);
  1296. var router_1 = __webpack_require__(25);
  1297. var transitionCount = 0;
  1298. var stateSelf = hof_1.prop("self");
  1299. /**
  1300. * Represents a transition between two states.
  1301. *
  1302. * When navigating to a state, we are transitioning **from** the current state **to** the new state.
  1303. *
  1304. * This object contains all contextual information about the to/from states, parameters, resolves.
  1305. * It has information about all states being entered and exited as a result of the transition.
  1306. */
  1307. var Transition = (function () {
  1308. /**
  1309. * Creates a new Transition object.
  1310. *
  1311. * If the target state is not valid, an error is thrown.
  1312. *
  1313. * @param fromPath The path of [[PathNode]]s from which the transition is leaving. The last node in the `fromPath`
  1314. * encapsulates the "from state".
  1315. * @param targetState The target state and parameters being transitioned to (also, the transition options)
  1316. * @param router The [[UIRouter]] instance
  1317. */
  1318. function Transition(fromPath, targetState, router) {
  1319. var _this = this;
  1320. /** @hidden */
  1321. this._deferred = coreservices_1.services.$q.defer();
  1322. /**
  1323. * This promise is resolved or rejected based on the outcome of the Transition.
  1324. *
  1325. * When the transition is successful, the promise is resolved
  1326. * When the transition is unsuccessful, the promise is rejected with the [[TransitionRejection]] or javascript error
  1327. */
  1328. this.promise = this._deferred.promise;
  1329. this.treeChanges = function () { return _this._treeChanges; };
  1330. this.isActive = function () { return _this === _this._options.current(); };
  1331. this.router = router;
  1332. this._targetState = targetState;
  1333. if (!targetState.valid()) {
  1334. throw new Error(targetState.error());
  1335. }
  1336. // Makes the Transition instance a hook registry (onStart, etc)
  1337. hookRegistry_1.HookRegistry.mixin(new hookRegistry_1.HookRegistry(), this);
  1338. // current() is assumed to come from targetState.options, but provide a naive implementation otherwise.
  1339. this._options = common_1.extend({ current: hof_1.val(this) }, targetState.options());
  1340. this.$id = transitionCount++;
  1341. var toPath = pathFactory_1.PathFactory.buildToPath(fromPath, targetState);
  1342. this._treeChanges = pathFactory_1.PathFactory.treeChanges(fromPath, toPath, this._options.reloadState);
  1343. var enteringStates = this._treeChanges.entering.map(function (node) { return node.state; });
  1344. pathFactory_1.PathFactory.applyViewConfigs(router.transitionService.$view, this._treeChanges.to, enteringStates);
  1345. var rootResolvables = [
  1346. new resolvable_1.Resolvable(router_1.UIRouter, function () { return router; }, [], undefined, router),
  1347. new resolvable_1.Resolvable(Transition, function () { return _this; }, [], undefined, this),
  1348. new resolvable_1.Resolvable('$transition$', function () { return _this; }, [], undefined, this),
  1349. new resolvable_1.Resolvable('$stateParams', function () { return _this.params(); }, [], undefined, this.params())
  1350. ];
  1351. var rootNode = this._treeChanges.to[0];
  1352. var context = new resolveContext_1.ResolveContext(this._treeChanges.to);
  1353. context.addResolvables(rootResolvables, rootNode.state);
  1354. }
  1355. /** @inheritdoc */
  1356. Transition.prototype.onBefore = function (matchCriteria, callback, options) { throw ""; };
  1357. ;
  1358. /** @inheritdoc */
  1359. Transition.prototype.onStart = function (matchCriteria, callback, options) { throw ""; };
  1360. ;
  1361. /** @inheritdoc */
  1362. Transition.prototype.onExit = function (matchCriteria, callback, options) { throw ""; };
  1363. ;
  1364. /** @inheritdoc */
  1365. Transition.prototype.onRetain = function (matchCriteria, callback, options) { throw ""; };
  1366. ;
  1367. /** @inheritdoc */
  1368. Transition.prototype.onEnter = function (matchCriteria, callback, options) { throw ""; };
  1369. ;
  1370. /** @inheritdoc */
  1371. Transition.prototype.onFinish = function (matchCriteria, callback, options) { throw ""; };
  1372. ;
  1373. /** @inheritdoc */
  1374. Transition.prototype.onSuccess = function (matchCriteria, callback, options) { throw ""; };
  1375. ;
  1376. /** @inheritdoc */
  1377. Transition.prototype.onError = function (matchCriteria, callback, options) { throw ""; };
  1378. ;
  1379. Transition.prototype.$from = function () {
  1380. return common_1.tail(this._treeChanges.from).state;
  1381. };
  1382. Transition.prototype.$to = function () {
  1383. return common_1.tail(this._treeChanges.to).state;
  1384. };
  1385. /**
  1386. * Returns the "from state"
  1387. *
  1388. * @returns The state object for the Transition's "from state".
  1389. */
  1390. Transition.prototype.from = function () {
  1391. return this.$from().self;
  1392. };
  1393. /**
  1394. * Returns the "to state"
  1395. *
  1396. * @returns The state object for the Transition's target state ("to state").
  1397. */
  1398. Transition.prototype.to = function () {
  1399. return this.$to().self;
  1400. };
  1401. /**
  1402. * Gets the Target State
  1403. *
  1404. * A transition's [[TargetState]] encapsulates the [[to]] state, the [[params]], and the [[options]].
  1405. *
  1406. * @returns the [[TargetState]] of this Transition
  1407. */
  1408. Transition.prototype.targetState = function () {
  1409. return this._targetState;
  1410. };
  1411. /**
  1412. * Determines whether two transitions are equivalent.
  1413. */
  1414. Transition.prototype.is = function (compare) {
  1415. if (compare instanceof Transition) {
  1416. // TODO: Also compare parameters
  1417. return this.is({ to: compare.$to().name, from: compare.$from().name });
  1418. }
  1419. return !((compare.to && !hookRegistry_1.matchState(this.$to(), compare.to)) ||
  1420. (compare.from && !hookRegistry_1.matchState(this.$from(), compare.from)));
  1421. };
  1422. /**
  1423. * Gets transition parameter values
  1424. *
  1425. * @param pathname Pick which treeChanges path to get parameters for:
  1426. * (`'to'`, `'from'`, `'entering'`, `'exiting'`, `'retained'`)
  1427. * @returns transition parameter values for the desired path.
  1428. */
  1429. Transition.prototype.params = function (pathname) {
  1430. if (pathname === void 0) { pathname = "to"; }
  1431. return this._treeChanges[pathname].map(hof_1.prop("paramValues")).reduce(common_1.mergeR, {});
  1432. };
  1433. /**
  1434. * Creates a [[UIInjector]] Dependency Injector
  1435. *
  1436. * Returns a Dependency Injector for the Transition's target state (to state).
  1437. * The injector provides resolve values which the target state has access to.
  1438. *
  1439. * The `UIInjector` can also provide values from the native root/global injector (ng1/ng2).
  1440. *
  1441. * If a `state` is provided, the injector that is returned will be limited to resolve values that the provided state has access to.
  1442. *
  1443. * @param state Limits the resolves provided to only the resolves the provided state has access to.
  1444. * @returns a [[UIInjector]]
  1445. */
  1446. Transition.prototype.injector = function (state) {
  1447. var path = this.treeChanges().to;
  1448. if (state)
  1449. path = pathFactory_1.PathFactory.subPath(path, function (node) { return node.state === state || node.state.name === state; });
  1450. return new resolveContext_1.ResolveContext(path).injector();
  1451. };
  1452. /**
  1453. * Gets all available resolve tokens (keys)
  1454. *
  1455. * This method can be used in conjunction with [[getResolve]] to inspect the resolve values
  1456. * available to the Transition.
  1457. *
  1458. * The returned tokens include those defined on [[StateDeclaration.resolve]] blocks, for the states
  1459. * in the Transition's [[TreeChanges.to]] path.
  1460. *
  1461. * @returns an array of resolve tokens (keys)
  1462. */
  1463. Transition.prototype.getResolveTokens = function () {
  1464. return new resolveContext_1.ResolveContext(this._treeChanges.to).getTokens();
  1465. };
  1466. /**
  1467. * Gets resolved values
  1468. *
  1469. * This method can be used in conjunction with [[getResolveTokens]] to inspect what resolve values
  1470. * are available to the Transition.
  1471. *
  1472. * Given a token, returns the resolved data for that token.
  1473. * Given an array of tokens, returns an array of resolved data for those tokens.
  1474. *
  1475. * If a resolvable hasn't yet been fetched, returns `undefined` for that token
  1476. * If a resolvable doesn't exist for the token, throws an error.
  1477. *
  1478. * @param token the token (or array of tokens)
  1479. *
  1480. * @returns an array of resolve tokens (keys)
  1481. */
  1482. Transition.prototype.getResolveValue = function (token) {
  1483. var resolveContext = new resolveContext_1.ResolveContext(this._treeChanges.to);
  1484. var getData = function (token) {
  1485. var resolvable = resolveContext.getResolvable(token);
  1486. if (resolvable === undefined) {
  1487. throw new Error("Dependency Injection token not found: " + strings_1.stringify(token));
  1488. }
  1489. return resolvable.data;
  1490. };
  1491. if (predicates_1.isArray(token)) {
  1492. return token.map(getData);
  1493. }
  1494. return getData(token);
  1495. };
  1496. /**
  1497. * Gets a [[Resolvable]] primitive
  1498. *
  1499. * This is a lower level API that returns a [[Resolvable]] from the Transition for a given token.
  1500. *
  1501. * @param token the DI token
  1502. *
  1503. * @returns the [[Resolvable]] in the transition's to path, or undefined
  1504. */
  1505. Transition.prototype.getResolvable = function (token) {
  1506. return new resolveContext_1.ResolveContext(this._treeChanges.to).getResolvable(token);
  1507. };
  1508. /**
  1509. * Dynamically adds a new [[Resolvable]] (`resolve`) to this transition.
  1510. *
  1511. * @param resolvable an [[Resolvable]] object
  1512. * @param state the state in the "to path" which should receive the new resolve (otherwise, the root state)
  1513. */
  1514. Transition.prototype.addResolvable = function (resolvable, state) {
  1515. if (state === void 0) { state = ""; }
  1516. var stateName = (typeof state === "string") ? state : state.name;
  1517. var topath = this._treeChanges.to;
  1518. var targetNode = common_1.find(topath, function (node) { return node.state.name === stateName; });
  1519. var resolveContext = new resolveContext_1.ResolveContext(topath);
  1520. resolveContext.addResolvables([resolvable], targetNode.state);
  1521. };
  1522. /**
  1523. * If the current transition is a redirect, returns the transition that was redirected.
  1524. *
  1525. * Gets the transition from which this transition was redirected.
  1526. *
  1527. *
  1528. * @example
  1529. * ```js
  1530. *
  1531. * let transitionA = $state.go('A').transitionA
  1532. * transitionA.onStart({}, () => $state.target('B'));
  1533. * $transitions.onSuccess({ to: 'B' }, (trans) => {
  1534. * trans.to().name === 'B'; // true
  1535. * trans.redirectedFrom() === transitionA; // true
  1536. * });
  1537. * ```
  1538. *
  1539. * @returns The previous Transition, or null if this Transition is not the result of a redirection
  1540. */
  1541. Transition.prototype.redirectedFrom = function () {
  1542. return this._options.redirectedFrom || null;
  1543. };
  1544. /**
  1545. * Get the transition options
  1546. *
  1547. * @returns the options for this Transition.
  1548. */
  1549. Transition.prototype.options = function () {
  1550. return this._options;
  1551. };
  1552. /**
  1553. * Gets the states being entered.
  1554. *
  1555. * @returns an array of states that will be entered during this transition.
  1556. */
  1557. Transition.prototype.entering = function () {
  1558. return common_1.map(this._treeChanges.entering, hof_1.prop('state')).map(stateSelf);
  1559. };
  1560. /**
  1561. * Gets the states being exited.
  1562. *
  1563. * @returns an array of states that will be exited during this transition.
  1564. */
  1565. Transition.prototype.exiting = function () {
  1566. return common_1.map(this._treeChanges.exiting, hof_1.prop('state')).map(stateSelf).reverse();
  1567. };
  1568. /**
  1569. * Gets the states being retained.
  1570. *
  1571. * @returns an array of states that are already entered from a previous Transition, that will not be
  1572. * exited during this Transition
  1573. */
  1574. Transition.prototype.retained = function () {
  1575. return common_1.map(this._treeChanges.retained, hof_1.prop('state')).map(stateSelf);
  1576. };
  1577. /**
  1578. * Get the [[ViewConfig]]s associated with this Transition
  1579. *
  1580. * Each state can define one or more views (template/controller), which are encapsulated as `ViewConfig` objects.
  1581. * This method fetches the `ViewConfigs` for a given path in the Transition (e.g., "to" or "entering").
  1582. *
  1583. * @param pathname the name of the path to fetch views for:
  1584. * (`'to'`, `'from'`, `'entering'`, `'exiting'`, `'retained'`)
  1585. * @param state If provided, only returns the `ViewConfig`s for a single state in the path
  1586. *
  1587. * @returns a list of ViewConfig objects for the given path.
  1588. */
  1589. Transition.prototype.views = function (pathname, state) {
  1590. if (pathname === void 0) { pathname = "entering"; }
  1591. var path = this._treeChanges[pathname];
  1592. path = !state ? path : path.filter(hof_1.propEq('state', state));
  1593. return path.map(hof_1.prop("views")).filter(common_1.identity).reduce(common_1.unnestR, []);
  1594. };
  1595. /**
  1596. * Creates a new transition that is a redirection of the current one.
  1597. *
  1598. * This transition can be returned from a [[TransitionService]] hook to
  1599. * redirect a transition to a new state and/or set of parameters.
  1600. *
  1601. * @returns Returns a new [[Transition]] instance.
  1602. */
  1603. Transition.prototype.redirect = function (targetState) {
  1604. var newOptions = common_1.extend({}, this.options(), targetState.options(), { redirectedFrom: this, source: "redirect" });
  1605. targetState = new targetState_1.TargetState(targetState.identifier(), targetState.$state(), targetState.params(), newOptions);
  1606. var newTransition = this.router.transitionService.create(this._treeChanges.from, targetState);
  1607. var originalEnteringNodes = this.treeChanges().entering;
  1608. var redirectEnteringNodes = newTransition.treeChanges().entering;
  1609. // --- Re-use resolve data from original transition ---
  1610. // When redirecting from a parent state to a child state where the parent parameter values haven't changed
  1611. // (because of the redirect), the resolves fetched by the original transition are still valid in the
  1612. // redirected transition.
  1613. //
  1614. // This allows you to define a redirect on a parent state which depends on an async resolve value.
  1615. // You can wait for the resolve, then redirect to a child state based on the result.
  1616. // The redirected transition does not have to re-fetch the resolve.
  1617. // ---------------------------------------------------------
  1618. var nodeIsReloading = function (reloadState) { return function (node) {
  1619. return reloadState && node.state.includes[reloadState.name];
  1620. }; };
  1621. // Find any "entering" nodes in the redirect path that match the original path and aren't being reloaded
  1622. var matchingEnteringNodes = node_1.PathNode.matching(redirectEnteringNodes, originalEnteringNodes)
  1623. .filter(hof_1.not(nodeIsReloading(targetState.options().reloadState)));
  1624. // Use the existing (possibly pre-resolved) resolvables for the matching entering nodes.
  1625. matchingEnteringNodes.forEach(function (node, idx) {
  1626. node.resolvables = originalEnteringNodes[idx].resolvables;
  1627. });
  1628. return newTransition;
  1629. };
  1630. /** @hidden If a transition doesn't exit/enter any states, returns any [[Param]] whose value changed */
  1631. Transition.prototype._changedParams = function () {
  1632. var _a = this._treeChanges, to = _a.to, from = _a.from;
  1633. if (this._options.reload || common_1.tail(to).state !== common_1.tail(from).state)
  1634. return undefined;
  1635. var nodeSchemas = to.map(function (node) { return node.paramSchema; });
  1636. var _b = [to, from].map(function (path) { return path.map(function (x) { return x.paramValues; }); }), toValues = _b[0], fromValues = _b[1];
  1637. var tuples = common_1.arrayTuples(nodeSchemas, toValues, fromValues);
  1638. return tuples.map(function (_a) {
  1639. var schema = _a[0], toVals = _a[1], fromVals = _a[2];
  1640. return param_1.Param.changed(schema, toVals, fromVals);
  1641. }).reduce(common_1.unnestR, []);
  1642. };
  1643. /**
  1644. * Returns true if the transition is dynamic.
  1645. *
  1646. * A transition is dynamic if no states are entered nor exited, but at least one dynamic parameter has changed.
  1647. *
  1648. * @returns true if the Transition is dynamic
  1649. */
  1650. Transition.prototype.dynamic = function () {
  1651. var changes = this._changedParams();
  1652. return !changes ? false : changes.map(function (x) { return x.dynamic; }).reduce(common_1.anyTrueR, false);
  1653. };
  1654. /**
  1655. * Returns true if the transition is ignored.
  1656. *
  1657. * A transition is ignored if no states are entered nor exited, and no parameter values have changed.
  1658. *
  1659. * @returns true if the Transition is ignored.
  1660. */
  1661. Transition.prototype.ignored = function () {
  1662. var changes = this._changedParams();
  1663. return !changes ? false : changes.length === 0;
  1664. };
  1665. /**
  1666. * @hidden
  1667. */
  1668. Transition.prototype.hookBuilder = function () {
  1669. return new hookBuilder_1.HookBuilder(this.router.transitionService, this, {
  1670. transition: this,
  1671. current: this._options.current
  1672. });
  1673. };
  1674. /**
  1675. * Runs the transition
  1676. *
  1677. * This method is generally called from the [[StateService.transitionTo]]
  1678. *
  1679. * @returns a promise for a successful transition.
  1680. */
  1681. Transition.prototype.run = function () {
  1682. var _this = this;
  1683. var runSynchronousHooks = transitionHook_1.TransitionHook.runSynchronousHooks;
  1684. var hookBuilder = this.hookBuilder();
  1685. var globals = this.router.globals;
  1686. globals.transitionHistory.enqueue(this);
  1687. var syncResult = runSynchronousHooks(hookBuilder.getOnBeforeHooks());
  1688. if (rejectFactory_1.Rejection.isTransitionRejectionPromise(syncResult)) {
  1689. syncResult.catch(function () { return 0; }); // issue #2676
  1690. var rejectReason = syncResult._transitionRejection;
  1691. this._deferred.reject(rejectReason);
  1692. return this.promise;
  1693. }
  1694. if (!this.valid()) {
  1695. var error = new Error(this.error());
  1696. this._deferred.reject(error);
  1697. return this.promise;
  1698. }
  1699. if (this.ignored()) {
  1700. trace_1.trace.traceTransitionIgnored(this);
  1701. this._deferred.reject(rejectFactory_1.Rejection.ignored());
  1702. return this.promise;
  1703. }
  1704. // When the chain is complete, then resolve or reject the deferred
  1705. var transitionSuccess = function () {
  1706. trace_1.trace.traceSuccess(_this.$to(), _this);
  1707. _this.success = true;
  1708. _this._deferred.resolve(_this.to());
  1709. runSynchronousHooks(hookBuilder.getOnSuccessHooks(), true);
  1710. };
  1711. var transitionError = function (reason) {
  1712. trace_1.trace.traceError(reason, _this);
  1713. _this.success = false;
  1714. _this._deferred.reject(reason);
  1715. _this._error = reason;
  1716. runSynchronousHooks(hookBuilder.getOnErrorHooks(), true);
  1717. };
  1718. trace_1.trace.traceTransitionStart(this);
  1719. // Chain the next hook off the previous
  1720. var appendHookToChain = function (prev, nextHook) {
  1721. return prev.then(function () { return nextHook.invokeHook(); });
  1722. };
  1723. // Run the hooks, then resolve or reject the overall deferred in the .then() handler
  1724. hookBuilder.asyncHooks()
  1725. .reduce(appendHookToChain, syncResult)
  1726. .then(transitionSuccess, transitionError);
  1727. return this.promise;
  1728. };
  1729. /**
  1730. * Checks if the Transition is valid
  1731. *
  1732. * @returns true if the Transition is valid
  1733. */
  1734. Transition.prototype.valid = function () {
  1735. return !this.error() || this.success !== undefined;
  1736. };
  1737. /**
  1738. * The Transition error reason.
  1739. *
  1740. * If the transition is invalid (and could not be run), returns the reason the transition is invalid.
  1741. * If the transition was valid and ran, but was not successful, returns the reason the transition failed.
  1742. *
  1743. * @returns an error message explaining why the transition is invalid, or the reason the transition failed.
  1744. */
  1745. Transition.prototype.error = function () {
  1746. var state = this.$to();
  1747. var redirects = 0, trans = this;
  1748. while ((trans = trans.redirectedFrom()) != null) {
  1749. if (++redirects > 20)
  1750. return "Too many Transition redirects (20+)";
  1751. }
  1752. if (state.self.abstract)
  1753. return "Cannot transition to abstract state '" + state.name + "'";
  1754. if (!param_1.Param.validates(state.parameters(), this.params()))
  1755. return "Param values not valid for state '" + state.name + "'";
  1756. if (this.success === false)
  1757. return this._error;
  1758. };
  1759. /**
  1760. * A string representation of the Transition
  1761. *
  1762. * @returns A string representation of the Transition
  1763. */
  1764. Transition.prototype.toString = function () {
  1765. var fromStateOrName = this.from();
  1766. var toStateOrName = this.to();
  1767. var avoidEmptyHash = function (params) {
  1768. return (params["#"] !== null && params["#"] !== undefined) ? params : common_1.omit(params, "#");
  1769. };
  1770. // (X) means the to state is invalid.
  1771. var id = this.$id, from = predicates_1.isObject(fromStateOrName) ? fromStateOrName.name : fromStateOrName, fromParams = common_1.toJson(avoidEmptyHash(this._treeChanges.from.map(hof_1.prop('paramValues')).reduce(common_1.mergeR, {}))), toValid = this.valid() ? "" : "(X) ", to = predicates_1.isObject(toStateOrName) ? toStateOrName.name : toStateOrName, toParams = common_1.toJson(avoidEmptyHash(this.params()));
  1772. return "Transition#" + id + "( '" + from + "'" + fromParams + " -> " + toValid + "'" + to + "'" + toParams + " )";
  1773. };
  1774. Transition.diToken = Transition;
  1775. return Transition;
  1776. }());
  1777. exports.Transition = Transition;
  1778. /***/ },
  1779. /* 12 */
  1780. /***/ function(module, exports, __webpack_require__) {
  1781. "use strict";
  1782. /**
  1783. * UI-Router Transition Tracing
  1784. *
  1785. * Enable transition tracing to print transition information to the console, in order to help debug your application.
  1786. * Tracing logs detailed information about each Transition to your console.
  1787. *
  1788. * To enable tracing, import the [[trace]] singleton and enable one or more categories.
  1789. *
  1790. * ES6
  1791. * ```
  1792. *
  1793. * import {trace} from "ui-router-ng2"; // or "angular-ui-router"
  1794. * trace.enable(1, 5); // TRANSITION and VIEWCONFIG
  1795. * ```
  1796. *
  1797. * CJS
  1798. * ```
  1799. *
  1800. * let trace = require("angular-ui-router").trace; // or "ui-router-ng2"
  1801. * trace.enable("TRANSITION", "VIEWCONFIG");
  1802. * ```
  1803. *
  1804. * Globals
  1805. * ```
  1806. *
  1807. * let trace = window["angular-ui-router"].trace; // or "ui-router-ng2"
  1808. * trace.enable(); // Trace everything (very verbose)
  1809. * ```
  1810. *
  1811. * @module trace
  1812. */ /** for typedoc */
  1813. var hof_1 = __webpack_require__(5);
  1814. var predicates_1 = __webpack_require__(4);
  1815. var strings_1 = __webpack_require__(9);
  1816. /** @hidden */
  1817. function uiViewString(viewData) {
  1818. if (!viewData)
  1819. return 'ui-view (defunct)';
  1820. return ("[ui-view#" + viewData.id + " tag ") +
  1821. ("in template from '" + (viewData.creationContext && viewData.creationContext.name || '(root)') + "' state]: ") +
  1822. ("fqn: '" + viewData.fqn + "', ") +
  1823. ("name: '" + viewData.name + "@" + viewData.creationContext + "')");
  1824. }
  1825. /** @hidden */
  1826. var viewConfigString = function (viewConfig) {
  1827. return ("[ViewConfig#" + viewConfig.$id + " from '" + (viewConfig.viewDecl.$context.name || '(root)') + "' state]: target ui-view: '" + viewConfig.viewDecl.$uiViewName + "@" + viewConfig.viewDecl.$uiViewContextAnchor + "'");
  1828. };
  1829. /** @hidden */
  1830. function normalizedCat(input) {
  1831. return predicates_1.isNumber(input) ? Category[input] : Category[Category[input]];
  1832. }
  1833. /**
  1834. * Trace categories
  1835. *
  1836. * [[Trace.enable]] or [[Trace.disable]] a category
  1837. *
  1838. * `trace.enable(Category.TRANSITION)`
  1839. *
  1840. * These can also be provided using a matching string, or position ordinal
  1841. *
  1842. * `trace.enable("TRANSITION")`
  1843. *
  1844. * `trace.enable(1)`
  1845. */
  1846. (function (Category) {
  1847. Category[Category["RESOLVE"] = 0] = "RESOLVE";
  1848. Category[Category["TRANSITION"] = 1] = "TRANSITION";
  1849. Category[Category["HOOK"] = 2] = "HOOK";
  1850. Category[Category["UIVIEW"] = 3] = "UIVIEW";
  1851. Category[Category["VIEWCONFIG"] = 4] = "VIEWCONFIG";
  1852. })(exports.Category || (exports.Category = {}));
  1853. var Category = exports.Category;
  1854. /**
  1855. * Prints UI-Router Transition trace information to the console.
  1856. */
  1857. var Trace = (function () {
  1858. function Trace() {
  1859. /** @hidden */
  1860. this._enabled = {};
  1861. this.approximateDigests = 0;
  1862. }
  1863. /** @hidden */
  1864. Trace.prototype._set = function (enabled, categories) {
  1865. var _this = this;
  1866. if (!categories.length) {
  1867. categories = Object.keys(Category)
  1868. .map(function (k) { return parseInt(k, 10); })
  1869. .filter(function (k) { return !isNaN(k); })
  1870. .map(function (key) { return Category[key]; });
  1871. }
  1872. categories.map(normalizedCat).forEach(function (category) { return _this._enabled[category] = enabled; });
  1873. };
  1874. /**
  1875. * Enables a trace [[Category]]
  1876. *
  1877. * ```
  1878. * trace.enable("TRANSITION");
  1879. * ```
  1880. *
  1881. * @param categories categories to enable. If `categories` is omitted, all categories are enabled.
  1882. * Also takes strings (category name) or ordinal (category position)
  1883. */
  1884. Trace.prototype.enable = function () {
  1885. var categories = [];
  1886. for (var _i = 0; _i < arguments.length; _i++) {
  1887. categories[_i - 0] = arguments[_i];
  1888. }
  1889. this._set(true, categories);
  1890. };
  1891. /**
  1892. * Disables a trace [[Category]]
  1893. *
  1894. * ```
  1895. * trace.disable("VIEWCONFIG");
  1896. * ```
  1897. *
  1898. * @param categories categories to disable. If `categories` is omitted, all categories are disabled.
  1899. * Also takes strings (category name) or ordinal (category position)
  1900. */
  1901. Trace.prototype.disable = function () {
  1902. var categories = [];
  1903. for (var _i = 0; _i < arguments.length; _i++) {
  1904. categories[_i - 0] = arguments[_i];
  1905. }
  1906. this._set(false, categories);
  1907. };
  1908. /**
  1909. * Retrieves the enabled stateus of a [[Category]]
  1910. *
  1911. * ```
  1912. * trace.enabled("VIEWCONFIG"); // true or false
  1913. * ```
  1914. *
  1915. * @returns boolean true if the category is enabled
  1916. */
  1917. Trace.prototype.enabled = function (category) {
  1918. return !!this._enabled[normalizedCat(category)];
  1919. };
  1920. /** called by ui-router code */
  1921. Trace.prototype.traceTransitionStart = function (transition) {
  1922. if (!this.enabled(Category.TRANSITION))
  1923. return;
  1924. var tid = transition.$id, digest = this.approximateDigests, transitionStr = strings_1.stringify(transition);
  1925. console.log("Transition #" + tid + " Digest #" + digest + ": Started -> " + transitionStr);
  1926. };
  1927. /** called by ui-router code */
  1928. Trace.prototype.traceTransitionIgnored = function (trans) {
  1929. if (!this.enabled(Category.TRANSITION))
  1930. return;
  1931. var tid = trans && trans.$id, digest = this.approximateDigests, transitionStr = strings_1.stringify(trans);
  1932. console.log("Transition #" + tid + " Digest #" + digest + ": Ignored <> " + transitionStr);
  1933. };
  1934. /** called by ui-router code */
  1935. Trace.prototype.traceHookInvocation = function (step, options) {
  1936. if (!this.enabled(Category.HOOK))
  1937. return;
  1938. var tid = hof_1.parse("transition.$id")(options), digest = this.approximateDigests, event = hof_1.parse("traceData.hookType")(options) || "internal", context = hof_1.parse("traceData.context.state.name")(options) || hof_1.parse("traceData.context")(options) || "unknown", name = strings_1.functionToString(step.eventHook.callback);
  1939. console.log("Transition #" + tid + " Digest #" + digest + ": Hook -> " + event + " context: " + context + ", " + strings_1.maxLength(200, name));
  1940. };
  1941. /** called by ui-router code */
  1942. Trace.prototype.traceHookResult = function (hookResult, transitionOptions) {
  1943. if (!this.enabled(Category.HOOK))
  1944. return;
  1945. var tid = hof_1.parse("transition.$id")(transitionOptions), digest = this.approximateDigests, hookResultStr = strings_1.stringify(hookResult);
  1946. console.log("Transition #" + tid + " Digest #" + digest + ": <- Hook returned: " + strings_1.maxLength(200, hookResultStr));
  1947. };
  1948. /** called by ui-router code */
  1949. Trace.prototype.traceResolvePath = function (path, when, trans) {
  1950. if (!this.enabled(Category.RESOLVE))
  1951. return;
  1952. var tid = trans && trans.$id, digest = this.approximateDigests, pathStr = path && path.toString();
  1953. console.log("Transition #" + tid + " Digest #" + digest + ": Resolving " + pathStr + " (" + when + ")");
  1954. };
  1955. /** called by ui-router code */
  1956. Trace.prototype.traceResolvableResolved = function (resolvable, trans) {
  1957. if (!this.enabled(Category.RESOLVE))
  1958. return;
  1959. var tid = trans && trans.$id, digest = this.approximateDigests, resolvableStr = resolvable && resolvable.toString(), result = strings_1.stringify(resolvable.data);
  1960. console.log("Transition #" + tid + " Digest #" + digest + ": <- Resolved " + resolvableStr + " to: " + strings_1.maxLength(200, result));
  1961. };
  1962. /** called by ui-router code */
  1963. Trace.prototype.traceError = function (reason, trans) {
  1964. if (!this.enabled(Category.TRANSITION))
  1965. return;
  1966. var tid = trans && trans.$id, digest = this.approximateDigests, transitionStr = strings_1.stringify(trans);
  1967. console.log("Transition #" + tid + " Digest #" + digest + ": <- Rejected " + transitionStr + ", reason: " + reason);
  1968. };
  1969. /** called by ui-router code */
  1970. Trace.prototype.traceSuccess = function (finalState, trans) {
  1971. if (!this.enabled(Category.TRANSITION))
  1972. return;
  1973. var tid = trans && trans.$id, digest = this.approximateDigests, state = finalState.name, transitionStr = strings_1.stringify(trans);
  1974. console.log("Transition #" + tid + " Digest #" + digest + ": <- Success " + transitionStr + ", final state: " + state);
  1975. };
  1976. /** called by ui-router code */
  1977. Trace.prototype.traceUIViewEvent = function (event, viewData, extra) {
  1978. if (extra === void 0) { extra = ""; }
  1979. if (!this.enabled(Category.UIVIEW))
  1980. return;
  1981. console.log("ui-view: " + strings_1.padString(30, event) + " " + uiViewString(viewData) + extra);
  1982. };
  1983. /** called by ui-router code */
  1984. Trace.prototype.traceUIViewConfigUpdated = function (viewData, context) {
  1985. if (!this.enabled(Category.UIVIEW))
  1986. return;
  1987. this.traceUIViewEvent("Updating", viewData, " with ViewConfig from context='" + context + "'");
  1988. };
  1989. /** called by ui-router code */
  1990. Trace.prototype.traceUIViewFill = function (viewData, html) {
  1991. if (!this.enabled(Category.UIVIEW))
  1992. return;
  1993. this.traceUIViewEvent("Fill", viewData, " with: " + strings_1.maxLength(200, html));
  1994. };
  1995. /** called by ui-router code */
  1996. Trace.prototype.traceViewServiceEvent = function (event, viewConfig) {
  1997. if (!this.enabled(Category.VIEWCONFIG))
  1998. return;
  1999. console.log("VIEWCONFIG: " + event + " " + viewConfigString(viewConfig));
  2000. };
  2001. /** called by ui-router code */
  2002. Trace.prototype.traceViewServiceUIViewEvent = function (event, viewData) {
  2003. if (!this.enabled(Category.VIEWCONFIG))
  2004. return;
  2005. console.log("VIEWCONFIG: " + event + " " + uiViewString(viewData));
  2006. };
  2007. return Trace;
  2008. }());
  2009. exports.Trace = Trace;
  2010. /**
  2011. * The [[Trace]] singleton
  2012. *
  2013. * @example
  2014. * ```js
  2015. *
  2016. * import {trace} from "angular-ui-router";
  2017. * trace.enable(1, 5);
  2018. * ```
  2019. */
  2020. var trace = new Trace();
  2021. exports.trace = trace;
  2022. /***/ },
  2023. /* 13 */
  2024. /***/ function(module, exports, __webpack_require__) {
  2025. "use strict";
  2026. var common_1 = __webpack_require__(3);
  2027. var strings_1 = __webpack_require__(9);
  2028. var predicates_1 = __webpack_require__(4);
  2029. var hof_1 = __webpack_require__(5);
  2030. var trace_1 = __webpack_require__(12);
  2031. var coreservices_1 = __webpack_require__(6);
  2032. var rejectFactory_1 = __webpack_require__(10);
  2033. var targetState_1 = __webpack_require__(14);
  2034. var defaultOptions = {
  2035. async: true,
  2036. rejectIfSuperseded: true,
  2037. current: common_1.noop,
  2038. transition: null,
  2039. traceData: {},
  2040. bind: null
  2041. };
  2042. /** @hidden */
  2043. var TransitionHook = (function () {
  2044. function TransitionHook(transition, stateContext, eventHook, options) {
  2045. var _this = this;
  2046. this.transition = transition;
  2047. this.stateContext = stateContext;
  2048. this.eventHook = eventHook;
  2049. this.options = options;
  2050. this.isSuperseded = function () {
  2051. return _this.options.current() !== _this.options.transition;
  2052. };
  2053. this.options = common_1.defaults(options, defaultOptions);
  2054. }
  2055. TransitionHook.prototype.invokeHook = function () {
  2056. var _a = this, options = _a.options, eventHook = _a.eventHook;
  2057. trace_1.trace.traceHookInvocation(this, options);
  2058. if (options.rejectIfSuperseded && this.isSuperseded()) {
  2059. return rejectFactory_1.Rejection.superseded(options.current()).toPromise();
  2060. }
  2061. var synchronousHookResult = !eventHook._deregistered
  2062. ? eventHook.callback.call(options.bind, this.transition, this.stateContext)
  2063. : undefined;
  2064. return this.handleHookResult(synchronousHookResult);
  2065. };
  2066. /**
  2067. * This method handles the return value of a Transition Hook.
  2068. *
  2069. * A hook can return false (cancel), a TargetState (redirect),
  2070. * or a promise (which may later resolve to false or a redirect)
  2071. *
  2072. * This also handles "transition superseded" -- when a new transition
  2073. * was started while the hook was still running
  2074. */
  2075. TransitionHook.prototype.handleHookResult = function (result) {
  2076. // This transition is no longer current.
  2077. // Another transition started while this hook was still running.
  2078. if (this.isSuperseded()) {
  2079. // Abort this transition
  2080. return rejectFactory_1.Rejection.superseded(this.options.current()).toPromise();
  2081. }
  2082. // Hook returned a promise
  2083. if (predicates_1.isPromise(result)) {
  2084. // Wait for the promise, then reprocess the resolved value
  2085. return result.then(this.handleHookResult.bind(this));
  2086. }
  2087. trace_1.trace.traceHookResult(result, this.options);
  2088. // Hook returned false
  2089. if (result === false) {
  2090. // Abort this Transition
  2091. return rejectFactory_1.Rejection.aborted("Hook aborted transition").toPromise();
  2092. }
  2093. var isTargetState = hof_1.is(targetState_1.TargetState);
  2094. // hook returned a TargetState
  2095. if (isTargetState(result)) {
  2096. // Halt the current Transition and start a redirected Transition (to the TargetState).
  2097. return rejectFactory_1.Rejection.redirected(result).toPromise();
  2098. }
  2099. };
  2100. TransitionHook.prototype.toString = function () {
  2101. var _a = this, options = _a.options, eventHook = _a.eventHook;
  2102. var event = hof_1.parse("traceData.hookType")(options) || "internal", context = hof_1.parse("traceData.context.state.name")(options) || hof_1.parse("traceData.context")(options) || "unknown", name = strings_1.fnToString(eventHook.callback);
  2103. return event + " context: " + context + ", " + strings_1.maxLength(200, name);
  2104. };
  2105. /**
  2106. * Given an array of TransitionHooks, runs each one synchronously and sequentially.
  2107. *
  2108. * Returns a promise chain composed of any promises returned from each hook.invokeStep() call
  2109. */
  2110. TransitionHook.runSynchronousHooks = function (hooks, swallowExceptions) {
  2111. if (swallowExceptions === void 0) { swallowExceptions = false; }
  2112. var results = [];
  2113. for (var i = 0; i < hooks.length; i++) {
  2114. var hook = hooks[i];
  2115. try {
  2116. results.push(hook.invokeHook());
  2117. }
  2118. catch (exception) {
  2119. if (!swallowExceptions) {
  2120. return rejectFactory_1.Rejection.errored(exception).toPromise();
  2121. }
  2122. var errorHandler = hook.transition.router.stateService.defaultErrorHandler();
  2123. errorHandler(exception);
  2124. }
  2125. }
  2126. var rejections = results.filter(rejectFactory_1.Rejection.isTransitionRejectionPromise);
  2127. if (rejections.length)
  2128. return rejections[0];
  2129. return results
  2130. .filter(predicates_1.isPromise)
  2131. .reduce(function (chain, promise) { return chain.then(hof_1.val(promise)); }, coreservices_1.services.$q.when());
  2132. };
  2133. return TransitionHook;
  2134. }());
  2135. exports.TransitionHook = TransitionHook;
  2136. /***/ },
  2137. /* 14 */
  2138. /***/ function(module, exports, __webpack_require__) {
  2139. /** @module state */ /** for typedoc */
  2140. "use strict";
  2141. var common_1 = __webpack_require__(3);
  2142. /**
  2143. * @ngdoc object
  2144. * @name ui.router.state.type:TargetState
  2145. *
  2146. * @description
  2147. * Encapsulate the desired target of a transition.
  2148. * Wraps an identifier for a state, a set of parameters, and transition options with the definition of the state.
  2149. *
  2150. * @param {StateOrName} _identifier An identifier for a state. Either a fully-qualified path, or the object
  2151. * used to define the state.
  2152. * @param {IState} _definition The `State` object definition.
  2153. * @param {ParamsOrArray} _params Parameters for the target state
  2154. * @param {TransitionOptions} _options Transition options.
  2155. */
  2156. var TargetState = (function () {
  2157. function TargetState(_identifier, _definition, _params, _options) {
  2158. if (_params === void 0) { _params = {}; }
  2159. if (_options === void 0) { _options = {}; }
  2160. this._identifier = _identifier;
  2161. this._definition = _definition;
  2162. this._options = _options;
  2163. this._params = _params || {};
  2164. }
  2165. TargetState.prototype.name = function () {
  2166. return this._definition && this._definition.name || this._identifier;
  2167. };
  2168. TargetState.prototype.identifier = function () {
  2169. return this._identifier;
  2170. };
  2171. TargetState.prototype.params = function () {
  2172. return this._params;
  2173. };
  2174. TargetState.prototype.$state = function () {
  2175. return this._definition;
  2176. };
  2177. TargetState.prototype.state = function () {
  2178. return this._definition && this._definition.self;
  2179. };
  2180. TargetState.prototype.options = function () {
  2181. return this._options;
  2182. };
  2183. TargetState.prototype.exists = function () {
  2184. return !!(this._definition && this._definition.self);
  2185. };
  2186. TargetState.prototype.valid = function () {
  2187. return !this.error();
  2188. };
  2189. TargetState.prototype.error = function () {
  2190. var base = this.options().relative;
  2191. if (!this._definition && !!base) {
  2192. var stateName = base.name ? base.name : base;
  2193. return "Could not resolve '" + this.name() + "' from state '" + stateName + "'";
  2194. }
  2195. if (!this._definition)
  2196. return "No such state '" + this.name() + "'";
  2197. if (!this._definition.self)
  2198. return "State '" + this.name() + "' has an invalid definition";
  2199. };
  2200. TargetState.prototype.toString = function () {
  2201. return "'" + this.name() + "'" + common_1.toJson(this.params());
  2202. };
  2203. return TargetState;
  2204. }());
  2205. exports.TargetState = TargetState;
  2206. /***/ },
  2207. /* 15 */
  2208. /***/ function(module, exports, __webpack_require__) {
  2209. "use strict";
  2210. /** @module transition */ /** for typedoc */
  2211. var common_1 = __webpack_require__(3);
  2212. var predicates_1 = __webpack_require__(4);
  2213. var glob_1 = __webpack_require__(7);
  2214. /**
  2215. * Determines if the given state matches the matchCriteria
  2216. *
  2217. * @hidden
  2218. *
  2219. * @param state a State Object to test against
  2220. * @param criterion
  2221. * - If a string, matchState uses the string as a glob-matcher against the state name
  2222. * - If an array (of strings), matchState uses each string in the array as a glob-matchers against the state name
  2223. * and returns a positive match if any of the globs match.
  2224. * - If a function, matchState calls the function with the state and returns true if the function's result is truthy.
  2225. * @returns {boolean}
  2226. */
  2227. function matchState(state, criterion) {
  2228. var toMatch = predicates_1.isString(criterion) ? [criterion] : criterion;
  2229. function matchGlobs(_state) {
  2230. var globStrings = toMatch;
  2231. for (var i = 0; i < globStrings.length; i++) {
  2232. var glob = glob_1.Glob.fromString(globStrings[i]);
  2233. if ((glob && glob.matches(_state.name)) || (!glob && globStrings[i] === _state.name)) {
  2234. return true;
  2235. }
  2236. }
  2237. return false;
  2238. }
  2239. var matchFn = (predicates_1.isFunction(toMatch) ? toMatch : matchGlobs);
  2240. return !!matchFn(state);
  2241. }
  2242. exports.matchState = matchState;
  2243. /** @hidden */
  2244. var EventHook = (function () {
  2245. function EventHook(matchCriteria, callback, options) {
  2246. if (options === void 0) { options = {}; }
  2247. this.callback = callback;
  2248. this.matchCriteria = common_1.extend({ to: true, from: true, exiting: true, retained: true, entering: true }, matchCriteria);
  2249. this.priority = options.priority || 0;
  2250. this.bind = options.bind || null;
  2251. this._deregistered = false;
  2252. }
  2253. EventHook._matchingNodes = function (nodes, criterion) {
  2254. if (criterion === true)
  2255. return nodes;
  2256. var matching = nodes.filter(function (node) { return matchState(node.state, criterion); });
  2257. return matching.length ? matching : null;
  2258. };
  2259. /**
  2260. * Determines if this hook's [[matchCriteria]] match the given [[TreeChanges]]
  2261. *
  2262. * @returns an IMatchingNodes object, or null. If an IMatchingNodes object is returned, its values
  2263. * are the matching [[PathNode]]s for each [[HookMatchCriterion]] (to, from, exiting, retained, entering)
  2264. */
  2265. EventHook.prototype.matches = function (treeChanges) {
  2266. var mc = this.matchCriteria, _matchingNodes = EventHook._matchingNodes;
  2267. var matches = {
  2268. to: _matchingNodes([common_1.tail(treeChanges.to)], mc.to),
  2269. from: _matchingNodes([common_1.tail(treeChanges.from)], mc.from),
  2270. exiting: _matchingNodes(treeChanges.exiting, mc.exiting),
  2271. retained: _matchingNodes(treeChanges.retained, mc.retained),
  2272. entering: _matchingNodes(treeChanges.entering, mc.entering),
  2273. };
  2274. // Check if all the criteria matched the TreeChanges object
  2275. var allMatched = ["to", "from", "exiting", "retained", "entering"]
  2276. .map(function (prop) { return matches[prop]; })
  2277. .reduce(common_1.allTrueR, true);
  2278. return allMatched ? matches : null;
  2279. };
  2280. return EventHook;
  2281. }());
  2282. exports.EventHook = EventHook;
  2283. /** @hidden Return a registration function of the requested type. */
  2284. function makeHookRegistrationFn(hooks, name) {
  2285. return function (matchObject, callback, options) {
  2286. if (options === void 0) { options = {}; }
  2287. var eventHook = new EventHook(matchObject, callback, options);
  2288. hooks[name].push(eventHook);
  2289. return function deregisterEventHook() {
  2290. eventHook._deregistered = true;
  2291. common_1.removeFrom(hooks[name])(eventHook);
  2292. };
  2293. };
  2294. }
  2295. /**
  2296. * Mixin class acts as a Transition Hook registry.
  2297. *
  2298. * Holds the registered [[HookFn]] objects.
  2299. * Exposes functions to register new hooks.
  2300. *
  2301. * This is a Mixin class which can be applied to other objects.
  2302. *
  2303. * The hook registration functions are [[onBefore]], [[onStart]], [[onEnter]], [[onRetain]], [[onExit]], [[onFinish]], [[onSuccess]], [[onError]].
  2304. *
  2305. * This class is mixed into both the [[TransitionService]] and every [[Transition]] object.
  2306. * Global hooks are added to the [[TransitionService]].
  2307. * Since each [[Transition]] is itself a `HookRegistry`, hooks can also be added to individual Transitions
  2308. * (note: the hook criteria still must match the Transition).
  2309. */
  2310. var HookRegistry = (function () {
  2311. function HookRegistry() {
  2312. var _this = this;
  2313. this._transitionEvents = {
  2314. onBefore: [], onStart: [], onEnter: [], onRetain: [], onExit: [], onFinish: [], onSuccess: [], onError: []
  2315. };
  2316. this.getHooks = function (name) { return _this._transitionEvents[name]; };
  2317. /** @inheritdoc */
  2318. this.onBefore = makeHookRegistrationFn(this._transitionEvents, "onBefore");
  2319. /** @inheritdoc */
  2320. this.onStart = makeHookRegistrationFn(this._transitionEvents, "onStart");
  2321. /** @inheritdoc */
  2322. this.onEnter = makeHookRegistrationFn(this._transitionEvents, "onEnter");
  2323. /** @inheritdoc */
  2324. this.onRetain = makeHookRegistrationFn(this._transitionEvents, "onRetain");
  2325. /** @inheritdoc */
  2326. this.onExit = makeHookRegistrationFn(this._transitionEvents, "onExit");
  2327. /** @inheritdoc */
  2328. this.onFinish = makeHookRegistrationFn(this._transitionEvents, "onFinish");
  2329. /** @inheritdoc */
  2330. this.onSuccess = makeHookRegistrationFn(this._transitionEvents, "onSuccess");
  2331. /** @inheritdoc */
  2332. this.onError = makeHookRegistrationFn(this._transitionEvents, "onError");
  2333. }
  2334. HookRegistry.mixin = function (source, target) {
  2335. Object.keys(source._transitionEvents).concat(["getHooks"]).forEach(function (key) { return target[key] = source[key]; });
  2336. };
  2337. return HookRegistry;
  2338. }());
  2339. exports.HookRegistry = HookRegistry;
  2340. /***/ },
  2341. /* 16 */
  2342. /***/ function(module, exports, __webpack_require__) {
  2343. /** @module transition */ /** for typedoc */
  2344. "use strict";
  2345. var common_1 = __webpack_require__(3);
  2346. var predicates_1 = __webpack_require__(4);
  2347. var transitionHook_1 = __webpack_require__(13);
  2348. var resolveContext_1 = __webpack_require__(17);
  2349. /**
  2350. * This class returns applicable TransitionHooks for a specific Transition instance.
  2351. *
  2352. * Hooks (IEventHook) may be registered globally, e.g., $transitions.onEnter(...), or locally, e.g.
  2353. * myTransition.onEnter(...). The HookBuilder finds matching IEventHooks (where the match criteria is
  2354. * determined by the type of hook)
  2355. *
  2356. * The HookBuilder also converts IEventHooks objects to TransitionHook objects, which are used to run a Transition.
  2357. *
  2358. * The HookBuilder constructor is given the $transitions service and a Transition instance. Thus, a HookBuilder
  2359. * instance may only be used for one specific Transition object. (side note: the _treeChanges accessor is private
  2360. * in the Transition class, so we must also provide the Transition's _treeChanges)
  2361. *
  2362. */
  2363. var HookBuilder = (function () {
  2364. function HookBuilder($transitions, transition, baseHookOptions) {
  2365. var _this = this;
  2366. this.$transitions = $transitions;
  2367. this.transition = transition;
  2368. this.baseHookOptions = baseHookOptions;
  2369. this.getOnBeforeHooks = function () { return _this._buildNodeHooks("onBefore", "to", tupleSort(), { async: false }); };
  2370. this.getOnStartHooks = function () { return _this._buildNodeHooks("onStart", "to", tupleSort()); };
  2371. this.getOnExitHooks = function () { return _this._buildNodeHooks("onExit", "exiting", tupleSort(true), { stateHook: true }); };
  2372. this.getOnRetainHooks = function () { return _this._buildNodeHooks("onRetain", "retained", tupleSort(false), { stateHook: true }); };
  2373. this.getOnEnterHooks = function () { return _this._buildNodeHooks("onEnter", "entering", tupleSort(false), { stateHook: true }); };
  2374. this.getOnFinishHooks = function () { return _this._buildNodeHooks("onFinish", "to", tupleSort()); };
  2375. this.getOnSuccessHooks = function () { return _this._buildNodeHooks("onSuccess", "to", tupleSort(), { async: false, rejectIfSuperseded: false }); };
  2376. this.getOnErrorHooks = function () { return _this._buildNodeHooks("onError", "to", tupleSort(), { async: false, rejectIfSuperseded: false }); };
  2377. this.treeChanges = transition.treeChanges();
  2378. this.toState = common_1.tail(this.treeChanges.to).state;
  2379. this.fromState = common_1.tail(this.treeChanges.from).state;
  2380. this.transitionOptions = transition.options();
  2381. }
  2382. HookBuilder.prototype.asyncHooks = function () {
  2383. var onStartHooks = this.getOnStartHooks();
  2384. var onExitHooks = this.getOnExitHooks();
  2385. var onRetainHooks = this.getOnRetainHooks();
  2386. var onEnterHooks = this.getOnEnterHooks();
  2387. var onFinishHooks = this.getOnFinishHooks();
  2388. var asyncHooks = [onStartHooks, onExitHooks, onRetainHooks, onEnterHooks, onFinishHooks];
  2389. return asyncHooks.reduce(common_1.unnestR, []).filter(common_1.identity);
  2390. };
  2391. /**
  2392. * Returns an array of newly built TransitionHook objects.
  2393. *
  2394. * - Finds all IEventHooks registered for the given `hookType` which matched the transition's [[TreeChanges]].
  2395. * - Finds [[PathNode]] (or `PathNode[]`) to use as the TransitionHook context(s)
  2396. * - For each of the [[PathNode]]s, creates a TransitionHook
  2397. *
  2398. * @param hookType the name of the hook registration function, e.g., 'onEnter', 'onFinish'.
  2399. * @param matchingNodesProp selects which [[PathNode]]s from the [[IMatchingNodes]] object to create hooks for.
  2400. * @param getLocals a function which accepts a [[PathNode]] and returns additional locals to provide to the hook as injectables
  2401. * @param sortHooksFn a function which compares two HookTuple and returns <1, 0, or >1
  2402. * @param options any specific Transition Hook Options
  2403. */
  2404. HookBuilder.prototype._buildNodeHooks = function (hookType, matchingNodesProp, sortHooksFn, options) {
  2405. var _this = this;
  2406. // Find all the matching registered hooks for a given hook type
  2407. var matchingHooks = this._matchingHooks(hookType, this.treeChanges);
  2408. if (!matchingHooks)
  2409. return [];
  2410. var makeTransitionHooks = function (hook) {
  2411. // Fetch the Nodes that caused this hook to match.
  2412. var matches = hook.matches(_this.treeChanges);
  2413. // Select the PathNode[] that will be used as TransitionHook context objects
  2414. var matchingNodes = matches[matchingNodesProp];
  2415. // When invoking 'exiting' hooks, give them the "from path" for resolve data.
  2416. // Everything else gets the "to path"
  2417. var resolvePath = matchingNodesProp === 'exiting' ? _this.treeChanges.from : _this.treeChanges.to;
  2418. var resolveContext = new resolveContext_1.ResolveContext(resolvePath);
  2419. // Return an array of HookTuples
  2420. return matchingNodes.map(function (node) {
  2421. var _options = common_1.extend({ bind: hook.bind, traceData: { hookType: hookType, context: node } }, _this.baseHookOptions, options);
  2422. var state = _options.stateHook ? node.state : null;
  2423. var transitionHook = new transitionHook_1.TransitionHook(_this.transition, state, hook, _options);
  2424. return { hook: hook, node: node, transitionHook: transitionHook };
  2425. });
  2426. };
  2427. return matchingHooks.map(makeTransitionHooks)
  2428. .reduce(common_1.unnestR, [])
  2429. .sort(sortHooksFn)
  2430. .map(function (tuple) { return tuple.transitionHook; });
  2431. };
  2432. /**
  2433. * Finds all IEventHooks from:
  2434. * - The Transition object instance hook registry
  2435. * - The TransitionService ($transitions) global hook registry
  2436. *
  2437. * which matched:
  2438. * - the eventType
  2439. * - the matchCriteria (to, from, exiting, retained, entering)
  2440. *
  2441. * @returns an array of matched [[IEventHook]]s
  2442. */
  2443. HookBuilder.prototype._matchingHooks = function (hookName, treeChanges) {
  2444. return [this.transition, this.$transitions] // Instance and Global hook registries
  2445. .map(function (reg) { return reg.getHooks(hookName); }) // Get named hooks from registries
  2446. .filter(common_1.assertPredicate(predicates_1.isArray, "broken event named: " + hookName)) // Sanity check
  2447. .reduce(common_1.unnestR, []) // Un-nest IEventHook[][] to IEventHook[] array
  2448. .filter(function (hook) { return hook.matches(treeChanges); }); // Only those satisfying matchCriteria
  2449. };
  2450. return HookBuilder;
  2451. }());
  2452. exports.HookBuilder = HookBuilder;
  2453. /**
  2454. * A factory for a sort function for HookTuples.
  2455. *
  2456. * The sort function first compares the PathNode depth (how deep in the state tree a node is), then compares
  2457. * the EventHook priority.
  2458. *
  2459. * @param reverseDepthSort a boolean, when true, reverses the sort order for the node depth
  2460. * @returns a tuple sort function
  2461. */
  2462. function tupleSort(reverseDepthSort) {
  2463. if (reverseDepthSort === void 0) { reverseDepthSort = false; }
  2464. return function nodeDepthThenPriority(l, r) {
  2465. var factor = reverseDepthSort ? -1 : 1;
  2466. var depthDelta = (l.node.state.path.length - r.node.state.path.length) * factor;
  2467. return depthDelta !== 0 ? depthDelta : r.hook.priority - l.hook.priority;
  2468. };
  2469. }
  2470. /***/ },
  2471. /* 17 */
  2472. /***/ function(module, exports, __webpack_require__) {
  2473. "use strict";
  2474. /** @module resolve */ /** for typedoc */
  2475. var common_1 = __webpack_require__(3);
  2476. var hof_1 = __webpack_require__(5);
  2477. var trace_1 = __webpack_require__(12);
  2478. var coreservices_1 = __webpack_require__(6);
  2479. var interface_1 = __webpack_require__(18);
  2480. var resolvable_1 = __webpack_require__(19);
  2481. var pathFactory_1 = __webpack_require__(20);
  2482. var strings_1 = __webpack_require__(9);
  2483. var when = interface_1.resolvePolicies.when;
  2484. var ALL_WHENS = [when.EAGER, when.LAZY];
  2485. var EAGER_WHENS = [when.EAGER];
  2486. exports.NATIVE_INJECTOR_TOKEN = "Native Injector";
  2487. /**
  2488. * Encapsulates Depenency Injection for a path of nodes
  2489. *
  2490. * UI-Router states are organized as a tree.
  2491. * A nested state has a path of ancestors to the root of the tree.
  2492. * When a state is being activated, each element in the path is wrapped as a [[PathNode]].
  2493. * A `PathNode` is a stateful object that holds things like parameters and resolvables for the state being activated.
  2494. *
  2495. * The ResolveContext closes over the [[PathNode]]s, and provides DI for the last node in the path.
  2496. */
  2497. var ResolveContext = (function () {
  2498. function ResolveContext(_path) {
  2499. this._path = _path;
  2500. }
  2501. /** Gets all the tokens found in the resolve context, de-duplicated */
  2502. ResolveContext.prototype.getTokens = function () {
  2503. return this._path.reduce(function (acc, node) { return acc.concat(node.resolvables.map(function (r) { return r.token; })); }, []).reduce(common_1.uniqR, []);
  2504. };
  2505. /**
  2506. * Gets the Resolvable that matches the token
  2507. *
  2508. * Gets the last Resolvable that matches the token in this context, or undefined.
  2509. * Throws an error if it doesn't exist in the ResolveContext
  2510. */
  2511. ResolveContext.prototype.getResolvable = function (token) {
  2512. var matching = this._path.map(function (node) { return node.resolvables; })
  2513. .reduce(common_1.unnestR, [])
  2514. .filter(function (r) { return r.token === token; });
  2515. return common_1.tail(matching);
  2516. };
  2517. /**
  2518. * Returns a ResolveContext that includes a portion of this one
  2519. *
  2520. * Given a state, this method creates a new ResolveContext from this one.
  2521. * The new context starts at the first node (root) and stops at the node for the `state` parameter.
  2522. *
  2523. * #### Why
  2524. *
  2525. * When a transition is created, the nodes in the "To Path" are injected from a ResolveContext.
  2526. * A ResolveContext closes over a path of [[PathNode]]s and processes the resolvables.
  2527. * The "To State" can inject values from its own resolvables, as well as those from all its ancestor state's (node's).
  2528. * This method is used to create a narrower context when injecting ancestor nodes.
  2529. *
  2530. * @example
  2531. * `let ABCD = new ResolveContext([A, B, C, D]);`
  2532. *
  2533. * Given a path `[A, B, C, D]`, where `A`, `B`, `C` and `D` are nodes for states `a`, `b`, `c`, `d`:
  2534. * When injecting `D`, `D` should have access to all resolvables from `A`, `B`, `C`, `D`.
  2535. * However, `B` should only be able to access resolvables from `A`, `B`.
  2536. *
  2537. * When resolving for the `B` node, first take the full "To Path" Context `[A,B,C,D]` and limit to the subpath `[A,B]`.
  2538. * `let AB = ABCD.subcontext(a)`
  2539. */
  2540. ResolveContext.prototype.subContext = function (state) {
  2541. return new ResolveContext(pathFactory_1.PathFactory.subPath(this._path, function (node) { return node.state === state; }));
  2542. };
  2543. /**
  2544. * Adds Resolvables to the node that matches the state
  2545. *
  2546. * This adds a [[Resolvable]] (generally one created on the fly; not declared on a [[StateDeclaration.resolve]] block).
  2547. * The resolvable is added to the node matching the `state` parameter.
  2548. *
  2549. * These new resolvables are not automatically fetched.
  2550. * The calling code should either fetch them, fetch something that depends on them,
  2551. * or rely on [[resolvePath]] being called when some state is being entered.
  2552. *
  2553. * Note: each resolvable's [[ResolvePolicy]] is merged with the state's policy, and the global default.
  2554. *
  2555. * @param newResolvables the new Resolvables
  2556. * @param state Used to find the node to put the resolvable on
  2557. */
  2558. ResolveContext.prototype.addResolvables = function (newResolvables, state) {
  2559. var node = common_1.find(this._path, hof_1.propEq('state', state));
  2560. var keys = newResolvables.map(function (r) { return r.token; });
  2561. node.resolvables = node.resolvables.filter(function (r) { return keys.indexOf(r.token) === -1; }).concat(newResolvables);
  2562. };
  2563. /**
  2564. * Returns a promise for an array of resolved path Element promises
  2565. *
  2566. * @param when
  2567. * @param trans
  2568. * @returns {Promise<any>|any}
  2569. */
  2570. ResolveContext.prototype.resolvePath = function (when, trans) {
  2571. var _this = this;
  2572. if (when === void 0) { when = "LAZY"; }
  2573. // This option determines which 'when' policy Resolvables we are about to fetch.
  2574. var whenOption = common_1.inArray(ALL_WHENS, when) ? when : "LAZY";
  2575. // If the caller specified EAGER, only the EAGER Resolvables are fetched.
  2576. // if the caller specified LAZY, both EAGER and LAZY Resolvables are fetched.`
  2577. var matchedWhens = whenOption === interface_1.resolvePolicies.when.EAGER ? EAGER_WHENS : ALL_WHENS;
  2578. // get the subpath to the state argument, if provided
  2579. trace_1.trace.traceResolvePath(this._path, when, trans);
  2580. var promises = this._path.reduce(function (acc, node) {
  2581. var matchesRequestedPolicy = function (resolvable) {
  2582. return common_1.inArray(matchedWhens, resolvable.getPolicy(node.state).when);
  2583. };
  2584. var nodeResolvables = node.resolvables.filter(matchesRequestedPolicy);
  2585. var subContext = _this.subContext(node.state);
  2586. // For the matching Resolvables, start their async fetch process.
  2587. var getResult = function (r) { return r.get(subContext, trans)
  2588. .then(function (value) { return ({ token: r.token, value: value }); }); };
  2589. return acc.concat(nodeResolvables.map(getResult));
  2590. }, []);
  2591. return coreservices_1.services.$q.all(promises);
  2592. };
  2593. ResolveContext.prototype.injector = function () {
  2594. return this._injector || (this._injector = new UIInjectorImpl(this));
  2595. };
  2596. ResolveContext.prototype.findNode = function (resolvable) {
  2597. return common_1.find(this._path, function (node) { return common_1.inArray(node.resolvables, resolvable); });
  2598. };
  2599. /**
  2600. * Gets the async dependencies of a Resolvable
  2601. *
  2602. * Given a Resolvable, returns its dependencies as a Resolvable[]
  2603. */
  2604. ResolveContext.prototype.getDependencies = function (resolvable) {
  2605. var _this = this;
  2606. var node = this.findNode(resolvable);
  2607. // Find which other resolvables are "visible" to the `resolvable` argument
  2608. // subpath stopping at resolvable's node, or the whole path (if the resolvable isn't in the path)
  2609. var subPath = pathFactory_1.PathFactory.subPath(this._path, function (x) { return x === node; }) || this._path;
  2610. var availableResolvables = subPath
  2611. .reduce(function (acc, node) { return acc.concat(node.resolvables); }, []) //all of subpath's resolvables
  2612. .filter(function (res) { return res !== resolvable; }); // filter out the `resolvable` argument
  2613. var getDependency = function (token) {
  2614. var matching = availableResolvables.filter(function (r) { return r.token === token; });
  2615. if (matching.length)
  2616. return common_1.tail(matching);
  2617. var fromInjector = _this.injector().getNative(token);
  2618. if (!fromInjector) {
  2619. throw new Error("Could not find Dependency Injection token: " + strings_1.stringify(token));
  2620. }
  2621. return new resolvable_1.Resolvable(token, function () { return fromInjector; }, [], fromInjector);
  2622. };
  2623. return resolvable.deps.map(getDependency);
  2624. };
  2625. return ResolveContext;
  2626. }());
  2627. exports.ResolveContext = ResolveContext;
  2628. var UIInjectorImpl = (function () {
  2629. function UIInjectorImpl(context) {
  2630. this.context = context;
  2631. this.native = this.get(exports.NATIVE_INJECTOR_TOKEN) || coreservices_1.services.$injector;
  2632. }
  2633. UIInjectorImpl.prototype.get = function (token) {
  2634. var resolvable = this.context.getResolvable(token);
  2635. if (resolvable) {
  2636. if (!resolvable.resolved) {
  2637. throw new Error("Resolvable async .get() not complete:" + strings_1.stringify(resolvable.token));
  2638. }
  2639. return resolvable.data;
  2640. }
  2641. return this.native && this.native.get(token);
  2642. };
  2643. UIInjectorImpl.prototype.getAsync = function (token) {
  2644. var resolvable = this.context.getResolvable(token);
  2645. if (resolvable)
  2646. return resolvable.get(this.context);
  2647. return coreservices_1.services.$q.when(this.native.get(token));
  2648. };
  2649. UIInjectorImpl.prototype.getNative = function (token) {
  2650. return this.native.get(token);
  2651. };
  2652. return UIInjectorImpl;
  2653. }());
  2654. /***/ },
  2655. /* 18 */
  2656. /***/ function(module, exports) {
  2657. "use strict";
  2658. exports.resolvePolicies = {
  2659. when: {
  2660. LAZY: "LAZY",
  2661. EAGER: "EAGER"
  2662. },
  2663. async: {
  2664. WAIT: "WAIT",
  2665. NOWAIT: "NOWAIT",
  2666. RXWAIT: "RXWAIT"
  2667. }
  2668. };
  2669. /***/ },
  2670. /* 19 */
  2671. /***/ function(module, exports, __webpack_require__) {
  2672. "use strict";
  2673. /** @module resolve */ /** for typedoc */
  2674. var common_1 = __webpack_require__(3);
  2675. var coreservices_1 = __webpack_require__(6);
  2676. var trace_1 = __webpack_require__(12);
  2677. var strings_1 = __webpack_require__(9);
  2678. var predicates_1 = __webpack_require__(4);
  2679. // TODO: explicitly make this user configurable
  2680. exports.defaultResolvePolicy = {
  2681. when: "LAZY",
  2682. async: "WAIT"
  2683. };
  2684. /**
  2685. * The basic building block for the resolve system.
  2686. *
  2687. * Resolvables encapsulate a state's resolve's resolveFn, the resolveFn's declared dependencies, the wrapped (.promise),
  2688. * and the unwrapped-when-complete (.data) result of the resolveFn.
  2689. *
  2690. * Resolvable.get() either retrieves the Resolvable's existing promise, or else invokes resolve() (which invokes the
  2691. * resolveFn) and returns the resulting promise.
  2692. *
  2693. * Resolvable.get() and Resolvable.resolve() both execute within a context path, which is passed as the first
  2694. * parameter to those fns.
  2695. */
  2696. var Resolvable = (function () {
  2697. function Resolvable(arg1, resolveFn, deps, policy, data) {
  2698. this.resolved = false;
  2699. this.promise = undefined;
  2700. if (arg1 instanceof Resolvable) {
  2701. common_1.extend(this, arg1);
  2702. }
  2703. else if (predicates_1.isFunction(resolveFn)) {
  2704. if (arg1 == null || arg1 == undefined)
  2705. throw new Error("new Resolvable(): token argument is required");
  2706. if (!predicates_1.isFunction(resolveFn))
  2707. throw new Error("new Resolvable(): resolveFn argument must be a function");
  2708. this.token = arg1;
  2709. this.policy = policy;
  2710. this.resolveFn = resolveFn;
  2711. this.deps = deps || [];
  2712. this.data = data;
  2713. this.resolved = data !== undefined;
  2714. this.promise = this.resolved ? coreservices_1.services.$q.when(this.data) : undefined;
  2715. }
  2716. else if (predicates_1.isObject(arg1) && arg1.token && predicates_1.isFunction(arg1.resolveFn)) {
  2717. var literal = arg1;
  2718. return new Resolvable(literal.token, literal.resolveFn, literal.deps, literal.policy, literal.data);
  2719. }
  2720. }
  2721. Resolvable.prototype.getPolicy = function (state) {
  2722. var thisPolicy = this.policy || {};
  2723. var statePolicy = state && state.resolvePolicy || {};
  2724. return {
  2725. when: thisPolicy.when || statePolicy.when || exports.defaultResolvePolicy.when,
  2726. async: thisPolicy.async || statePolicy.async || exports.defaultResolvePolicy.async,
  2727. };
  2728. };
  2729. /**
  2730. * Asynchronously resolve this Resolvable's data
  2731. *
  2732. * Given a ResolveContext that this Resolvable is found in:
  2733. * Wait for this Resolvable's dependencies, then invoke this Resolvable's function
  2734. * and update the Resolvable's state
  2735. */
  2736. Resolvable.prototype.resolve = function (resolveContext, trans) {
  2737. var _this = this;
  2738. var $q = coreservices_1.services.$q;
  2739. // Gets all dependencies from ResolveContext and wait for them to be resolved
  2740. var getResolvableDependencies = function () {
  2741. return $q.all(resolveContext.getDependencies(_this).map(function (r) {
  2742. return r.get(resolveContext, trans);
  2743. }));
  2744. };
  2745. // Invokes the resolve function passing the resolved dependencies as arguments
  2746. var invokeResolveFn = function (resolvedDeps) {
  2747. return _this.resolveFn.apply(null, resolvedDeps);
  2748. };
  2749. /**
  2750. * For RXWAIT policy:
  2751. *
  2752. * Given an observable returned from a resolve function:
  2753. * - enables .cache() mode (this allows multicast subscribers)
  2754. * - then calls toPromise() (this triggers subscribe() and thus fetches)
  2755. * - Waits for the promise, then return the cached observable (not the first emitted value).
  2756. */
  2757. var waitForRx = function (observable$) {
  2758. var cached = observable$.cache(1);
  2759. return cached.take(1).toPromise().then(function () { return cached; });
  2760. };
  2761. // If the resolve policy is RXWAIT, wait for the observable to emit something. otherwise pass through.
  2762. var node = resolveContext.findNode(this);
  2763. var state = node && node.state;
  2764. var maybeWaitForRx = this.getPolicy(state).async === "RXWAIT" ? waitForRx : common_1.identity;
  2765. // After the final value has been resolved, update the state of the Resolvable
  2766. var applyResolvedValue = function (resolvedValue) {
  2767. _this.data = resolvedValue;
  2768. _this.resolved = true;
  2769. trace_1.trace.traceResolvableResolved(_this, trans);
  2770. return _this.data;
  2771. };
  2772. // Sets the promise property first, then getsResolvableDependencies in the context of the promise chain. Always waits one tick.
  2773. return this.promise = $q.when()
  2774. .then(getResolvableDependencies)
  2775. .then(invokeResolveFn)
  2776. .then(maybeWaitForRx)
  2777. .then(applyResolvedValue);
  2778. };
  2779. /**
  2780. * Gets a promise for this Resolvable's data.
  2781. *
  2782. * Fetches the data and returns a promise.
  2783. * Returns the existing promise if it has already been fetched once.
  2784. */
  2785. Resolvable.prototype.get = function (resolveContext, trans) {
  2786. return this.promise || this.resolve(resolveContext, trans);
  2787. };
  2788. Resolvable.prototype.toString = function () {
  2789. return "Resolvable(token: " + strings_1.stringify(this.token) + ", requires: [" + this.deps.map(strings_1.stringify) + "])";
  2790. };
  2791. Resolvable.prototype.clone = function () {
  2792. return new Resolvable(this);
  2793. };
  2794. Resolvable.fromData = function (token, data) {
  2795. return new Resolvable(token, function () { return data; }, null, null, data);
  2796. };
  2797. return Resolvable;
  2798. }());
  2799. exports.Resolvable = Resolvable;
  2800. /***/ },
  2801. /* 20 */
  2802. /***/ function(module, exports, __webpack_require__) {
  2803. /** @module path */ /** for typedoc */
  2804. "use strict";
  2805. var common_1 = __webpack_require__(3);
  2806. var hof_1 = __webpack_require__(5);
  2807. var targetState_1 = __webpack_require__(14);
  2808. var node_1 = __webpack_require__(21);
  2809. /**
  2810. * This class contains functions which convert TargetStates, Nodes and paths from one type to another.
  2811. */
  2812. var PathFactory = (function () {
  2813. function PathFactory() {
  2814. }
  2815. /** Given a PathNode[], create an TargetState */
  2816. PathFactory.makeTargetState = function (path) {
  2817. var state = common_1.tail(path).state;
  2818. return new targetState_1.TargetState(state, state, path.map(hof_1.prop("paramValues")).reduce(common_1.mergeR, {}));
  2819. };
  2820. PathFactory.buildPath = function (targetState) {
  2821. var toParams = targetState.params();
  2822. return targetState.$state().path.map(function (state) { return new node_1.PathNode(state).applyRawParams(toParams); });
  2823. };
  2824. /** Given a fromPath: PathNode[] and a TargetState, builds a toPath: PathNode[] */
  2825. PathFactory.buildToPath = function (fromPath, targetState) {
  2826. var toPath = PathFactory.buildPath(targetState);
  2827. if (targetState.options().inherit) {
  2828. return PathFactory.inheritParams(fromPath, toPath, Object.keys(targetState.params()));
  2829. }
  2830. return toPath;
  2831. };
  2832. /**
  2833. * Creates ViewConfig objects and adds to nodes.
  2834. *
  2835. * On each [[PathNode]], creates ViewConfig objects from the views: property of the node's state
  2836. */
  2837. PathFactory.applyViewConfigs = function ($view, path, states) {
  2838. // Only apply the viewConfigs to the nodes for the given states
  2839. path.filter(function (node) { return common_1.inArray(states, node.state); }).forEach(function (node) {
  2840. var viewDecls = common_1.values(node.state.views || {});
  2841. var subPath = PathFactory.subPath(path, function (n) { return n === node; });
  2842. var viewConfigs = viewDecls.map(function (view) { return $view.createViewConfig(subPath, view); });
  2843. node.views = viewConfigs.reduce(common_1.unnestR, []);
  2844. });
  2845. };
  2846. /**
  2847. * Given a fromPath and a toPath, returns a new to path which inherits parameters from the fromPath
  2848. *
  2849. * For a parameter in a node to be inherited from the from path:
  2850. * - The toPath's node must have a matching node in the fromPath (by state).
  2851. * - The parameter name must not be found in the toKeys parameter array.
  2852. *
  2853. * Note: the keys provided in toKeys are intended to be those param keys explicitly specified by some
  2854. * caller, for instance, $state.transitionTo(..., toParams). If a key was found in toParams,
  2855. * it is not inherited from the fromPath.
  2856. */
  2857. PathFactory.inheritParams = function (fromPath, toPath, toKeys) {
  2858. if (toKeys === void 0) { toKeys = []; }
  2859. function nodeParamVals(path, state) {
  2860. var node = common_1.find(path, hof_1.propEq('state', state));
  2861. return common_1.extend({}, node && node.paramValues);
  2862. }
  2863. /**
  2864. * Given an [[PathNode]] "toNode", return a new [[PathNode]] with param values inherited from the
  2865. * matching node in fromPath. Only inherit keys that aren't found in "toKeys" from the node in "fromPath""
  2866. */
  2867. function makeInheritedParamsNode(toNode) {
  2868. // All param values for the node (may include default key/vals, when key was not found in toParams)
  2869. var toParamVals = common_1.extend({}, toNode && toNode.paramValues);
  2870. // limited to only those keys found in toParams
  2871. var incomingParamVals = common_1.pick(toParamVals, toKeys);
  2872. toParamVals = common_1.omit(toParamVals, toKeys);
  2873. var fromParamVals = nodeParamVals(fromPath, toNode.state) || {};
  2874. // extend toParamVals with any fromParamVals, then override any of those those with incomingParamVals
  2875. var ownParamVals = common_1.extend(toParamVals, fromParamVals, incomingParamVals);
  2876. return new node_1.PathNode(toNode.state).applyRawParams(ownParamVals);
  2877. }
  2878. // The param keys specified by the incoming toParams
  2879. return toPath.map(makeInheritedParamsNode);
  2880. };
  2881. /**
  2882. * Computes the tree changes (entering, exiting) between a fromPath and toPath.
  2883. */
  2884. PathFactory.treeChanges = function (fromPath, toPath, reloadState) {
  2885. var keep = 0, max = Math.min(fromPath.length, toPath.length);
  2886. var staticParams = function (state) {
  2887. return state.parameters({ inherit: false }).filter(hof_1.not(hof_1.prop('dynamic'))).map(hof_1.prop('id'));
  2888. };
  2889. var nodesMatch = function (node1, node2) {
  2890. return node1.equals(node2, staticParams(node1.state));
  2891. };
  2892. while (keep < max && fromPath[keep].state !== reloadState && nodesMatch(fromPath[keep], toPath[keep])) {
  2893. keep++;
  2894. }
  2895. /** Given a retained node, return a new node which uses the to node's param values */
  2896. function applyToParams(retainedNode, idx) {
  2897. var cloned = node_1.PathNode.clone(retainedNode);
  2898. cloned.paramValues = toPath[idx].paramValues;
  2899. return cloned;
  2900. }
  2901. var from, retained, exiting, entering, to;
  2902. from = fromPath;
  2903. retained = from.slice(0, keep);
  2904. exiting = from.slice(keep);
  2905. // Create a new retained path (with shallow copies of nodes) which have the params of the toPath mapped
  2906. var retainedWithToParams = retained.map(applyToParams);
  2907. entering = toPath.slice(keep);
  2908. to = (retainedWithToParams).concat(entering);
  2909. return { from: from, to: to, retained: retained, exiting: exiting, entering: entering };
  2910. };
  2911. /**
  2912. * Return a subpath of a path, which stops at the first matching node
  2913. *
  2914. * Given an array of nodes, returns a subset of the array starting from the first node,
  2915. * stopping when the first node matches the predicate.
  2916. *
  2917. * @param path a path of [[PathNode]]s
  2918. * @param predicate a [[Predicate]] fn that matches [[PathNode]]s
  2919. * @returns a subpath up to the matching node, or undefined if no match is found
  2920. */
  2921. PathFactory.subPath = function (path, predicate) {
  2922. var node = common_1.find(path, predicate);
  2923. var elementIdx = path.indexOf(node);
  2924. return elementIdx === -1 ? undefined : path.slice(0, elementIdx + 1);
  2925. };
  2926. /** Gets the raw parameter values from a path */
  2927. PathFactory.paramValues = function (path) { return path.reduce(function (acc, node) { return common_1.extend(acc, node.paramValues); }, {}); };
  2928. return PathFactory;
  2929. }());
  2930. exports.PathFactory = PathFactory;
  2931. /***/ },
  2932. /* 21 */
  2933. /***/ function(module, exports, __webpack_require__) {
  2934. "use strict";
  2935. /** @module path */ /** for typedoc */
  2936. var common_1 = __webpack_require__(3);
  2937. var hof_1 = __webpack_require__(5);
  2938. var param_1 = __webpack_require__(22);
  2939. /**
  2940. * A node in a [[TreeChanges]] path
  2941. *
  2942. * For a [[TreeChanges]] path, this class holds the stateful information for a single node in the path.
  2943. * Each PathNode corresponds to a state being entered, exited, or retained.
  2944. * The stateful information includes parameter values and resolve data.
  2945. */
  2946. var PathNode = (function () {
  2947. function PathNode(stateOrPath) {
  2948. if (stateOrPath instanceof PathNode) {
  2949. var node = stateOrPath;
  2950. this.state = node.state;
  2951. this.paramSchema = node.paramSchema.slice();
  2952. this.paramValues = common_1.extend({}, node.paramValues);
  2953. this.resolvables = node.resolvables.slice();
  2954. this.views = node.views && node.views.slice();
  2955. }
  2956. else {
  2957. var state = stateOrPath;
  2958. this.state = state;
  2959. this.paramSchema = state.parameters({ inherit: false });
  2960. this.paramValues = {};
  2961. this.resolvables = state.resolvables.map(function (res) { return res.clone(); });
  2962. }
  2963. }
  2964. /** Sets [[paramValues]] for the node, from the values of an object hash */
  2965. PathNode.prototype.applyRawParams = function (params) {
  2966. var getParamVal = function (paramDef) { return [paramDef.id, paramDef.value(params[paramDef.id])]; };
  2967. this.paramValues = this.paramSchema.reduce(function (memo, pDef) { return common_1.applyPairs(memo, getParamVal(pDef)); }, {});
  2968. return this;
  2969. };
  2970. /** Gets a specific [[Param]] metadata that belongs to the node */
  2971. PathNode.prototype.parameter = function (name) {
  2972. return common_1.find(this.paramSchema, hof_1.propEq("id", name));
  2973. };
  2974. /**
  2975. * @returns true if the state and parameter values for another PathNode are
  2976. * equal to the state and param values for this PathNode
  2977. */
  2978. PathNode.prototype.equals = function (node, keys) {
  2979. var _this = this;
  2980. if (keys === void 0) { keys = this.paramSchema.map(function (p) { return p.id; }); }
  2981. var paramValsEq = function (key) {
  2982. return _this.parameter(key).type.equals(_this.paramValues[key], node.paramValues[key]);
  2983. };
  2984. return this.state === node.state && keys.map(paramValsEq).reduce(common_1.allTrueR, true);
  2985. };
  2986. /** Returns a clone of the PathNode */
  2987. PathNode.clone = function (node) {
  2988. return new PathNode(node);
  2989. };
  2990. /**
  2991. * Returns a new path which is a subpath of the first path which matched the second path.
  2992. *
  2993. * The new path starts from root and contains any nodes that match the nodes in the second path.
  2994. * Nodes are compared using their state property and parameter values.
  2995. *
  2996. * @param pathA the first path
  2997. * @param pathB the second path
  2998. * @param ignoreDynamicParams don't compare dynamic parameter values
  2999. */
  3000. PathNode.matching = function (pathA, pathB, ignoreDynamicParams) {
  3001. if (ignoreDynamicParams === void 0) { ignoreDynamicParams = true; }
  3002. var matching = [];
  3003. for (var i = 0; i < pathA.length && i < pathB.length; i++) {
  3004. var a = pathA[i], b = pathB[i];
  3005. if (a.state !== b.state)
  3006. break;
  3007. var changedParams = param_1.Param.changed(a.paramSchema, a.paramValues, b.paramValues)
  3008. .filter(function (param) { return !(ignoreDynamicParams && param.dynamic); });
  3009. if (changedParams.length)
  3010. break;
  3011. matching.push(a);
  3012. }
  3013. return matching;
  3014. };
  3015. return PathNode;
  3016. }());
  3017. exports.PathNode = PathNode;
  3018. /***/ },
  3019. /* 22 */
  3020. /***/ function(module, exports, __webpack_require__) {
  3021. "use strict";
  3022. /** @module params */ /** for typedoc */
  3023. var common_1 = __webpack_require__(3);
  3024. var hof_1 = __webpack_require__(5);
  3025. var predicates_1 = __webpack_require__(4);
  3026. var coreservices_1 = __webpack_require__(6);
  3027. var urlMatcherConfig_1 = __webpack_require__(23);
  3028. var type_1 = __webpack_require__(24);
  3029. var hasOwn = Object.prototype.hasOwnProperty;
  3030. var isShorthand = function (cfg) {
  3031. return ["value", "type", "squash", "array", "dynamic"].filter(hasOwn.bind(cfg || {})).length === 0;
  3032. };
  3033. (function (DefType) {
  3034. DefType[DefType["PATH"] = 0] = "PATH";
  3035. DefType[DefType["SEARCH"] = 1] = "SEARCH";
  3036. DefType[DefType["CONFIG"] = 2] = "CONFIG";
  3037. })(exports.DefType || (exports.DefType = {}));
  3038. var DefType = exports.DefType;
  3039. function unwrapShorthand(cfg) {
  3040. cfg = isShorthand(cfg) && { value: cfg } || cfg;
  3041. return common_1.extend(cfg, {
  3042. $$fn: predicates_1.isInjectable(cfg.value) ? cfg.value : function () { return cfg.value; }
  3043. });
  3044. }
  3045. function getType(cfg, urlType, location, id, paramTypes) {
  3046. if (cfg.type && urlType && urlType.name !== 'string')
  3047. throw new Error("Param '" + id + "' has two type configurations.");
  3048. if (cfg.type && urlType && urlType.name === 'string' && paramTypes.type(cfg.type))
  3049. return paramTypes.type(cfg.type);
  3050. if (urlType)
  3051. return urlType;
  3052. if (!cfg.type)
  3053. return (location === DefType.CONFIG ? paramTypes.type("any") : paramTypes.type("string"));
  3054. return cfg.type instanceof type_1.ParamType ? cfg.type : paramTypes.type(cfg.type);
  3055. }
  3056. /**
  3057. * returns false, true, or the squash value to indicate the "default parameter url squash policy".
  3058. */
  3059. function getSquashPolicy(config, isOptional) {
  3060. var squash = config.squash;
  3061. if (!isOptional || squash === false)
  3062. return false;
  3063. if (!predicates_1.isDefined(squash) || squash == null)
  3064. return urlMatcherConfig_1.matcherConfig.defaultSquashPolicy();
  3065. if (squash === true || predicates_1.isString(squash))
  3066. return squash;
  3067. throw new Error("Invalid squash policy: '" + squash + "'. Valid policies: false, true, or arbitrary string");
  3068. }
  3069. function getReplace(config, arrayMode, isOptional, squash) {
  3070. var replace, configuredKeys, defaultPolicy = [
  3071. { from: "", to: (isOptional || arrayMode ? undefined : "") },
  3072. { from: null, to: (isOptional || arrayMode ? undefined : "") }
  3073. ];
  3074. replace = predicates_1.isArray(config.replace) ? config.replace : [];
  3075. if (predicates_1.isString(squash))
  3076. replace.push({ from: squash, to: undefined });
  3077. configuredKeys = common_1.map(replace, hof_1.prop("from"));
  3078. return common_1.filter(defaultPolicy, function (item) { return configuredKeys.indexOf(item.from) === -1; }).concat(replace);
  3079. }
  3080. var Param = (function () {
  3081. function Param(id, type, config, location, paramTypes) {
  3082. config = unwrapShorthand(config);
  3083. type = getType(config, type, location, id, paramTypes);
  3084. var arrayMode = getArrayMode();
  3085. type = arrayMode ? type.$asArray(arrayMode, location === DefType.SEARCH) : type;
  3086. var isOptional = config.value !== undefined;
  3087. var dynamic = predicates_1.isDefined(config.dynamic) ? !!config.dynamic : !!type.dynamic;
  3088. var squash = getSquashPolicy(config, isOptional);
  3089. var replace = getReplace(config, arrayMode, isOptional, squash);
  3090. // array config: param name (param[]) overrides default settings. explicit config overrides param name.
  3091. function getArrayMode() {
  3092. var arrayDefaults = { array: (location === DefType.SEARCH ? "auto" : false) };
  3093. var arrayParamNomenclature = id.match(/\[\]$/) ? { array: true } : {};
  3094. return common_1.extend(arrayDefaults, arrayParamNomenclature, config).array;
  3095. }
  3096. common_1.extend(this, { id: id, type: type, location: location, squash: squash, replace: replace, isOptional: isOptional, dynamic: dynamic, config: config, array: arrayMode });
  3097. }
  3098. Param.prototype.isDefaultValue = function (value) {
  3099. return this.isOptional && this.type.equals(this.value(), value);
  3100. };
  3101. /**
  3102. * [Internal] Gets the decoded representation of a value if the value is defined, otherwise, returns the
  3103. * default value, which may be the result of an injectable function.
  3104. */
  3105. Param.prototype.value = function (value) {
  3106. var _this = this;
  3107. /**
  3108. * [Internal] Get the default value of a parameter, which may be an injectable function.
  3109. */
  3110. var $$getDefaultValue = function () {
  3111. if (!coreservices_1.services.$injector)
  3112. throw new Error("Injectable functions cannot be called at configuration time");
  3113. var defaultValue = coreservices_1.services.$injector.invoke(_this.config.$$fn);
  3114. if (defaultValue !== null && defaultValue !== undefined && !_this.type.is(defaultValue))
  3115. throw new Error("Default value (" + defaultValue + ") for parameter '" + _this.id + "' is not an instance of ParamType (" + _this.type.name + ")");
  3116. return defaultValue;
  3117. };
  3118. var $replace = function (val) {
  3119. var replacement = common_1.map(common_1.filter(_this.replace, hof_1.propEq('from', val)), hof_1.prop("to"));
  3120. return replacement.length ? replacement[0] : val;
  3121. };
  3122. value = $replace(value);
  3123. return !predicates_1.isDefined(value) ? $$getDefaultValue() : this.type.$normalize(value);
  3124. };
  3125. Param.prototype.isSearch = function () {
  3126. return this.location === DefType.SEARCH;
  3127. };
  3128. Param.prototype.validates = function (value) {
  3129. // There was no parameter value, but the param is optional
  3130. if ((!predicates_1.isDefined(value) || value === null) && this.isOptional)
  3131. return true;
  3132. // The value was not of the correct ParamType, and could not be decoded to the correct ParamType
  3133. var normalized = this.type.$normalize(value);
  3134. if (!this.type.is(normalized))
  3135. return false;
  3136. // The value was of the correct type, but when encoded, did not match the ParamType's regexp
  3137. var encoded = this.type.encode(normalized);
  3138. return !(predicates_1.isString(encoded) && !this.type.pattern.exec(encoded));
  3139. };
  3140. Param.prototype.toString = function () {
  3141. return "{Param:" + this.id + " " + this.type + " squash: '" + this.squash + "' optional: " + this.isOptional + "}";
  3142. };
  3143. /** Creates a new [[Param]] from a CONFIG block */
  3144. Param.fromConfig = function (id, type, config, paramTypes) {
  3145. return new Param(id, type, config, DefType.CONFIG, paramTypes);
  3146. };
  3147. /** Creates a new [[Param]] from a url PATH */
  3148. Param.fromPath = function (id, type, config, paramTypes) {
  3149. return new Param(id, type, config, DefType.PATH, paramTypes);
  3150. };
  3151. /** Creates a new [[Param]] from a url SEARCH */
  3152. Param.fromSearch = function (id, type, config, paramTypes) {
  3153. return new Param(id, type, config, DefType.SEARCH, paramTypes);
  3154. };
  3155. Param.values = function (params, values) {
  3156. if (values === void 0) { values = {}; }
  3157. return params.map(function (param) { return [param.id, param.value(values[param.id])]; }).reduce(common_1.applyPairs, {});
  3158. };
  3159. /**
  3160. * Finds [[Param]] objects which have different param values
  3161. *
  3162. * Filters a list of [[Param]] objects to only those whose parameter values differ in two param value objects
  3163. *
  3164. * @param params: The list of Param objects to filter
  3165. * @param values1: The first set of parameter values
  3166. * @param values2: the second set of parameter values
  3167. *
  3168. * @returns any Param objects whose values were different between values1 and values2
  3169. */
  3170. Param.changed = function (params, values1, values2) {
  3171. if (values1 === void 0) { values1 = {}; }
  3172. if (values2 === void 0) { values2 = {}; }
  3173. return params.filter(function (param) { return !param.type.equals(values1[param.id], values2[param.id]); });
  3174. };
  3175. /**
  3176. * Checks if two param value objects are equal (for a set of [[Param]] objects)
  3177. *
  3178. * @param params The list of [[Param]] objects to check
  3179. * @param values1 The first set of param values
  3180. * @param values2 The second set of param values
  3181. *
  3182. * @returns true if the param values in values1 and values2 are equal
  3183. */
  3184. Param.equals = function (params, values1, values2) {
  3185. if (values1 === void 0) { values1 = {}; }
  3186. if (values2 === void 0) { values2 = {}; }
  3187. return Param.changed(params, values1, values2).length === 0;
  3188. };
  3189. /** Returns true if a the parameter values are valid, according to the Param definitions */
  3190. Param.validates = function (params, values) {
  3191. if (values === void 0) { values = {}; }
  3192. return params.map(function (param) { return param.validates(values[param.id]); }).reduce(common_1.allTrueR, true);
  3193. };
  3194. return Param;
  3195. }());
  3196. exports.Param = Param;
  3197. /***/ },
  3198. /* 23 */
  3199. /***/ function(module, exports, __webpack_require__) {
  3200. "use strict";
  3201. /** @module url */ /** for typedoc */
  3202. var predicates_1 = __webpack_require__(4);
  3203. var MatcherConfig = (function () {
  3204. function MatcherConfig() {
  3205. this._isCaseInsensitive = false;
  3206. this._isStrictMode = true;
  3207. this._defaultSquashPolicy = false;
  3208. }
  3209. MatcherConfig.prototype.caseInsensitive = function (value) {
  3210. return this._isCaseInsensitive = predicates_1.isDefined(value) ? value : this._isCaseInsensitive;
  3211. };
  3212. MatcherConfig.prototype.strictMode = function (value) {
  3213. return this._isStrictMode = predicates_1.isDefined(value) ? value : this._isStrictMode;
  3214. };
  3215. MatcherConfig.prototype.defaultSquashPolicy = function (value) {
  3216. if (predicates_1.isDefined(value) && value !== true && value !== false && !predicates_1.isString(value))
  3217. throw new Error("Invalid squash policy: " + value + ". Valid policies: false, true, arbitrary-string");
  3218. return this._defaultSquashPolicy = predicates_1.isDefined(value) ? value : this._defaultSquashPolicy;
  3219. };
  3220. return MatcherConfig;
  3221. }());
  3222. exports.MatcherConfig = MatcherConfig;
  3223. // TODO: Do not export global instance; create one in UIRouter() constructor
  3224. exports.matcherConfig = new MatcherConfig();
  3225. /***/ },
  3226. /* 24 */
  3227. /***/ function(module, exports, __webpack_require__) {
  3228. "use strict";
  3229. /** @module params */ /** for typedoc */
  3230. var common_1 = __webpack_require__(3);
  3231. var predicates_1 = __webpack_require__(4);
  3232. /**
  3233. * Wraps up a `ParamType` object to handle array values.
  3234. */
  3235. function ArrayType(type, mode) {
  3236. var _this = this;
  3237. // Wrap non-array value as array
  3238. function arrayWrap(val) {
  3239. return predicates_1.isArray(val) ? val : (predicates_1.isDefined(val) ? [val] : []);
  3240. }
  3241. // Unwrap array value for "auto" mode. Return undefined for empty array.
  3242. function arrayUnwrap(val) {
  3243. switch (val.length) {
  3244. case 0: return undefined;
  3245. case 1: return mode === "auto" ? val[0] : val;
  3246. default: return val;
  3247. }
  3248. }
  3249. // Wraps type (.is/.encode/.decode) functions to operate on each value of an array
  3250. function arrayHandler(callback, allTruthyMode) {
  3251. return function handleArray(val) {
  3252. if (predicates_1.isArray(val) && val.length === 0)
  3253. return val;
  3254. var arr = arrayWrap(val);
  3255. var result = common_1.map(arr, callback);
  3256. return (allTruthyMode === true) ? common_1.filter(result, function (x) { return !x; }).length === 0 : arrayUnwrap(result);
  3257. };
  3258. }
  3259. // Wraps type (.equals) functions to operate on each value of an array
  3260. function arrayEqualsHandler(callback) {
  3261. return function handleArray(val1, val2) {
  3262. var left = arrayWrap(val1), right = arrayWrap(val2);
  3263. if (left.length !== right.length)
  3264. return false;
  3265. for (var i = 0; i < left.length; i++) {
  3266. if (!callback(left[i], right[i]))
  3267. return false;
  3268. }
  3269. return true;
  3270. };
  3271. }
  3272. ['encode', 'decode', 'equals', '$normalize'].forEach(function (name) {
  3273. var paramTypeFn = type[name].bind(type);
  3274. var wrapperFn = name === 'equals' ? arrayEqualsHandler : arrayHandler;
  3275. _this[name] = wrapperFn(paramTypeFn);
  3276. });
  3277. common_1.extend(this, {
  3278. dynamic: type.dynamic,
  3279. name: type.name,
  3280. pattern: type.pattern,
  3281. is: arrayHandler(type.is.bind(type), true),
  3282. $arrayMode: mode
  3283. });
  3284. }
  3285. /**
  3286. * A class that implements Custom Parameter Type functionality.
  3287. *
  3288. * This class has naive implementations for all the [[ParamTypeDefinition]] methods.
  3289. *
  3290. * An instance of this class is created when a custom [[ParamTypeDefinition]] object is registered with the [[UrlMatcherFactory.type]].
  3291. *
  3292. * Used by [[UrlMatcher]] when matching or formatting URLs, or comparing and validating parameter values.
  3293. *
  3294. * @example
  3295. * ```
  3296. *
  3297. * {
  3298. * decode: function(val) { return parseInt(val, 10); },
  3299. * encode: function(val) { return val && val.toString(); },
  3300. * equals: function(a, b) { return this.is(a) && a === b; },
  3301. * is: function(val) { return angular.isNumber(val) && isFinite(val) && val % 1 === 0; },
  3302. * pattern: /\d+/
  3303. * }
  3304. * ```
  3305. */
  3306. var ParamType = (function () {
  3307. /**
  3308. * @param def A configuration object which contains the custom type definition. The object's
  3309. * properties will override the default methods and/or pattern in `ParamType`'s public interface.
  3310. * @returns a new ParamType object
  3311. */
  3312. function ParamType(def) {
  3313. this.pattern = /.*/;
  3314. common_1.extend(this, def);
  3315. }
  3316. // consider these four methods to be "abstract methods" that should be overridden
  3317. /** @inheritdoc */
  3318. ParamType.prototype.is = function (val, key) { return true; };
  3319. /** @inheritdoc */
  3320. ParamType.prototype.encode = function (val, key) { return val; };
  3321. /** @inheritdoc */
  3322. ParamType.prototype.decode = function (val, key) { return val; };
  3323. /** @inheritdoc */
  3324. ParamType.prototype.equals = function (a, b) { return a == b; };
  3325. ParamType.prototype.$subPattern = function () {
  3326. var sub = this.pattern.toString();
  3327. return sub.substr(1, sub.length - 2);
  3328. };
  3329. ParamType.prototype.toString = function () {
  3330. return "{ParamType:" + this.name + "}";
  3331. };
  3332. /** Given an encoded string, or a decoded object, returns a decoded object */
  3333. ParamType.prototype.$normalize = function (val) {
  3334. return this.is(val) ? val : this.decode(val);
  3335. };
  3336. /**
  3337. * Wraps an existing custom ParamType as an array of ParamType, depending on 'mode'.
  3338. * e.g.:
  3339. * - urlmatcher pattern "/path?{queryParam[]:int}"
  3340. * - url: "/path?queryParam=1&queryParam=2
  3341. * - $stateParams.queryParam will be [1, 2]
  3342. * if `mode` is "auto", then
  3343. * - url: "/path?queryParam=1 will create $stateParams.queryParam: 1
  3344. * - url: "/path?queryParam=1&queryParam=2 will create $stateParams.queryParam: [1, 2]
  3345. */
  3346. ParamType.prototype.$asArray = function (mode, isSearch) {
  3347. if (!mode)
  3348. return this;
  3349. if (mode === "auto" && !isSearch)
  3350. throw new Error("'auto' array mode is for query parameters only");
  3351. return new ArrayType(this, mode);
  3352. };
  3353. return ParamType;
  3354. }());
  3355. exports.ParamType = ParamType;
  3356. /***/ },
  3357. /* 25 */
  3358. /***/ function(module, exports, __webpack_require__) {
  3359. "use strict";
  3360. /** @module core */ /** */
  3361. var urlMatcherFactory_1 = __webpack_require__(26);
  3362. var urlRouter_1 = __webpack_require__(29);
  3363. var urlRouter_2 = __webpack_require__(29);
  3364. var transitionService_1 = __webpack_require__(30);
  3365. var view_1 = __webpack_require__(37);
  3366. var stateRegistry_1 = __webpack_require__(38);
  3367. var stateService_1 = __webpack_require__(43);
  3368. var globals_1 = __webpack_require__(44);
  3369. /**
  3370. * The master class used to instantiate an instance of UI-Router.
  3371. *
  3372. * This class instantiates and wires the global UI-Router services.
  3373. *
  3374. * After instantiating a new instance of the Router class, configure it for your app. For instance, register
  3375. * your app states with the [[stateRegistry]] (and set url options using ...). Then, tell UI-Router to monitor
  3376. * the URL by calling `urlRouter.listen()` ([[URLRouter.listen]])
  3377. */
  3378. var UIRouter = (function () {
  3379. function UIRouter() {
  3380. this.viewService = new view_1.ViewService();
  3381. this.transitionService = new transitionService_1.TransitionService(this);
  3382. this.globals = new globals_1.Globals(this.transitionService);
  3383. this.urlMatcherFactory = new urlMatcherFactory_1.UrlMatcherFactory();
  3384. this.urlRouterProvider = new urlRouter_1.UrlRouterProvider(this.urlMatcherFactory, this.globals.params);
  3385. this.urlRouter = new urlRouter_2.UrlRouter(this.urlRouterProvider);
  3386. this.stateRegistry = new stateRegistry_1.StateRegistry(this.urlMatcherFactory, this.urlRouterProvider);
  3387. this.stateService = new stateService_1.StateService(this);
  3388. this.viewService.rootContext(this.stateRegistry.root());
  3389. this.globals.$current = this.stateRegistry.root();
  3390. this.globals.current = this.globals.$current.self;
  3391. }
  3392. return UIRouter;
  3393. }());
  3394. exports.UIRouter = UIRouter;
  3395. /***/ },
  3396. /* 26 */
  3397. /***/ function(module, exports, __webpack_require__) {
  3398. "use strict";
  3399. /** @module url */ /** for typedoc */
  3400. var common_1 = __webpack_require__(3);
  3401. var predicates_1 = __webpack_require__(4);
  3402. var urlMatcher_1 = __webpack_require__(27);
  3403. var urlMatcherConfig_1 = __webpack_require__(23);
  3404. var param_1 = __webpack_require__(22);
  3405. var paramTypes_1 = __webpack_require__(28);
  3406. /** @hidden */
  3407. function getDefaultConfig() {
  3408. return {
  3409. strict: urlMatcherConfig_1.matcherConfig.strictMode(),
  3410. caseInsensitive: urlMatcherConfig_1.matcherConfig.caseInsensitive()
  3411. };
  3412. }
  3413. /**
  3414. * Factory for [[UrlMatcher]] instances.
  3415. *
  3416. * The factory is available to ng1 services as
  3417. * `$urlMatcherFactor` or ng1 providers as `$urlMatcherFactoryProvider`.
  3418. */
  3419. var UrlMatcherFactory = (function () {
  3420. function UrlMatcherFactory() {
  3421. this.paramTypes = new paramTypes_1.ParamTypes();
  3422. common_1.extend(this, { UrlMatcher: urlMatcher_1.UrlMatcher, Param: param_1.Param });
  3423. }
  3424. /**
  3425. * Defines whether URL matching should be case sensitive (the default behavior), or not.
  3426. *
  3427. * @param value `false` to match URL in a case sensitive manner; otherwise `true`;
  3428. * @returns the current value of caseInsensitive
  3429. */
  3430. UrlMatcherFactory.prototype.caseInsensitive = function (value) {
  3431. return urlMatcherConfig_1.matcherConfig.caseInsensitive(value);
  3432. };
  3433. /**
  3434. * Defines whether URLs should match trailing slashes, or not (the default behavior).
  3435. *
  3436. * @param value `false` to match trailing slashes in URLs, otherwise `true`.
  3437. * @returns the current value of strictMode
  3438. */
  3439. UrlMatcherFactory.prototype.strictMode = function (value) {
  3440. return urlMatcherConfig_1.matcherConfig.strictMode(value);
  3441. };
  3442. /**
  3443. * Sets the default behavior when generating or matching URLs with default parameter values.
  3444. *
  3445. * @param value A string that defines the default parameter URL squashing behavior.
  3446. * - `nosquash`: When generating an href with a default parameter value, do not squash the parameter value from the URL
  3447. * - `slash`: When generating an href with a default parameter value, squash (remove) the parameter value, and, if the
  3448. * parameter is surrounded by slashes, squash (remove) one slash from the URL
  3449. * - any other string, e.g. "~": When generating an href with a default parameter value, squash (remove)
  3450. * the parameter value from the URL and replace it with this string.
  3451. * @returns the current value of defaultSquashPolicy
  3452. */
  3453. UrlMatcherFactory.prototype.defaultSquashPolicy = function (value) {
  3454. return urlMatcherConfig_1.matcherConfig.defaultSquashPolicy(value);
  3455. };
  3456. /**
  3457. * Creates a [[UrlMatcher]] for the specified pattern.
  3458. *
  3459. * @param pattern The URL pattern.
  3460. * @param config The config object hash.
  3461. * @returns The UrlMatcher.
  3462. */
  3463. UrlMatcherFactory.prototype.compile = function (pattern, config) {
  3464. return new urlMatcher_1.UrlMatcher(pattern, this.paramTypes, common_1.extend(getDefaultConfig(), config));
  3465. };
  3466. /**
  3467. * Returns true if the specified object is a [[UrlMatcher]], or false otherwise.
  3468. *
  3469. * @param object The object to perform the type check against.
  3470. * @returns `true` if the object matches the `UrlMatcher` interface, by
  3471. * implementing all the same methods.
  3472. */
  3473. UrlMatcherFactory.prototype.isMatcher = function (object) {
  3474. // TODO: typeof?
  3475. if (!predicates_1.isObject(object))
  3476. return false;
  3477. var result = true;
  3478. common_1.forEach(urlMatcher_1.UrlMatcher.prototype, function (val, name) {
  3479. if (predicates_1.isFunction(val))
  3480. result = result && (predicates_1.isDefined(object[name]) && predicates_1.isFunction(object[name]));
  3481. });
  3482. return result;
  3483. };
  3484. ;
  3485. /**
  3486. * Creates and registers a custom [[ParamType]] object
  3487. *
  3488. * A [[ParamType]] can be used to generate URLs with typed parameters.
  3489. *
  3490. * @param name The type name.
  3491. * @param definition The type definition. See [[ParamTypeDefinition]] for information on the values accepted.
  3492. * @param definitionFn A function that is injected before the app runtime starts.
  3493. * The result of this function should be a [[ParamTypeDefinition]].
  3494. * The result is merged into the existing `definition`.
  3495. * See [[ParamType]] for information on the values accepted.
  3496. *
  3497. * @returns - if a type was registered: the [[UrlMatcherFactory]]
  3498. * - if only the `name` parameter was specified: the currently registered [[ParamType]] object, or undefined
  3499. *
  3500. * Note: Register custom types *before using them* in a state definition.
  3501. *
  3502. * See [[ParamTypeDefinition]] for examples
  3503. */
  3504. UrlMatcherFactory.prototype.type = function (name, definition, definitionFn) {
  3505. var type = this.paramTypes.type(name, definition, definitionFn);
  3506. return !predicates_1.isDefined(definition) ? type : this;
  3507. };
  3508. ;
  3509. /** @hidden */
  3510. UrlMatcherFactory.prototype.$get = function () {
  3511. this.paramTypes.enqueue = false;
  3512. this.paramTypes._flushTypeQueue();
  3513. return this;
  3514. };
  3515. ;
  3516. return UrlMatcherFactory;
  3517. }());
  3518. exports.UrlMatcherFactory = UrlMatcherFactory;
  3519. /***/ },
  3520. /* 27 */
  3521. /***/ function(module, exports, __webpack_require__) {
  3522. "use strict";
  3523. /** @module url */ /** for typedoc */
  3524. var common_1 = __webpack_require__(3);
  3525. var hof_1 = __webpack_require__(5);
  3526. var predicates_1 = __webpack_require__(4);
  3527. var param_1 = __webpack_require__(22);
  3528. var predicates_2 = __webpack_require__(4);
  3529. var param_2 = __webpack_require__(22);
  3530. var common_2 = __webpack_require__(3);
  3531. var common_3 = __webpack_require__(3);
  3532. /** @hidden */
  3533. function quoteRegExp(string, param) {
  3534. var surroundPattern = ['', ''], result = string.replace(/[\\\[\]\^$*+?.()|{}]/g, "\\$&");
  3535. if (!param)
  3536. return result;
  3537. switch (param.squash) {
  3538. case false:
  3539. surroundPattern = ['(', ')' + (param.isOptional ? '?' : '')];
  3540. break;
  3541. case true:
  3542. result = result.replace(/\/$/, '');
  3543. surroundPattern = ['(?:\/(', ')|\/)?'];
  3544. break;
  3545. default:
  3546. surroundPattern = [("(" + param.squash + "|"), ')?'];
  3547. break;
  3548. }
  3549. return result + surroundPattern[0] + param.type.pattern.source + surroundPattern[1];
  3550. }
  3551. /** @hidden */
  3552. var memoizeTo = function (obj, prop, fn) {
  3553. return obj[prop] = obj[prop] || fn();
  3554. };
  3555. /**
  3556. * Matches URLs against patterns.
  3557. *
  3558. * Matches URLs against patterns and extracts named parameters from the path or the search
  3559. * part of the URL.
  3560. *
  3561. * A URL pattern consists of a path pattern, optionally followed by '?' and a list of search (query)
  3562. * parameters. Multiple search parameter names are separated by '&'. Search parameters
  3563. * do not influence whether or not a URL is matched, but their values are passed through into
  3564. * the matched parameters returned by [[UrlMatcher.exec]].
  3565. *
  3566. * - *Path parameters* are defined using curly brace placeholders (`/somepath/{param}`)
  3567. * or colon placeholders (`/somePath/:param`).
  3568. *
  3569. * - *A parameter RegExp* may be defined for a param after a colon
  3570. * (`/somePath/{param:[a-zA-Z0-9]+}`) in a curly brace placeholder.
  3571. * The regexp must match for the url to be matched.
  3572. * Should the regexp itself contain curly braces, they must be in matched pairs or escaped with a backslash.
  3573. *
  3574. * - *Custom parameter types* may also be specified after a colon (`/somePath/{param:int}`)
  3575. * in curly brace parameters. See [[UrlMatcherFactory.type]] for more information.
  3576. *
  3577. * - *Catch-all parameters* are defined using an asterisk placeholder (`/somepath/*catchallparam`). A catch-all
  3578. * parameter value will contain the remainder of the URL.
  3579. *
  3580. * ---
  3581. *
  3582. * Parameter names may contain only word characters (latin letters, digits, and underscore) and
  3583. * must be unique within the pattern (across both path and search parameters).
  3584. * A path parameter matches any number of characters other than '/'. For catch-all
  3585. * placeholders the path parameter matches any number of characters.
  3586. *
  3587. * Examples:
  3588. *
  3589. * * `'/hello/'` - Matches only if the path is exactly '/hello/'. There is no special treatment for
  3590. * trailing slashes, and patterns have to match the entire path, not just a prefix.
  3591. * * `'/user/:id'` - Matches '/user/bob' or '/user/1234!!!' or even '/user/' but not '/user' or
  3592. * '/user/bob/details'. The second path segment will be captured as the parameter 'id'.
  3593. * * `'/user/{id}'` - Same as the previous example, but using curly brace syntax.
  3594. * * `'/user/{id:[^/]*}'` - Same as the previous example.
  3595. * * `'/user/{id:[0-9a-fA-F]{1,8}}'` - Similar to the previous example, but only matches if the id
  3596. * parameter consists of 1 to 8 hex digits.
  3597. * * `'/files/{path:.*}'` - Matches any URL starting with '/files/' and captures the rest of the
  3598. * path into the parameter 'path'.
  3599. * * `'/files/*path'` - ditto.
  3600. * * `'/calendar/{start:date}'` - Matches "/calendar/2014-11-12" (because the pattern defined
  3601. * in the built-in `date` ParamType matches `2014-11-12`) and provides a Date object in $stateParams.start
  3602. *
  3603. */
  3604. var UrlMatcher = (function () {
  3605. /**
  3606. * @param pattern The pattern to compile into a matcher.
  3607. * @param paramTypes The [[ParamTypes]] registry
  3608. * @param config A configuration object
  3609. * - `caseInsensitive` - `true` if URL matching should be case insensitive, otherwise `false`, the default value (for backward compatibility) is `false`.
  3610. * - `strict` - `false` if matching against a URL with a trailing slash should be treated as equivalent to a URL without a trailing slash, the default value is `true`.
  3611. */
  3612. function UrlMatcher(pattern, paramTypes, config) {
  3613. var _this = this;
  3614. this.config = config;
  3615. /** @hidden */
  3616. this._cache = { path: [], pattern: null };
  3617. /** @hidden */
  3618. this._children = [];
  3619. /** @hidden */
  3620. this._params = [];
  3621. /** @hidden */
  3622. this._segments = [];
  3623. /** @hidden */
  3624. this._compiled = [];
  3625. this.pattern = pattern;
  3626. this.config = common_1.defaults(this.config, {
  3627. params: {},
  3628. strict: true,
  3629. caseInsensitive: false,
  3630. paramMap: common_1.identity
  3631. });
  3632. // Find all placeholders and create a compiled pattern, using either classic or curly syntax:
  3633. // '*' name
  3634. // ':' name
  3635. // '{' name '}'
  3636. // '{' name ':' regexp '}'
  3637. // The regular expression is somewhat complicated due to the need to allow curly braces
  3638. // inside the regular expression. The placeholder regexp breaks down as follows:
  3639. // ([:*])([\w\[\]]+) - classic placeholder ($1 / $2) (search version has - for snake-case)
  3640. // \{([\w\[\]]+)(?:\:\s*( ... ))?\} - curly brace placeholder ($3) with optional regexp/type ... ($4) (search version has - for snake-case
  3641. // (?: ... | ... | ... )+ - the regexp consists of any number of atoms, an atom being either
  3642. // [^{}\\]+ - anything other than curly braces or backslash
  3643. // \\. - a backslash escape
  3644. // \{(?:[^{}\\]+|\\.)*\} - a matched set of curly braces containing other atoms
  3645. var placeholder = /([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g, searchPlaceholder = /([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g, last = 0, m, patterns = [];
  3646. var checkParamErrors = function (id) {
  3647. if (!UrlMatcher.nameValidator.test(id))
  3648. throw new Error("Invalid parameter name '" + id + "' in pattern '" + pattern + "'");
  3649. if (common_1.find(_this._params, hof_1.propEq('id', id)))
  3650. throw new Error("Duplicate parameter name '" + id + "' in pattern '" + pattern + "'");
  3651. };
  3652. // Split into static segments separated by path parameter placeholders.
  3653. // The number of segments is always 1 more than the number of parameters.
  3654. var matchDetails = function (m, isSearch) {
  3655. // IE[78] returns '' for unmatched groups instead of null
  3656. var id = m[2] || m[3], regexp = isSearch ? m[4] : m[4] || (m[1] === '*' ? '.*' : null);
  3657. return {
  3658. id: id,
  3659. regexp: regexp,
  3660. cfg: _this.config.params[id],
  3661. segment: pattern.substring(last, m.index),
  3662. type: !regexp ? null : paramTypes.type(regexp || "string") || common_1.inherit(paramTypes.type("string"), {
  3663. pattern: new RegExp(regexp, _this.config.caseInsensitive ? 'i' : undefined)
  3664. })
  3665. };
  3666. };
  3667. var p, segment;
  3668. while ((m = placeholder.exec(pattern))) {
  3669. p = matchDetails(m, false);
  3670. if (p.segment.indexOf('?') >= 0)
  3671. break; // we're into the search part
  3672. checkParamErrors(p.id);
  3673. this._params.push(param_1.Param.fromPath(p.id, p.type, this.config.paramMap(p.cfg, false), paramTypes));
  3674. this._segments.push(p.segment);
  3675. patterns.push([p.segment, common_1.tail(this._params)]);
  3676. last = placeholder.lastIndex;
  3677. }
  3678. segment = pattern.substring(last);
  3679. // Find any search parameter names and remove them from the last segment
  3680. var i = segment.indexOf('?');
  3681. if (i >= 0) {
  3682. var search = segment.substring(i);
  3683. segment = segment.substring(0, i);
  3684. if (search.length > 0) {
  3685. last = 0;
  3686. while ((m = searchPlaceholder.exec(search))) {
  3687. p = matchDetails(m, true);
  3688. checkParamErrors(p.id);
  3689. this._params.push(param_1.Param.fromSearch(p.id, p.type, this.config.paramMap(p.cfg, true), paramTypes));
  3690. last = placeholder.lastIndex;
  3691. }
  3692. }
  3693. }
  3694. this._segments.push(segment);
  3695. common_1.extend(this, {
  3696. _compiled: patterns.map(function (pattern) { return quoteRegExp.apply(null, pattern); }).concat(quoteRegExp(segment)),
  3697. prefix: this._segments[0]
  3698. });
  3699. Object.freeze(this);
  3700. }
  3701. /**
  3702. * Creates a new concatenated UrlMatcher
  3703. *
  3704. * Builds a new UrlMatcher by appending another UrlMatcher to this one.
  3705. *
  3706. * @param url A `UrlMatcher` instance to append as a child of the current `UrlMatcher`.
  3707. */
  3708. UrlMatcher.prototype.append = function (url) {
  3709. this._children.push(url);
  3710. common_1.forEach(url._cache, function (val, key) { return url._cache[key] = predicates_1.isArray(val) ? [] : null; });
  3711. url._cache.path = this._cache.path.concat(this);
  3712. return url;
  3713. };
  3714. /** @hidden */
  3715. UrlMatcher.prototype.isRoot = function () {
  3716. return this._cache.path.length === 0;
  3717. };
  3718. /** Returns the input pattern string */
  3719. UrlMatcher.prototype.toString = function () {
  3720. return this.pattern;
  3721. };
  3722. /**
  3723. * Tests the specified url/path against this matcher.
  3724. *
  3725. * Tests if the given url matches this matcher's pattern, and returns an object containing the captured
  3726. * parameter values. Returns null if the path does not match.
  3727. *
  3728. * The returned object contains the values
  3729. * of any search parameters that are mentioned in the pattern, but their value may be null if
  3730. * they are not present in `search`. This means that search parameters are always treated
  3731. * as optional.
  3732. *
  3733. * @example
  3734. * ```js
  3735. *
  3736. * new UrlMatcher('/user/{id}?q&r').exec('/user/bob', {
  3737. * x: '1', q: 'hello'
  3738. * });
  3739. * // returns { id: 'bob', q: 'hello', r: null }
  3740. * ```
  3741. *
  3742. * @param path The URL path to match, e.g. `$location.path()`.
  3743. * @param search URL search parameters, e.g. `$location.search()`.
  3744. * @param hash URL hash e.g. `$location.hash()`.
  3745. * @param options
  3746. *
  3747. * @returns The captured parameter values.
  3748. */
  3749. UrlMatcher.prototype.exec = function (path, search, hash, options) {
  3750. var _this = this;
  3751. if (search === void 0) { search = {}; }
  3752. if (options === void 0) { options = {}; }
  3753. var match = memoizeTo(this._cache, 'pattern', function () {
  3754. return new RegExp([
  3755. '^',
  3756. common_1.unnest(_this._cache.path.concat(_this).map(hof_1.prop('_compiled'))).join(''),
  3757. _this.config.strict === false ? '\/?' : '',
  3758. '$'
  3759. ].join(''), _this.config.caseInsensitive ? 'i' : undefined);
  3760. }).exec(path);
  3761. if (!match)
  3762. return null;
  3763. //options = defaults(options, { isolate: false });
  3764. var allParams = this.parameters(), pathParams = allParams.filter(function (param) { return !param.isSearch(); }), searchParams = allParams.filter(function (param) { return param.isSearch(); }), nPathSegments = this._cache.path.concat(this).map(function (urlm) { return urlm._segments.length - 1; }).reduce(function (a, x) { return a + x; }), values = {};
  3765. if (nPathSegments !== match.length - 1)
  3766. throw new Error("Unbalanced capture group in route '" + this.pattern + "'");
  3767. function decodePathArray(string) {
  3768. var reverseString = function (str) { return str.split("").reverse().join(""); };
  3769. var unquoteDashes = function (str) { return str.replace(/\\-/g, "-"); };
  3770. var split = reverseString(string).split(/-(?!\\)/);
  3771. var allReversed = common_1.map(split, reverseString);
  3772. return common_1.map(allReversed, unquoteDashes).reverse();
  3773. }
  3774. for (var i = 0; i < nPathSegments; i++) {
  3775. var param = pathParams[i];
  3776. var value = match[i + 1];
  3777. // if the param value matches a pre-replace pair, replace the value before decoding.
  3778. for (var j = 0; j < param.replace.length; j++) {
  3779. if (param.replace[j].from === value)
  3780. value = param.replace[j].to;
  3781. }
  3782. if (value && param.array === true)
  3783. value = decodePathArray(value);
  3784. if (predicates_2.isDefined(value))
  3785. value = param.type.decode(value);
  3786. values[param.id] = param.value(value);
  3787. }
  3788. searchParams.forEach(function (param) {
  3789. var value = search[param.id];
  3790. for (var j = 0; j < param.replace.length; j++) {
  3791. if (param.replace[j].from === value)
  3792. value = param.replace[j].to;
  3793. }
  3794. if (predicates_2.isDefined(value))
  3795. value = param.type.decode(value);
  3796. values[param.id] = param.value(value);
  3797. });
  3798. if (hash)
  3799. values["#"] = hash;
  3800. return values;
  3801. };
  3802. /**
  3803. * @hidden
  3804. * Returns all the [[Param]] objects of all path and search parameters of this pattern in order of appearance.
  3805. *
  3806. * @returns {Array.<Param>} An array of [[Param]] objects. Must be treated as read-only. If the
  3807. * pattern has no parameters, an empty array is returned.
  3808. */
  3809. UrlMatcher.prototype.parameters = function (opts) {
  3810. if (opts === void 0) { opts = {}; }
  3811. if (opts.inherit === false)
  3812. return this._params;
  3813. return common_1.unnest(this._cache.path.concat(this).map(hof_1.prop('_params')));
  3814. };
  3815. /**
  3816. * @hidden
  3817. * Returns a single parameter from this UrlMatcher by id
  3818. *
  3819. * @param id
  3820. * @param opts
  3821. * @returns {T|Param|any|boolean|UrlMatcher|null}
  3822. */
  3823. UrlMatcher.prototype.parameter = function (id, opts) {
  3824. if (opts === void 0) { opts = {}; }
  3825. var parent = common_1.tail(this._cache.path);
  3826. return (common_1.find(this._params, hof_1.propEq('id', id)) ||
  3827. (opts.inherit !== false && parent && parent.parameter(id)) ||
  3828. null);
  3829. };
  3830. /**
  3831. * Validates the input parameter values against this UrlMatcher
  3832. *
  3833. * Checks an object hash of parameters to validate their correctness according to the parameter
  3834. * types of this `UrlMatcher`.
  3835. *
  3836. * @param params The object hash of parameters to validate.
  3837. * @returns Returns `true` if `params` validates, otherwise `false`.
  3838. */
  3839. UrlMatcher.prototype.validates = function (params) {
  3840. var _this = this;
  3841. var validParamVal = function (param, val) {
  3842. return !param || param.validates(val);
  3843. };
  3844. return common_1.pairs(params || {}).map(function (_a) {
  3845. var key = _a[0], val = _a[1];
  3846. return validParamVal(_this.parameter(key), val);
  3847. }).reduce(common_1.allTrueR, true);
  3848. };
  3849. /**
  3850. * Given a set of parameter values, creates a URL from this UrlMatcher.
  3851. *
  3852. * Creates a URL that matches this pattern by substituting the specified values
  3853. * for the path and search parameters.
  3854. *
  3855. * @example
  3856. * ```js
  3857. *
  3858. * new UrlMatcher('/user/{id}?q').format({ id:'bob', q:'yes' });
  3859. * // returns '/user/bob?q=yes'
  3860. * ```
  3861. *
  3862. * @param values the values to substitute for the parameters in this pattern.
  3863. * @returns the formatted URL (path and optionally search part).
  3864. */
  3865. UrlMatcher.prototype.format = function (values) {
  3866. if (values === void 0) { values = {}; }
  3867. if (!this.validates(values))
  3868. return null;
  3869. // Build the full path of UrlMatchers (including all parent UrlMatchers)
  3870. var urlMatchers = this._cache.path.slice().concat(this);
  3871. // Extract all the static segments and Params into an ordered array
  3872. var pathSegmentsAndParams = urlMatchers.map(UrlMatcher.pathSegmentsAndParams).reduce(common_2.unnestR, []);
  3873. // Extract the query params into a separate array
  3874. var queryParams = urlMatchers.map(UrlMatcher.queryParams).reduce(common_2.unnestR, []);
  3875. /**
  3876. * Given a Param,
  3877. * Applies the parameter value, then returns details about it
  3878. */
  3879. function getDetails(param) {
  3880. // Normalize to typed value
  3881. var value = param.value(values[param.id]);
  3882. var isDefaultValue = param.isDefaultValue(value);
  3883. // Check if we're in squash mode for the parameter
  3884. var squash = isDefaultValue ? param.squash : false;
  3885. // Allow the Parameter's Type to encode the value
  3886. var encoded = param.type.encode(value);
  3887. return { param: param, value: value, isDefaultValue: isDefaultValue, squash: squash, encoded: encoded };
  3888. }
  3889. // Build up the path-portion from the list of static segments and parameters
  3890. var pathString = pathSegmentsAndParams.reduce(function (acc, x) {
  3891. // The element is a static segment (a raw string); just append it
  3892. if (predicates_1.isString(x))
  3893. return acc + x;
  3894. // Otherwise, it's a Param. Fetch details about the parameter value
  3895. var _a = getDetails(x), squash = _a.squash, encoded = _a.encoded, param = _a.param;
  3896. // If squash is === true, try to remove a slash from the path
  3897. if (squash === true)
  3898. return (acc.match(/\/$/)) ? acc.slice(0, -1) : acc;
  3899. // If squash is a string, use the string for the param value
  3900. if (predicates_1.isString(squash))
  3901. return acc + squash;
  3902. if (squash !== false)
  3903. return acc; // ?
  3904. if (encoded == null)
  3905. return acc;
  3906. // If this parameter value is an array, encode the value using encodeDashes
  3907. if (predicates_1.isArray(encoded))
  3908. return acc + common_1.map(encoded, UrlMatcher.encodeDashes).join("-");
  3909. // If the parameter type is "raw", then do not encodeURIComponent
  3910. if (param.type.raw)
  3911. return acc + encoded;
  3912. // Encode the value
  3913. return acc + encodeURIComponent(encoded);
  3914. }, "");
  3915. // Build the query string by applying parameter values (array or regular)
  3916. // then mapping to key=value, then flattening and joining using "&"
  3917. var queryString = queryParams.map(function (param) {
  3918. var _a = getDetails(param), squash = _a.squash, encoded = _a.encoded, isDefaultValue = _a.isDefaultValue;
  3919. if (encoded == null || (isDefaultValue && squash !== false))
  3920. return;
  3921. if (!predicates_1.isArray(encoded))
  3922. encoded = [encoded];
  3923. if (encoded.length === 0)
  3924. return;
  3925. if (!param.type.raw)
  3926. encoded = common_1.map(encoded, encodeURIComponent);
  3927. return encoded.map(function (val) { return (param.id + "=" + val); });
  3928. }).filter(common_1.identity).reduce(common_2.unnestR, []).join("&");
  3929. // Concat the pathstring with the queryString (if exists) and the hashString (if exists)
  3930. return pathString + (queryString ? "?" + queryString : "") + (values["#"] ? "#" + values["#"] : "");
  3931. };
  3932. /** @hidden */
  3933. UrlMatcher.encodeDashes = function (str) {
  3934. return encodeURIComponent(str).replace(/-/g, function (c) { return ("%5C%" + c.charCodeAt(0).toString(16).toUpperCase()); });
  3935. };
  3936. /** @hidden Given a matcher, return an array with the matcher's path segments and path params, in order */
  3937. UrlMatcher.pathSegmentsAndParams = function (matcher) {
  3938. var staticSegments = matcher._segments;
  3939. var pathParams = matcher._params.filter(function (p) { return p.location === param_2.DefType.PATH; });
  3940. return common_3.arrayTuples(staticSegments, pathParams.concat(undefined)).reduce(common_2.unnestR, []).filter(function (x) { return x !== "" && predicates_2.isDefined(x); });
  3941. };
  3942. /** @hidden Given a matcher, return an array with the matcher's query params */
  3943. UrlMatcher.queryParams = function (matcher) {
  3944. return matcher._params.filter(function (p) { return p.location === param_2.DefType.SEARCH; });
  3945. };
  3946. /** @hidden */
  3947. UrlMatcher.nameValidator = /^\w+([-.]+\w+)*(?:\[\])?$/;
  3948. return UrlMatcher;
  3949. }());
  3950. exports.UrlMatcher = UrlMatcher;
  3951. /***/ },
  3952. /* 28 */
  3953. /***/ function(module, exports, __webpack_require__) {
  3954. "use strict";
  3955. /** @module params */ /** for typedoc */
  3956. var common_1 = __webpack_require__(3);
  3957. var predicates_1 = __webpack_require__(4);
  3958. var hof_1 = __webpack_require__(5);
  3959. var coreservices_1 = __webpack_require__(6);
  3960. var type_1 = __webpack_require__(24);
  3961. // Use tildes to pre-encode slashes.
  3962. // If the slashes are simply URLEncoded, the browser can choose to pre-decode them,
  3963. // and bidirectional encoding/decoding fails.
  3964. // Tilde was chosen because it's not a RFC 3986 section 2.2 Reserved Character
  3965. function valToString(val) { return val != null ? val.toString().replace(/(~|\/)/g, function (m) { return ({ '~': '~~', '/': '~2F' }[m]); }) : val; }
  3966. function valFromString(val) { return val != null ? val.toString().replace(/(~~|~2F)/g, function (m) { return ({ '~~': '~', '~2F': '/' }[m]); }) : val; }
  3967. var ParamTypes = (function () {
  3968. function ParamTypes() {
  3969. this.enqueue = true;
  3970. this.typeQueue = [];
  3971. this.defaultTypes = {
  3972. "hash": {
  3973. encode: valToString,
  3974. decode: valFromString,
  3975. is: hof_1.is(String),
  3976. pattern: /.*/,
  3977. equals: function (a, b) { return a == b; } // allow coersion for null/undefined/""
  3978. },
  3979. "string": {
  3980. encode: valToString,
  3981. decode: valFromString,
  3982. is: hof_1.is(String),
  3983. pattern: /[^/]*/
  3984. },
  3985. "int": {
  3986. encode: valToString,
  3987. decode: function (val) { return parseInt(val, 10); },
  3988. is: function (val) { return predicates_1.isDefined(val) && this.decode(val.toString()) === val; },
  3989. pattern: /-?\d+/
  3990. },
  3991. "bool": {
  3992. encode: function (val) { return val && 1 || 0; },
  3993. decode: function (val) { return parseInt(val, 10) !== 0; },
  3994. is: hof_1.is(Boolean),
  3995. pattern: /0|1/
  3996. },
  3997. "date": {
  3998. encode: function (val) {
  3999. return !this.is(val) ? undefined : [
  4000. val.getFullYear(),
  4001. ('0' + (val.getMonth() + 1)).slice(-2),
  4002. ('0' + val.getDate()).slice(-2)
  4003. ].join("-");
  4004. },
  4005. decode: function (val) {
  4006. if (this.is(val))
  4007. return val;
  4008. var match = this.capture.exec(val);
  4009. return match ? new Date(match[1], match[2] - 1, match[3]) : undefined;
  4010. },
  4011. is: function (val) { return val instanceof Date && !isNaN(val.valueOf()); },
  4012. equals: function (l, r) {
  4013. return ['getFullYear', 'getMonth', 'getDate']
  4014. .reduce(function (acc, fn) { return acc && l[fn]() === r[fn](); }, true);
  4015. },
  4016. pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,
  4017. capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/
  4018. },
  4019. "json": {
  4020. encode: common_1.toJson,
  4021. decode: common_1.fromJson,
  4022. is: hof_1.is(Object),
  4023. equals: common_1.equals,
  4024. pattern: /[^/]*/
  4025. },
  4026. "any": {
  4027. encode: common_1.identity,
  4028. decode: common_1.identity,
  4029. equals: common_1.equals,
  4030. pattern: /.*/
  4031. }
  4032. };
  4033. // Register default types. Store them in the prototype of this.types.
  4034. var makeType = function (definition, name) { return new type_1.ParamType(common_1.extend({ name: name }, definition)); };
  4035. this.types = common_1.inherit(common_1.map(this.defaultTypes, makeType), {});
  4036. }
  4037. ParamTypes.prototype.type = function (name, definition, definitionFn) {
  4038. if (!predicates_1.isDefined(definition))
  4039. return this.types[name];
  4040. if (this.types.hasOwnProperty(name))
  4041. throw new Error("A type named '" + name + "' has already been defined.");
  4042. this.types[name] = new type_1.ParamType(common_1.extend({ name: name }, definition));
  4043. if (definitionFn) {
  4044. this.typeQueue.push({ name: name, def: definitionFn });
  4045. if (!this.enqueue)
  4046. this._flushTypeQueue();
  4047. }
  4048. return this;
  4049. };
  4050. ParamTypes.prototype._flushTypeQueue = function () {
  4051. while (this.typeQueue.length) {
  4052. var type = this.typeQueue.shift();
  4053. if (type.pattern)
  4054. throw new Error("You cannot override a type's .pattern at runtime.");
  4055. common_1.extend(this.types[type.name], coreservices_1.services.$injector.invoke(type.def));
  4056. }
  4057. };
  4058. return ParamTypes;
  4059. }());
  4060. exports.ParamTypes = ParamTypes;
  4061. /***/ },
  4062. /* 29 */
  4063. /***/ function(module, exports, __webpack_require__) {
  4064. "use strict";
  4065. /** @module url */ /** for typedoc */
  4066. var common_1 = __webpack_require__(3);
  4067. var predicates_1 = __webpack_require__(4);
  4068. var coreservices_1 = __webpack_require__(6);
  4069. /** @hidden */
  4070. var $location = coreservices_1.services.location;
  4071. /** @hidden Returns a string that is a prefix of all strings matching the RegExp */
  4072. function regExpPrefix(re) {
  4073. var prefix = /^\^((?:\\[^a-zA-Z0-9]|[^\\\[\]\^$*+?.()|{}]+)*)/.exec(re.source);
  4074. return (prefix != null) ? prefix[1].replace(/\\(.)/g, "$1") : '';
  4075. }
  4076. /** @hidden Interpolates matched values into a String.replace()-style pattern */
  4077. function interpolate(pattern, match) {
  4078. return pattern.replace(/\$(\$|\d{1,2})/, function (m, what) {
  4079. return match[what === '$' ? 0 : Number(what)];
  4080. });
  4081. }
  4082. /** @hidden */
  4083. function handleIfMatch($injector, $stateParams, handler, match) {
  4084. if (!match)
  4085. return false;
  4086. var result = $injector.invoke(handler, handler, { $match: match, $stateParams: $stateParams });
  4087. return predicates_1.isDefined(result) ? result : true;
  4088. }
  4089. /** @hidden */
  4090. function appendBasePath(url, isHtml5, absolute) {
  4091. var baseHref = coreservices_1.services.locationConfig.baseHref();
  4092. if (baseHref === '/')
  4093. return url;
  4094. if (isHtml5)
  4095. return baseHref.slice(0, -1) + url;
  4096. if (absolute)
  4097. return baseHref.slice(1) + url;
  4098. return url;
  4099. }
  4100. // TODO: Optimize groups of rules with non-empty prefix into some sort of decision tree
  4101. /** @hidden */
  4102. function update(rules, otherwiseFn, evt) {
  4103. if (evt && evt.defaultPrevented)
  4104. return;
  4105. function check(rule) {
  4106. var handled = rule(coreservices_1.services.$injector, $location);
  4107. if (!handled)
  4108. return false;
  4109. if (predicates_1.isString(handled)) {
  4110. $location.setUrl(handled, true);
  4111. }
  4112. return true;
  4113. }
  4114. var n = rules.length;
  4115. for (var i = 0; i < n; i++) {
  4116. if (check(rules[i]))
  4117. return;
  4118. }
  4119. // always check otherwise last to allow dynamic updates to the set of rules
  4120. if (otherwiseFn)
  4121. check(otherwiseFn);
  4122. }
  4123. /**
  4124. * Manages rules for client-side URL
  4125. *
  4126. * This class manages the router rules for what to do when the URL changes.
  4127. */
  4128. var UrlRouterProvider = (function () {
  4129. function UrlRouterProvider($urlMatcherFactory, $stateParams) {
  4130. /** @hidden */
  4131. this.rules = [];
  4132. /** @hidden */
  4133. this.interceptDeferred = false;
  4134. this.$urlMatcherFactory = $urlMatcherFactory;
  4135. this.$stateParams = $stateParams;
  4136. }
  4137. /**
  4138. * Registers a url handler function.
  4139. *
  4140. * Registers a low level url handler (a `rule`). A rule detects specific URL patterns and returns
  4141. * a redirect, or performs some action.
  4142. *
  4143. * If a rule returns a string, the URL is replaced with the string, and all rules are fired again.
  4144. *
  4145. * @example
  4146. * ```js
  4147. *
  4148. * var app = angular.module('app', ['ui.router.router']);
  4149. *
  4150. * app.config(function ($urlRouterProvider) {
  4151. * // Here's an example of how you might allow case insensitive urls
  4152. * $urlRouterProvider.rule(function ($injector, $location) {
  4153. * var path = $location.path(),
  4154. * normalized = path.toLowerCase();
  4155. *
  4156. * if (path !== normalized) {
  4157. * return normalized;
  4158. * }
  4159. * });
  4160. * });
  4161. * ```
  4162. *
  4163. * @param rule
  4164. * Handler function that takes `$injector` and `$location` services as arguments.
  4165. * You can use them to detect a url and return a different url as a string.
  4166. *
  4167. * @return [[$urlRouterProvider]] (`this`)
  4168. */
  4169. UrlRouterProvider.prototype.rule = function (rule) {
  4170. if (!predicates_1.isFunction(rule))
  4171. throw new Error("'rule' must be a function");
  4172. this.rules.push(rule);
  4173. return this;
  4174. };
  4175. ;
  4176. /**
  4177. * Remove a rule previously registered
  4178. *
  4179. * @param rule the matcher rule that was previously registered using [[rule]]
  4180. * @return true if the rule was found (and removed)
  4181. */
  4182. UrlRouterProvider.prototype.removeRule = function (rule) {
  4183. return this.rules.length !== common_1.removeFrom(this.rules, rule).length;
  4184. };
  4185. /**
  4186. * Defines the path or behavior to use when no url can be matched.
  4187. *
  4188. * @example
  4189. * ```js
  4190. *
  4191. * var app = angular.module('app', ['ui.router.router']);
  4192. *
  4193. * app.config(function ($urlRouterProvider) {
  4194. * // if the path doesn't match any of the urls you configured
  4195. * // otherwise will take care of routing the user to the
  4196. * // specified url
  4197. * $urlRouterProvider.otherwise('/index');
  4198. *
  4199. * // Example of using function rule as param
  4200. * $urlRouterProvider.otherwise(function ($injector, $location) {
  4201. * return '/a/valid/url';
  4202. * });
  4203. * });
  4204. * ```
  4205. *
  4206. * @param rule
  4207. * The url path you want to redirect to or a function rule that returns the url path or performs a `$state.go()`.
  4208. * The function version is passed two params: `$injector` and `$location` services, and should return a url string.
  4209. *
  4210. * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
  4211. */
  4212. UrlRouterProvider.prototype.otherwise = function (rule) {
  4213. if (!predicates_1.isFunction(rule) && !predicates_1.isString(rule))
  4214. throw new Error("'rule' must be a string or function");
  4215. this.otherwiseFn = predicates_1.isString(rule) ? function () { return rule; } : rule;
  4216. return this;
  4217. };
  4218. ;
  4219. /**
  4220. * Registers a handler for a given url matching.
  4221. *
  4222. * If the handler is a string, it is
  4223. * treated as a redirect, and is interpolated according to the syntax of match
  4224. * (i.e. like `String.replace()` for `RegExp`, or like a `UrlMatcher` pattern otherwise).
  4225. *
  4226. * If the handler is a function, it is injectable.
  4227. * It gets invoked if `$location` matches.
  4228. * You have the option of inject the match object as `$match`.
  4229. *
  4230. * The handler can return
  4231. *
  4232. * - **falsy** to indicate that the rule didn't match after all, then `$urlRouter`
  4233. * will continue trying to find another one that matches.
  4234. * - **string** which is treated as a redirect and passed to `$location.url()`
  4235. * - **void** or any **truthy** value tells `$urlRouter` that the url was handled.
  4236. *
  4237. * @example
  4238. * ```js
  4239. *
  4240. * var app = angular.module('app', ['ui.router.router']);
  4241. *
  4242. * app.config(function ($urlRouterProvider) {
  4243. * $urlRouterProvider.when($state.url, function ($match, $stateParams) {
  4244. * if ($state.$current.navigable !== state ||
  4245. * !equalForKeys($match, $stateParams) {
  4246. * $state.transitionTo(state, $match, false);
  4247. * }
  4248. * });
  4249. * });
  4250. * ```
  4251. *
  4252. * @param what A pattern string to match, compiled as a [[UrlMatcher]].
  4253. * @param handler The path (or function that returns a path) that you want to redirect your user to.
  4254. * @param ruleCallback [optional] A callback that receives the `rule` registered with [[UrlMatcher.rule]]
  4255. *
  4256. * Note: the handler may also invoke arbitrary code, such as `$state.go()`
  4257. */
  4258. UrlRouterProvider.prototype.when = function (what, handler, ruleCallback) {
  4259. if (ruleCallback === void 0) { ruleCallback = function (rule) { }; }
  4260. var _a = this, $urlMatcherFactory = _a.$urlMatcherFactory, $stateParams = _a.$stateParams;
  4261. var redirect, handlerIsString = predicates_1.isString(handler);
  4262. // @todo Queue this
  4263. if (predicates_1.isString(what))
  4264. what = $urlMatcherFactory.compile(what);
  4265. if (!handlerIsString && !predicates_1.isFunction(handler) && !predicates_1.isArray(handler))
  4266. throw new Error("invalid 'handler' in when()");
  4267. var strategies = {
  4268. matcher: function (_what, _handler) {
  4269. if (handlerIsString) {
  4270. redirect = $urlMatcherFactory.compile(_handler);
  4271. _handler = ['$match', redirect.format.bind(redirect)];
  4272. }
  4273. return common_1.extend(function () {
  4274. return handleIfMatch(coreservices_1.services.$injector, $stateParams, _handler, _what.exec($location.path(), $location.search(), $location.hash()));
  4275. }, {
  4276. prefix: predicates_1.isString(_what.prefix) ? _what.prefix : ''
  4277. });
  4278. },
  4279. regex: function (_what, _handler) {
  4280. if (_what.global || _what.sticky)
  4281. throw new Error("when() RegExp must not be global or sticky");
  4282. if (handlerIsString) {
  4283. redirect = _handler;
  4284. _handler = ['$match', function ($match) { return interpolate(redirect, $match); }];
  4285. }
  4286. return common_1.extend(function () {
  4287. return handleIfMatch(coreservices_1.services.$injector, $stateParams, _handler, _what.exec($location.path()));
  4288. }, {
  4289. prefix: regExpPrefix(_what)
  4290. });
  4291. }
  4292. };
  4293. var check = {
  4294. matcher: $urlMatcherFactory.isMatcher(what),
  4295. regex: what instanceof RegExp
  4296. };
  4297. for (var n in check) {
  4298. if (check[n]) {
  4299. var rule = strategies[n](what, handler);
  4300. ruleCallback(rule);
  4301. return this.rule(rule);
  4302. }
  4303. }
  4304. throw new Error("invalid 'what' in when()");
  4305. };
  4306. ;
  4307. /**
  4308. * Disables monitoring of the URL.
  4309. *
  4310. * Call this method before UI-Router has bootstrapped.
  4311. * It will stop UI-Router from performing the initial url sync.
  4312. *
  4313. * This can be useful to perform some asynchronous initialization before the router starts.
  4314. * Once the initialization is complete, call [[listen]] to tell UI-Router to start watching and synchronizing the URL.
  4315. *
  4316. * @example
  4317. * ```js
  4318. *
  4319. * var app = angular.module('app', ['ui.router']);
  4320. *
  4321. * app.config(function ($urlRouterProvider) {
  4322. * // Prevent $urlRouter from automatically intercepting URL changes;
  4323. * $urlRouterProvider.deferIntercept();
  4324. * })
  4325. *
  4326. * app.run(function (MyService, $urlRouter, $http) {
  4327. * $http.get("/stuff").then(function(resp) {
  4328. * MyService.doStuff(resp.data);
  4329. * $urlRouter.listen();
  4330. * $urlRouter.sync();
  4331. * });
  4332. * });
  4333. * ```
  4334. *
  4335. * @param defer Indicates whether to defer location change interception. Passing
  4336. * no parameter is equivalent to `true`.
  4337. */
  4338. UrlRouterProvider.prototype.deferIntercept = function (defer) {
  4339. if (defer === undefined)
  4340. defer = true;
  4341. this.interceptDeferred = defer;
  4342. };
  4343. ;
  4344. return UrlRouterProvider;
  4345. }());
  4346. exports.UrlRouterProvider = UrlRouterProvider;
  4347. var UrlRouter = (function () {
  4348. /** @hidden */
  4349. function UrlRouter(urlRouterProvider) {
  4350. this.urlRouterProvider = urlRouterProvider;
  4351. common_1.bindFunctions(UrlRouter.prototype, this, this);
  4352. }
  4353. /**
  4354. * Checks the current URL for a matching rule
  4355. *
  4356. * Triggers an update; the same update that happens when the address bar url changes, aka `$locationChangeSuccess`.
  4357. * This method is useful when you need to use `preventDefault()` on the `$locationChangeSuccess` event,
  4358. * perform some custom logic (route protection, auth, config, redirection, etc) and then finally proceed
  4359. * with the transition by calling `$urlRouter.sync()`.
  4360. *
  4361. * @example
  4362. * ```js
  4363. *
  4364. * angular.module('app', ['ui.router'])
  4365. * .run(function($rootScope, $urlRouter) {
  4366. * $rootScope.$on('$locationChangeSuccess', function(evt) {
  4367. * // Halt state change from even starting
  4368. * evt.preventDefault();
  4369. * // Perform custom logic
  4370. * var meetsRequirement = ...
  4371. * // Continue with the update and state transition if logic allows
  4372. * if (meetsRequirement) $urlRouter.sync();
  4373. * });
  4374. * });
  4375. * ```
  4376. */
  4377. UrlRouter.prototype.sync = function () {
  4378. update(this.urlRouterProvider.rules, this.urlRouterProvider.otherwiseFn);
  4379. };
  4380. /**
  4381. * Starts listening for URL changes
  4382. *
  4383. * Call this sometime after calling [[deferIntercept]] to start monitoring the url.
  4384. * This causes [[UrlRouter]] to start listening for changes to the URL, if it wasn't already listening.
  4385. */
  4386. UrlRouter.prototype.listen = function () {
  4387. var _this = this;
  4388. return this.listener = this.listener || $location.onChange(function (evt) { return update(_this.urlRouterProvider.rules, _this.urlRouterProvider.otherwiseFn, evt); });
  4389. };
  4390. /**
  4391. * Internal API.
  4392. */
  4393. UrlRouter.prototype.update = function (read) {
  4394. if (read) {
  4395. this.location = $location.path();
  4396. return;
  4397. }
  4398. if ($location.path() === this.location)
  4399. return;
  4400. $location.setUrl(this.location, true);
  4401. };
  4402. /**
  4403. * Internal API.
  4404. *
  4405. * Pushes a new location to the browser history.
  4406. *
  4407. * @param urlMatcher
  4408. * @param params
  4409. * @param options
  4410. */
  4411. UrlRouter.prototype.push = function (urlMatcher, params, options) {
  4412. var replace = options && !!options.replace;
  4413. $location.setUrl(urlMatcher.format(params || {}), replace);
  4414. };
  4415. /**
  4416. * Builds and returns a URL with interpolated parameters
  4417. *
  4418. * @example
  4419. * ```js
  4420. *
  4421. * $bob = $urlRouter.href(new UrlMatcher("/about/:person"), {
  4422. * person: "bob"
  4423. * });
  4424. * // $bob == "/about/bob";
  4425. * ```
  4426. *
  4427. * @param urlMatcher The [[UrlMatcher]] object which is used as the template of the URL to generate.
  4428. * @param params An object of parameter values to fill the matcher's required parameters.
  4429. * @param options Options object. The options are:
  4430. *
  4431. * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
  4432. *
  4433. * @returns Returns the fully compiled URL, or `null` if `params` fail validation against `urlMatcher`
  4434. */
  4435. UrlRouter.prototype.href = function (urlMatcher, params, options) {
  4436. if (!urlMatcher.validates(params))
  4437. return null;
  4438. var url = urlMatcher.format(params);
  4439. options = options || { absolute: false };
  4440. var cfg = coreservices_1.services.locationConfig;
  4441. var isHtml5 = cfg.html5Mode();
  4442. if (!isHtml5 && url !== null) {
  4443. url = "#" + cfg.hashPrefix() + url;
  4444. }
  4445. url = appendBasePath(url, isHtml5, options.absolute);
  4446. if (!options.absolute || !url) {
  4447. return url;
  4448. }
  4449. var slash = (!isHtml5 && url ? '/' : ''), port = cfg.port();
  4450. port = (port === 80 || port === 443 ? '' : ':' + port);
  4451. return [cfg.protocol(), '://', cfg.host(), port, slash, url].join('');
  4452. };
  4453. return UrlRouter;
  4454. }());
  4455. exports.UrlRouter = UrlRouter;
  4456. /***/ },
  4457. /* 30 */
  4458. /***/ function(module, exports, __webpack_require__) {
  4459. "use strict";
  4460. var transition_1 = __webpack_require__(11);
  4461. var hookRegistry_1 = __webpack_require__(15);
  4462. var resolve_1 = __webpack_require__(31);
  4463. var views_1 = __webpack_require__(32);
  4464. var url_1 = __webpack_require__(33);
  4465. var redirectTo_1 = __webpack_require__(34);
  4466. var onEnterExitRetain_1 = __webpack_require__(35);
  4467. var lazyLoadStates_1 = __webpack_require__(36);
  4468. /**
  4469. * The default [[Transition]] options.
  4470. *
  4471. * Include this object when applying custom defaults:
  4472. * let reloadOpts = { reload: true, notify: true }
  4473. * let options = defaults(theirOpts, customDefaults, defaultOptions);
  4474. */
  4475. exports.defaultTransOpts = {
  4476. location: true,
  4477. relative: null,
  4478. inherit: false,
  4479. notify: true,
  4480. reload: false,
  4481. custom: {},
  4482. current: function () { return null; },
  4483. source: "unknown"
  4484. };
  4485. /**
  4486. * This class provides services related to Transitions.
  4487. *
  4488. * - Most importantly, it allows global Transition Hooks to be registered.
  4489. * - It allows the default transition error handler to be set.
  4490. * - It also has a factory function for creating new [[Transition]] objects, (used internally by the [[StateService]]).
  4491. *
  4492. * At bootstrap, [[UIRouter]] creates a single instance (singleton) of this class.
  4493. */
  4494. var TransitionService = (function () {
  4495. function TransitionService(_router) {
  4496. this._router = _router;
  4497. this.$view = _router.viewService;
  4498. hookRegistry_1.HookRegistry.mixin(new hookRegistry_1.HookRegistry(), this);
  4499. this._deregisterHookFns = {};
  4500. this.registerTransitionHooks();
  4501. }
  4502. /** @hidden */
  4503. TransitionService.prototype.registerTransitionHooks = function () {
  4504. var fns = this._deregisterHookFns;
  4505. // Wire up redirectTo hook
  4506. fns.redirectTo = redirectTo_1.registerRedirectToHook(this);
  4507. // Wire up onExit/Retain/Enter state hooks
  4508. fns.onExit = onEnterExitRetain_1.registerOnExitHook(this);
  4509. fns.onRetain = onEnterExitRetain_1.registerOnRetainHook(this);
  4510. fns.onEnter = onEnterExitRetain_1.registerOnEnterHook(this);
  4511. // Wire up Resolve hooks
  4512. fns.eagerResolve = resolve_1.registerEagerResolvePath(this);
  4513. fns.lazyResolve = resolve_1.registerLazyResolveState(this);
  4514. // Wire up the View management hooks
  4515. fns.loadViews = views_1.registerLoadEnteringViews(this);
  4516. fns.activateViews = views_1.registerActivateViews(this);
  4517. // After globals.current is updated at priority: 10000
  4518. fns.updateUrl = url_1.registerUpdateUrl(this);
  4519. // Lazy load state trees
  4520. fns.lazyLoad = lazyLoadStates_1.registerLazyLoadHook(this);
  4521. };
  4522. /** @inheritdoc */
  4523. TransitionService.prototype.onBefore = function (matchCriteria, callback, options) { throw ""; };
  4524. ;
  4525. /** @inheritdoc */
  4526. TransitionService.prototype.onStart = function (matchCriteria, callback, options) { throw ""; };
  4527. ;
  4528. /** @inheritdoc */
  4529. TransitionService.prototype.onExit = function (matchCriteria, callback, options) { throw ""; };
  4530. ;
  4531. /** @inheritdoc */
  4532. TransitionService.prototype.onRetain = function (matchCriteria, callback, options) { throw ""; };
  4533. ;
  4534. /** @inheritdoc */
  4535. TransitionService.prototype.onEnter = function (matchCriteria, callback, options) { throw ""; };
  4536. ;
  4537. /** @inheritdoc */
  4538. TransitionService.prototype.onFinish = function (matchCriteria, callback, options) { throw ""; };
  4539. ;
  4540. /** @inheritdoc */
  4541. TransitionService.prototype.onSuccess = function (matchCriteria, callback, options) { throw ""; };
  4542. ;
  4543. /** @inheritdoc */
  4544. TransitionService.prototype.onError = function (matchCriteria, callback, options) { throw ""; };
  4545. ;
  4546. /**
  4547. * Creates a new [[Transition]] object
  4548. *
  4549. * This is a factory function for creating new Transition objects.
  4550. * It is used internally by the [[StateService]] and should generally not be called by application code.
  4551. *
  4552. * @param fromPath the path to the current state (the from state)
  4553. * @param targetState the target state (destination)
  4554. * @returns a Transition
  4555. */
  4556. TransitionService.prototype.create = function (fromPath, targetState) {
  4557. return new transition_1.Transition(fromPath, targetState, this._router);
  4558. };
  4559. return TransitionService;
  4560. }());
  4561. exports.TransitionService = TransitionService;
  4562. /***/ },
  4563. /* 31 */
  4564. /***/ function(module, exports, __webpack_require__) {
  4565. "use strict";
  4566. /** @module hooks */ /** for typedoc */
  4567. var common_1 = __webpack_require__(3);
  4568. var resolveContext_1 = __webpack_require__(17);
  4569. var hof_1 = __webpack_require__(5);
  4570. /**
  4571. * A [[TransitionHookFn]] which resolves all EAGER Resolvables in the To Path
  4572. *
  4573. * Registered using `transitionService.onStart({}, eagerResolvePath);`
  4574. *
  4575. * When a Transition starts, this hook resolves all the EAGER Resolvables, which the transition then waits for.
  4576. *
  4577. * See [[StateDeclaration.resolve]]
  4578. */
  4579. var eagerResolvePath = function (trans) {
  4580. return new resolveContext_1.ResolveContext(trans.treeChanges().to)
  4581. .resolvePath("EAGER", trans)
  4582. .then(common_1.noop);
  4583. };
  4584. exports.registerEagerResolvePath = function (transitionService) {
  4585. return transitionService.onStart({}, eagerResolvePath, { priority: 1000 });
  4586. };
  4587. /**
  4588. * A [[TransitionHookFn]] which resolves all LAZY Resolvables for the state (and all its ancestors) in the To Path
  4589. *
  4590. * Registered using `transitionService.onEnter({ entering: () => true }, lazyResolveState);`
  4591. *
  4592. * When a State is being entered, this hook resolves all the Resolvables for this state, which the transition then waits for.
  4593. *
  4594. * See [[StateDeclaration.resolve]]
  4595. */
  4596. var lazyResolveState = function (trans, state) {
  4597. return new resolveContext_1.ResolveContext(trans.treeChanges().to)
  4598. .subContext(state)
  4599. .resolvePath("LAZY", trans)
  4600. .then(common_1.noop);
  4601. };
  4602. exports.registerLazyResolveState = function (transitionService) {
  4603. return transitionService.onEnter({ entering: hof_1.val(true) }, lazyResolveState, { priority: 1000 });
  4604. };
  4605. /***/ },
  4606. /* 32 */
  4607. /***/ function(module, exports, __webpack_require__) {
  4608. "use strict";
  4609. /** @module hooks */ /** for typedoc */
  4610. var common_1 = __webpack_require__(3);
  4611. var coreservices_1 = __webpack_require__(6);
  4612. /**
  4613. * A [[TransitionHookFn]] which waits for the views to load
  4614. *
  4615. * Registered using `transitionService.onStart({}, loadEnteringViews);`
  4616. *
  4617. * Allows the views to do async work in [[ViewConfig.load]] before the transition continues.
  4618. * In angular 1, this includes loading the templates.
  4619. */
  4620. var loadEnteringViews = function (transition) {
  4621. var enteringViews = transition.views("entering");
  4622. if (!enteringViews.length)
  4623. return;
  4624. return coreservices_1.services.$q.all(enteringViews.map(function (view) { return view.load(); })).then(common_1.noop);
  4625. };
  4626. exports.registerLoadEnteringViews = function (transitionService) {
  4627. return transitionService.onStart({}, loadEnteringViews);
  4628. };
  4629. /**
  4630. * A [[TransitionHookFn]] which activates the new views when a transition is successful.
  4631. *
  4632. * Registered using `transitionService.onSuccess({}, activateViews);`
  4633. *
  4634. * After a transition is complete, this hook deactivates the old views from the previous state,
  4635. * and activates the new views from the destination state.
  4636. *
  4637. * See [[ViewService]]
  4638. */
  4639. var activateViews = function (transition) {
  4640. var enteringViews = transition.views("entering");
  4641. var exitingViews = transition.views("exiting");
  4642. if (!enteringViews.length && !exitingViews.length)
  4643. return;
  4644. var $view = transition.router.viewService;
  4645. exitingViews.forEach(function (vc) { return $view.deactivateViewConfig(vc); });
  4646. enteringViews.forEach(function (vc) { return $view.activateViewConfig(vc); });
  4647. $view.sync();
  4648. };
  4649. exports.registerActivateViews = function (transitionService) {
  4650. return transitionService.onSuccess({}, activateViews);
  4651. };
  4652. /***/ },
  4653. /* 33 */
  4654. /***/ function(module, exports) {
  4655. "use strict";
  4656. /**
  4657. * A [[TransitionHookFn]] which updates the URL after a successful transition
  4658. *
  4659. * Registered using `transitionService.onSuccess({}, updateUrl);`
  4660. */
  4661. var updateUrl = function (transition) {
  4662. var options = transition.options();
  4663. var $state = transition.router.stateService;
  4664. var $urlRouter = transition.router.urlRouter;
  4665. // Dont update the url in these situations:
  4666. // The transition was triggered by a URL sync (options.source === 'url')
  4667. // The user doesn't want the url to update (options.location === false)
  4668. // The destination state, and all parents have no navigable url
  4669. if (options.source !== 'url' && options.location && $state.$current.navigable) {
  4670. var urlOptions = { replace: options.location === 'replace' };
  4671. $urlRouter.push($state.$current.navigable.url, $state.params, urlOptions);
  4672. }
  4673. $urlRouter.update(true);
  4674. };
  4675. exports.registerUpdateUrl = function (transitionService) {
  4676. return transitionService.onSuccess({}, updateUrl, { priority: 9999 });
  4677. };
  4678. /***/ },
  4679. /* 34 */
  4680. /***/ function(module, exports, __webpack_require__) {
  4681. "use strict";
  4682. /** @module hooks */ /** */
  4683. var predicates_1 = __webpack_require__(4);
  4684. var coreservices_1 = __webpack_require__(6);
  4685. var targetState_1 = __webpack_require__(14);
  4686. /**
  4687. * A [[TransitionHookFn]] that redirects to a different state or params
  4688. *
  4689. * Registered using `transitionService.onStart({ to: (state) => !!state.redirectTo }, redirectHook);`
  4690. *
  4691. * See [[StateDeclaration.redirectTo]]
  4692. */
  4693. var redirectToHook = function (trans) {
  4694. var redirect = trans.to().redirectTo;
  4695. if (!redirect)
  4696. return;
  4697. function handleResult(result) {
  4698. var $state = trans.router.stateService;
  4699. if (result instanceof targetState_1.TargetState)
  4700. return result;
  4701. if (predicates_1.isString(result))
  4702. return $state.target(result, trans.params(), trans.options());
  4703. if (result['state'] || result['params'])
  4704. return $state.target(result['state'] || trans.to(), result['params'] || trans.params(), trans.options());
  4705. }
  4706. if (predicates_1.isFunction(redirect)) {
  4707. return coreservices_1.services.$q.when(redirect(trans)).then(handleResult);
  4708. }
  4709. return handleResult(redirect);
  4710. };
  4711. exports.registerRedirectToHook = function (transitionService) {
  4712. return transitionService.onStart({ to: function (state) { return !!state.redirectTo; } }, redirectToHook);
  4713. };
  4714. /***/ },
  4715. /* 35 */
  4716. /***/ function(module, exports) {
  4717. "use strict";
  4718. /**
  4719. * A factory which creates an onEnter, onExit or onRetain transition hook function
  4720. *
  4721. * The returned function invokes the (for instance) state.onEnter hook when the
  4722. * state is being entered.
  4723. *
  4724. * @hidden
  4725. */
  4726. function makeEnterExitRetainHook(hookName) {
  4727. return function (transition, state) {
  4728. var hookFn = state[hookName];
  4729. return hookFn(transition, state);
  4730. };
  4731. }
  4732. /**
  4733. * The [[TransitionStateHookFn]] for onExit
  4734. *
  4735. * When the state is being exited, the state's .onExit function is invoked.
  4736. *
  4737. * Registered using `transitionService.onExit({ exiting: (state) => !!state.onExit }, onExitHook);`
  4738. *
  4739. * See: [[IHookRegistry.onExit]]
  4740. */
  4741. var onExitHook = makeEnterExitRetainHook('onExit');
  4742. exports.registerOnExitHook = function (transitionService) {
  4743. return transitionService.onExit({ exiting: function (state) { return !!state.onExit; } }, onExitHook);
  4744. };
  4745. /**
  4746. * The [[TransitionStateHookFn]] for onRetain
  4747. *
  4748. * When the state was already entered, and is not being exited or re-entered, the state's .onRetain function is invoked.
  4749. *
  4750. * Registered using `transitionService.onRetain({ retained: (state) => !!state.onRetain }, onRetainHook);`
  4751. *
  4752. * See: [[IHookRegistry.onRetain]]
  4753. */
  4754. var onRetainHook = makeEnterExitRetainHook('onRetain');
  4755. exports.registerOnRetainHook = function (transitionService) {
  4756. return transitionService.onRetain({ retained: function (state) { return !!state.onRetain; } }, onRetainHook);
  4757. };
  4758. /**
  4759. * The [[TransitionStateHookFn]] for onEnter
  4760. *
  4761. * When the state is being entered, the state's .onEnter function is invoked.
  4762. *
  4763. * Registered using `transitionService.onEnter({ entering: (state) => !!state.onEnter }, onEnterHook);`
  4764. *
  4765. * See: [[IHookRegistry.onEnter]]
  4766. */
  4767. var onEnterHook = makeEnterExitRetainHook('onEnter');
  4768. exports.registerOnEnterHook = function (transitionService) {
  4769. return transitionService.onEnter({ entering: function (state) { return !!state.onEnter; } }, onEnterHook);
  4770. };
  4771. /***/ },
  4772. /* 36 */
  4773. /***/ function(module, exports, __webpack_require__) {
  4774. "use strict";
  4775. var coreservices_1 = __webpack_require__(6);
  4776. /**
  4777. * A [[TransitionHookFn]] that lazy loads a state tree.
  4778. *
  4779. * When transitioning to a state "abc" which has a `lazyLoad` function defined:
  4780. * - Invoke the `lazyLoad` function
  4781. * - The function should return a promise for an array of lazy loaded [[StateDeclaration]]s
  4782. * - Wait for the promise to resolve
  4783. * - Deregister the original state "abc"
  4784. * - The original state definition is a placeholder for the lazy loaded states
  4785. * - Register the new states
  4786. * - Retry the transition
  4787. *
  4788. * See [[StateDeclaration.lazyLoad]]
  4789. */
  4790. var lazyLoadHook = function (transition) {
  4791. var toState = transition.to();
  4792. var registry = transition.router.stateRegistry;
  4793. function retryOriginalTransition() {
  4794. if (transition.options().source === 'url') {
  4795. var loc = coreservices_1.services.location, path_1 = loc.path(), search_1 = loc.search(), hash_1 = loc.hash();
  4796. var matchState = function (state) { return [state, state.url && state.url.exec(path_1, search_1, hash_1)]; };
  4797. var matches = registry.get().map(function (s) { return s.$$state(); }).map(matchState).filter(function (_a) {
  4798. var state = _a[0], params = _a[1];
  4799. return !!params;
  4800. });
  4801. if (matches.length) {
  4802. var _a = matches[0], state = _a[0], params = _a[1];
  4803. return transition.router.stateService.target(state, params, transition.options());
  4804. }
  4805. transition.router.urlRouter.sync();
  4806. }
  4807. // The original transition was not triggered via url sync
  4808. // The lazy state should be loaded now, so re-try the original transition
  4809. var orig = transition.targetState();
  4810. return transition.router.stateService.target(orig.identifier(), orig.params(), orig.options());
  4811. }
  4812. /**
  4813. * Replace the placeholder state with the newly loaded states from the NgModule.
  4814. */
  4815. function updateStateRegistry(result) {
  4816. // deregister placeholder state
  4817. registry.deregister(transition.$to());
  4818. if (result && Array.isArray(result.states)) {
  4819. result.states.forEach(function (state) { return registry.register(state); });
  4820. }
  4821. }
  4822. var hook = toState.lazyLoad;
  4823. // Store/get the lazy load promise on/from the hookfn so it doesn't get re-invoked
  4824. var promise = hook['_promise'];
  4825. if (!promise) {
  4826. promise = hook['_promise'] = hook(transition).then(updateStateRegistry);
  4827. var cleanup = function () { return delete hook['_promise']; };
  4828. promise.then(cleanup, cleanup);
  4829. }
  4830. return promise.then(retryOriginalTransition);
  4831. };
  4832. exports.registerLazyLoadHook = function (transitionService) {
  4833. return transitionService.onBefore({ to: function (state) { return !!state.lazyLoad; } }, lazyLoadHook);
  4834. };
  4835. /***/ },
  4836. /* 37 */
  4837. /***/ function(module, exports, __webpack_require__) {
  4838. "use strict";
  4839. /** @module view */ /** for typedoc */
  4840. var common_1 = __webpack_require__(3);
  4841. var hof_1 = __webpack_require__(5);
  4842. var predicates_1 = __webpack_require__(4);
  4843. var trace_1 = __webpack_require__(12);
  4844. /**
  4845. * The View service
  4846. */
  4847. var ViewService = (function () {
  4848. function ViewService() {
  4849. var _this = this;
  4850. this.uiViews = [];
  4851. this.viewConfigs = [];
  4852. this._viewConfigFactories = {};
  4853. this.sync = function () {
  4854. var uiViewsByFqn = _this.uiViews.map(function (uiv) { return [uiv.fqn, uiv]; }).reduce(common_1.applyPairs, {});
  4855. /**
  4856. * Given a ui-view and a ViewConfig, determines if they "match".
  4857. *
  4858. * A ui-view has a fully qualified name (fqn) and a context object. The fqn is built from its overall location in
  4859. * the DOM, describing its nesting relationship to any parent ui-view tags it is nested inside of.
  4860. *
  4861. * A ViewConfig has a target ui-view name and a context anchor. The ui-view name can be a simple name, or
  4862. * can be a segmented ui-view path, describing a portion of a ui-view fqn.
  4863. *
  4864. * In order for a ui-view to match ViewConfig, ui-view's $type must match the ViewConfig's $type
  4865. *
  4866. * If the ViewConfig's target ui-view name is a simple name (no dots), then a ui-view matches if:
  4867. * - the ui-view's name matches the ViewConfig's target name
  4868. * - the ui-view's context matches the ViewConfig's anchor
  4869. *
  4870. * If the ViewConfig's target ui-view name is a segmented name (with dots), then a ui-view matches if:
  4871. * - There exists a parent ui-view where:
  4872. * - the parent ui-view's name matches the first segment (index 0) of the ViewConfig's target name
  4873. * - the parent ui-view's context matches the ViewConfig's anchor
  4874. * - And the remaining segments (index 1..n) of the ViewConfig's target name match the tail of the ui-view's fqn
  4875. *
  4876. * Example:
  4877. *
  4878. * DOM:
  4879. * <div ui-view> <!-- created in the root context (name: "") -->
  4880. * <div ui-view="foo"> <!-- created in the context named: "A" -->
  4881. * <div ui-view> <!-- created in the context named: "A.B" -->
  4882. * <div ui-view="bar"> <!-- created in the context named: "A.B.C" -->
  4883. * </div>
  4884. * </div>
  4885. * </div>
  4886. * </div>
  4887. *
  4888. * uiViews: [
  4889. * { fqn: "$default", creationContext: { name: "" } },
  4890. * { fqn: "$default.foo", creationContext: { name: "A" } },
  4891. * { fqn: "$default.foo.$default", creationContext: { name: "A.B" } }
  4892. * { fqn: "$default.foo.$default.bar", creationContext: { name: "A.B.C" } }
  4893. * ]
  4894. *
  4895. * These four view configs all match the ui-view with the fqn: "$default.foo.$default.bar":
  4896. *
  4897. * - ViewConfig1: { uiViewName: "bar", uiViewContextAnchor: "A.B.C" }
  4898. * - ViewConfig2: { uiViewName: "$default.bar", uiViewContextAnchor: "A.B" }
  4899. * - ViewConfig3: { uiViewName: "foo.$default.bar", uiViewContextAnchor: "A" }
  4900. * - ViewConfig4: { uiViewName: "$default.foo.$default.bar", uiViewContextAnchor: "" }
  4901. *
  4902. * Using ViewConfig3 as an example, it matches the ui-view with fqn "$default.foo.$default.bar" because:
  4903. * - The ViewConfig's segmented target name is: [ "foo", "$default", "bar" ]
  4904. * - There exists a parent ui-view (which has fqn: "$default.foo") where:
  4905. * - the parent ui-view's name "foo" matches the first segment "foo" of the ViewConfig's target name
  4906. * - the parent ui-view's context "A" matches the ViewConfig's anchor context "A"
  4907. * - And the remaining segments [ "$default", "bar" ].join("."_ of the ViewConfig's target name match
  4908. * the tail of the ui-view's fqn "default.bar"
  4909. */
  4910. var matches = function (uiView) { return function (viewConfig) {
  4911. // Don't supply an ng1 ui-view with an ng2 ViewConfig, etc
  4912. if (uiView.$type !== viewConfig.viewDecl.$type)
  4913. return false;
  4914. // Split names apart from both viewConfig and uiView into segments
  4915. var vc = viewConfig.viewDecl;
  4916. var vcSegments = vc.$uiViewName.split(".");
  4917. var uivSegments = uiView.fqn.split(".");
  4918. // Check if the tails of the segment arrays match. ex, these arrays' tails match:
  4919. // vc: ["foo", "bar"], uiv fqn: ["$default", "foo", "bar"]
  4920. if (!common_1.equals(vcSegments, uivSegments.slice(0 - vcSegments.length)))
  4921. return false;
  4922. // Now check if the fqn ending at the first segment of the viewConfig matches the context:
  4923. // ["$default", "foo"].join(".") == "$default.foo", does the ui-view $default.foo context match?
  4924. var negOffset = (1 - vcSegments.length) || undefined;
  4925. var fqnToFirstSegment = uivSegments.slice(0, negOffset).join(".");
  4926. var uiViewContext = uiViewsByFqn[fqnToFirstSegment].creationContext;
  4927. return vc.$uiViewContextAnchor === (uiViewContext && uiViewContext.name);
  4928. }; };
  4929. // Return the number of dots in the fully qualified name
  4930. function uiViewDepth(uiView) {
  4931. return uiView.fqn.split(".").length;
  4932. }
  4933. // Return the ViewConfig's context's depth in the context tree.
  4934. function viewConfigDepth(config) {
  4935. var context = config.viewDecl.$context, count = 0;
  4936. while (++count && context.parent)
  4937. context = context.parent;
  4938. return count;
  4939. }
  4940. // Given a depth function, returns a compare function which can return either ascending or descending order
  4941. var depthCompare = hof_1.curry(function (depthFn, posNeg, left, right) { return posNeg * (depthFn(left) - depthFn(right)); });
  4942. var matchingConfigPair = function (uiView) {
  4943. var matchingConfigs = _this.viewConfigs.filter(matches(uiView));
  4944. if (matchingConfigs.length > 1)
  4945. matchingConfigs.sort(depthCompare(viewConfigDepth, -1)); // descending
  4946. return [uiView, matchingConfigs[0]];
  4947. };
  4948. var configureUIView = function (_a) {
  4949. var uiView = _a[0], viewConfig = _a[1];
  4950. // If a parent ui-view is reconfigured, it could destroy child ui-views.
  4951. // Before configuring a child ui-view, make sure it's still in the active uiViews array.
  4952. if (_this.uiViews.indexOf(uiView) !== -1)
  4953. uiView.configUpdated(viewConfig);
  4954. };
  4955. _this.uiViews.sort(depthCompare(uiViewDepth, 1)).map(matchingConfigPair).forEach(configureUIView);
  4956. };
  4957. }
  4958. ViewService.prototype.rootContext = function (context) {
  4959. return this._rootContext = context || this._rootContext;
  4960. };
  4961. ;
  4962. ViewService.prototype.viewConfigFactory = function (viewType, factory) {
  4963. this._viewConfigFactories[viewType] = factory;
  4964. };
  4965. ViewService.prototype.createViewConfig = function (path, decl) {
  4966. var cfgFactory = this._viewConfigFactories[decl.$type];
  4967. if (!cfgFactory)
  4968. throw new Error("ViewService: No view config factory registered for type " + decl.$type);
  4969. var cfgs = cfgFactory(path, decl);
  4970. return predicates_1.isArray(cfgs) ? cfgs : [cfgs];
  4971. };
  4972. /**
  4973. * De-registers a ViewConfig.
  4974. *
  4975. * @param viewConfig The ViewConfig view to deregister.
  4976. */
  4977. ViewService.prototype.deactivateViewConfig = function (viewConfig) {
  4978. trace_1.trace.traceViewServiceEvent("<- Removing", viewConfig);
  4979. common_1.removeFrom(this.viewConfigs, viewConfig);
  4980. };
  4981. ;
  4982. ViewService.prototype.activateViewConfig = function (viewConfig) {
  4983. trace_1.trace.traceViewServiceEvent("-> Registering", viewConfig);
  4984. this.viewConfigs.push(viewConfig);
  4985. };
  4986. ;
  4987. /**
  4988. * Allows a `ui-view` element to register its canonical name with a callback that allows it to
  4989. * be updated with a template, controller, and local variables.
  4990. *
  4991. * @param {String} name The fully-qualified name of the `ui-view` object being registered.
  4992. * @param {Function} configUpdatedCallback A callback that receives updates to the content & configuration
  4993. * of the view.
  4994. * @return {Function} Returns a de-registration function used when the view is destroyed.
  4995. */
  4996. ViewService.prototype.registerUIView = function (uiView) {
  4997. trace_1.trace.traceViewServiceUIViewEvent("-> Registering", uiView);
  4998. var uiViews = this.uiViews;
  4999. var fqnMatches = function (uiv) { return uiv.fqn === uiView.fqn; };
  5000. if (uiViews.filter(fqnMatches).length)
  5001. trace_1.trace.traceViewServiceUIViewEvent("!!!! duplicate uiView named:", uiView);
  5002. uiViews.push(uiView);
  5003. this.sync();
  5004. return function () {
  5005. var idx = uiViews.indexOf(uiView);
  5006. if (idx === -1) {
  5007. trace_1.trace.traceViewServiceUIViewEvent("Tried removing non-registered uiView", uiView);
  5008. return;
  5009. }
  5010. trace_1.trace.traceViewServiceUIViewEvent("<- Deregistering", uiView);
  5011. common_1.removeFrom(uiViews)(uiView);
  5012. };
  5013. };
  5014. ;
  5015. /**
  5016. * Returns the list of views currently available on the page, by fully-qualified name.
  5017. *
  5018. * @return {Array} Returns an array of fully-qualified view names.
  5019. */
  5020. ViewService.prototype.available = function () {
  5021. return this.uiViews.map(hof_1.prop("fqn"));
  5022. };
  5023. /**
  5024. * Returns the list of views on the page containing loaded content.
  5025. *
  5026. * @return {Array} Returns an array of fully-qualified view names.
  5027. */
  5028. ViewService.prototype.active = function () {
  5029. return this.uiViews.filter(hof_1.prop("$config")).map(hof_1.prop("name"));
  5030. };
  5031. /**
  5032. * Normalizes a view's name from a state.views configuration block.
  5033. *
  5034. * @param context the context object (state declaration) that the view belongs to
  5035. * @param rawViewName the name of the view, as declared in the [[StateDeclaration.views]]
  5036. *
  5037. * @returns the normalized uiViewName and uiViewContextAnchor that the view targets
  5038. */
  5039. ViewService.normalizeUIViewTarget = function (context, rawViewName) {
  5040. if (rawViewName === void 0) { rawViewName = ""; }
  5041. // TODO: Validate incoming view name with a regexp to allow:
  5042. // ex: "view.name@foo.bar" , "^.^.view.name" , "view.name@^.^" , "" ,
  5043. // "@" , "$default@^" , "!$default.$default" , "!foo.bar"
  5044. var viewAtContext = rawViewName.split("@");
  5045. var uiViewName = viewAtContext[0] || "$default"; // default to unnamed view
  5046. var uiViewContextAnchor = predicates_1.isString(viewAtContext[1]) ? viewAtContext[1] : "^"; // default to parent context
  5047. // Handle relative view-name sugar syntax.
  5048. // Matches rawViewName "^.^.^.foo.bar" into array: ["^.^.^.foo.bar", "^.^.^", "foo.bar"],
  5049. var relativeViewNameSugar = /^(\^(?:\.\^)*)\.(.*$)/.exec(uiViewName);
  5050. if (relativeViewNameSugar) {
  5051. // Clobbers existing contextAnchor (rawViewName validation will fix this)
  5052. uiViewContextAnchor = relativeViewNameSugar[1]; // set anchor to "^.^.^"
  5053. uiViewName = relativeViewNameSugar[2]; // set view-name to "foo.bar"
  5054. }
  5055. if (uiViewName.charAt(0) === '!') {
  5056. uiViewName = uiViewName.substr(1);
  5057. uiViewContextAnchor = ""; // target absolutely from root
  5058. }
  5059. // handle parent relative targeting "^.^.^"
  5060. var relativeMatch = /^(\^(?:\.\^)*)$/;
  5061. if (relativeMatch.exec(uiViewContextAnchor)) {
  5062. var anchor = uiViewContextAnchor.split(".").reduce((function (anchor, x) { return anchor.parent; }), context);
  5063. uiViewContextAnchor = anchor.name;
  5064. }
  5065. return { uiViewName: uiViewName, uiViewContextAnchor: uiViewContextAnchor };
  5066. };
  5067. return ViewService;
  5068. }());
  5069. exports.ViewService = ViewService;
  5070. /***/ },
  5071. /* 38 */
  5072. /***/ function(module, exports, __webpack_require__) {
  5073. /** @module state */ /** for typedoc */
  5074. "use strict";
  5075. var stateMatcher_1 = __webpack_require__(39);
  5076. var stateBuilder_1 = __webpack_require__(40);
  5077. var stateQueueManager_1 = __webpack_require__(41);
  5078. var common_1 = __webpack_require__(3);
  5079. var StateRegistry = (function () {
  5080. function StateRegistry(urlMatcherFactory, urlRouterProvider) {
  5081. this.urlRouterProvider = urlRouterProvider;
  5082. this.states = {};
  5083. this.listeners = [];
  5084. this.matcher = new stateMatcher_1.StateMatcher(this.states);
  5085. this.builder = new stateBuilder_1.StateBuilder(this.matcher, urlMatcherFactory);
  5086. this.stateQueue = new stateQueueManager_1.StateQueueManager(this.states, this.builder, urlRouterProvider, this.listeners);
  5087. var rootStateDef = {
  5088. name: '',
  5089. url: '^',
  5090. views: null,
  5091. params: {
  5092. '#': { value: null, type: 'hash', dynamic: true }
  5093. },
  5094. abstract: true
  5095. };
  5096. var _root = this._root = this.stateQueue.register(rootStateDef);
  5097. _root.navigable = null;
  5098. }
  5099. /**
  5100. * Listen for a State Registry events
  5101. *
  5102. * Adds a callback that is invoked when states are registered or deregistered with the StateRegistry.
  5103. *
  5104. * @example
  5105. * ```js
  5106. *
  5107. * let allStates = registry.get();
  5108. *
  5109. * // Later, invoke deregisterFn() to remove the listener
  5110. * let deregisterFn = registry.onStatesChanged((event, states) => {
  5111. * switch(event) {
  5112. * case: 'registered':
  5113. * states.forEach(state => allStates.push(state));
  5114. * break;
  5115. * case: 'deregistered':
  5116. * states.forEach(state => {
  5117. * let idx = allStates.indexOf(state);
  5118. * if (idx !== -1) allStates.splice(idx, 1);
  5119. * });
  5120. * break;
  5121. * }
  5122. * });
  5123. * ```
  5124. *
  5125. * @param listener a callback function invoked when the registered states changes.
  5126. * The function receives two parameters, `event` and `state`.
  5127. * See [[StateRegistryListener]]
  5128. * @return a function that deregisters the listener
  5129. */
  5130. StateRegistry.prototype.onStatesChanged = function (listener) {
  5131. this.listeners.push(listener);
  5132. return function deregisterListener() {
  5133. common_1.removeFrom(this.listeners)(listener);
  5134. }.bind(this);
  5135. };
  5136. /**
  5137. * Gets the implicit root state
  5138. *
  5139. * Gets the root of the state tree.
  5140. * The root state is implicitly created by UI-Router.
  5141. * Note: this returns the internal [[State]] representation, not a [[StateDeclaration]]
  5142. *
  5143. * @return the root [[State]]
  5144. */
  5145. StateRegistry.prototype.root = function () {
  5146. return this._root;
  5147. };
  5148. /**
  5149. * Adds a state to the registry
  5150. *
  5151. * Registers a [[StateDefinition]] or queues it for registration.
  5152. *
  5153. * Note: a state will be queued if the state's parent isn't yet registered.
  5154. * It will also be queued if the queue is not yet in [[StateQueueManager.autoFlush]] mode.
  5155. *
  5156. * @param stateDefinition the definition of the state to register.
  5157. * @returns the internal [[State]] object.
  5158. * If the state was successfully registered, then the object is fully built (See: [[StateBuilder]]).
  5159. * If the state was only queued, then the object is not fully built.
  5160. */
  5161. StateRegistry.prototype.register = function (stateDefinition) {
  5162. return this.stateQueue.register(stateDefinition);
  5163. };
  5164. /** @hidden */
  5165. StateRegistry.prototype._deregisterTree = function (state) {
  5166. var _this = this;
  5167. var all = this.get().map(function (s) { return s.$$state(); });
  5168. var getChildren = function (states) {
  5169. var children = all.filter(function (s) { return states.indexOf(s.parent) !== -1; });
  5170. return children.length === 0 ? children : children.concat(getChildren(children));
  5171. };
  5172. var children = getChildren([state]);
  5173. var deregistered = [state].concat(children).reverse();
  5174. deregistered.forEach(function (state) {
  5175. _this.urlRouterProvider.removeRule(state._urlRule);
  5176. delete _this.states[state.name];
  5177. });
  5178. return deregistered;
  5179. };
  5180. /**
  5181. * Removes a state from the registry
  5182. *
  5183. * This removes a state from the registry.
  5184. * If the state has children, they are are also removed from the registry.
  5185. *
  5186. * @param stateOrName the state's name or object representation
  5187. * @returns {State[]} a list of removed states
  5188. */
  5189. StateRegistry.prototype.deregister = function (stateOrName) {
  5190. var _state = this.get(stateOrName);
  5191. if (!_state)
  5192. throw new Error("Can't deregister state; not found: " + stateOrName);
  5193. var deregisteredStates = this._deregisterTree(_state.$$state());
  5194. this.listeners.forEach(function (listener) { return listener("deregistered", deregisteredStates.map(function (s) { return s.self; })); });
  5195. return deregisteredStates;
  5196. };
  5197. StateRegistry.prototype.get = function (stateOrName, base) {
  5198. var _this = this;
  5199. if (arguments.length === 0)
  5200. return Object.keys(this.states).map(function (name) { return _this.states[name].self; });
  5201. var found = this.matcher.find(stateOrName, base);
  5202. return found && found.self || null;
  5203. };
  5204. StateRegistry.prototype.decorator = function (name, func) {
  5205. return this.builder.builder(name, func);
  5206. };
  5207. return StateRegistry;
  5208. }());
  5209. exports.StateRegistry = StateRegistry;
  5210. /***/ },
  5211. /* 39 */
  5212. /***/ function(module, exports, __webpack_require__) {
  5213. "use strict";
  5214. /** @module state */ /** for typedoc */
  5215. var predicates_1 = __webpack_require__(4);
  5216. var glob_1 = __webpack_require__(7);
  5217. var common_1 = __webpack_require__(3);
  5218. var StateMatcher = (function () {
  5219. function StateMatcher(_states) {
  5220. this._states = _states;
  5221. }
  5222. StateMatcher.prototype.isRelative = function (stateName) {
  5223. stateName = stateName || "";
  5224. return stateName.indexOf(".") === 0 || stateName.indexOf("^") === 0;
  5225. };
  5226. StateMatcher.prototype.find = function (stateOrName, base) {
  5227. if (!stateOrName && stateOrName !== "")
  5228. return undefined;
  5229. var isStr = predicates_1.isString(stateOrName);
  5230. var name = isStr ? stateOrName : stateOrName.name;
  5231. if (this.isRelative(name))
  5232. name = this.resolvePath(name, base);
  5233. var state = this._states[name];
  5234. if (state && (isStr || (!isStr && (state === stateOrName || state.self === stateOrName)))) {
  5235. return state;
  5236. }
  5237. else if (isStr) {
  5238. var matches = common_1.values(this._states)
  5239. .filter(function (state) { return new glob_1.Glob(state.name).matches(name); });
  5240. if (matches.length > 1) {
  5241. console.log("stateMatcher.find: Found multiple matches for " + name + " using glob: ", matches.map(function (match) { return match.name; }));
  5242. }
  5243. return matches[0];
  5244. }
  5245. return undefined;
  5246. };
  5247. StateMatcher.prototype.resolvePath = function (name, base) {
  5248. if (!base)
  5249. throw new Error("No reference point given for path '" + name + "'");
  5250. var baseState = this.find(base);
  5251. var splitName = name.split("."), i = 0, pathLength = splitName.length, current = baseState;
  5252. for (; i < pathLength; i++) {
  5253. if (splitName[i] === "" && i === 0) {
  5254. current = baseState;
  5255. continue;
  5256. }
  5257. if (splitName[i] === "^") {
  5258. if (!current.parent)
  5259. throw new Error("Path '" + name + "' not valid for state '" + baseState.name + "'");
  5260. current = current.parent;
  5261. continue;
  5262. }
  5263. break;
  5264. }
  5265. var relName = splitName.slice(i).join(".");
  5266. return current.name + (current.name && relName ? "." : "") + relName;
  5267. };
  5268. return StateMatcher;
  5269. }());
  5270. exports.StateMatcher = StateMatcher;
  5271. /***/ },
  5272. /* 40 */
  5273. /***/ function(module, exports, __webpack_require__) {
  5274. "use strict";
  5275. /** @module state */ /** for typedoc */
  5276. var common_1 = __webpack_require__(3);
  5277. var predicates_1 = __webpack_require__(4);
  5278. var strings_1 = __webpack_require__(9);
  5279. var hof_1 = __webpack_require__(5);
  5280. var param_1 = __webpack_require__(22);
  5281. var resolvable_1 = __webpack_require__(19);
  5282. var coreservices_1 = __webpack_require__(6);
  5283. var parseUrl = function (url) {
  5284. if (!predicates_1.isString(url))
  5285. return false;
  5286. var root = url.charAt(0) === '^';
  5287. return { val: root ? url.substring(1) : url, root: root };
  5288. };
  5289. function nameBuilder(state) {
  5290. if (state.lazyLoad)
  5291. state.name = state.self.name + ".**";
  5292. return state.name;
  5293. }
  5294. function selfBuilder(state) {
  5295. state.self.$$state = function () { return state; };
  5296. return state.self;
  5297. }
  5298. function dataBuilder(state) {
  5299. if (state.parent && state.parent.data) {
  5300. state.data = state.self.data = common_1.inherit(state.parent.data, state.data);
  5301. }
  5302. return state.data;
  5303. }
  5304. var getUrlBuilder = function ($urlMatcherFactoryProvider, root) {
  5305. return function urlBuilder(state) {
  5306. var stateDec = state;
  5307. if (stateDec && stateDec.url && stateDec.lazyLoad) {
  5308. stateDec.url += "{remainder:any}"; // match any path (.*)
  5309. }
  5310. var parsed = parseUrl(stateDec.url), parent = state.parent;
  5311. var url = !parsed ? stateDec.url : $urlMatcherFactoryProvider.compile(parsed.val, {
  5312. params: state.params || {},
  5313. paramMap: function (paramConfig, isSearch) {
  5314. if (stateDec.reloadOnSearch === false && isSearch)
  5315. paramConfig = common_1.extend(paramConfig || {}, { dynamic: true });
  5316. return paramConfig;
  5317. }
  5318. });
  5319. if (!url)
  5320. return null;
  5321. if (!$urlMatcherFactoryProvider.isMatcher(url))
  5322. throw new Error("Invalid url '" + url + "' in state '" + state + "'");
  5323. return (parsed && parsed.root) ? url : ((parent && parent.navigable) || root()).url.append(url);
  5324. };
  5325. };
  5326. var getNavigableBuilder = function (isRoot) {
  5327. return function navigableBuilder(state) {
  5328. return !isRoot(state) && state.url ? state : (state.parent ? state.parent.navigable : null);
  5329. };
  5330. };
  5331. var getParamsBuilder = function (paramTypes) {
  5332. return function paramsBuilder(state) {
  5333. var makeConfigParam = function (config, id) { return param_1.Param.fromConfig(id, null, config, paramTypes); };
  5334. var urlParams = (state.url && state.url.parameters({ inherit: false })) || [];
  5335. var nonUrlParams = common_1.values(common_1.mapObj(common_1.omit(state.params || {}, urlParams.map(hof_1.prop('id'))), makeConfigParam));
  5336. return urlParams.concat(nonUrlParams).map(function (p) { return [p.id, p]; }).reduce(common_1.applyPairs, {});
  5337. };
  5338. };
  5339. function pathBuilder(state) {
  5340. return state.parent ? state.parent.path.concat(state) : [state];
  5341. }
  5342. function includesBuilder(state) {
  5343. var includes = state.parent ? common_1.extend({}, state.parent.includes) : {};
  5344. includes[state.name] = true;
  5345. return includes;
  5346. }
  5347. /**
  5348. * This is a [[StateBuilder.builder]] function for the `resolve:` block on a [[StateDeclaration]].
  5349. *
  5350. * When the [[StateBuilder]] builds a [[State]] object from a raw [[StateDeclaration]], this builder
  5351. * validates the `resolve` property and converts it to a [[Resolvable]] array.
  5352. *
  5353. * resolve: input value can be:
  5354. *
  5355. * {
  5356. * // analyzed but not injected
  5357. * myFooResolve: function() { return "myFooData"; },
  5358. *
  5359. * // function.toString() parsed, "DependencyName" dep as string (not min-safe)
  5360. * myBarResolve: function(DependencyName) { return DependencyName.fetchSomethingAsPromise() },
  5361. *
  5362. * // Array split; "DependencyName" dep as string
  5363. * myBazResolve: [ "DependencyName", function(dep) { return dep.fetchSomethingAsPromise() },
  5364. *
  5365. * // Array split; DependencyType dep as token (compared using ===)
  5366. * myQuxResolve: [ DependencyType, function(dep) { return dep.fetchSometingAsPromise() },
  5367. *
  5368. * // val.$inject used as deps
  5369. * // where:
  5370. * // corgeResolve.$inject = ["DependencyName"];
  5371. * // function corgeResolve(dep) { dep.fetchSometingAsPromise() }
  5372. * // then "DependencyName" dep as string
  5373. * myCorgeResolve: corgeResolve,
  5374. *
  5375. * // inject service by name
  5376. * // When a string is found, desugar creating a resolve that injects the named service
  5377. * myGraultResolve: "SomeService"
  5378. * }
  5379. *
  5380. * or:
  5381. *
  5382. * [
  5383. * new Resolvable("myFooResolve", function() { return "myFooData" }),
  5384. * new Resolvable("myBarResolve", function(dep) { return dep.fetchSomethingAsPromise() }, [ "DependencyName" ]),
  5385. * { provide: "myBazResolve", useFactory: function(dep) { dep.fetchSomethingAsPromise() }, deps: [ "DependencyName" ] }
  5386. * ]
  5387. */
  5388. function resolvablesBuilder(state) {
  5389. /** convert resolve: {} and resolvePolicy: {} objects to an array of tuples */
  5390. var objects2Tuples = function (resolveObj, resolvePolicies) {
  5391. return Object.keys(resolveObj || {}).map(function (token) { return ({ token: token, val: resolveObj[token], deps: undefined, policy: resolvePolicies[token] }); });
  5392. };
  5393. /** fetch DI annotations from a function or ng1-style array */
  5394. var annotate = function (fn) {
  5395. return fn['$inject'] || coreservices_1.services.$injector.annotate(fn, coreservices_1.services.$injector.strictDi);
  5396. };
  5397. /** true if the object has both `token` and `resolveFn`, and is probably a [[ResolveLiteral]] */
  5398. var isResolveLiteral = function (obj) { return !!(obj.token && obj.resolveFn); };
  5399. /** true if the object looks like a provide literal, or a ng2 Provider */
  5400. var isLikeNg2Provider = function (obj) { return !!((obj.provide || obj.token) && (obj.useValue || obj.useFactory || obj.useExisting || obj.useClass)); };
  5401. /** true if the object looks like a tuple from obj2Tuples */
  5402. var isTupleFromObj = function (obj) { return !!(obj && obj.val && (predicates_1.isString(obj.val) || predicates_1.isArray(obj.val) || predicates_1.isFunction(obj.val))); };
  5403. /** extracts the token from a Provider or provide literal */
  5404. var token = function (p) { return p.provide || p.token; };
  5405. /** Given a literal resolve or provider object, returns a Resolvable */
  5406. var literal2Resolvable = hof_1.pattern([
  5407. [hof_1.prop('resolveFn'), function (p) { return new resolvable_1.Resolvable(token(p), p.resolveFn, p.deps, p.policy); }],
  5408. [hof_1.prop('useFactory'), function (p) { return new resolvable_1.Resolvable(token(p), p.useFactory, (p.deps || p.dependencies), p.policy); }],
  5409. [hof_1.prop('useClass'), function (p) { return new resolvable_1.Resolvable(token(p), function () { return new p.useClass(); }, [], p.policy); }],
  5410. [hof_1.prop('useValue'), function (p) { return new resolvable_1.Resolvable(token(p), function () { return p.useValue; }, [], p.policy, p.useValue); }],
  5411. [hof_1.prop('useExisting'), function (p) { return new resolvable_1.Resolvable(token(p), common_1.identity, [p.useExisting], p.policy); }],
  5412. ]);
  5413. var tuple2Resolvable = hof_1.pattern([
  5414. [hof_1.pipe(hof_1.prop("val"), predicates_1.isString), function (tuple) { return new resolvable_1.Resolvable(tuple.token, common_1.identity, [tuple.val], tuple.policy); }],
  5415. [hof_1.pipe(hof_1.prop("val"), predicates_1.isArray), function (tuple) { return new resolvable_1.Resolvable(tuple.token, common_1.tail(tuple.val), tuple.val.slice(0, -1), tuple.policy); }],
  5416. [hof_1.pipe(hof_1.prop("val"), predicates_1.isFunction), function (tuple) { return new resolvable_1.Resolvable(tuple.token, tuple.val, annotate(tuple.val), tuple.policy); }],
  5417. ]);
  5418. var item2Resolvable = hof_1.pattern([
  5419. [hof_1.is(resolvable_1.Resolvable), function (r) { return r; }],
  5420. [isResolveLiteral, literal2Resolvable],
  5421. [isLikeNg2Provider, literal2Resolvable],
  5422. [isTupleFromObj, tuple2Resolvable],
  5423. [hof_1.val(true), function (obj) { throw new Error("Invalid resolve value: " + strings_1.stringify(obj)); }]
  5424. ]);
  5425. // If resolveBlock is already an array, use it as-is.
  5426. // Otherwise, assume it's an object and convert to an Array of tuples
  5427. var decl = state.resolve;
  5428. var items = predicates_1.isArray(decl) ? decl : objects2Tuples(decl, state.resolvePolicy || {});
  5429. return items.map(item2Resolvable);
  5430. }
  5431. exports.resolvablesBuilder = resolvablesBuilder;
  5432. /**
  5433. * @internalapi A internal global service
  5434. *
  5435. * StateBuilder is a factory for the internal [[State]] objects.
  5436. *
  5437. * When you register a state with the [[StateRegistry]], you register a plain old javascript object which
  5438. * conforms to the [[StateDeclaration]] interface. This factory takes that object and builds the corresponding
  5439. * [[State]] object, which has an API and is used internally.
  5440. *
  5441. * Custom properties or API may be added to the internal [[State]] object by registering a decorator function
  5442. * using the [[builder]] method.
  5443. */
  5444. var StateBuilder = (function () {
  5445. function StateBuilder(matcher, $urlMatcherFactoryProvider) {
  5446. this.matcher = matcher;
  5447. var self = this;
  5448. var root = function () { return matcher.find(""); };
  5449. var isRoot = function (state) { return state.name === ""; };
  5450. function parentBuilder(state) {
  5451. if (isRoot(state))
  5452. return null;
  5453. return matcher.find(self.parentName(state)) || root();
  5454. }
  5455. this.builders = {
  5456. name: [nameBuilder],
  5457. self: [selfBuilder],
  5458. parent: [parentBuilder],
  5459. data: [dataBuilder],
  5460. // Build a URLMatcher if necessary, either via a relative or absolute URL
  5461. url: [getUrlBuilder($urlMatcherFactoryProvider, root)],
  5462. // Keep track of the closest ancestor state that has a URL (i.e. is navigable)
  5463. navigable: [getNavigableBuilder(isRoot)],
  5464. params: [getParamsBuilder($urlMatcherFactoryProvider.paramTypes)],
  5465. // Each framework-specific ui-router implementation should define its own `views` builder
  5466. // e.g., src/ng1/statebuilders/views.ts
  5467. views: [],
  5468. // Keep a full path from the root down to this state as this is needed for state activation.
  5469. path: [pathBuilder],
  5470. // Speed up $state.includes() as it's used a lot
  5471. includes: [includesBuilder],
  5472. resolvables: [resolvablesBuilder]
  5473. };
  5474. }
  5475. /**
  5476. * Registers a [[BuilderFunction]] for a specific [[State]] property (e.g., `parent`, `url`, or `path`).
  5477. * More than one BuilderFunction can be registered for a given property.
  5478. *
  5479. * The BuilderFunction(s) will be used to define the property on any subsequently built [[State]] objects.
  5480. *
  5481. * @param name The name of the State property being registered for.
  5482. * @param fn The BuilderFunction which will be used to build the State property
  5483. * @returns a function which deregisters the BuilderFunction
  5484. */
  5485. StateBuilder.prototype.builder = function (name, fn) {
  5486. var builders = this.builders;
  5487. var array = builders[name] || [];
  5488. // Backwards compat: if only one builder exists, return it, else return whole arary.
  5489. if (predicates_1.isString(name) && !predicates_1.isDefined(fn))
  5490. return array.length > 1 ? array : array[0];
  5491. if (!predicates_1.isString(name) || !predicates_1.isFunction(fn))
  5492. return;
  5493. builders[name] = array;
  5494. builders[name].push(fn);
  5495. return function () { return builders[name].splice(builders[name].indexOf(fn, 1)) && null; };
  5496. };
  5497. /**
  5498. * Builds all of the properties on an essentially blank State object, returning a State object which has all its
  5499. * properties and API built.
  5500. *
  5501. * @param state an uninitialized State object
  5502. * @returns the built State object
  5503. */
  5504. StateBuilder.prototype.build = function (state) {
  5505. var _a = this, matcher = _a.matcher, builders = _a.builders;
  5506. var parent = this.parentName(state);
  5507. if (parent && !matcher.find(parent))
  5508. return null;
  5509. for (var key in builders) {
  5510. if (!builders.hasOwnProperty(key))
  5511. continue;
  5512. var chain = builders[key].reduce(function (parentFn, step) { return function (_state) { return step(_state, parentFn); }; }, common_1.noop);
  5513. state[key] = chain(state);
  5514. }
  5515. return state;
  5516. };
  5517. StateBuilder.prototype.parentName = function (state) {
  5518. var name = state.name || "";
  5519. var segments = name.split('.');
  5520. if (segments.length > 1) {
  5521. if (state.parent) {
  5522. throw new Error("States that specify the 'parent:' property should not have a '.' in their name (" + name + ")");
  5523. }
  5524. var lastSegment = segments.pop();
  5525. if (lastSegment === '**')
  5526. segments.pop();
  5527. return segments.join(".");
  5528. }
  5529. if (!state.parent)
  5530. return "";
  5531. return predicates_1.isString(state.parent) ? state.parent : state.parent.name;
  5532. };
  5533. StateBuilder.prototype.name = function (state) {
  5534. var name = state.name;
  5535. if (name.indexOf('.') !== -1 || !state.parent)
  5536. return name;
  5537. var parentName = predicates_1.isString(state.parent) ? state.parent : state.parent.name;
  5538. return parentName ? parentName + "." + name : name;
  5539. };
  5540. return StateBuilder;
  5541. }());
  5542. exports.StateBuilder = StateBuilder;
  5543. /***/ },
  5544. /* 41 */
  5545. /***/ function(module, exports, __webpack_require__) {
  5546. "use strict";
  5547. /** @module state */ /** for typedoc */
  5548. var common_1 = __webpack_require__(3);
  5549. var predicates_1 = __webpack_require__(4);
  5550. var stateObject_1 = __webpack_require__(42);
  5551. var StateQueueManager = (function () {
  5552. function StateQueueManager(states, builder, $urlRouterProvider, listeners) {
  5553. this.states = states;
  5554. this.builder = builder;
  5555. this.$urlRouterProvider = $urlRouterProvider;
  5556. this.listeners = listeners;
  5557. this.queue = [];
  5558. }
  5559. StateQueueManager.prototype.register = function (config) {
  5560. var _a = this, states = _a.states, queue = _a.queue, $state = _a.$state;
  5561. // Wrap a new object around the state so we can store our private details easily.
  5562. // @TODO: state = new State(extend({}, config, { ... }))
  5563. var state = common_1.inherit(new stateObject_1.State(), common_1.extend({}, config, {
  5564. self: config,
  5565. resolve: config.resolve || [],
  5566. toString: function () { return config.name; }
  5567. }));
  5568. if (!predicates_1.isString(state.name))
  5569. throw new Error("State must have a valid name");
  5570. if (states.hasOwnProperty(state.name) || common_1.pluck(queue, 'name').indexOf(state.name) !== -1)
  5571. throw new Error("State '" + state.name + "' is already defined");
  5572. queue.push(state);
  5573. if (this.$state) {
  5574. this.flush($state);
  5575. }
  5576. return state;
  5577. };
  5578. StateQueueManager.prototype.flush = function ($state) {
  5579. var _a = this, queue = _a.queue, states = _a.states, builder = _a.builder;
  5580. var registered = [], // states that got registered
  5581. orphans = [], // states that dodn't yet have a parent registered
  5582. previousQueueLength = {}; // keep track of how long the queue when an orphan was first encountered
  5583. while (queue.length > 0) {
  5584. var state = queue.shift();
  5585. var result = builder.build(state);
  5586. var orphanIdx = orphans.indexOf(state);
  5587. if (result) {
  5588. if (states.hasOwnProperty(state.name))
  5589. throw new Error("State '" + name + "' is already defined");
  5590. states[state.name] = state;
  5591. this.attachRoute($state, state);
  5592. if (orphanIdx >= 0)
  5593. orphans.splice(orphanIdx, 1);
  5594. registered.push(state);
  5595. continue;
  5596. }
  5597. var prev = previousQueueLength[state.name];
  5598. previousQueueLength[state.name] = queue.length;
  5599. if (orphanIdx >= 0 && prev === queue.length) {
  5600. // Wait until two consecutive iterations where no additional states were dequeued successfully.
  5601. // throw new Error(`Cannot register orphaned state '${state.name}'`);
  5602. queue.push(state);
  5603. return states;
  5604. }
  5605. else if (orphanIdx < 0) {
  5606. orphans.push(state);
  5607. }
  5608. queue.push(state);
  5609. }
  5610. if (registered.length) {
  5611. this.listeners.forEach(function (listener) { return listener("registered", registered.map(function (s) { return s.self; })); });
  5612. }
  5613. return states;
  5614. };
  5615. StateQueueManager.prototype.autoFlush = function ($state) {
  5616. this.$state = $state;
  5617. this.flush($state);
  5618. };
  5619. StateQueueManager.prototype.attachRoute = function ($state, state) {
  5620. var $urlRouterProvider = this.$urlRouterProvider;
  5621. if (state.abstract || !state.url)
  5622. return;
  5623. $urlRouterProvider.when(state.url, ['$match', '$stateParams', function ($match, $stateParams) {
  5624. if ($state.$current.navigable !== state || !common_1.equalForKeys($match, $stateParams)) {
  5625. $state.transitionTo(state, $match, { inherit: true, source: "url" });
  5626. }
  5627. }], function (rule) { return state._urlRule = rule; });
  5628. };
  5629. return StateQueueManager;
  5630. }());
  5631. exports.StateQueueManager = StateQueueManager;
  5632. /***/ },
  5633. /* 42 */
  5634. /***/ function(module, exports, __webpack_require__) {
  5635. /** @module state */ /** for typedoc */
  5636. "use strict";
  5637. var common_1 = __webpack_require__(3);
  5638. var hof_1 = __webpack_require__(5);
  5639. /**
  5640. * @ngdoc object
  5641. * @name ui.router.state.type:State
  5642. *
  5643. * @description
  5644. * Definition object for states. Includes methods for manipulating the state heirarchy.
  5645. *
  5646. * @param {Object} config A configuration object hash that includes the results of user-supplied
  5647. * values, as well as values from `StateBuilder`.
  5648. *
  5649. * @returns {Object} Returns a new `State` object.
  5650. */
  5651. var State = (function () {
  5652. function State(config) {
  5653. common_1.extend(this, config);
  5654. // Object.freeze(this);
  5655. }
  5656. /**
  5657. * @ngdoc function
  5658. * @name ui.router.state.type:State#is
  5659. * @methodOf ui.router.state.type:State
  5660. *
  5661. * @description
  5662. * Compares the identity of the state against the passed value, which is either an object
  5663. * reference to the actual `State` instance, the original definition object passed to
  5664. * `$stateProvider.state()`, or the fully-qualified name.
  5665. *
  5666. * @param {Object} ref Can be one of (a) a `State` instance, (b) an object that was passed
  5667. * into `$stateProvider.state()`, (c) the fully-qualified name of a state as a string.
  5668. * @returns {boolean} Returns `true` if `ref` matches the current `State` instance.
  5669. */
  5670. State.prototype.is = function (ref) {
  5671. return this === ref || this.self === ref || this.fqn() === ref;
  5672. };
  5673. /**
  5674. * @ngdoc function
  5675. * @name ui.router.state.type:State#fqn
  5676. * @methodOf ui.router.state.type:State
  5677. *
  5678. * @description
  5679. * Returns the fully-qualified name of the state, based on its current position in the tree.
  5680. *
  5681. * @returns {string} Returns a dot-separated name of the state.
  5682. */
  5683. State.prototype.fqn = function () {
  5684. if (!this.parent || !(this.parent instanceof this.constructor))
  5685. return this.name;
  5686. var name = this.parent.fqn();
  5687. return name ? name + "." + this.name : this.name;
  5688. };
  5689. /**
  5690. * @ngdoc function
  5691. * @name ui.router.state.type:State#root
  5692. * @methodOf ui.router.state.type:State
  5693. *
  5694. * @description
  5695. * Returns the root node of this state's tree.
  5696. *
  5697. * @returns {State} The root of this state's tree.
  5698. */
  5699. State.prototype.root = function () {
  5700. return this.parent && this.parent.root() || this;
  5701. };
  5702. State.prototype.parameters = function (opts) {
  5703. opts = common_1.defaults(opts, { inherit: true });
  5704. var inherited = opts.inherit && this.parent && this.parent.parameters() || [];
  5705. return inherited.concat(common_1.values(this.params));
  5706. };
  5707. State.prototype.parameter = function (id, opts) {
  5708. if (opts === void 0) { opts = {}; }
  5709. return (this.url && this.url.parameter(id, opts) ||
  5710. common_1.find(common_1.values(this.params), hof_1.propEq('id', id)) ||
  5711. opts.inherit && this.parent && this.parent.parameter(id));
  5712. };
  5713. State.prototype.toString = function () {
  5714. return this.fqn();
  5715. };
  5716. return State;
  5717. }());
  5718. exports.State = State;
  5719. /***/ },
  5720. /* 43 */
  5721. /***/ function(module, exports, __webpack_require__) {
  5722. "use strict";
  5723. /** @module state */ /** */
  5724. var common_1 = __webpack_require__(3);
  5725. var predicates_1 = __webpack_require__(4);
  5726. var queue_1 = __webpack_require__(8);
  5727. var coreservices_1 = __webpack_require__(6);
  5728. var pathFactory_1 = __webpack_require__(20);
  5729. var node_1 = __webpack_require__(21);
  5730. var transitionService_1 = __webpack_require__(30);
  5731. var rejectFactory_1 = __webpack_require__(10);
  5732. var targetState_1 = __webpack_require__(14);
  5733. var param_1 = __webpack_require__(22);
  5734. var glob_1 = __webpack_require__(7);
  5735. var common_2 = __webpack_require__(3);
  5736. var common_3 = __webpack_require__(3);
  5737. var resolveContext_1 = __webpack_require__(17);
  5738. var StateService = (function () {
  5739. /** @hidden */
  5740. function StateService(router) {
  5741. this.router = router;
  5742. this.invalidCallbacks = [];
  5743. /** @hidden */
  5744. this._defaultErrorHandler = function $defaultErrorHandler($error$) {
  5745. if ($error$ instanceof Error && $error$.stack) {
  5746. console.error($error$);
  5747. console.error($error$.stack);
  5748. }
  5749. else if ($error$ instanceof rejectFactory_1.Rejection) {
  5750. console.error($error$.toString());
  5751. if ($error$.detail && $error$.detail.stack)
  5752. console.error($error$.detail.stack);
  5753. }
  5754. else {
  5755. console.error($error$);
  5756. }
  5757. };
  5758. var getters = ['current', '$current', 'params', 'transition'];
  5759. var boundFns = Object.keys(StateService.prototype).filter(function (key) { return getters.indexOf(key) === -1; });
  5760. common_3.bindFunctions(StateService.prototype, this, this, boundFns);
  5761. }
  5762. Object.defineProperty(StateService.prototype, "transition", {
  5763. get: function () { return this.router.globals.transition; },
  5764. enumerable: true,
  5765. configurable: true
  5766. });
  5767. Object.defineProperty(StateService.prototype, "params", {
  5768. get: function () { return this.router.globals.params; },
  5769. enumerable: true,
  5770. configurable: true
  5771. });
  5772. Object.defineProperty(StateService.prototype, "current", {
  5773. get: function () { return this.router.globals.current; },
  5774. enumerable: true,
  5775. configurable: true
  5776. });
  5777. Object.defineProperty(StateService.prototype, "$current", {
  5778. get: function () { return this.router.globals.$current; },
  5779. enumerable: true,
  5780. configurable: true
  5781. });
  5782. /**
  5783. * Handler for when [[transitionTo]] is called with an invalid state.
  5784. *
  5785. * Invokes the [[onInvalid]] callbacks, in natural order.
  5786. * Each callback's return value is checked in sequence until one of them returns an instance of TargetState.
  5787. * The results of the callbacks are wrapped in $q.when(), so the callbacks may return promises.
  5788. *
  5789. * If a callback returns an TargetState, then it is used as arguments to $state.transitionTo() and the result returned.
  5790. */
  5791. StateService.prototype._handleInvalidTargetState = function (fromPath, toState) {
  5792. var _this = this;
  5793. var fromState = pathFactory_1.PathFactory.makeTargetState(fromPath);
  5794. var globals = this.router.globals;
  5795. var latestThing = function () { return globals.transitionHistory.peekTail(); };
  5796. var latest = latestThing();
  5797. var callbackQueue = new queue_1.Queue(this.invalidCallbacks.slice());
  5798. var injector = new resolveContext_1.ResolveContext(fromPath).injector();
  5799. var checkForRedirect = function (result) {
  5800. if (!(result instanceof targetState_1.TargetState)) {
  5801. return;
  5802. }
  5803. var target = result;
  5804. // Recreate the TargetState, in case the state is now defined.
  5805. target = _this.target(target.identifier(), target.params(), target.options());
  5806. if (!target.valid())
  5807. return rejectFactory_1.Rejection.invalid(target.error()).toPromise();
  5808. if (latestThing() !== latest)
  5809. return rejectFactory_1.Rejection.superseded().toPromise();
  5810. return _this.transitionTo(target.identifier(), target.params(), target.options());
  5811. };
  5812. function invokeNextCallback() {
  5813. var nextCallback = callbackQueue.dequeue();
  5814. if (nextCallback === undefined)
  5815. return rejectFactory_1.Rejection.invalid(toState.error()).toPromise();
  5816. var callbackResult = coreservices_1.services.$q.when(nextCallback(toState, fromState, injector));
  5817. return callbackResult.then(checkForRedirect).then(function (result) { return result || invokeNextCallback(); });
  5818. }
  5819. return invokeNextCallback();
  5820. };
  5821. /**
  5822. * Registers an Invalid State handler
  5823. *
  5824. * Registers a [[OnInvalidCallback]] function to be invoked when [[StateService.transitionTo]]
  5825. * has been called with an invalid state reference parameter
  5826. *
  5827. * Example:
  5828. * ```js
  5829. * stateService.onInvalid(function(to, from, injector) {
  5830. * if (to.name() === 'foo') {
  5831. * let lazyLoader = injector.get('LazyLoadService');
  5832. * return lazyLoader.load('foo')
  5833. * .then(() => stateService.target('foo'));
  5834. * }
  5835. * });
  5836. * ```
  5837. *
  5838. * @param {function} callback invoked when the toState is invalid
  5839. * This function receives the (invalid) toState, the fromState, and an injector.
  5840. * The function may optionally return a [[TargetState]] or a Promise for a TargetState.
  5841. * If one is returned, it is treated as a redirect.
  5842. *
  5843. * @returns a function which deregisters the callback
  5844. */
  5845. StateService.prototype.onInvalid = function (callback) {
  5846. this.invalidCallbacks.push(callback);
  5847. return function deregisterListener() {
  5848. common_1.removeFrom(this.invalidCallbacks)(callback);
  5849. }.bind(this);
  5850. };
  5851. /**
  5852. * @ngdoc function
  5853. * @name ui.router.state.$state#reload
  5854. * @methodOf ui.router.state.$state
  5855. *
  5856. * @description
  5857. * A method that force reloads the current state, or a partial state hierarchy. All resolves are re-resolved,
  5858. * controllers reinstantiated, and events re-fired.
  5859. *
  5860. * @example
  5861. * <pre>
  5862. * let app angular.module('app', ['ui.router']);
  5863. *
  5864. * app.controller('ctrl', function ($scope, $state) {
  5865. * $scope.reload = function(){
  5866. * $state.reload();
  5867. * }
  5868. * });
  5869. * </pre>
  5870. *
  5871. * `reload()` is just an alias for:
  5872. * <pre>
  5873. * $state.transitionTo($state.current, $stateParams, {
  5874. * reload: true, inherit: false, notify: true
  5875. * });
  5876. * </pre>
  5877. *
  5878. * @param {string=|object=} reloadState - A state name or a state object, which is the root of the resolves to be re-resolved.
  5879. * @example
  5880. * <pre>
  5881. * //assuming app application consists of 3 states: 'contacts', 'contacts.detail', 'contacts.detail.item'
  5882. * //and current state is 'contacts.detail.item'
  5883. * let app angular.module('app', ['ui.router']);
  5884. *
  5885. * app.controller('ctrl', function ($scope, $state) {
  5886. * $scope.reload = function(){
  5887. * //will reload 'contact.detail' and nested 'contact.detail.item' states
  5888. * $state.reload('contact.detail');
  5889. * }
  5890. * });
  5891. * </pre>
  5892. *
  5893. * @returns {promise} A promise representing the state of the new transition. See
  5894. * {@link ui.router.state.$state#methods_go $state.go}.
  5895. */
  5896. StateService.prototype.reload = function (reloadState) {
  5897. return this.transitionTo(this.current, this.params, {
  5898. reload: predicates_1.isDefined(reloadState) ? reloadState : true,
  5899. inherit: false,
  5900. notify: false
  5901. });
  5902. };
  5903. ;
  5904. /**
  5905. * @ngdoc function
  5906. * @name ui.router.state.$state#go
  5907. * @methodOf ui.router.state.$state
  5908. *
  5909. * @description
  5910. * Convenience method for transitioning to a new state. `$state.go` calls
  5911. * `$state.transitionTo` internally but automatically sets options to
  5912. * `{ location: true, inherit: true, relative: $state.$current, notify: true }`.
  5913. * This allows you to easily use an absolute or relative to path and specify
  5914. * only the parameters you'd like to update (while letting unspecified parameters
  5915. * inherit from the currently active ancestor states).
  5916. *
  5917. * @example
  5918. * <pre>
  5919. * let app = angular.module('app', ['ui.router']);
  5920. *
  5921. * app.controller('ctrl', function ($scope, $state) {
  5922. * $scope.changeState = function () {
  5923. * $state.go('contact.detail');
  5924. * };
  5925. * });
  5926. * </pre>
  5927. * <img src='../ngdoc_assets/StateGoExamples.png'/>
  5928. *
  5929. * @param {string|object} to Absolute state name, state object, or relative state path. Some examples:
  5930. *
  5931. * - `$state.go('contact.detail')` - will go to the `contact.detail` state
  5932. * - `$state.go('^')` - will go to a parent state
  5933. * - `$state.go('^.sibling')` - will go to a sibling state
  5934. * - `$state.go('.child.grandchild')` - will go to grandchild state
  5935. *
  5936. * @param {object=} params A map of the parameters that will be sent to the state,
  5937. * will populate $stateParams. Any parameters that are not specified will be inherited from currently
  5938. * defined parameters. This allows, for example, going to a sibling state that shares parameters
  5939. * specified in a parent state. Parameter inheritance only works between common ancestor states, I.e.
  5940. * transitioning to a sibling will get you the parameters for all parents, transitioning to a child
  5941. * will get you all current parameters, etc.
  5942. * @param {object=} options Options object. The options are:
  5943. *
  5944. * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false`
  5945. * will not. If string, must be `"replace"`, which will update url and also replace last history record.
  5946. * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url.
  5947. * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'),
  5948. * defines which state to be relative from.
  5949. * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events.
  5950. * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params
  5951. * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd
  5952. * use this when you want to force a reload when *everything* is the same, including search params.
  5953. *
  5954. * @returns {promise} A promise representing the state of the new transition.
  5955. *
  5956. * Possible success values:
  5957. *
  5958. * - $state.current
  5959. *
  5960. * <br/>Possible rejection values:
  5961. *
  5962. * - 'transition superseded' - when a newer transition has been started after this one
  5963. * - 'transition prevented' - when `event.preventDefault()` has been called in a `$stateChangeStart` listener
  5964. * - 'transition aborted' - when `event.preventDefault()` has been called in a `$stateNotFound` listener or
  5965. * when a `$stateNotFound` `event.retry` promise errors.
  5966. * - 'transition failed' - when a state has been unsuccessfully found after 2 tries.
  5967. * - *resolve error* - when an error has occurred with a `resolve`
  5968. *
  5969. */
  5970. StateService.prototype.go = function (to, params, options) {
  5971. var defautGoOpts = { relative: this.$current, inherit: true };
  5972. var transOpts = common_1.defaults(options, defautGoOpts, transitionService_1.defaultTransOpts);
  5973. return this.transitionTo(to, params, transOpts);
  5974. };
  5975. ;
  5976. /** Factory method for creating a TargetState */
  5977. StateService.prototype.target = function (identifier, params, options) {
  5978. if (options === void 0) { options = {}; }
  5979. // If we're reloading, find the state object to reload from
  5980. if (predicates_1.isObject(options.reload) && !options.reload.name)
  5981. throw new Error('Invalid reload state object');
  5982. var reg = this.router.stateRegistry;
  5983. options.reloadState = options.reload === true ? reg.root() : reg.matcher.find(options.reload, options.relative);
  5984. if (options.reload && !options.reloadState)
  5985. throw new Error("No such reload state '" + (predicates_1.isString(options.reload) ? options.reload : options.reload.name) + "'");
  5986. var stateDefinition = reg.matcher.find(identifier, options.relative);
  5987. return new targetState_1.TargetState(identifier, stateDefinition, params, options);
  5988. };
  5989. ;
  5990. /**
  5991. * @ngdoc function
  5992. * @name ui.router.state.$state#transitionTo
  5993. * @methodOf ui.router.state.$state
  5994. *
  5995. * @description
  5996. * Low-level method for transitioning to a new state. {@link ui.router.state.$state#methods_go $state.go}
  5997. * uses `transitionTo` internally. `$state.go` is recommended in most situations.
  5998. *
  5999. * @example
  6000. * <pre>
  6001. * let app = angular.module('app', ['ui.router']);
  6002. *
  6003. * app.controller('ctrl', function ($scope, $state) {
  6004. * $scope.changeState = function () {
  6005. * $state.transitionTo('contact.detail');
  6006. * };
  6007. * });
  6008. * </pre>
  6009. *
  6010. * @param {string|object} to State name or state object.
  6011. * @param {object=} toParams A map of the parameters that will be sent to the state,
  6012. * will populate $stateParams.
  6013. * @param {object=} options Options object. The options are:
  6014. *
  6015. * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false`
  6016. * will not. If string, must be `"replace"`, which will update url and also replace last history record.
  6017. * - **`inherit`** - {boolean=false}, If `true` will inherit url parameters from current url.
  6018. * - **`relative`** - {object=}, When transitioning with relative path (e.g '^'),
  6019. * defines which state to be relative from.
  6020. * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events.
  6021. * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params
  6022. * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd
  6023. * use this when you want to force a reload when *everything* is the same, including search params.
  6024. *
  6025. * @returns {promise} A promise representing the state of the new transition. See
  6026. * {@link ui.router.state.$state#methods_go $state.go}.
  6027. */
  6028. StateService.prototype.transitionTo = function (to, toParams, options) {
  6029. var _this = this;
  6030. if (toParams === void 0) { toParams = {}; }
  6031. if (options === void 0) { options = {}; }
  6032. var router = this.router;
  6033. var globals = router.globals;
  6034. var transHistory = globals.transitionHistory;
  6035. options = common_1.defaults(options, transitionService_1.defaultTransOpts);
  6036. options = common_1.extend(options, { current: transHistory.peekTail.bind(transHistory) });
  6037. var ref = this.target(to, toParams, options);
  6038. var latestSuccess = globals.successfulTransitions.peekTail();
  6039. var rootPath = function () { return [new node_1.PathNode(_this.router.stateRegistry.root())]; };
  6040. var currentPath = latestSuccess ? latestSuccess.treeChanges().to : rootPath();
  6041. if (!ref.exists())
  6042. return this._handleInvalidTargetState(currentPath, ref);
  6043. if (!ref.valid())
  6044. return common_1.silentRejection(ref.error());
  6045. /**
  6046. * Special handling for Ignored, Aborted, and Redirected transitions
  6047. *
  6048. * The semantics for the transition.run() promise and the StateService.transitionTo()
  6049. * promise differ. For instance, the run() promise may be rejected because it was
  6050. * IGNORED, but the transitionTo() promise is resolved because from the user perspective
  6051. * no error occurred. Likewise, the transition.run() promise may be rejected because of
  6052. * a Redirect, but the transitionTo() promise is chained to the new Transition's promise.
  6053. */
  6054. var rejectedTransitionHandler = function (transition) { return function (error) {
  6055. if (error instanceof rejectFactory_1.Rejection) {
  6056. if (error.type === rejectFactory_1.RejectType.IGNORED) {
  6057. // Consider ignored `Transition.run()` as a successful `transitionTo`
  6058. router.urlRouter.update();
  6059. return coreservices_1.services.$q.when(globals.current);
  6060. }
  6061. var detail = error.detail;
  6062. if (error.type === rejectFactory_1.RejectType.SUPERSEDED && error.redirected && detail instanceof targetState_1.TargetState) {
  6063. // If `Transition.run()` was redirected, allow the `transitionTo()` promise to resolve successfully
  6064. // by returning the promise for the new (redirect) `Transition.run()`.
  6065. var redirect = transition.redirect(detail);
  6066. return redirect.run().catch(rejectedTransitionHandler(redirect));
  6067. }
  6068. if (error.type === rejectFactory_1.RejectType.ABORTED) {
  6069. router.urlRouter.update();
  6070. }
  6071. }
  6072. var errorHandler = _this.defaultErrorHandler();
  6073. errorHandler(error);
  6074. return coreservices_1.services.$q.reject(error);
  6075. }; };
  6076. var transition = this.router.transitionService.create(currentPath, ref);
  6077. var transitionToPromise = transition.run().catch(rejectedTransitionHandler(transition));
  6078. common_1.silenceUncaughtInPromise(transitionToPromise); // issue #2676
  6079. // Return a promise for the transition, which also has the transition object on it.
  6080. return common_1.extend(transitionToPromise, { transition: transition });
  6081. };
  6082. ;
  6083. /**
  6084. * @ngdoc function
  6085. * @name ui.router.state.$state#is
  6086. * @methodOf ui.router.state.$state
  6087. *
  6088. * @description
  6089. * Similar to {@link ui.router.state.$state#methods_includes $state.includes},
  6090. * but only checks for the full state name. If params is supplied then it will be
  6091. * tested for strict equality against the current active params object, so all params
  6092. * must match with none missing and no extras.
  6093. *
  6094. * @example
  6095. * <pre>
  6096. * $state.$current.name = 'contacts.details.item';
  6097. *
  6098. * // absolute name
  6099. * $state.is('contact.details.item'); // returns true
  6100. * $state.is(contactDetailItemStateObject); // returns true
  6101. *
  6102. * // relative name (. and ^), typically from a template
  6103. * // E.g. from the 'contacts.details' template
  6104. * <div ng-class="{highlighted: $state.is('.item')}">Item</div>
  6105. * </pre>
  6106. *
  6107. * @param {string|object} stateOrName The state name (absolute or relative) or state object you'd like to check.
  6108. * @param {object=} params A param object, e.g. `{sectionId: section.id}`, that you'd like
  6109. * to test against the current active state.
  6110. * @param {object=} options An options object. The options are:
  6111. *
  6112. * - **`relative`** - {string|object} - If `stateOrName` is a relative state name and `options.relative` is set, .is will
  6113. * test relative to `options.relative` state (or name).
  6114. *
  6115. * @returns {boolean} Returns true if it is the state.
  6116. */
  6117. StateService.prototype.is = function (stateOrName, params, options) {
  6118. options = common_1.defaults(options, { relative: this.$current });
  6119. var state = this.router.stateRegistry.matcher.find(stateOrName, options.relative);
  6120. if (!predicates_1.isDefined(state))
  6121. return undefined;
  6122. if (this.$current !== state)
  6123. return false;
  6124. return predicates_1.isDefined(params) && params !== null ? param_1.Param.equals(state.parameters(), this.params, params) : true;
  6125. };
  6126. ;
  6127. /**
  6128. * @ngdoc function
  6129. * @name ui.router.state.$state#includes
  6130. * @methodOf ui.router.state.$state
  6131. *
  6132. * @description
  6133. * A method to determine if the current active state is equal to or is the child of the
  6134. * state stateName. If any params are passed then they will be tested for a match as well.
  6135. * Not all the parameters need to be passed, just the ones you'd like to test for equality.
  6136. *
  6137. * @example
  6138. * Partial and relative names
  6139. * <pre>
  6140. * $state.$current.name = 'contacts.details.item';
  6141. *
  6142. * // Using partial names
  6143. * $state.includes("contacts"); // returns true
  6144. * $state.includes("contacts.details"); // returns true
  6145. * $state.includes("contacts.details.item"); // returns true
  6146. * $state.includes("contacts.list"); // returns false
  6147. * $state.includes("about"); // returns false
  6148. *
  6149. * // Using relative names (. and ^), typically from a template
  6150. * // E.g. from the 'contacts.details' template
  6151. * <div ng-class="{highlighted: $state.includes('.item')}">Item</div>
  6152. * </pre>
  6153. *
  6154. * Basic globbing patterns
  6155. * <pre>
  6156. * $state.$current.name = 'contacts.details.item.url';
  6157. *
  6158. * $state.includes("*.details.*.*"); // returns true
  6159. * $state.includes("*.details.**"); // returns true
  6160. * $state.includes("**.item.**"); // returns true
  6161. * $state.includes("*.details.item.url"); // returns true
  6162. * $state.includes("*.details.*.url"); // returns true
  6163. * $state.includes("*.details.*"); // returns false
  6164. * $state.includes("item.**"); // returns false
  6165. * </pre>
  6166. *
  6167. * @param {string|object} stateOrName A partial name, relative name, glob pattern,
  6168. * or state object to be searched for within the current state name.
  6169. * @param {object=} params A param object, e.g. `{sectionId: section.id}`,
  6170. * that you'd like to test against the current active state.
  6171. * @param {object=} options An options object. The options are:
  6172. *
  6173. * - **`relative`** - {string|object=} - If `stateOrName` is a relative state reference and `options.relative` is set,
  6174. * .includes will test relative to `options.relative` state (or name).
  6175. *
  6176. * @returns {boolean} Returns true if it does include the state
  6177. */
  6178. StateService.prototype.includes = function (stateOrName, params, options) {
  6179. options = common_1.defaults(options, { relative: this.$current });
  6180. var glob = predicates_1.isString(stateOrName) && glob_1.Glob.fromString(stateOrName);
  6181. if (glob) {
  6182. if (!glob.matches(this.$current.name))
  6183. return false;
  6184. stateOrName = this.$current.name;
  6185. }
  6186. var state = this.router.stateRegistry.matcher.find(stateOrName, options.relative), include = this.$current.includes;
  6187. if (!predicates_1.isDefined(state))
  6188. return undefined;
  6189. if (!predicates_1.isDefined(include[state.name]))
  6190. return false;
  6191. // @TODO Replace with Param.equals() ?
  6192. return params ? common_2.equalForKeys(param_1.Param.values(state.parameters(), params), this.params, Object.keys(params)) : true;
  6193. };
  6194. ;
  6195. /**
  6196. * @ngdoc function
  6197. * @name ui.router.state.$state#href
  6198. * @methodOf ui.router.state.$state
  6199. *
  6200. * @description
  6201. * A url generation method that returns the compiled url for the given state populated with the given params.
  6202. *
  6203. * @example
  6204. * <pre>
  6205. * expect($state.href("about.person", { person: "bob" })).toEqual("/about/bob");
  6206. * </pre>
  6207. *
  6208. * @param {string|object} stateOrName The state name or state object you'd like to generate a url from.
  6209. * @param {object=} params An object of parameter values to fill the state's required parameters.
  6210. * @param {object=} options Options object. The options are:
  6211. *
  6212. * - **`lossy`** - {boolean=true} - If true, and if there is no url associated with the state provided in the
  6213. * first parameter, then the constructed href url will be built from the first navigable ancestor (aka
  6214. * ancestor with a valid url).
  6215. * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url.
  6216. * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'),
  6217. * defines which state to be relative from.
  6218. * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
  6219. *
  6220. * @returns {string} compiled state url
  6221. */
  6222. StateService.prototype.href = function (stateOrName, params, options) {
  6223. var defaultHrefOpts = {
  6224. lossy: true,
  6225. inherit: true,
  6226. absolute: false,
  6227. relative: this.$current
  6228. };
  6229. options = common_1.defaults(options, defaultHrefOpts);
  6230. params = params || {};
  6231. var state = this.router.stateRegistry.matcher.find(stateOrName, options.relative);
  6232. if (!predicates_1.isDefined(state))
  6233. return null;
  6234. if (options.inherit)
  6235. params = this.params.$inherit(params, this.$current, state);
  6236. var nav = (state && options.lossy) ? state.navigable : state;
  6237. if (!nav || nav.url === undefined || nav.url === null) {
  6238. return null;
  6239. }
  6240. return this.router.urlRouter.href(nav.url, param_1.Param.values(state.parameters(), params), {
  6241. absolute: options.absolute
  6242. });
  6243. };
  6244. ;
  6245. /**
  6246. * Sets or gets the default [[transitionTo]] error handler.
  6247. *
  6248. * The error handler is called when a [[Transition]] is rejected or when any error occurred during the Transition.
  6249. * This includes errors caused by resolves and transition hooks.
  6250. *
  6251. * Note:
  6252. * This handler does not receive certain Transition rejections.
  6253. * Redirected and Ignored Transitions are not considered to be errors by [[StateService.transitionTo]].
  6254. *
  6255. * The built-in default error handler logs the error to the console.
  6256. *
  6257. * You can provide your own custom handler.
  6258. *
  6259. * @example
  6260. * ```js
  6261. *
  6262. * stateService.defaultErrorHandler(function() {
  6263. * // Do not log transitionTo errors
  6264. * });
  6265. * ```
  6266. *
  6267. * @param handler a global error handler function
  6268. * @returns the current global error handler
  6269. */
  6270. StateService.prototype.defaultErrorHandler = function (handler) {
  6271. return this._defaultErrorHandler = handler || this._defaultErrorHandler;
  6272. };
  6273. StateService.prototype.get = function (stateOrName, base) {
  6274. var reg = this.router.stateRegistry;
  6275. if (arguments.length === 0)
  6276. return reg.get();
  6277. return reg.get(stateOrName, base || this.$current);
  6278. };
  6279. return StateService;
  6280. }());
  6281. exports.StateService = StateService;
  6282. /***/ },
  6283. /* 44 */
  6284. /***/ function(module, exports, __webpack_require__) {
  6285. "use strict";
  6286. /** @module core */ /** */
  6287. var stateParams_1 = __webpack_require__(45);
  6288. var queue_1 = __webpack_require__(8);
  6289. var common_1 = __webpack_require__(3);
  6290. /**
  6291. * Global mutable state
  6292. */
  6293. var Globals = (function () {
  6294. function Globals(transitionService) {
  6295. var _this = this;
  6296. this.params = new stateParams_1.StateParams();
  6297. this.transitionHistory = new queue_1.Queue([], 1);
  6298. this.successfulTransitions = new queue_1.Queue([], 1);
  6299. var beforeNewTransition = function ($transition$) {
  6300. _this.transition = $transition$;
  6301. _this.transitionHistory.enqueue($transition$);
  6302. var updateGlobalState = function () {
  6303. _this.successfulTransitions.enqueue($transition$);
  6304. _this.$current = $transition$.$to();
  6305. _this.current = _this.$current.self;
  6306. common_1.copy($transition$.params(), _this.params);
  6307. };
  6308. $transition$.onSuccess({}, updateGlobalState, { priority: 10000 });
  6309. var clearCurrentTransition = function () { if (_this.transition === $transition$)
  6310. _this.transition = null; };
  6311. $transition$.promise.then(clearCurrentTransition, clearCurrentTransition);
  6312. };
  6313. transitionService.onBefore({}, beforeNewTransition);
  6314. }
  6315. return Globals;
  6316. }());
  6317. exports.Globals = Globals;
  6318. /***/ },
  6319. /* 45 */
  6320. /***/ function(module, exports, __webpack_require__) {
  6321. "use strict";
  6322. /** @module params */ /** for typedoc */
  6323. var common_1 = __webpack_require__(3);
  6324. var StateParams = (function () {
  6325. function StateParams(params) {
  6326. if (params === void 0) { params = {}; }
  6327. common_1.extend(this, params);
  6328. }
  6329. /**
  6330. * Merges a set of parameters with all parameters inherited between the common parents of the
  6331. * current state and a given destination state.
  6332. *
  6333. * @param {Object} newParams The set of parameters which will be composited with inherited params.
  6334. * @param {Object} $current Internal definition of object representing the current state.
  6335. * @param {Object} $to Internal definition of object representing state to transition to.
  6336. */
  6337. StateParams.prototype.$inherit = function (newParams, $current, $to) {
  6338. var parents = common_1.ancestors($current, $to), parentParams, inherited = {}, inheritList = [];
  6339. for (var i in parents) {
  6340. if (!parents[i] || !parents[i].params)
  6341. continue;
  6342. parentParams = Object.keys(parents[i].params);
  6343. if (!parentParams.length)
  6344. continue;
  6345. for (var j in parentParams) {
  6346. if (inheritList.indexOf(parentParams[j]) >= 0)
  6347. continue;
  6348. inheritList.push(parentParams[j]);
  6349. inherited[parentParams[j]] = this[parentParams[j]];
  6350. }
  6351. }
  6352. return common_1.extend({}, inherited, newParams);
  6353. };
  6354. ;
  6355. return StateParams;
  6356. }());
  6357. exports.StateParams = StateParams;
  6358. /***/ },
  6359. /* 46 */
  6360. /***/ function(module, exports, __webpack_require__) {
  6361. "use strict";
  6362. function __export(m) {
  6363. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6364. }
  6365. /**
  6366. * This module contains code for State Parameters.
  6367. *
  6368. * See [[ParamDeclaration]]
  6369. * @module params
  6370. * @preferred doc
  6371. */
  6372. /** for typedoc */
  6373. __export(__webpack_require__(22));
  6374. __export(__webpack_require__(28));
  6375. __export(__webpack_require__(45));
  6376. __export(__webpack_require__(24));
  6377. /***/ },
  6378. /* 47 */
  6379. /***/ function(module, exports, __webpack_require__) {
  6380. "use strict";
  6381. function __export(m) {
  6382. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6383. }
  6384. /** @module path */ /** for typedoc */
  6385. __export(__webpack_require__(21));
  6386. __export(__webpack_require__(20));
  6387. /***/ },
  6388. /* 48 */
  6389. /***/ function(module, exports, __webpack_require__) {
  6390. "use strict";
  6391. function __export(m) {
  6392. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6393. }
  6394. /** @module resolve */ /** for typedoc */
  6395. __export(__webpack_require__(18));
  6396. __export(__webpack_require__(19));
  6397. __export(__webpack_require__(17));
  6398. /***/ },
  6399. /* 49 */
  6400. /***/ function(module, exports, __webpack_require__) {
  6401. "use strict";
  6402. function __export(m) {
  6403. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6404. }
  6405. /** @module state */ /** for typedoc */
  6406. __export(__webpack_require__(40));
  6407. __export(__webpack_require__(42));
  6408. __export(__webpack_require__(39));
  6409. __export(__webpack_require__(41));
  6410. __export(__webpack_require__(38));
  6411. __export(__webpack_require__(43));
  6412. __export(__webpack_require__(14));
  6413. /***/ },
  6414. /* 50 */
  6415. /***/ function(module, exports, __webpack_require__) {
  6416. "use strict";
  6417. function __export(m) {
  6418. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6419. }
  6420. /**
  6421. * This module contains APIs related to a Transition.
  6422. *
  6423. * See [[Transition]], [[$transitions]]
  6424. *
  6425. * @module transition
  6426. * @preferred
  6427. */
  6428. /** for typedoc */
  6429. __export(__webpack_require__(16));
  6430. __export(__webpack_require__(15));
  6431. __export(__webpack_require__(10));
  6432. __export(__webpack_require__(11));
  6433. __export(__webpack_require__(13));
  6434. __export(__webpack_require__(30));
  6435. /***/ },
  6436. /* 51 */
  6437. /***/ function(module, exports, __webpack_require__) {
  6438. "use strict";
  6439. function __export(m) {
  6440. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6441. }
  6442. /** @module url */ /** for typedoc */
  6443. __export(__webpack_require__(27));
  6444. __export(__webpack_require__(23));
  6445. __export(__webpack_require__(26));
  6446. __export(__webpack_require__(29));
  6447. /***/ },
  6448. /* 52 */
  6449. /***/ function(module, exports, __webpack_require__) {
  6450. "use strict";
  6451. function __export(m) {
  6452. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6453. }
  6454. /** @module view */ /** for typedoc */
  6455. __export(__webpack_require__(37));
  6456. /***/ },
  6457. /* 53 */
  6458. /***/ function(module, exports, __webpack_require__) {
  6459. /**
  6460. * # UI-Router for Angular 1
  6461. *
  6462. * - Provides an implementation for the [[CoreServices]] API, based on angular 1 services.
  6463. * - Also registers some services with the angular 1 injector.
  6464. * - Creates and bootstraps a new [[UIRouter]] object. Ties it to the the angular 1 lifecycle.
  6465. *
  6466. * @module ng1
  6467. * @preferred
  6468. */
  6469. "use strict";
  6470. /** for typedoc */
  6471. var router_1 = __webpack_require__(25);
  6472. var coreservices_1 = __webpack_require__(6);
  6473. var common_1 = __webpack_require__(3);
  6474. var hof_1 = __webpack_require__(5);
  6475. var predicates_1 = __webpack_require__(4);
  6476. var resolveService_1 = __webpack_require__(54);
  6477. var trace_1 = __webpack_require__(12);
  6478. var views_1 = __webpack_require__(55);
  6479. var templateFactory_1 = __webpack_require__(56);
  6480. var stateProvider_1 = __webpack_require__(58);
  6481. var onEnterExitRetain_1 = __webpack_require__(59);
  6482. var angular = __webpack_require__(57);
  6483. /** @hidden */
  6484. var app = angular.module("ui.router.angular1", []);
  6485. /**
  6486. * @ngdoc overview
  6487. * @name ui.router.util
  6488. *
  6489. * @description
  6490. * # ui.router.util sub-module
  6491. *
  6492. * This module is a dependency of other sub-modules. Do not include this module as a dependency
  6493. * in your angular app (use {@link ui.router} module instead).
  6494. *
  6495. */
  6496. angular.module('ui.router.util', ['ng', 'ui.router.init']);
  6497. /**
  6498. * @ngdoc overview
  6499. * @name ui.router.router
  6500. *
  6501. * @requires ui.router.util
  6502. *
  6503. * @description
  6504. * # ui.router.router sub-module
  6505. *
  6506. * This module is a dependency of other sub-modules. Do not include this module as a dependency
  6507. * in your angular app (use {@link ui.router} module instead).
  6508. */
  6509. angular.module('ui.router.router', ['ui.router.util']);
  6510. /**
  6511. * @ngdoc overview
  6512. * @name ui.router.state
  6513. *
  6514. * @requires ui.router.router
  6515. * @requires ui.router.util
  6516. *
  6517. * @description
  6518. * # ui.router.state sub-module
  6519. *
  6520. * This module is a dependency of the main ui.router module. Do not include this module as a dependency
  6521. * in your angular app (use {@link ui.router} module instead).
  6522. *
  6523. */
  6524. angular.module('ui.router.state', ['ui.router.router', 'ui.router.util', 'ui.router.angular1']);
  6525. /**
  6526. * @ngdoc overview
  6527. * @name ui.router
  6528. *
  6529. * @requires ui.router.state
  6530. *
  6531. * @description
  6532. * # ui.router
  6533. *
  6534. * ## The main module for ui.router
  6535. * There are several sub-modules included with the ui.router module, however only this module is needed
  6536. * as a dependency within your angular app. The other modules are for organization purposes.
  6537. *
  6538. * The modules are:
  6539. * * ui.router - the main "umbrella" module
  6540. * * ui.router.router -
  6541. *
  6542. * *You'll need to include **only** this module as the dependency within your angular app.*
  6543. *
  6544. * <pre>
  6545. * <!doctype html>
  6546. * <html ng-app="myApp">
  6547. * <head>
  6548. * <script src="js/angular.js"></script>
  6549. * <!-- Include the ui-router script -->
  6550. * <script src="js/angular-ui-router.min.js"></script>
  6551. * <script>
  6552. * // ...and add 'ui.router' as a dependency
  6553. * var myApp = angular.module('myApp', ['ui.router']);
  6554. * </script>
  6555. * </head>
  6556. * <body>
  6557. * </body>
  6558. * </html>
  6559. * </pre>
  6560. */
  6561. angular.module('ui.router', ['ui.router.init', 'ui.router.state', 'ui.router.angular1']);
  6562. angular.module('ui.router.compat', ['ui.router']);
  6563. /**
  6564. * Annotates a controller expression (may be a controller function(), a "controllername",
  6565. * or "controllername as name")
  6566. *
  6567. * - Temporarily decorates $injector.instantiate.
  6568. * - Invokes $controller() service
  6569. * - Calls $injector.instantiate with controller constructor
  6570. * - Annotate constructor
  6571. * - Undecorate $injector
  6572. *
  6573. * returns an array of strings, which are the arguments of the controller expression
  6574. */
  6575. function annotateController(controllerExpression) {
  6576. var $injector = coreservices_1.services.$injector;
  6577. var $controller = $injector.get("$controller");
  6578. var oldInstantiate = $injector.instantiate;
  6579. try {
  6580. var deps_1;
  6581. $injector.instantiate = function fakeInstantiate(constructorFunction) {
  6582. $injector.instantiate = oldInstantiate; // Un-decorate ASAP
  6583. deps_1 = $injector.annotate(constructorFunction);
  6584. };
  6585. $controller(controllerExpression, { $scope: {} });
  6586. return deps_1;
  6587. }
  6588. finally {
  6589. $injector.instantiate = oldInstantiate;
  6590. }
  6591. }
  6592. exports.annotateController = annotateController;
  6593. var router = null;
  6594. $uiRouter.$inject = ['$locationProvider'];
  6595. /** This angular 1 provider instantiates a Router and exposes its services via the angular injector */
  6596. function $uiRouter($locationProvider) {
  6597. // Create a new instance of the Router when the $uiRouterProvider is initialized
  6598. router = new router_1.UIRouter();
  6599. router.stateProvider = new stateProvider_1.StateProvider(router.stateRegistry, router.stateService);
  6600. // Apply ng1 specific StateBuilder code for `views`, `resolve`, and `onExit/Retain/Enter` properties
  6601. router.stateRegistry.decorator("views", views_1.ng1ViewsBuilder);
  6602. router.stateRegistry.decorator("onExit", onEnterExitRetain_1.getStateHookBuilder("onExit"));
  6603. router.stateRegistry.decorator("onRetain", onEnterExitRetain_1.getStateHookBuilder("onRetain"));
  6604. router.stateRegistry.decorator("onEnter", onEnterExitRetain_1.getStateHookBuilder("onEnter"));
  6605. router.viewService.viewConfigFactory('ng1', views_1.ng1ViewConfigFactory);
  6606. // Bind LocationConfig.hashPrefix to $locationProvider.hashPrefix
  6607. common_1.bindFunctions($locationProvider, coreservices_1.services.locationConfig, $locationProvider, ['hashPrefix']);
  6608. // Create a LocationService.onChange registry
  6609. var urlListeners = [];
  6610. coreservices_1.services.location.onChange = function (callback) {
  6611. urlListeners.push(callback);
  6612. return function () { return common_1.removeFrom(urlListeners)(callback); };
  6613. };
  6614. this.$get = $get;
  6615. $get.$inject = ['$location', '$browser', '$sniffer', '$rootScope', '$http', '$templateCache'];
  6616. function $get($location, $browser, $sniffer, $rootScope, $http, $templateCache) {
  6617. // Bind $locationChangeSuccess to the listeners registered in LocationService.onChange
  6618. $rootScope.$on("$locationChangeSuccess", function (evt) { return urlListeners.forEach(function (fn) { return fn(evt); }); });
  6619. // Bind LocationConfig.html5Mode to $locationProvider.html5Mode and $sniffer.history
  6620. coreservices_1.services.locationConfig.html5Mode = function () {
  6621. var html5Mode = $locationProvider.html5Mode();
  6622. html5Mode = predicates_1.isObject(html5Mode) ? html5Mode.enabled : html5Mode;
  6623. return html5Mode && $sniffer.history;
  6624. };
  6625. coreservices_1.services.location.setUrl = function (newUrl, replace) {
  6626. if (replace === void 0) { replace = false; }
  6627. $location.url(newUrl);
  6628. if (replace)
  6629. $location.replace();
  6630. };
  6631. coreservices_1.services.template.get = function (url) {
  6632. return $http.get(url, { cache: $templateCache, headers: { Accept: 'text/html' } }).then(hof_1.prop("data"));
  6633. };
  6634. // Bind these LocationService functions to $location
  6635. common_1.bindFunctions($location, coreservices_1.services.location, $location, ["replace", "url", "path", "search", "hash"]);
  6636. // Bind these LocationConfig functions to $location
  6637. common_1.bindFunctions($location, coreservices_1.services.locationConfig, $location, ['port', 'protocol', 'host']);
  6638. // Bind these LocationConfig functions to $browser
  6639. common_1.bindFunctions($browser, coreservices_1.services.locationConfig, $browser, ['baseHref']);
  6640. return router;
  6641. }
  6642. }
  6643. // The 'ui.router' ng1 module depends on 'ui.router.init' module.
  6644. angular.module('ui.router.init', []).provider("$uiRouter", $uiRouter);
  6645. runBlock.$inject = ['$injector', '$q'];
  6646. function runBlock($injector, $q) {
  6647. coreservices_1.services.$injector = $injector;
  6648. coreservices_1.services.$q = $q;
  6649. }
  6650. angular.module('ui.router.init').run(runBlock);
  6651. // This effectively calls $get() to init when we enter runtime
  6652. angular.module('ui.router.init').run(['$uiRouter', function ($uiRouter) { }]);
  6653. // $urlMatcherFactory service and $urlMatcherFactoryProvider
  6654. angular.module('ui.router.util').provider('$urlMatcherFactory', ['$uiRouterProvider', function () { return router.urlMatcherFactory; }]);
  6655. angular.module('ui.router.util').run(['$urlMatcherFactory', function ($urlMatcherFactory) { }]);
  6656. // $urlRouter service and $urlRouterProvider
  6657. function getUrlRouterProvider() {
  6658. router.urlRouterProvider["$get"] = function () {
  6659. router.urlRouter.update(true);
  6660. if (!this.interceptDeferred)
  6661. router.urlRouter.listen();
  6662. return router.urlRouter;
  6663. };
  6664. return router.urlRouterProvider;
  6665. }
  6666. angular.module('ui.router.router').provider('$urlRouter', ['$uiRouterProvider', getUrlRouterProvider]);
  6667. angular.module('ui.router.router').run(['$urlRouter', function ($urlRouter) { }]);
  6668. // $state service and $stateProvider
  6669. // $urlRouter service and $urlRouterProvider
  6670. function getStateProvider() {
  6671. router.stateProvider["$get"] = function () {
  6672. // Autoflush once we are in runtime
  6673. router.stateRegistry.stateQueue.autoFlush(router.stateService);
  6674. return router.stateService;
  6675. };
  6676. return router.stateProvider;
  6677. }
  6678. angular.module('ui.router.state').provider('$state', ['$uiRouterProvider', getStateProvider]);
  6679. angular.module('ui.router.state').run(['$state', function ($state) { }]);
  6680. // $stateParams service
  6681. angular.module('ui.router.state').factory('$stateParams', ['$uiRouter', function ($uiRouter) {
  6682. return $uiRouter.globals.params;
  6683. }]);
  6684. // $transitions service and $transitionsProvider
  6685. function getTransitionsProvider() {
  6686. router.transitionService["$get"] = function () { return router.transitionService; };
  6687. return router.transitionService;
  6688. }
  6689. angular.module('ui.router.state').provider('$transitions', ['$uiRouterProvider', getTransitionsProvider]);
  6690. // $templateFactory service
  6691. angular.module('ui.router.util').factory('$templateFactory', ['$uiRouter', function () { return new templateFactory_1.TemplateFactory(); }]);
  6692. // The $view service
  6693. angular.module('ui.router').factory('$view', function () { return router.viewService; });
  6694. // The old $resolve service
  6695. angular.module('ui.router').factory('$resolve', resolveService_1.resolveFactory);
  6696. // $trace service
  6697. angular.module("ui.router").service("$trace", function () { return trace_1.trace; });
  6698. watchDigests.$inject = ['$rootScope'];
  6699. function watchDigests($rootScope) {
  6700. $rootScope.$watch(function () { trace_1.trace.approximateDigests++; });
  6701. }
  6702. exports.watchDigests = watchDigests;
  6703. angular.module("ui.router").run(watchDigests);
  6704. exports.getLocals = function (ctx) {
  6705. var tokens = ctx.getTokens().filter(predicates_1.isString);
  6706. var tuples = tokens.map(function (key) { return [key, ctx.getResolvable(key).data]; });
  6707. return tuples.reduce(common_1.applyPairs, {});
  6708. };
  6709. /** Injectable services */
  6710. /**
  6711. * An injectable service object which has the current state parameters
  6712. *
  6713. * This angular service (singleton object) holds the current state parameters.
  6714. * The values in `$stateParams` are not updated until *after* a [[Transition]] successfully completes.
  6715. *
  6716. * This object can be injected into other services.
  6717. *
  6718. * @example
  6719. * ```js
  6720. *
  6721. * SomeService.$inject = ['$http', '$stateParams'];
  6722. * function SomeService($http, $stateParams) {
  6723. * return {
  6724. * getUser: function() {
  6725. * return $http.get('/api/users/' + $stateParams.username);
  6726. * }
  6727. * }
  6728. * };
  6729. * angular.service('SomeService', SomeService);
  6730. * ```
  6731. *
  6732. * ### Deprecation warning:
  6733. *
  6734. * When `$stateParams` is injected into transition hooks, resolves and view controllers, they receive a different
  6735. * object than this global service object. In those cases, the injected object has the parameter values for the
  6736. * *pending* Transition.
  6737. *
  6738. * Because of these confusing details, this service is deprecated.
  6739. *
  6740. * @deprecated Instead of using `$stateParams, inject the current [[Transition]] as `$transition$` and use [[Transition.params]]
  6741. * ```js
  6742. * MyController.$inject = ['$transition$'];
  6743. * function MyController($transition$) {
  6744. * var username = $transition$.params().username;
  6745. * // .. do something with username
  6746. * }
  6747. * ```
  6748. */
  6749. var $stateParams;
  6750. /**
  6751. * An injectable service primarily used to register transition hooks
  6752. *
  6753. * This angular service exposes the [[TransitionService]] singleton, which is primarily used to add transition hooks.
  6754. *
  6755. * The same object is also exposed as [[$transitionsProvider]] for injection during angular config time.
  6756. */
  6757. var $transitions;
  6758. /**
  6759. * A config-time injectable provider primarily used to register transition hooks
  6760. *
  6761. * This angular provider exposes the [[TransitionService]] singleton, which is primarily used to add transition hooks.
  6762. *
  6763. * The same object is also exposed as [[$transitions]] for injection at runtime.
  6764. */
  6765. var $transitionsProvider;
  6766. /**
  6767. * An injectable service used to query for current state information.
  6768. *
  6769. * This angular service exposes the [[StateService]] singleton.
  6770. */
  6771. var $state;
  6772. /**
  6773. * A config-time injectable provider used to register states.
  6774. *
  6775. * This angular service exposes the [[StateProvider]] singleton.
  6776. */
  6777. var $stateProvider;
  6778. /**
  6779. * A config-time injectable provider used to manage the URL.
  6780. *
  6781. * This angular service exposes the [[UrlRouterProvider]] singleton.
  6782. */
  6783. var $urlRouterProvider;
  6784. /**
  6785. * An injectable service used to configure URL redirects.
  6786. *
  6787. * This angular service exposes the [[UrlRouter]] singleton.
  6788. */
  6789. var $urlRouter;
  6790. /**
  6791. * An injectable service used to configure the URL.
  6792. *
  6793. * This service is used to set url mapping options, and create [[UrlMatcher]] objects.
  6794. *
  6795. * This angular service exposes the [[UrlMatcherFactory]] singleton.
  6796. * The singleton is also exposed at config-time as the [[$urlMatcherFactoryProvider]].
  6797. */
  6798. var $urlMatcherFactory;
  6799. /**
  6800. * An injectable service used to configure the URL.
  6801. *
  6802. * This service is used to set url mapping options, and create [[UrlMatcher]] objects.
  6803. *
  6804. * This angular service exposes the [[UrlMatcherFactory]] singleton at config-time.
  6805. * The singleton is also exposed at runtime as the [[$urlMatcherFactory]].
  6806. */
  6807. var $urlMatcherFactoryProvider;
  6808. /***/ },
  6809. /* 54 */
  6810. /***/ function(module, exports, __webpack_require__) {
  6811. "use strict";
  6812. /** @module ng1 */ /** */
  6813. var stateObject_1 = __webpack_require__(42);
  6814. var node_1 = __webpack_require__(21);
  6815. var resolveContext_1 = __webpack_require__(17);
  6816. var common_1 = __webpack_require__(3);
  6817. var stateBuilder_1 = __webpack_require__(40);
  6818. /**
  6819. * Implementation of the legacy `$resolve` service for angular 1.
  6820. */
  6821. var $resolve = {
  6822. /**
  6823. * Asynchronously injects a resolve block.
  6824. *
  6825. * This emulates most of the behavior of the ui-router 0.2.x $resolve.resolve() service API.
  6826. *
  6827. * Given an object `invocables`, where keys are strings and values are injectable functions,
  6828. * injects each function, and waits for the resulting promise to resolve.
  6829. * When all resulting promises are resolved, returns the results as an object.
  6830. *
  6831. * @example
  6832. * ```js
  6833. *
  6834. * let invocables = {
  6835. * foo: [ '$http', ($http) =>
  6836. * $http.get('/api/foo').then(resp => resp.data) ],
  6837. * bar: [ 'foo', '$http', (foo, $http) =>
  6838. * $http.get('/api/bar/' + foo.barId).then(resp => resp.data) ]
  6839. * }
  6840. * $resolve.resolve(invocables)
  6841. * .then(results => console.log(results.foo, results.bar))
  6842. * // Logs foo and bar:
  6843. * // { id: 123, barId: 456, fooData: 'foo data' }
  6844. * // { id: 456, barData: 'bar data' }
  6845. * ```
  6846. *
  6847. * @param invocables an object which looks like an [[StateDefinition.resolve]] object; keys are resolve names and values are injectable functions
  6848. * @param locals key/value pre-resolved data (locals)
  6849. * @param parent a promise for a "parent resolve"
  6850. */
  6851. resolve: function (invocables, locals, parent) {
  6852. if (locals === void 0) { locals = {}; }
  6853. var parentNode = new node_1.PathNode(new stateObject_1.State({ params: {}, resolvables: [] }));
  6854. var node = new node_1.PathNode(new stateObject_1.State({ params: {}, resolvables: [] }));
  6855. var context = new resolveContext_1.ResolveContext([parentNode, node]);
  6856. context.addResolvables(stateBuilder_1.resolvablesBuilder({ resolve: invocables }), node.state);
  6857. var resolveData = function (parentLocals) {
  6858. var rewrap = function (_locals) { return stateBuilder_1.resolvablesBuilder({ resolve: common_1.mapObj(_locals, function (local) { return function () { return local; }; }) }); };
  6859. context.addResolvables(rewrap(parentLocals), parentNode.state);
  6860. context.addResolvables(rewrap(locals), node.state);
  6861. var tuples2ObjR = function (acc, tuple) {
  6862. acc[tuple.token] = tuple.value;
  6863. return acc;
  6864. };
  6865. return context.resolvePath().then(function (results) { return results.reduce(tuples2ObjR, {}); });
  6866. };
  6867. return parent ? parent.then(resolveData) : resolveData({});
  6868. }
  6869. };
  6870. /** @hidden */
  6871. exports.resolveFactory = function () { return $resolve; };
  6872. /***/ },
  6873. /* 55 */
  6874. /***/ function(module, exports, __webpack_require__) {
  6875. "use strict";
  6876. var common_1 = __webpack_require__(3);
  6877. var strings_1 = __webpack_require__(9);
  6878. var view_1 = __webpack_require__(37);
  6879. var predicates_1 = __webpack_require__(4);
  6880. var coreservices_1 = __webpack_require__(6);
  6881. var trace_1 = __webpack_require__(12);
  6882. var templateFactory_1 = __webpack_require__(56);
  6883. var resolveContext_1 = __webpack_require__(17);
  6884. var resolvable_1 = __webpack_require__(19);
  6885. var angular = __webpack_require__(57);
  6886. exports.ng1ViewConfigFactory = function (path, view) {
  6887. return [new Ng1ViewConfig(path, view)];
  6888. };
  6889. /**
  6890. * This is a [[StateBuilder.builder]] function for angular1 `views`.
  6891. *
  6892. * When the [[StateBuilder]] builds a [[State]] object from a raw [[StateDeclaration]], this builder
  6893. * handles the `views` property with logic specific to angular-ui-router (ng1).
  6894. *
  6895. * If no `views: {}` property exists on the [[StateDeclaration]], then it creates the `views` object
  6896. * and applies the state-level configuration to a view named `$default`.
  6897. */
  6898. function ng1ViewsBuilder(state) {
  6899. var tplKeys = ['templateProvider', 'templateUrl', 'template', 'notify', 'async'], ctrlKeys = ['controller', 'controllerProvider', 'controllerAs', 'resolveAs'], compKeys = ['component', 'bindings'], nonCompKeys = tplKeys.concat(ctrlKeys), allKeys = compKeys.concat(nonCompKeys);
  6900. var views = {}, viewsObject = state.views || { "$default": common_1.pick(state, allKeys) };
  6901. common_1.forEach(viewsObject, function (config, name) {
  6902. // Account for views: { "": { template... } }
  6903. name = name || "$default";
  6904. // Account for views: { header: "headerComponent" }
  6905. if (predicates_1.isString(config))
  6906. config = { component: config };
  6907. if (!Object.keys(config).length)
  6908. return;
  6909. // Configure this view for routing to an angular 1.5+ style .component (or any directive, really)
  6910. if (config.component) {
  6911. if (nonCompKeys.map(function (key) { return predicates_1.isDefined(config[key]); }).reduce(common_1.anyTrueR, false)) {
  6912. throw new Error("Cannot combine: " + compKeys.join("|") + " with: " + nonCompKeys.join("|") + " in stateview: 'name@" + state.name + "'");
  6913. }
  6914. // Dynamically build a template like "<component-name input1='::$resolve.foo'></component-name>"
  6915. config.templateProvider = ['$injector', function ($injector) {
  6916. var resolveFor = function (key) {
  6917. return config.bindings && config.bindings[key] || key;
  6918. };
  6919. var prefix = angular.version.minor >= 3 ? "::" : "";
  6920. var attributeTpl = function (input) {
  6921. var attrName = strings_1.kebobString(input.name);
  6922. var resolveName = resolveFor(input.name);
  6923. if (input.type === '@')
  6924. return attrName + "='{{" + prefix + "$resolve." + resolveName + "}}'";
  6925. return attrName + "='" + prefix + "$resolve." + resolveName + "'";
  6926. };
  6927. var attrs = getComponentInputs($injector, config.component).map(attributeTpl).join(" ");
  6928. var kebobName = strings_1.kebobString(config.component);
  6929. return "<" + kebobName + " " + attrs + "></" + kebobName + ">";
  6930. }];
  6931. }
  6932. config.resolveAs = config.resolveAs || '$resolve';
  6933. config.$type = "ng1";
  6934. config.$context = state;
  6935. config.$name = name;
  6936. var normalized = view_1.ViewService.normalizeUIViewTarget(config.$context, config.$name);
  6937. config.$uiViewName = normalized.uiViewName;
  6938. config.$uiViewContextAnchor = normalized.uiViewContextAnchor;
  6939. views[name] = config;
  6940. });
  6941. return views;
  6942. }
  6943. exports.ng1ViewsBuilder = ng1ViewsBuilder;
  6944. // for ng 1.2 style, process the scope: { input: "=foo" }
  6945. // for ng 1.3 through ng 1.5, process the component's bindToController: { input: "=foo" } object
  6946. var scopeBindings = function (bindingsObj) { return Object.keys(bindingsObj || {})
  6947. .map(function (key) { return [key, /^([=<@])[?]?(.*)/.exec(bindingsObj[key])]; })
  6948. .filter(function (tuple) { return predicates_1.isDefined(tuple) && predicates_1.isDefined(tuple[1]); })
  6949. .map(function (tuple) { return ({ name: tuple[1][2] || tuple[0], type: tuple[1][1] }); }); };
  6950. // Given a directive definition, find its object input attributes
  6951. // Use different properties, depending on the type of directive (component, bindToController, normal)
  6952. var getBindings = function (def) {
  6953. if (predicates_1.isObject(def.bindToController))
  6954. return scopeBindings(def.bindToController);
  6955. return scopeBindings(def.scope);
  6956. };
  6957. // Gets all the directive(s)' inputs ('@', '=', and '<')
  6958. function getComponentInputs($injector, name) {
  6959. var cmpDefs = $injector.get(name + "Directive"); // could be multiple
  6960. if (!cmpDefs || !cmpDefs.length)
  6961. throw new Error("Unable to find component named '" + name + "'");
  6962. return cmpDefs.map(getBindings).reduce(common_1.unnestR, []);
  6963. }
  6964. var id = 0;
  6965. var Ng1ViewConfig = (function () {
  6966. function Ng1ViewConfig(path, viewDecl) {
  6967. this.path = path;
  6968. this.viewDecl = viewDecl;
  6969. this.$id = id++;
  6970. this.loaded = false;
  6971. }
  6972. Ng1ViewConfig.prototype.load = function () {
  6973. var _this = this;
  6974. var $q = coreservices_1.services.$q;
  6975. if (!this.hasTemplate())
  6976. throw new Error("No template configuration specified for '" + this.viewDecl.$uiViewName + "@" + this.viewDecl.$uiViewContextAnchor + "'");
  6977. var context = new resolveContext_1.ResolveContext(this.path);
  6978. var params = this.path.reduce(function (acc, node) { return common_1.extend(acc, node.paramValues); }, {});
  6979. var promises = {
  6980. template: $q.when(this.getTemplate(params, new templateFactory_1.TemplateFactory(), context)),
  6981. controller: $q.when(this.getController(context))
  6982. };
  6983. return $q.all(promises).then(function (results) {
  6984. trace_1.trace.traceViewServiceEvent("Loaded", _this);
  6985. _this.controller = results.controller;
  6986. _this.template = results.template;
  6987. return _this;
  6988. });
  6989. };
  6990. /**
  6991. * Checks a view configuration to ensure that it specifies a template.
  6992. *
  6993. * @return {boolean} Returns `true` if the configuration contains a valid template, otherwise `false`.
  6994. */
  6995. Ng1ViewConfig.prototype.hasTemplate = function () {
  6996. return !!(this.viewDecl.template || this.viewDecl.templateUrl || this.viewDecl.templateProvider);
  6997. };
  6998. Ng1ViewConfig.prototype.getTemplate = function (params, $factory, context) {
  6999. return $factory.fromConfig(this.viewDecl, params, context);
  7000. };
  7001. /**
  7002. * Gets the controller for a view configuration.
  7003. *
  7004. * @returns {Function|Promise.<Function>} Returns a controller, or a promise that resolves to a controller.
  7005. */
  7006. Ng1ViewConfig.prototype.getController = function (context) {
  7007. var provider = this.viewDecl.controllerProvider;
  7008. if (!predicates_1.isInjectable(provider))
  7009. return this.viewDecl.controller;
  7010. var deps = coreservices_1.services.$injector.annotate(provider);
  7011. var providerFn = predicates_1.isArray(provider) ? common_1.tail(provider) : provider;
  7012. var resolvable = new resolvable_1.Resolvable("", providerFn, deps);
  7013. return resolvable.get(context);
  7014. };
  7015. return Ng1ViewConfig;
  7016. }());
  7017. exports.Ng1ViewConfig = Ng1ViewConfig;
  7018. /***/ },
  7019. /* 56 */
  7020. /***/ function(module, exports, __webpack_require__) {
  7021. "use strict";
  7022. /** @module view */ /** for typedoc */
  7023. var predicates_1 = __webpack_require__(4);
  7024. var coreservices_1 = __webpack_require__(6);
  7025. var common_1 = __webpack_require__(3);
  7026. var resolvable_1 = __webpack_require__(19);
  7027. /**
  7028. * Service which manages loading of templates from a ViewConfig.
  7029. */
  7030. var TemplateFactory = (function () {
  7031. function TemplateFactory() {
  7032. }
  7033. /**
  7034. * Creates a template from a configuration object.
  7035. *
  7036. * @param config Configuration object for which to load a template.
  7037. * The following properties are search in the specified order, and the first one
  7038. * that is defined is used to create the template:
  7039. *
  7040. * @param params Parameters to pass to the template function.
  7041. * @param context The resolve context associated with the template's view
  7042. *
  7043. * @return {string|object} The template html as a string, or a promise for
  7044. * that string,or `null` if no template is configured.
  7045. */
  7046. TemplateFactory.prototype.fromConfig = function (config, params, context) {
  7047. return (predicates_1.isDefined(config.template) ? this.fromString(config.template, params) :
  7048. predicates_1.isDefined(config.templateUrl) ? this.fromUrl(config.templateUrl, params) :
  7049. predicates_1.isDefined(config.templateProvider) ? this.fromProvider(config.templateProvider, params, context) :
  7050. null);
  7051. };
  7052. ;
  7053. /**
  7054. * Creates a template from a string or a function returning a string.
  7055. *
  7056. * @param template html template as a string or function that returns an html template as a string.
  7057. * @param params Parameters to pass to the template function.
  7058. *
  7059. * @return {string|object} The template html as a string, or a promise for that
  7060. * string.
  7061. */
  7062. TemplateFactory.prototype.fromString = function (template, params) {
  7063. return predicates_1.isFunction(template) ? template(params) : template;
  7064. };
  7065. ;
  7066. /**
  7067. * Loads a template from the a URL via `$http` and `$templateCache`.
  7068. *
  7069. * @param {string|Function} url url of the template to load, or a function
  7070. * that returns a url.
  7071. * @param {Object} params Parameters to pass to the url function.
  7072. * @return {string|Promise.<string>} The template html as a string, or a promise
  7073. * for that string.
  7074. */
  7075. TemplateFactory.prototype.fromUrl = function (url, params) {
  7076. if (predicates_1.isFunction(url))
  7077. url = url(params);
  7078. if (url == null)
  7079. return null;
  7080. return coreservices_1.services.template.get(url);
  7081. };
  7082. ;
  7083. /**
  7084. * Creates a template by invoking an injectable provider function.
  7085. *
  7086. * @param provider Function to invoke via `locals`
  7087. * @param {Function} injectFn a function used to invoke the template provider
  7088. * @return {string|Promise.<string>} The template html as a string, or a promise
  7089. * for that string.
  7090. */
  7091. TemplateFactory.prototype.fromProvider = function (provider, params, context) {
  7092. var deps = coreservices_1.services.$injector.annotate(provider);
  7093. var providerFn = predicates_1.isArray(provider) ? common_1.tail(provider) : provider;
  7094. var resolvable = new resolvable_1.Resolvable("", providerFn, deps);
  7095. return resolvable.get(context);
  7096. };
  7097. ;
  7098. return TemplateFactory;
  7099. }());
  7100. exports.TemplateFactory = TemplateFactory;
  7101. /***/ },
  7102. /* 57 */
  7103. /***/ function(module, exports) {
  7104. module.exports = __WEBPACK_EXTERNAL_MODULE_57__;
  7105. /***/ },
  7106. /* 58 */
  7107. /***/ function(module, exports, __webpack_require__) {
  7108. "use strict";
  7109. /** @module ng1 */ /** for typedoc */
  7110. var predicates_1 = __webpack_require__(4);
  7111. var common_1 = __webpack_require__(3);
  7112. /**
  7113. * @ngdoc object
  7114. * @name ui.router.state.$stateProvider
  7115. *
  7116. * @requires ui.router.router.$urlRouterProvider
  7117. * @requires ui.router.util.$urlMatcherFactoryProvider
  7118. *
  7119. * @description
  7120. * The new `$stateProvider` works similar to Angular's v1 router, but it focuses purely
  7121. * on state.
  7122. *
  7123. * A state corresponds to a "place" in the application in terms of the overall UI and
  7124. * navigation. A state describes (via the controller / template / view properties) what
  7125. * the UI looks like and does at that place.
  7126. *
  7127. * States often have things in common, and the primary way of factoring out these
  7128. * commonalities in this model is via the state hierarchy, i.e. parent/child states aka
  7129. * nested states.
  7130. *
  7131. * The `$stateProvider` provides interfaces to declare these states for your app.
  7132. */
  7133. var StateProvider = (function () {
  7134. function StateProvider(stateRegistry, stateService) {
  7135. this.stateRegistry = stateRegistry;
  7136. this.stateService = stateService;
  7137. common_1.bindFunctions(StateProvider.prototype, this, this);
  7138. }
  7139. /**
  7140. * @ngdoc function
  7141. * @name ui.router.state.$stateProvider#decorator
  7142. * @methodOf ui.router.state.$stateProvider
  7143. *
  7144. * @description
  7145. * Allows you to extend (carefully) or override (at your own peril) the
  7146. * `stateBuilder` object used internally by `$stateProvider`. This can be used
  7147. * to add custom functionality to ui-router, for example inferring templateUrl
  7148. * based on the state name.
  7149. *
  7150. * When passing only a name, it returns the current (original or decorated) builder
  7151. * function that matches `name`.
  7152. *
  7153. * The builder functions that can be decorated are listed below. Though not all
  7154. * necessarily have a good use case for decoration, that is up to you to decide.
  7155. *
  7156. * In addition, users can attach custom decorators, which will generate new
  7157. * properties within the state's internal definition. There is currently no clear
  7158. * use-case for this beyond accessing internal states (i.e. $state.$current),
  7159. * however, expect this to become increasingly relevant as we introduce additional
  7160. * meta-programming features.
  7161. *
  7162. * **Warning**: Decorators should not be interdependent because the order of
  7163. * execution of the builder functions in non-deterministic. Builder functions
  7164. * should only be dependent on the state definition object and super function.
  7165. *
  7166. *
  7167. * Existing builder functions and current return values:
  7168. *
  7169. * - **parent** `{object}` - returns the parent state object.
  7170. * - **data** `{object}` - returns state data, including any inherited data that is not
  7171. * overridden by own values (if any).
  7172. * - **url** `{object}` - returns a {@link ui.router.util.type:UrlMatcher UrlMatcher}
  7173. * or `null`.
  7174. * - **navigable** `{object}` - returns closest ancestor state that has a URL (aka is
  7175. * navigable).
  7176. * - **params** `{object}` - returns an array of state params that are ensured to
  7177. * be a super-set of parent's params.
  7178. * - **views** `{object}` - returns a views object where each key is an absolute view
  7179. * name (i.e. "viewName@stateName") and each value is the config object
  7180. * (template, controller) for the view. Even when you don't use the views object
  7181. * explicitly on a state config, one is still created for you internally.
  7182. * So by decorating this builder function you have access to decorating template
  7183. * and controller properties.
  7184. * - **ownParams** `{object}` - returns an array of params that belong to the state,
  7185. * not including any params defined by ancestor states.
  7186. * - **path** `{string}` - returns the full path from the root down to this state.
  7187. * Needed for state activation.
  7188. * - **includes** `{object}` - returns an object that includes every state that
  7189. * would pass a `$state.includes()` test.
  7190. *
  7191. * @example
  7192. * <pre>
  7193. * // Override the internal 'views' builder with a function that takes the state
  7194. * // definition, and a reference to the internal function being overridden:
  7195. * $stateProvider.decorator('views', function (state, parent) {
  7196. * let result = {},
  7197. * views = parent(state);
  7198. *
  7199. * angular.forEach(views, function (config, name) {
  7200. * let autoName = (state.name + '.' + name).replace('.', '/');
  7201. * config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html';
  7202. * result[name] = config;
  7203. * });
  7204. * return result;
  7205. * });
  7206. *
  7207. * $stateProvider.state('home', {
  7208. * views: {
  7209. * 'contact.list': { controller: 'ListController' },
  7210. * 'contact.item': { controller: 'ItemController' }
  7211. * }
  7212. * });
  7213. *
  7214. * // ...
  7215. *
  7216. * $state.go('home');
  7217. * // Auto-populates list and item views with /partials/home/contact/list.html,
  7218. * // and /partials/home/contact/item.html, respectively.
  7219. * </pre>
  7220. *
  7221. * @param {string} name The name of the builder function to decorate.
  7222. * @param {object} func A function that is responsible for decorating the original
  7223. * builder function. The function receives two parameters:
  7224. *
  7225. * - `{object}` - state - The state config object.
  7226. * - `{object}` - super - The original builder function.
  7227. *
  7228. * @return {object} $stateProvider - $stateProvider instance
  7229. */
  7230. StateProvider.prototype.decorator = function (name, func) {
  7231. return this.stateRegistry.decorator(name, func) || this;
  7232. };
  7233. StateProvider.prototype.state = function (name, definition) {
  7234. if (predicates_1.isObject(name)) {
  7235. definition = name;
  7236. }
  7237. else {
  7238. definition.name = name;
  7239. }
  7240. this.stateRegistry.register(definition);
  7241. return this;
  7242. };
  7243. /**
  7244. * Registers an invalid state handler
  7245. *
  7246. * This is a passthrough to [[StateService.onInvalid]] for ng1.
  7247. */
  7248. StateProvider.prototype.onInvalid = function (callback) {
  7249. return this.stateService.onInvalid(callback);
  7250. };
  7251. return StateProvider;
  7252. }());
  7253. exports.StateProvider = StateProvider;
  7254. /***/ },
  7255. /* 59 */
  7256. /***/ function(module, exports, __webpack_require__) {
  7257. "use strict";
  7258. var coreservices_1 = __webpack_require__(6);
  7259. var services_1 = __webpack_require__(53);
  7260. var resolveContext_1 = __webpack_require__(17);
  7261. var common_1 = __webpack_require__(3);
  7262. /**
  7263. * This is a [[StateBuilder.builder]] function for angular1 `onEnter`, `onExit`,
  7264. * `onRetain` callback hooks on a [[Ng1StateDeclaration]].
  7265. *
  7266. * When the [[StateBuilder]] builds a [[State]] object from a raw [[StateDeclaration]], this builder
  7267. * ensures that those hooks are injectable for angular-ui-router (ng1).
  7268. */
  7269. exports.getStateHookBuilder = function (hookName) {
  7270. return function stateHookBuilder(state, parentFn) {
  7271. var hook = state[hookName];
  7272. function decoratedNg1Hook(trans, state) {
  7273. var resolveContext = new resolveContext_1.ResolveContext(trans.treeChanges().to);
  7274. return coreservices_1.services.$injector.invoke(hook, this, common_1.extend({ $state$: state }, services_1.getLocals(resolveContext)));
  7275. }
  7276. return hook ? decoratedNg1Hook : undefined;
  7277. };
  7278. };
  7279. /***/ },
  7280. /* 60 */
  7281. /***/ function(module, exports, __webpack_require__) {
  7282. "use strict";
  7283. /**
  7284. * These are the UI-Router angular 1 directives.
  7285. *
  7286. * These directives are used in templates to create viewports and navigate to states
  7287. *
  7288. * @preferred @module ng1_directives
  7289. */ /** for typedoc */
  7290. var angular = __webpack_require__(57);
  7291. var common_1 = __webpack_require__(3);
  7292. var predicates_1 = __webpack_require__(4);
  7293. var hof_1 = __webpack_require__(5);
  7294. /** @hidden */
  7295. function parseStateRef(ref, current) {
  7296. var preparsed = ref.match(/^\s*({[^}]*})\s*$/), parsed;
  7297. if (preparsed)
  7298. ref = current + '(' + preparsed[1] + ')';
  7299. parsed = ref.replace(/\n/g, " ").match(/^([^(]+?)\s*(\((.*)\))?$/);
  7300. if (!parsed || parsed.length !== 4)
  7301. throw new Error("Invalid state ref '" + ref + "'");
  7302. return { state: parsed[1], paramExpr: parsed[3] || null };
  7303. }
  7304. /** @hidden */
  7305. function stateContext(el) {
  7306. var $uiView = el.parent().inheritedData('$uiView');
  7307. var path = hof_1.parse('$cfg.path')($uiView);
  7308. return path ? common_1.tail(path).state.name : undefined;
  7309. }
  7310. /** @hidden */
  7311. function getTypeInfo(el) {
  7312. // SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
  7313. var isSvg = Object.prototype.toString.call(el.prop('href')) === '[object SVGAnimatedString]';
  7314. var isForm = el[0].nodeName === "FORM";
  7315. return {
  7316. attr: isForm ? "action" : (isSvg ? 'xlink:href' : 'href'),
  7317. isAnchor: el.prop("tagName").toUpperCase() === "A",
  7318. clickable: !isForm
  7319. };
  7320. }
  7321. /** @hidden */
  7322. function clickHook(el, $state, $timeout, type, current) {
  7323. return function (e) {
  7324. var button = e.which || e.button, target = current();
  7325. if (!(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || el.attr('target'))) {
  7326. // HACK: This is to allow ng-clicks to be processed before the transition is initiated:
  7327. var transition = $timeout(function () {
  7328. $state.go(target.state, target.params, target.options);
  7329. });
  7330. e.preventDefault();
  7331. // if the state has no URL, ignore one preventDefault from the <a> directive.
  7332. var ignorePreventDefaultCount = type.isAnchor && !target.href ? 1 : 0;
  7333. e.preventDefault = function () {
  7334. if (ignorePreventDefaultCount-- <= 0)
  7335. $timeout.cancel(transition);
  7336. };
  7337. }
  7338. };
  7339. }
  7340. /** @hidden */
  7341. function defaultOpts(el, $state) {
  7342. return {
  7343. relative: stateContext(el) || $state.$current,
  7344. inherit: true,
  7345. source: "sref"
  7346. };
  7347. }
  7348. /**
  7349. * `ui-sref`: A directive for linking to a state
  7350. *
  7351. * A directive that binds a link (`<a>` tag) to a state.
  7352. * If the state has an associated URL, the directive will automatically generate and
  7353. * update the `href` attribute via the [[StateService.href]] method.
  7354. * Clicking the link will trigger a state transition with optional parameters.
  7355. *
  7356. * Also middle-clicking, right-clicking, and ctrl-clicking on the link will be
  7357. * handled natively by the browser.
  7358. *
  7359. * You can also use relative state paths within ui-sref, just like the relative
  7360. * paths passed to `$state.go()`.
  7361. * You just need to be aware that the path is relative to the state that the link lives in.
  7362. * In other words, the state that created the view containing the link.
  7363. *
  7364. * You can specify options to pass to [[StateService.go]] using the `ui-sref-opts` attribute.
  7365. * Options are restricted to `location`, `inherit`, and `reload`.
  7366. *
  7367. * Here's an example of how you'd use ui-sref and how it would compile.
  7368. * If you have the following template:
  7369. *
  7370. * @example
  7371. * ```html
  7372. *
  7373. * <pre>
  7374. * <a ui-sref="home">Home</a> | <a ui-sref="about">About</a> | <a ui-sref="{page: 2}">Next page</a>
  7375. *
  7376. * <ul>
  7377. * <li ng-repeat="contact in contacts">
  7378. * <a ui-sref="contacts.detail({ id: contact.id })">{{ contact.name }}</a>
  7379. * </li>
  7380. * </ul>
  7381. * </pre>
  7382. * ```
  7383. *
  7384. * Then the compiled html would be (assuming Html5Mode is off and current state is contacts):
  7385. *
  7386. * ```html
  7387. *
  7388. * <pre>
  7389. * <a href="#/home" ui-sref="home">Home</a> | <a href="#/about" ui-sref="about">About</a> | <a href="#/contacts?page=2" ui-sref="{page: 2}">Next page</a>
  7390. *
  7391. * <ul>
  7392. * <li ng-repeat="contact in contacts">
  7393. * <a href="#/contacts/1" ui-sref="contacts.detail({ id: contact.id })">Joe</a>
  7394. * </li>
  7395. * <li ng-repeat="contact in contacts">
  7396. * <a href="#/contacts/2" ui-sref="contacts.detail({ id: contact.id })">Alice</a>
  7397. * </li>
  7398. * <li ng-repeat="contact in contacts">
  7399. * <a href="#/contacts/3" ui-sref="contacts.detail({ id: contact.id })">Bob</a>
  7400. * </li>
  7401. * </ul>
  7402. *
  7403. * <a ui-sref="home" ui-sref-opts="{reload: true}">Home</a>
  7404. * </pre>
  7405. * ```
  7406. *
  7407. * @param {string} ui-sref 'stateName' can be any valid absolute or relative state
  7408. * @param {Object} ui-sref-opts options to pass to [[StateService.go]]
  7409. */
  7410. var uiSref = ['$state', '$timeout',
  7411. function $StateRefDirective($state, $timeout) {
  7412. return {
  7413. restrict: 'A',
  7414. require: ['?^uiSrefActive', '?^uiSrefActiveEq'],
  7415. link: function (scope, element, attrs, uiSrefActive) {
  7416. var ref = parseStateRef(attrs.uiSref, $state.current.name);
  7417. var def = { state: ref.state, href: null, params: null, options: null };
  7418. var type = getTypeInfo(element);
  7419. var active = uiSrefActive[1] || uiSrefActive[0];
  7420. var unlinkInfoFn = null;
  7421. var hookFn;
  7422. def.options = common_1.extend(defaultOpts(element, $state), attrs.uiSrefOpts ? scope.$eval(attrs.uiSrefOpts) : {});
  7423. var update = function (val) {
  7424. if (val)
  7425. def.params = angular.copy(val);
  7426. def.href = $state.href(ref.state, def.params, def.options);
  7427. if (unlinkInfoFn)
  7428. unlinkInfoFn();
  7429. if (active)
  7430. unlinkInfoFn = active.$$addStateInfo(ref.state, def.params);
  7431. if (def.href !== null)
  7432. attrs.$set(type.attr, def.href);
  7433. };
  7434. if (ref.paramExpr) {
  7435. scope.$watch(ref.paramExpr, function (val) { if (val !== def.params)
  7436. update(val); }, true);
  7437. def.params = angular.copy(scope.$eval(ref.paramExpr));
  7438. }
  7439. update();
  7440. if (!type.clickable)
  7441. return;
  7442. hookFn = clickHook(element, $state, $timeout, type, function () { return def; });
  7443. element.on("click", hookFn);
  7444. scope.$on('$destroy', function () {
  7445. element.off("click", hookFn);
  7446. });
  7447. }
  7448. };
  7449. }];
  7450. /**
  7451. * `ui-state`: A dynamic version of `ui-sref`
  7452. *
  7453. * Much like ui-sref, but will accept named $scope properties to evaluate for a state definition,
  7454. * params and override options.
  7455. *
  7456. * @example
  7457. * ```html
  7458. *
  7459. * <li ng-repeat="nav in navlinks">
  7460. * <a ui-state="nav.statename">{{nav.description}}</a>
  7461. * </li>
  7462. *
  7463. * @param {string} ui-state 'stateName' can be any valid absolute or relative state
  7464. * @param {Object} ui-state-params params to pass to [[StateService.href]]
  7465. * @param {Object} ui-state-opts options to pass to [[StateService.go]]
  7466. */
  7467. var uiState = ['$state', '$timeout',
  7468. function $StateRefDynamicDirective($state, $timeout) {
  7469. return {
  7470. restrict: 'A',
  7471. require: ['?^uiSrefActive', '?^uiSrefActiveEq'],
  7472. link: function (scope, element, attrs, uiSrefActive) {
  7473. var type = getTypeInfo(element);
  7474. var active = uiSrefActive[1] || uiSrefActive[0];
  7475. var group = [attrs.uiState, attrs.uiStateParams || null, attrs.uiStateOpts || null];
  7476. var watch = '[' + group.map(function (val) { return val || 'null'; }).join(', ') + ']';
  7477. var def = { state: null, params: null, options: null, href: null };
  7478. var unlinkInfoFn = null;
  7479. var hookFn;
  7480. function runStateRefLink(group) {
  7481. def.state = group[0];
  7482. def.params = group[1];
  7483. def.options = group[2];
  7484. def.href = $state.href(def.state, def.params, def.options);
  7485. if (unlinkInfoFn)
  7486. unlinkInfoFn();
  7487. if (active)
  7488. unlinkInfoFn = active.$$addStateInfo(def.state, def.params);
  7489. if (def.href)
  7490. attrs.$set(type.attr, def.href);
  7491. }
  7492. scope.$watch(watch, runStateRefLink, true);
  7493. runStateRefLink(scope.$eval(watch));
  7494. if (!type.clickable)
  7495. return;
  7496. hookFn = clickHook(element, $state, $timeout, type, function () { return def; });
  7497. element.on("click", hookFn);
  7498. scope.$on('$destroy', function () {
  7499. element.off("click", hookFn);
  7500. });
  7501. }
  7502. };
  7503. }];
  7504. /**
  7505. * `ui-sref-active` and `ui-sref-active-eq`: A directive that adds a CSS class when a `ui-sref` is active
  7506. *
  7507. * A directive working alongside ui-sref to add classes to an element when the
  7508. * related ui-sref directive's state is active, and removing them when it is inactive.
  7509. * The primary use-case is to simplify the special appearance of navigation menus
  7510. * relying on `ui-sref`, by having the "active" state's menu button appear different,
  7511. * distinguishing it from the inactive menu items.
  7512. *
  7513. * ui-sref-active can live on the same element as ui-sref or on a parent element. The first
  7514. * ui-sref-active found at the same level or above the ui-sref will be used.
  7515. *
  7516. * Will activate when the ui-sref's target state or any child state is active. If you
  7517. * need to activate only when the ui-sref target state is active and *not* any of
  7518. * it's children, then you will use ui-sref-active-eq
  7519. *
  7520. * Given the following template:
  7521. * @example
  7522. * ```html
  7523. *
  7524. * <pre>
  7525. * <ul>
  7526. * <li ui-sref-active="active" class="item">
  7527. * <a href ui-sref="app.user({user: 'bilbobaggins'})">@bilbobaggins</a>
  7528. * </li>
  7529. * </ul>
  7530. * </pre>
  7531. * ```
  7532. *
  7533. *
  7534. * When the app state is "app.user" (or any children states), and contains the state parameter "user" with value "bilbobaggins",
  7535. * the resulting HTML will appear as (note the 'active' class):
  7536. *
  7537. * ```html
  7538. *
  7539. * <pre>
  7540. * <ul>
  7541. * <li ui-sref-active="active" class="item active">
  7542. * <a ui-sref="app.user({user: 'bilbobaggins'})" href="/users/bilbobaggins">@bilbobaggins</a>
  7543. * </li>
  7544. * </ul>
  7545. * </pre>
  7546. * ```
  7547. *
  7548. * The class name is interpolated **once** during the directives link time (any further changes to the
  7549. * interpolated value are ignored).
  7550. *
  7551. * Multiple classes may be specified in a space-separated format:
  7552. *
  7553. * ```html
  7554. * <pre>
  7555. * <ul>
  7556. * <li ui-sref-active='class1 class2 class3'>
  7557. * <a ui-sref="app.user">link</a>
  7558. * </li>
  7559. * </ul>
  7560. * </pre>
  7561. * ```
  7562. *
  7563. * It is also possible to pass ui-sref-active an expression that evaluates
  7564. * to an object hash, whose keys represent active class names and whose
  7565. * values represent the respective state names/globs.
  7566. * ui-sref-active will match if the current active state **includes** any of
  7567. * the specified state names/globs, even the abstract ones.
  7568. *
  7569. * Given the following template, with "admin" being an abstract state:
  7570. * @example
  7571. * ```html
  7572. *
  7573. * <pre>
  7574. * <div ui-sref-active="{'active': 'admin.*'}">
  7575. * <a ui-sref-active="active" ui-sref="admin.roles">Roles</a>
  7576. * </div>
  7577. * </pre>
  7578. * ```
  7579. *
  7580. * When the current state is "admin.roles" the "active" class will be applied
  7581. * to both the <div> and <a> elements. It is important to note that the state
  7582. * names/globs passed to ui-sref-active shadow the state provided by ui-sref.
  7583. */
  7584. var uiSrefActive = ['$state', '$stateParams', '$interpolate', '$transitions', '$uiRouter',
  7585. function $StateRefActiveDirective($state, $stateParams, $interpolate, $transitions, $uiRouter) {
  7586. return {
  7587. restrict: "A",
  7588. controller: ['$scope', '$element', '$attrs', '$timeout',
  7589. function ($scope, $element, $attrs, $timeout) {
  7590. var states = [], activeClasses = {}, activeEqClass, uiSrefActive;
  7591. // There probably isn't much point in $observing this
  7592. // uiSrefActive and uiSrefActiveEq share the same directive object with some
  7593. // slight difference in logic routing
  7594. activeEqClass = $interpolate($attrs.uiSrefActiveEq || '', false)($scope);
  7595. try {
  7596. uiSrefActive = $scope.$eval($attrs.uiSrefActive);
  7597. }
  7598. catch (e) {
  7599. }
  7600. uiSrefActive = uiSrefActive || $interpolate($attrs.uiSrefActive || '', false)($scope);
  7601. if (predicates_1.isObject(uiSrefActive)) {
  7602. common_1.forEach(uiSrefActive, function (stateOrName, activeClass) {
  7603. if (predicates_1.isString(stateOrName)) {
  7604. var ref = parseStateRef(stateOrName, $state.current.name);
  7605. addState(ref.state, $scope.$eval(ref.paramExpr), activeClass);
  7606. }
  7607. });
  7608. }
  7609. // Allow uiSref to communicate with uiSrefActive[Equals]
  7610. this.$$addStateInfo = function (newState, newParams) {
  7611. // we already got an explicit state provided by ui-sref-active, so we
  7612. // shadow the one that comes from ui-sref
  7613. if (predicates_1.isObject(uiSrefActive) && states.length > 0) {
  7614. return;
  7615. }
  7616. var deregister = addState(newState, newParams, uiSrefActive);
  7617. update();
  7618. return deregister;
  7619. };
  7620. function updateAfterTransition(trans) { trans.promise.then(update); }
  7621. $scope.$on('$stateChangeSuccess', update);
  7622. $scope.$on('$destroy', $transitions.onStart({}, updateAfterTransition));
  7623. if ($uiRouter.globals.transition) {
  7624. updateAfterTransition($uiRouter.globals.transition);
  7625. }
  7626. function addState(stateName, stateParams, activeClass) {
  7627. var state = $state.get(stateName, stateContext($element));
  7628. var stateHash = createStateHash(stateName, stateParams);
  7629. var stateInfo = {
  7630. state: state || { name: stateName },
  7631. params: stateParams,
  7632. hash: stateHash
  7633. };
  7634. states.push(stateInfo);
  7635. activeClasses[stateHash] = activeClass;
  7636. return function removeState() {
  7637. var idx = states.indexOf(stateInfo);
  7638. if (idx !== -1)
  7639. states.splice(idx, 1);
  7640. };
  7641. }
  7642. /**
  7643. * @param {string} state
  7644. * @param {Object|string} [params]
  7645. * @return {string}
  7646. */
  7647. function createStateHash(state, params) {
  7648. if (!predicates_1.isString(state)) {
  7649. throw new Error('state should be a string');
  7650. }
  7651. if (predicates_1.isObject(params)) {
  7652. return state + common_1.toJson(params);
  7653. }
  7654. params = $scope.$eval(params);
  7655. if (predicates_1.isObject(params)) {
  7656. return state + common_1.toJson(params);
  7657. }
  7658. return state;
  7659. }
  7660. // Update route state
  7661. function update() {
  7662. for (var i = 0; i < states.length; i++) {
  7663. if (anyMatch(states[i].state, states[i].params)) {
  7664. addClass($element, activeClasses[states[i].hash]);
  7665. }
  7666. else {
  7667. removeClass($element, activeClasses[states[i].hash]);
  7668. }
  7669. if (exactMatch(states[i].state, states[i].params)) {
  7670. addClass($element, activeEqClass);
  7671. }
  7672. else {
  7673. removeClass($element, activeEqClass);
  7674. }
  7675. }
  7676. }
  7677. function addClass(el, className) { $timeout(function () { el.addClass(className); }); }
  7678. function removeClass(el, className) { el.removeClass(className); }
  7679. function anyMatch(state, params) { return $state.includes(state.name, params); }
  7680. function exactMatch(state, params) { return $state.is(state.name, params); }
  7681. update();
  7682. }]
  7683. };
  7684. }];
  7685. angular.module('ui.router.state')
  7686. .directive('uiSref', uiSref)
  7687. .directive('uiSrefActive', uiSrefActive)
  7688. .directive('uiSrefActiveEq', uiSrefActive)
  7689. .directive('uiState', uiState);
  7690. /***/ },
  7691. /* 61 */
  7692. /***/ function(module, exports, __webpack_require__) {
  7693. /** @module state */ /** for typedoc */
  7694. "use strict";
  7695. var angular = __webpack_require__(57);
  7696. /**
  7697. * @ngdoc filter
  7698. * @name ui.router.state.filter:isState
  7699. *
  7700. * @requires ui.router.state.$state
  7701. *
  7702. * @description
  7703. * Translates to {@link ui.router.state.$state#methods_is $state.is("stateName")}.
  7704. */
  7705. $IsStateFilter.$inject = ['$state'];
  7706. function $IsStateFilter($state) {
  7707. var isFilter = function (state, params, options) {
  7708. return $state.is(state, params, options);
  7709. };
  7710. isFilter.$stateful = true;
  7711. return isFilter;
  7712. }
  7713. exports.$IsStateFilter = $IsStateFilter;
  7714. /**
  7715. * @ngdoc filter
  7716. * @name ui.router.state.filter:includedByState
  7717. *
  7718. * @requires ui.router.state.$state
  7719. *
  7720. * @description
  7721. * Translates to {@link ui.router.state.$state#methods_includes $state.includes('fullOrPartialStateName')}.
  7722. */
  7723. $IncludedByStateFilter.$inject = ['$state'];
  7724. function $IncludedByStateFilter($state) {
  7725. var includesFilter = function (state, params, options) {
  7726. return $state.includes(state, params, options);
  7727. };
  7728. includesFilter.$stateful = true;
  7729. return includesFilter;
  7730. }
  7731. exports.$IncludedByStateFilter = $IncludedByStateFilter;
  7732. angular.module('ui.router.state')
  7733. .filter('isState', $IsStateFilter)
  7734. .filter('includedByState', $IncludedByStateFilter);
  7735. /***/ },
  7736. /* 62 */
  7737. /***/ function(module, exports, __webpack_require__) {
  7738. /** @module ng1_directives */ /** for typedoc */
  7739. "use strict";
  7740. var common_1 = __webpack_require__(3);
  7741. var predicates_1 = __webpack_require__(4);
  7742. var trace_1 = __webpack_require__(12);
  7743. var views_1 = __webpack_require__(55);
  7744. var hof_1 = __webpack_require__(5);
  7745. var resolveContext_1 = __webpack_require__(17);
  7746. var strings_1 = __webpack_require__(9);
  7747. var services_1 = __webpack_require__(53);
  7748. var angular = __webpack_require__(57);
  7749. /**
  7750. * `ui-view`: A viewport directive which is filled in by a view from the active state.
  7751. *
  7752. * @param {string=} name A view name. The name should be unique amongst the other views in the
  7753. * same state. You can have views of the same name that live in different states.
  7754. *
  7755. * @param {string=} autoscroll It allows you to set the scroll behavior of the browser window
  7756. * when a view is populated. By default, $anchorScroll is overridden by ui-router's custom scroll
  7757. * service, {@link ui.router.state.$uiViewScroll}. This custom service let's you
  7758. * scroll ui-view elements into view when they are populated during a state activation.
  7759. *
  7760. * *Note: To revert back to old [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll)
  7761. * functionality, call `$uiViewScrollProvider.useAnchorScroll()`.*
  7762. *
  7763. * @param {string=} onload Expression to evaluate whenever the view updates.
  7764. *
  7765. * A view can be unnamed or named.
  7766. * @example
  7767. * ```html
  7768. *
  7769. * <!-- Unnamed -->
  7770. * <div ui-view></div>
  7771. *
  7772. * <!-- Named -->
  7773. * <div ui-view="viewName"></div>
  7774. * ```
  7775. *
  7776. * You can only have one unnamed view within any template (or root html). If you are only using a
  7777. * single view and it is unnamed then you can populate it like so:
  7778. * ```
  7779. *
  7780. * <div ui-view></div>
  7781. * $stateProvider.state("home", {
  7782. * template: "<h1>HELLO!</h1>"
  7783. * })
  7784. * ```
  7785. *
  7786. * The above is a convenient shortcut equivalent to specifying your view explicitly with the {@link ui.router.state.$stateProvider#views `views`}
  7787. * config property, by name, in this case an empty name:
  7788. * ```js
  7789. *
  7790. * $stateProvider.state("home", {
  7791. * views: {
  7792. * "": {
  7793. * template: "<h1>HELLO!</h1>"
  7794. * }
  7795. * }
  7796. * })
  7797. * ```
  7798. *
  7799. * But typically you'll only use the views property if you name your view or have more than one view
  7800. * in the same template. There's not really a compelling reason to name a view if its the only one,
  7801. * but you could if you wanted, like so:
  7802. *
  7803. * ```html
  7804. *
  7805. * <div ui-view="main"></div>
  7806. * ```
  7807. *
  7808. * ```js
  7809. *
  7810. * $stateProvider.state("home", {
  7811. * views: {
  7812. * "main": {
  7813. * template: "<h1>HELLO!</h1>"
  7814. * }
  7815. * }
  7816. * })
  7817. * ```
  7818. *
  7819. * Really though, you'll use views to set up multiple views:
  7820. * ```html
  7821. *
  7822. * <div ui-view></div>
  7823. * <div ui-view="chart"></div>
  7824. * <div ui-view="data"></div>
  7825. * ```
  7826. *
  7827. * ```js
  7828. * $stateProvider.state("home", {
  7829. * views: {
  7830. * "": {
  7831. * template: "<h1>HELLO!</h1>"
  7832. * },
  7833. * "chart": {
  7834. * template: "<chart_thing/>"
  7835. * },
  7836. * "data": {
  7837. * template: "<data_thing/>"
  7838. * }
  7839. * }
  7840. * })
  7841. * ```
  7842. *
  7843. * Examples for `autoscroll`:
  7844. *
  7845. * ```html
  7846. *
  7847. * <!-- If autoscroll present with no expression,
  7848. * then scroll ui-view into view -->
  7849. * <ui-view autoscroll/>
  7850. *
  7851. * <!-- If autoscroll present with valid expression,
  7852. * then scroll ui-view into view if expression evaluates to true -->
  7853. * <ui-view autoscroll='true'/>
  7854. * <ui-view autoscroll='false'/>
  7855. * <ui-view autoscroll='scopeVariable'/>
  7856. * ```
  7857. *
  7858. * Resolve data:
  7859. *
  7860. * The resolved data from the state's `resolve` block is placed on the scope as `$resolve` (this
  7861. * can be customized using [[ViewDeclaration.resolveAs]]). This can be then accessed from the template.
  7862. *
  7863. * Note that when `controllerAs` is being used, `$resolve` is set on the controller instance *after* the
  7864. * controller is instantiated. The `$onInit()` hook can be used to perform initialization code which
  7865. * depends on `$resolve` data.
  7866. *
  7867. * @example
  7868. * ```js
  7869. *
  7870. * $stateProvider.state('home', {
  7871. * template: '<my-component user="$resolve.user"></my-component>',
  7872. * resolve: {
  7873. * user: function(UserService) { return UserService.fetchUser(); }
  7874. * }
  7875. * });
  7876. * ```
  7877. */
  7878. var uiView = ['$view', '$animate', '$uiViewScroll', '$interpolate', '$q',
  7879. function $ViewDirective($view, $animate, $uiViewScroll, $interpolate, $q) {
  7880. function getRenderer(attrs, scope) {
  7881. return {
  7882. enter: function (element, target, cb) {
  7883. if (angular.version.minor > 2) {
  7884. $animate.enter(element, null, target).then(cb);
  7885. }
  7886. else {
  7887. $animate.enter(element, null, target, cb);
  7888. }
  7889. },
  7890. leave: function (element, cb) {
  7891. if (angular.version.minor > 2) {
  7892. $animate.leave(element).then(cb);
  7893. }
  7894. else {
  7895. $animate.leave(element, cb);
  7896. }
  7897. }
  7898. };
  7899. }
  7900. function configsEqual(config1, config2) {
  7901. return config1 === config2;
  7902. }
  7903. var rootData = {
  7904. $cfg: { viewDecl: { $context: $view.rootContext() } },
  7905. $uiView: {}
  7906. };
  7907. var directive = {
  7908. count: 0,
  7909. restrict: 'ECA',
  7910. terminal: true,
  7911. priority: 400,
  7912. transclude: 'element',
  7913. compile: function (tElement, tAttrs, $transclude) {
  7914. return function (scope, $element, attrs) {
  7915. var previousEl, currentEl, currentScope, unregister, onloadExp = attrs['onload'] || '', autoScrollExp = attrs['autoscroll'], renderer = getRenderer(attrs, scope), viewConfig = undefined, inherited = $element.inheritedData('$uiView') || rootData, name = $interpolate(attrs['uiView'] || attrs['name'] || '')(scope) || '$default';
  7916. var activeUIView = {
  7917. $type: 'ng1',
  7918. id: directive.count++,
  7919. name: name,
  7920. fqn: inherited.$uiView.fqn ? inherited.$uiView.fqn + "." + name : name,
  7921. config: null,
  7922. configUpdated: configUpdatedCallback,
  7923. get creationContext() {
  7924. return hof_1.parse('$cfg.viewDecl.$context')(inherited);
  7925. }
  7926. };
  7927. trace_1.trace.traceUIViewEvent("Linking", activeUIView);
  7928. function configUpdatedCallback(config) {
  7929. if (config && !(config instanceof views_1.Ng1ViewConfig))
  7930. return;
  7931. if (configsEqual(viewConfig, config))
  7932. return;
  7933. trace_1.trace.traceUIViewConfigUpdated(activeUIView, config && config.viewDecl && config.viewDecl.$context);
  7934. viewConfig = config;
  7935. updateView(config);
  7936. }
  7937. $element.data('$uiView', { $uiView: activeUIView });
  7938. updateView();
  7939. unregister = $view.registerUIView(activeUIView);
  7940. scope.$on("$destroy", function () {
  7941. trace_1.trace.traceUIViewEvent("Destroying/Unregistering", activeUIView);
  7942. unregister();
  7943. });
  7944. function cleanupLastView() {
  7945. if (previousEl) {
  7946. trace_1.trace.traceUIViewEvent("Removing (previous) el", previousEl.data('$uiView'));
  7947. previousEl.remove();
  7948. previousEl = null;
  7949. }
  7950. if (currentScope) {
  7951. trace_1.trace.traceUIViewEvent("Destroying scope", activeUIView);
  7952. currentScope.$destroy();
  7953. currentScope = null;
  7954. }
  7955. if (currentEl) {
  7956. var _viewData_1 = currentEl.data('$uiViewAnim');
  7957. trace_1.trace.traceUIViewEvent("Animate out", _viewData_1);
  7958. renderer.leave(currentEl, function () {
  7959. _viewData_1.$$animLeave.resolve();
  7960. previousEl = null;
  7961. });
  7962. previousEl = currentEl;
  7963. currentEl = null;
  7964. }
  7965. }
  7966. function updateView(config) {
  7967. var newScope = scope.$new();
  7968. var animEnter = $q.defer(), animLeave = $q.defer();
  7969. var $uiViewData = {
  7970. $cfg: config,
  7971. $uiView: activeUIView,
  7972. };
  7973. var $uiViewAnim = {
  7974. $animEnter: animEnter.promise,
  7975. $animLeave: animLeave.promise,
  7976. $$animLeave: animLeave
  7977. };
  7978. var cloned = $transclude(newScope, function (clone) {
  7979. clone.data('$uiViewAnim', $uiViewAnim);
  7980. clone.data('$uiView', $uiViewData);
  7981. renderer.enter(clone, $element, function onUIViewEnter() {
  7982. animEnter.resolve();
  7983. if (currentScope)
  7984. currentScope.$emit('$viewContentAnimationEnded');
  7985. if (predicates_1.isDefined(autoScrollExp) && !autoScrollExp || scope.$eval(autoScrollExp)) {
  7986. $uiViewScroll(clone);
  7987. }
  7988. });
  7989. cleanupLastView();
  7990. });
  7991. currentEl = cloned;
  7992. currentScope = newScope;
  7993. /**
  7994. * @ngdoc event
  7995. * @name ui.router.state.directive:ui-view#$viewContentLoaded
  7996. * @eventOf ui.router.state.directive:ui-view
  7997. * @eventType emits on ui-view directive scope
  7998. * @description *
  7999. * Fired once the view is **loaded**, *after* the DOM is rendered.
  8000. *
  8001. * @param {Object} event Event object.
  8002. */
  8003. currentScope.$emit('$viewContentLoaded', config || viewConfig);
  8004. currentScope.$eval(onloadExp);
  8005. }
  8006. };
  8007. }
  8008. };
  8009. return directive;
  8010. }];
  8011. $ViewDirectiveFill.$inject = ['$compile', '$controller', '$transitions', '$view', '$timeout'];
  8012. /** @hidden */
  8013. function $ViewDirectiveFill($compile, $controller, $transitions, $view, $timeout) {
  8014. var getControllerAs = hof_1.parse('viewDecl.controllerAs');
  8015. var getResolveAs = hof_1.parse('viewDecl.resolveAs');
  8016. return {
  8017. restrict: 'ECA',
  8018. priority: -400,
  8019. compile: function (tElement) {
  8020. var initial = tElement.html();
  8021. return function (scope, $element) {
  8022. var data = $element.data('$uiView');
  8023. if (!data)
  8024. return;
  8025. var cfg = data.$cfg || { viewDecl: {} };
  8026. $element.html(cfg.template || initial);
  8027. trace_1.trace.traceUIViewFill(data.$uiView, $element.html());
  8028. var link = $compile($element.contents());
  8029. var controller = cfg.controller;
  8030. var controllerAs = getControllerAs(cfg);
  8031. var resolveAs = getResolveAs(cfg);
  8032. var resolveCtx = cfg.path && new resolveContext_1.ResolveContext(cfg.path);
  8033. var locals = resolveCtx && services_1.getLocals(resolveCtx);
  8034. scope[resolveAs] = locals;
  8035. if (controller) {
  8036. var controllerInstance = $controller(controller, common_1.extend({}, locals, { $scope: scope, $element: $element }));
  8037. if (controllerAs) {
  8038. scope[controllerAs] = controllerInstance;
  8039. scope[controllerAs][resolveAs] = locals;
  8040. }
  8041. // TODO: Use $view service as a central point for registering component-level hooks
  8042. // Then, when a component is created, tell the $view service, so it can invoke hooks
  8043. // $view.componentLoaded(controllerInstance, { $scope: scope, $element: $element });
  8044. // scope.$on('$destroy', () => $view.componentUnloaded(controllerInstance, { $scope: scope, $element: $element }));
  8045. $element.data('$ngControllerController', controllerInstance);
  8046. $element.children().data('$ngControllerController', controllerInstance);
  8047. registerControllerCallbacks($transitions, controllerInstance, scope, cfg);
  8048. }
  8049. // Wait for the component to appear in the DOM
  8050. if (predicates_1.isString(cfg.viewDecl.component)) {
  8051. var cmp_1 = cfg.viewDecl.component;
  8052. var kebobName_1 = strings_1.kebobString(cmp_1);
  8053. var getComponentController = function () {
  8054. var directiveEl = [].slice.call($element[0].children)
  8055. .filter(function (el) { return el && el.tagName && el.tagName.toLowerCase() === kebobName_1; });
  8056. return directiveEl && angular.element(directiveEl).data("$" + cmp_1 + "Controller");
  8057. };
  8058. var deregisterWatch_1 = scope.$watch(getComponentController, function (ctrlInstance) {
  8059. if (!ctrlInstance)
  8060. return;
  8061. registerControllerCallbacks($transitions, ctrlInstance, scope, cfg);
  8062. deregisterWatch_1();
  8063. });
  8064. }
  8065. link(scope);
  8066. };
  8067. }
  8068. };
  8069. }
  8070. /** @hidden */
  8071. var hasComponentImpl = typeof angular.module('ui.router')['component'] === 'function';
  8072. /** @hidden TODO: move these callbacks to $view and/or `/hooks/components.ts` or something */
  8073. function registerControllerCallbacks($transitions, controllerInstance, $scope, cfg) {
  8074. // Call $onInit() ASAP
  8075. if (predicates_1.isFunction(controllerInstance.$onInit) && !(cfg.viewDecl.component && hasComponentImpl))
  8076. controllerInstance.$onInit();
  8077. var viewState = common_1.tail(cfg.path).state.self;
  8078. var hookOptions = { bind: controllerInstance };
  8079. // Add component-level hook for onParamsChange
  8080. if (predicates_1.isFunction(controllerInstance.uiOnParamsChanged)) {
  8081. var resolveContext = new resolveContext_1.ResolveContext(cfg.path);
  8082. var viewCreationTrans_1 = resolveContext.getResolvable('$transition$').data;
  8083. // Fire callback on any successful transition
  8084. var paramsUpdated = function ($transition$) {
  8085. // Exit early if the $transition$ is the same as the view was created within.
  8086. // Exit early if the $transition$ will exit the state the view is for.
  8087. if ($transition$ === viewCreationTrans_1 || $transition$.exiting().indexOf(viewState) !== -1)
  8088. return;
  8089. var toParams = $transition$.params("to");
  8090. var fromParams = $transition$.params("from");
  8091. var toSchema = $transition$.treeChanges().to.map(function (node) { return node.paramSchema; }).reduce(common_1.unnestR, []);
  8092. var fromSchema = $transition$.treeChanges().from.map(function (node) { return node.paramSchema; }).reduce(common_1.unnestR, []);
  8093. // Find the to params that have different values than the from params
  8094. var changedToParams = toSchema.filter(function (param) {
  8095. var idx = fromSchema.indexOf(param);
  8096. return idx === -1 || !fromSchema[idx].type.equals(toParams[param.id], fromParams[param.id]);
  8097. });
  8098. // Only trigger callback if a to param has changed or is new
  8099. if (changedToParams.length) {
  8100. var changedKeys_1 = changedToParams.map(function (x) { return x.id; });
  8101. // Filter the params to only changed/new to params. `$transition$.params()` may be used to get all params.
  8102. controllerInstance.uiOnParamsChanged(common_1.filter(toParams, function (val, key) { return changedKeys_1.indexOf(key) !== -1; }), $transition$);
  8103. }
  8104. };
  8105. $scope.$on('$destroy', $transitions.onSuccess({}, paramsUpdated, hookOptions));
  8106. }
  8107. // Add component-level hook for uiCanExit
  8108. if (predicates_1.isFunction(controllerInstance.uiCanExit)) {
  8109. var criteria = { exiting: viewState.name };
  8110. $scope.$on('$destroy', $transitions.onBefore(criteria, controllerInstance.uiCanExit, hookOptions));
  8111. }
  8112. }
  8113. angular.module('ui.router.state').directive('uiView', uiView);
  8114. angular.module('ui.router.state').directive('uiView', $ViewDirectiveFill);
  8115. /***/ },
  8116. /* 63 */
  8117. /***/ function(module, exports, __webpack_require__) {
  8118. "use strict";
  8119. /** @module ng1 */ /** */
  8120. var angular = __webpack_require__(57);
  8121. /**
  8122. * @ngdoc object
  8123. * @name ui.router.state.$uiViewScrollProvider
  8124. *
  8125. * @description
  8126. * Provider that returns the {@link ui.router.state.$uiViewScroll} service function.
  8127. */
  8128. function $ViewScrollProvider() {
  8129. var useAnchorScroll = false;
  8130. /**
  8131. * @ngdoc function
  8132. * @name ui.router.state.$uiViewScrollProvider#useAnchorScroll
  8133. * @methodOf ui.router.state.$uiViewScrollProvider
  8134. *
  8135. * @description
  8136. * Reverts back to using the core [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll) service for
  8137. * scrolling based on the url anchor.
  8138. */
  8139. this.useAnchorScroll = function () {
  8140. useAnchorScroll = true;
  8141. };
  8142. /**
  8143. * @ngdoc object
  8144. * @name ui.router.state.$uiViewScroll
  8145. *
  8146. * @requires $anchorScroll
  8147. * @requires $timeout
  8148. *
  8149. * @description
  8150. * When called with a jqLite element, it scrolls the element into view (after a
  8151. * `$timeout` so the DOM has time to refresh).
  8152. *
  8153. * If you prefer to rely on `$anchorScroll` to scroll the view to the anchor,
  8154. * this can be enabled by calling {@link ui.router.state.$uiViewScrollProvider#methods_useAnchorScroll `$uiViewScrollProvider.useAnchorScroll()`}.
  8155. */
  8156. this.$get = ['$anchorScroll', '$timeout', function ($anchorScroll, $timeout) {
  8157. if (useAnchorScroll) {
  8158. return $anchorScroll;
  8159. }
  8160. return function ($element) {
  8161. return $timeout(function () {
  8162. $element[0].scrollIntoView();
  8163. }, 0, false);
  8164. };
  8165. }];
  8166. }
  8167. angular.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider);
  8168. /***/ }
  8169. /******/ ])
  8170. });
  8171. ;
  8172. //# sourceMappingURL=angular-ui-router.js.map