angular-ui-router.js 352 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366
  1. /*
  2. * Password Management Servlets (PWM)
  3. * http://www.pwm-project.org
  4. *
  5. * Copyright (c) 2006-2009 Novell, Inc.
  6. * Copyright (c) 2009-2018 The PWM Project
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. /*!
  23. * State-based routing for AngularJS
  24. * @version v1.0.0-beta.3
  25. * @link https://ui-router.github.io
  26. * @license MIT License, http://www.opensource.org/licenses/MIT
  27. */
  28. (function webpackUniversalModuleDefinition(root, factory) {
  29. if(typeof exports === 'object' && typeof module === 'object')
  30. module.exports = factory(require("angular"));
  31. else if(typeof define === 'function' && define.amd)
  32. define("angular-ui-router", ["angular"], factory);
  33. else if(typeof exports === 'object')
  34. exports["angular-ui-router"] = factory(require("angular"));
  35. else
  36. root["angular-ui-router"] = factory(root["angular"]);
  37. })(this, function(__WEBPACK_EXTERNAL_MODULE_57__) {
  38. return /******/ (function(modules) { // webpackBootstrap
  39. /******/ // The module cache
  40. /******/ var installedModules = {};
  41. /******/
  42. /******/ // The require function
  43. /******/ function __webpack_require__(moduleId) {
  44. /******/
  45. /******/ // Check if module is in cache
  46. /******/ if(installedModules[moduleId])
  47. /******/ return installedModules[moduleId].exports;
  48. /******/
  49. /******/ // Create a new module (and put it into the cache)
  50. /******/ var module = installedModules[moduleId] = {
  51. /******/ exports: {},
  52. /******/ id: moduleId,
  53. /******/ loaded: false
  54. /******/ };
  55. /******/
  56. /******/ // Execute the module function
  57. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  58. /******/
  59. /******/ // Flag the module as loaded
  60. /******/ module.loaded = true;
  61. /******/
  62. /******/ // Return the exports of the module
  63. /******/ return module.exports;
  64. /******/ }
  65. /******/
  66. /******/
  67. /******/ // expose the modules object (__webpack_modules__)
  68. /******/ __webpack_require__.m = modules;
  69. /******/
  70. /******/ // expose the module cache
  71. /******/ __webpack_require__.c = installedModules;
  72. /******/
  73. /******/ // __webpack_public_path__
  74. /******/ __webpack_require__.p = "";
  75. /******/
  76. /******/ // Load entry module and return exports
  77. /******/ return __webpack_require__(0);
  78. /******/ })
  79. /************************************************************************/
  80. /******/ ([
  81. /* 0 */
  82. /***/ function(module, exports, __webpack_require__) {
  83. /**
  84. * Main entry point for angular 1.x build
  85. * @module ng1
  86. */
  87. /** for typedoc */
  88. "use strict";
  89. function __export(m) {
  90. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  91. }
  92. __export(__webpack_require__(1));
  93. __export(__webpack_require__(53));
  94. __export(__webpack_require__(55));
  95. __export(__webpack_require__(58));
  96. __webpack_require__(60);
  97. __webpack_require__(61);
  98. __webpack_require__(62);
  99. __webpack_require__(63);
  100. Object.defineProperty(exports, "__esModule", { value: true });
  101. exports.default = "ui.router";
  102. /***/ },
  103. /* 1 */
  104. /***/ function(module, exports, __webpack_require__) {
  105. /** @module common */ /** */
  106. "use strict";
  107. function __export(m) {
  108. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  109. }
  110. __export(__webpack_require__(2));
  111. __export(__webpack_require__(46));
  112. __export(__webpack_require__(47));
  113. __export(__webpack_require__(48));
  114. __export(__webpack_require__(49));
  115. __export(__webpack_require__(50));
  116. __export(__webpack_require__(51));
  117. __export(__webpack_require__(52));
  118. __export(__webpack_require__(44));
  119. var router_1 = __webpack_require__(25);
  120. exports.UIRouter = router_1.UIRouter;
  121. /***/ },
  122. /* 2 */
  123. /***/ function(module, exports, __webpack_require__) {
  124. "use strict";
  125. function __export(m) {
  126. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  127. }
  128. /** @module common */ /** for typedoc */
  129. __export(__webpack_require__(3));
  130. __export(__webpack_require__(6));
  131. __export(__webpack_require__(7));
  132. __export(__webpack_require__(5));
  133. __export(__webpack_require__(4));
  134. __export(__webpack_require__(8));
  135. __export(__webpack_require__(9));
  136. __export(__webpack_require__(12));
  137. /***/ },
  138. /* 3 */
  139. /***/ function(module, exports, __webpack_require__) {
  140. /**
  141. * Random utility functions used in the UI-Router code
  142. *
  143. * @preferred @module common
  144. */ /** for typedoc */
  145. "use strict";
  146. var predicates_1 = __webpack_require__(4);
  147. var hof_1 = __webpack_require__(5);
  148. var coreservices_1 = __webpack_require__(6);
  149. var w = typeof window === 'undefined' ? {} : window;
  150. var angular = w.angular || {};
  151. exports.fromJson = angular.fromJson || JSON.parse.bind(JSON);
  152. exports.toJson = angular.toJson || JSON.stringify.bind(JSON);
  153. exports.copy = angular.copy || _copy;
  154. exports.forEach = angular.forEach || _forEach;
  155. exports.extend = angular.extend || _extend;
  156. exports.equals = angular.equals || _equals;
  157. exports.identity = function (x) { return x; };
  158. exports.noop = function () { return undefined; };
  159. /**
  160. * Binds and copies functions onto an object
  161. *
  162. * Takes functions from the 'from' object, binds those functions to the _this object, and puts the bound functions
  163. * on the 'to' object.
  164. *
  165. * This example creates an new class instance whose functions are prebound to the new'd object.
  166. * @example
  167. * ```
  168. *
  169. * class Foo {
  170. * constructor(data) {
  171. * // Binds all functions from Foo.prototype to 'this',
  172. * // then copies them to 'this'
  173. * bindFunctions(Foo.prototype, this, this);
  174. * this.data = data;
  175. * }
  176. *
  177. * log() {
  178. * console.log(this.data);
  179. * }
  180. * }
  181. *
  182. * let myFoo = new Foo([1,2,3]);
  183. * var logit = myFoo.log;
  184. * logit(); // logs [1, 2, 3] from the myFoo 'this' instance
  185. * ```
  186. *
  187. * This example creates a bound version of a service function, and copies it to another object
  188. * @example
  189. * ```
  190. *
  191. * var SomeService = {
  192. * this.data = [3, 4, 5];
  193. * this.log = function() {
  194. * console.log(this.data);
  195. * }
  196. * }
  197. *
  198. * // Constructor fn
  199. * function OtherThing() {
  200. * // Binds all functions from SomeService to SomeService,
  201. * // then copies them to 'this'
  202. * bindFunctions(SomeService, this, SomeService);
  203. * }
  204. *
  205. * let myOtherThing = new OtherThing();
  206. * myOtherThing.log(); // logs [3, 4, 5] from SomeService's 'this'
  207. * ```
  208. *
  209. * @param from The object which contains the functions to be bound
  210. * @param to The object which will receive the bound functions
  211. * @param bindTo The object which the functions will be bound to
  212. * @param fnNames The function names which will be bound (Defaults to all the functions found on the 'from' object)
  213. */
  214. function bindFunctions(from, to, bindTo, fnNames) {
  215. if (fnNames === void 0) { fnNames = Object.keys(from); }
  216. return fnNames.filter(function (name) { return typeof from[name] === 'function'; })
  217. .forEach(function (name) { return to[name] = from[name].bind(bindTo); });
  218. }
  219. exports.bindFunctions = bindFunctions;
  220. /**
  221. * prototypal inheritance helper.
  222. * Creates a new object which has `parent` object as its prototype, and then copies the properties from `extra` onto it
  223. */
  224. exports.inherit = function (parent, extra) {
  225. return exports.extend(new (exports.extend(function () { }, { prototype: parent }))(), extra);
  226. };
  227. /**
  228. * Given an arguments object, converts the arguments at index idx and above to an array.
  229. * This is similar to es6 rest parameters.
  230. *
  231. * Optionally, the argument at index idx may itself already be an array.
  232. *
  233. * For example,
  234. * given either:
  235. * arguments = [ obj, "foo", "bar" ]
  236. * or:
  237. * arguments = [ obj, ["foo", "bar"] ]
  238. * then:
  239. * restArgs(arguments, 1) == ["foo", "bar"]
  240. *
  241. * This allows functions like pick() to be implemented such that it allows either a bunch
  242. * of string arguments (like es6 rest parameters), or a single array of strings:
  243. *
  244. * given:
  245. * var obj = { foo: 1, bar: 2, baz: 3 };
  246. * then:
  247. * pick(obj, "foo", "bar"); // returns { foo: 1, bar: 2 }
  248. * pick(obj, ["foo", "bar"]); // returns { foo: 1, bar: 2 }
  249. */
  250. var restArgs = function (args, idx) {
  251. if (idx === void 0) { idx = 0; }
  252. return Array.prototype.concat.apply(Array.prototype, Array.prototype.slice.call(args, idx));
  253. };
  254. /** Given an array, returns true if the object is found in the array, (using indexOf) */
  255. exports.inArray = function (array, obj) {
  256. return array.indexOf(obj) !== -1;
  257. };
  258. /** Given an array, and an item, if the item is found in the array, it removes it (in-place). The same array is returned */
  259. exports.removeFrom = hof_1.curry(function (array, obj) {
  260. var idx = array.indexOf(obj);
  261. if (idx >= 0)
  262. array.splice(idx, 1);
  263. return array;
  264. });
  265. /**
  266. * Applies a set of defaults to an options object. The options object is filtered
  267. * to only those properties of the objects in the defaultsList.
  268. * Earlier objects in the defaultsList take precedence when applying defaults.
  269. */
  270. function defaults(opts) {
  271. if (opts === void 0) { opts = {}; }
  272. var defaultsList = [];
  273. for (var _i = 1; _i < arguments.length; _i++) {
  274. defaultsList[_i - 1] = arguments[_i];
  275. }
  276. var defaults = merge.apply(null, [{}].concat(defaultsList));
  277. return exports.extend({}, defaults, pick(opts || {}, Object.keys(defaults)));
  278. }
  279. exports.defaults = defaults;
  280. /**
  281. * Merges properties from the list of objects to the destination object.
  282. * If a property already exists in the destination object, then it is not overwritten.
  283. */
  284. function merge(dst) {
  285. var objs = [];
  286. for (var _i = 1; _i < arguments.length; _i++) {
  287. objs[_i - 1] = arguments[_i];
  288. }
  289. exports.forEach(objs, function (obj) {
  290. exports.forEach(obj, function (value, key) {
  291. if (!dst.hasOwnProperty(key))
  292. dst[key] = value;
  293. });
  294. });
  295. return dst;
  296. }
  297. exports.merge = merge;
  298. /** Reduce function that merges each element of the list into a single object, using extend */
  299. exports.mergeR = function (memo, item) { return exports.extend(memo, item); };
  300. /**
  301. * Finds the common ancestor path between two states.
  302. *
  303. * @param {Object} first The first state.
  304. * @param {Object} second The second state.
  305. * @return {Array} Returns an array of state names in descending order, not including the root.
  306. */
  307. function ancestors(first, second) {
  308. var path = [];
  309. for (var n in first.path) {
  310. if (first.path[n] !== second.path[n])
  311. break;
  312. path.push(first.path[n]);
  313. }
  314. return path;
  315. }
  316. exports.ancestors = ancestors;
  317. /**
  318. * Performs a non-strict comparison of the subset of two objects, defined by a list of keys.
  319. *
  320. * @param {Object} a The first object.
  321. * @param {Object} b The second object.
  322. * @param {Array} keys The list of keys within each object to compare. If the list is empty or not specified,
  323. * it defaults to the list of keys in `a`.
  324. * @return {Boolean} Returns `true` if the keys match, otherwise `false`.
  325. */
  326. function equalForKeys(a, b, keys) {
  327. if (keys === void 0) { keys = Object.keys(a); }
  328. for (var i = 0; i < keys.length; i++) {
  329. var k = keys[i];
  330. if (a[k] != b[k])
  331. return false; // Not '===', values aren't necessarily normalized
  332. }
  333. return true;
  334. }
  335. exports.equalForKeys = equalForKeys;
  336. function pickOmitImpl(predicate, obj) {
  337. var keys = [];
  338. for (var _i = 2; _i < arguments.length; _i++) {
  339. keys[_i - 2] = arguments[_i];
  340. }
  341. var objCopy = {};
  342. for (var key in obj) {
  343. if (predicate(keys, key))
  344. objCopy[key] = obj[key];
  345. }
  346. return objCopy;
  347. }
  348. /** Return a copy of the object only containing the whitelisted properties. */
  349. function pick(obj) {
  350. return pickOmitImpl.apply(null, [exports.inArray].concat(restArgs(arguments)));
  351. }
  352. exports.pick = pick;
  353. /** Return a copy of the object omitting the blacklisted properties. */
  354. function omit(obj) {
  355. var notInArray = function (array, item) { return !exports.inArray(array, item); };
  356. return pickOmitImpl.apply(null, [notInArray].concat(restArgs(arguments)));
  357. }
  358. exports.omit = omit;
  359. /**
  360. * Maps an array, or object to a property (by name)
  361. */
  362. function pluck(collection, propName) {
  363. return map(collection, hof_1.prop(propName));
  364. }
  365. exports.pluck = pluck;
  366. /** Filters an Array or an Object's properties based on a predicate */
  367. function filter(collection, callback) {
  368. var arr = predicates_1.isArray(collection), result = arr ? [] : {};
  369. var accept = arr ? function (x) { return result.push(x); } : function (x, key) { return result[key] = x; };
  370. exports.forEach(collection, function (item, i) {
  371. if (callback(item, i))
  372. accept(item, i);
  373. });
  374. return result;
  375. }
  376. exports.filter = filter;
  377. /** Finds an object from an array, or a property of an object, that matches a predicate */
  378. function find(collection, callback) {
  379. var result;
  380. exports.forEach(collection, function (item, i) {
  381. if (result)
  382. return;
  383. if (callback(item, i))
  384. result = item;
  385. });
  386. return result;
  387. }
  388. exports.find = find;
  389. /** Given an object, returns a new object, where each property is transformed by the callback function */
  390. exports.mapObj = map;
  391. /** Maps an array or object properties using a callback function */
  392. function map(collection, callback) {
  393. var result = predicates_1.isArray(collection) ? [] : {};
  394. exports.forEach(collection, function (item, i) { return result[i] = callback(item, i); });
  395. return result;
  396. }
  397. exports.map = map;
  398. /**
  399. * Given an object, return its enumerable property values
  400. *
  401. * @example
  402. * ```
  403. *
  404. * let foo = { a: 1, b: 2, c: 3 }
  405. * let vals = values(foo); // [ 1, 2, 3 ]
  406. * ```
  407. */
  408. exports.values = function (obj) {
  409. return Object.keys(obj).map(function (key) { return obj[key]; });
  410. };
  411. /**
  412. * Reduce function that returns true if all of the values are truthy.
  413. *
  414. * @example
  415. * ```
  416. *
  417. * let vals = [ 1, true, {}, "hello world"];
  418. * vals.reduce(allTrueR, true); // true
  419. *
  420. * vals.push(0);
  421. * vals.reduce(allTrueR, true); // false
  422. * ```
  423. */
  424. exports.allTrueR = function (memo, elem) { return memo && elem; };
  425. /**
  426. * Reduce function that returns true if any of the values are truthy.
  427. *
  428. * * @example
  429. * ```
  430. *
  431. * let vals = [ 0, null, undefined ];
  432. * vals.reduce(anyTrueR, true); // false
  433. *
  434. * vals.push("hello world");
  435. * vals.reduce(anyTrueR, true); // true
  436. * ```
  437. */
  438. exports.anyTrueR = function (memo, elem) { return memo || elem; };
  439. /**
  440. * Reduce function which un-nests a single level of arrays
  441. * @example
  442. * ```
  443. *
  444. * let input = [ [ "a", "b" ], [ "c", "d" ], [ [ "double", "nested" ] ] ];
  445. * input.reduce(unnestR, []) // [ "a", "b", "c", "d", [ "double, "nested" ] ]
  446. * ```
  447. */
  448. exports.unnestR = function (memo, elem) { return memo.concat(elem); };
  449. /**
  450. * Reduce function which recursively un-nests all arrays
  451. *
  452. * @example
  453. * ```
  454. *
  455. * let input = [ [ "a", "b" ], [ "c", "d" ], [ [ "double", "nested" ] ] ];
  456. * input.reduce(unnestR, []) // [ "a", "b", "c", "d", "double, "nested" ]
  457. * ```
  458. */
  459. exports.flattenR = function (memo, elem) {
  460. return predicates_1.isArray(elem) ? memo.concat(elem.reduce(exports.flattenR, [])) : pushR(memo, elem);
  461. };
  462. /**
  463. * Reduce function that pushes an object to an array, then returns the array.
  464. * Mostly just for [[flattenR]] and [[uniqR]]
  465. */
  466. function pushR(arr, obj) {
  467. arr.push(obj);
  468. return arr;
  469. }
  470. exports.pushR = pushR;
  471. /** Reduce function that filters out duplicates */
  472. exports.uniqR = function (acc, token) {
  473. return exports.inArray(acc, token) ? acc : pushR(acc, token);
  474. };
  475. /**
  476. * Return a new array with a single level of arrays unnested.
  477. *
  478. * @example
  479. * ```
  480. *
  481. * let input = [ [ "a", "b" ], [ "c", "d" ], [ [ "double", "nested" ] ] ];
  482. * unnest(input) // [ "a", "b", "c", "d", [ "double, "nested" ] ]
  483. * ```
  484. */
  485. exports.unnest = function (arr) { return arr.reduce(exports.unnestR, []); };
  486. /**
  487. * Return a completely flattened version of an array.
  488. *
  489. * @example
  490. * ```
  491. *
  492. * let input = [ [ "a", "b" ], [ "c", "d" ], [ [ "double", "nested" ] ] ];
  493. * flatten(input) // [ "a", "b", "c", "d", "double, "nested" ]
  494. * ```
  495. */
  496. exports.flatten = function (arr) { return arr.reduce(exports.flattenR, []); };
  497. /**
  498. * Given a .filter Predicate, builds a .filter Predicate which throws an error if any elements do not pass.
  499. * @example
  500. * ```
  501. *
  502. * let isNumber = (obj) => typeof(obj) === 'number';
  503. * let allNumbers = [ 1, 2, 3, 4, 5 ];
  504. * allNumbers.filter(assertPredicate(isNumber)); //OK
  505. *
  506. * let oneString = [ 1, 2, 3, 4, "5" ];
  507. * oneString.filter(assertPredicate(isNumber, "Not all numbers")); // throws Error(""Not all numbers"");
  508. * ```
  509. */
  510. function assertPredicate(predicate, errMsg) {
  511. if (errMsg === void 0) { errMsg = "assert failure"; }
  512. return function (obj) {
  513. if (!predicate(obj)) {
  514. throw new Error(predicates_1.isFunction(errMsg) ? errMsg(obj) : errMsg);
  515. }
  516. return true;
  517. };
  518. }
  519. exports.assertPredicate = assertPredicate;
  520. /**
  521. * Like _.pairs: Given an object, returns an array of key/value pairs
  522. *
  523. * @example
  524. * ```
  525. *
  526. * pairs({ foo: "FOO", bar: "BAR }) // [ [ "foo", "FOO" ], [ "bar": "BAR" ] ]
  527. * ```
  528. */
  529. exports.pairs = function (obj) {
  530. return Object.keys(obj).map(function (key) { return [key, obj[key]]; });
  531. };
  532. /**
  533. * Given two or more parallel arrays, returns an array of tuples where
  534. * each tuple is composed of [ a[i], b[i], ... z[i] ]
  535. *
  536. * @example
  537. * ```
  538. *
  539. * let foo = [ 0, 2, 4, 6 ];
  540. * let bar = [ 1, 3, 5, 7 ];
  541. * let baz = [ 10, 30, 50, 70 ];
  542. * arrayTuples(foo, bar); // [ [0, 1], [2, 3], [4, 5], [6, 7] ]
  543. * arrayTuples(foo, bar, baz); // [ [0, 1, 10], [2, 3, 30], [4, 5, 50], [6, 7, 70] ]
  544. * ```
  545. */
  546. function arrayTuples() {
  547. var arrayArgs = [];
  548. for (var _i = 0; _i < arguments.length; _i++) {
  549. arrayArgs[_i - 0] = arguments[_i];
  550. }
  551. if (arrayArgs.length === 0)
  552. return [];
  553. var length = arrayArgs.reduce(function (min, arr) { return Math.min(arr.length, min); }, 9007199254740991); // aka 2^53 − 1 aka Number.MAX_SAFE_INTEGER
  554. return Array.apply(null, Array(length)).map(function (ignored, idx) { return arrayArgs.map(function (arr) { return arr[idx]; }); });
  555. }
  556. exports.arrayTuples = arrayTuples;
  557. /**
  558. * Reduce function which builds an object from an array of [key, value] pairs.
  559. *
  560. * Each iteration sets the key/val pair on the memo object, then returns the memo for the next iteration.
  561. *
  562. * Each keyValueTuple should be an array with values [ key: string, value: any ]
  563. *
  564. * @example
  565. * ```
  566. *
  567. * var pairs = [ ["fookey", "fooval"], ["barkey", "barval"] ]
  568. *
  569. * var pairsToObj = pairs.reduce((memo, pair) => applyPairs(memo, pair), {})
  570. * // pairsToObj == { fookey: "fooval", barkey: "barval" }
  571. *
  572. * // Or, more simply:
  573. * var pairsToObj = pairs.reduce(applyPairs, {})
  574. * // pairsToObj == { fookey: "fooval", barkey: "barval" }
  575. * ```
  576. */
  577. function applyPairs(memo, keyValTuple) {
  578. var key, value;
  579. if (predicates_1.isArray(keyValTuple))
  580. key = keyValTuple[0], value = keyValTuple[1];
  581. if (!predicates_1.isString(key))
  582. throw new Error("invalid parameters to applyPairs");
  583. memo[key] = value;
  584. return memo;
  585. }
  586. exports.applyPairs = applyPairs;
  587. /** Get the last element of an array */
  588. function tail(arr) {
  589. return arr.length && arr[arr.length - 1] || undefined;
  590. }
  591. exports.tail = tail;
  592. /**
  593. * shallow copy from src to dest
  594. *
  595. * note: This is a shallow copy, while angular.copy is a deep copy.
  596. * ui-router uses `copy` only to make copies of state parameters.
  597. */
  598. function _copy(src, dest) {
  599. if (dest)
  600. Object.keys(dest).forEach(function (key) { return delete dest[key]; });
  601. if (!dest)
  602. dest = {};
  603. return exports.extend(dest, src);
  604. }
  605. /** Naive forEach implementation works with Objects or Arrays */
  606. function _forEach(obj, cb, _this) {
  607. if (predicates_1.isArray(obj))
  608. return obj.forEach(cb, _this);
  609. Object.keys(obj).forEach(function (key) { return cb(obj[key], key); });
  610. }
  611. function _copyProps(to, from) {
  612. Object.keys(from).forEach(function (key) { return to[key] = from[key]; });
  613. return to;
  614. }
  615. function _extend(toObj) {
  616. return restArgs(arguments, 1).filter(exports.identity).reduce(_copyProps, toObj);
  617. }
  618. function _equals(o1, o2) {
  619. if (o1 === o2)
  620. return true;
  621. if (o1 === null || o2 === null)
  622. return false;
  623. if (o1 !== o1 && o2 !== o2)
  624. return true; // NaN === NaN
  625. var t1 = typeof o1, t2 = typeof o2;
  626. if (t1 !== t2 || t1 !== 'object')
  627. return false;
  628. var tup = [o1, o2];
  629. if (hof_1.all(predicates_1.isArray)(tup))
  630. return _arraysEq(o1, o2);
  631. if (hof_1.all(predicates_1.isDate)(tup))
  632. return o1.getTime() === o2.getTime();
  633. if (hof_1.all(predicates_1.isRegExp)(tup))
  634. return o1.toString() === o2.toString();
  635. if (hof_1.all(predicates_1.isFunction)(tup))
  636. return true; // meh
  637. var predicates = [predicates_1.isFunction, predicates_1.isArray, predicates_1.isDate, predicates_1.isRegExp];
  638. if (predicates.map(hof_1.any).reduce(function (b, fn) { return b || !!fn(tup); }, false))
  639. return false;
  640. var key, keys = {};
  641. for (key in o1) {
  642. if (!_equals(o1[key], o2[key]))
  643. return false;
  644. keys[key] = true;
  645. }
  646. for (key in o2) {
  647. if (!keys[key])
  648. return false;
  649. }
  650. return true;
  651. }
  652. function _arraysEq(a1, a2) {
  653. if (a1.length !== a2.length)
  654. return false;
  655. return arrayTuples(a1, a2).reduce(function (b, t) { return b && _equals(t[0], t[1]); }, true);
  656. }
  657. // issue #2676
  658. exports.silenceUncaughtInPromise = function (promise) {
  659. return promise.catch(function (e) { return 0; }) && promise;
  660. };
  661. exports.silentRejection = function (error) {
  662. return exports.silenceUncaughtInPromise(coreservices_1.services.$q.reject(error));
  663. };
  664. /***/ },
  665. /* 4 */
  666. /***/ function(module, exports, __webpack_require__) {
  667. "use strict";
  668. /** Predicates @module common_predicates */ /** */
  669. var hof_1 = __webpack_require__(5);
  670. var toStr = Object.prototype.toString;
  671. var tis = function (t) { return function (x) { return typeof (x) === t; }; };
  672. exports.isUndefined = tis('undefined');
  673. exports.isDefined = hof_1.not(exports.isUndefined);
  674. exports.isNull = function (o) { return o === null; };
  675. exports.isFunction = tis('function');
  676. exports.isNumber = tis('number');
  677. exports.isString = tis('string');
  678. exports.isObject = function (x) { return x !== null && typeof x === 'object'; };
  679. exports.isArray = Array.isArray;
  680. exports.isDate = (function (x) { return toStr.call(x) === '[object Date]'; });
  681. exports.isRegExp = (function (x) { return toStr.call(x) === '[object RegExp]'; });
  682. /**
  683. * Predicate which checks if a value is injectable
  684. *
  685. * A value is "injectable" if it is a function, or if it is an ng1 array-notation-style array
  686. * where all the elements in the array are Strings, except the last one, which is a Function
  687. */
  688. function isInjectable(val) {
  689. if (exports.isArray(val) && val.length) {
  690. var head = val.slice(0, -1), tail = val.slice(-1);
  691. return !(head.filter(hof_1.not(exports.isString)).length || tail.filter(hof_1.not(exports.isFunction)).length);
  692. }
  693. return exports.isFunction(val);
  694. }
  695. exports.isInjectable = isInjectable;
  696. /**
  697. * Predicate which checks if a value looks like a Promise
  698. *
  699. * It is probably a Promise if it's an object, and it has a `then` property which is a Function
  700. */
  701. exports.isPromise = hof_1.and(exports.isObject, hof_1.pipe(hof_1.prop('then'), exports.isFunction));
  702. /***/ },
  703. /* 5 */
  704. /***/ function(module, exports) {
  705. /**
  706. * Higher order functions
  707. *
  708. * @module common_hof
  709. */ /** */
  710. "use strict";
  711. /**
  712. * Returns a new function for [Partial Application](https://en.wikipedia.org/wiki/Partial_application) of the original function.
  713. *
  714. * Given a function with N parameters, returns a new function that supports partial application.
  715. * The new function accepts anywhere from 1 to N parameters. When that function is called with M parameters,
  716. * where M is less than N, it returns a new function that accepts the remaining parameters. It continues to
  717. * accept more parameters until all N parameters have been supplied.
  718. *
  719. *
  720. * This contrived example uses a partially applied function as an predicate, which returns true
  721. * if an object is found in both arrays.
  722. * @example
  723. * ```
  724. * // returns true if an object is in both of the two arrays
  725. * function inBoth(array1, array2, object) {
  726. * return array1.indexOf(object) !== -1 &&
  727. * array2.indexOf(object) !== 1;
  728. * }
  729. * let obj1, obj2, obj3, obj4, obj5, obj6, obj7
  730. * let foos = [obj1, obj3]
  731. * let bars = [obj3, obj4, obj5]
  732. *
  733. * // A curried "copy" of inBoth
  734. * let curriedInBoth = curry(inBoth);
  735. * // Partially apply both the array1 and array2
  736. * let inFoosAndBars = curriedInBoth(foos, bars);
  737. *
  738. * // Supply the final argument; since all arguments are
  739. * // supplied, the original inBoth function is then called.
  740. * let obj1InBoth = inFoosAndBars(obj1); // false
  741. *
  742. * // Use the inFoosAndBars as a predicate.
  743. * // Filter, on each iteration, supplies the final argument
  744. * let allObjs = [ obj1, obj2, obj3, obj4, obj5, obj6, obj7 ];
  745. * let foundInBoth = allObjs.filter(inFoosAndBars); // [ obj3 ]
  746. *
  747. * ```
  748. *
  749. * Stolen from: http://stackoverflow.com/questions/4394747/javascript-curry-function
  750. *
  751. * @param fn
  752. * @returns {*|function(): (*|any)}
  753. */
  754. function curry(fn) {
  755. var initial_args = [].slice.apply(arguments, [1]);
  756. var func_args_length = fn.length;
  757. function curried(args) {
  758. if (args.length >= func_args_length)
  759. return fn.apply(null, args);
  760. return function () {
  761. return curried(args.concat([].slice.apply(arguments)));
  762. };
  763. }
  764. return curried(initial_args);
  765. }
  766. exports.curry = curry;
  767. /**
  768. * Given a varargs list of functions, returns a function that composes the argument functions, right-to-left
  769. * given: f(x), g(x), h(x)
  770. * let composed = compose(f,g,h)
  771. * then, composed is: f(g(h(x)))
  772. */
  773. function compose() {
  774. var args = arguments;
  775. var start = args.length - 1;
  776. return function () {
  777. var i = start, result = args[start].apply(this, arguments);
  778. while (i--)
  779. result = args[i].call(this, result);
  780. return result;
  781. };
  782. }
  783. exports.compose = compose;
  784. /**
  785. * Given a varargs list of functions, returns a function that is composes the argument functions, left-to-right
  786. * given: f(x), g(x), h(x)
  787. * let piped = pipe(f,g,h);
  788. * then, piped is: h(g(f(x)))
  789. */
  790. function pipe() {
  791. var funcs = [];
  792. for (var _i = 0; _i < arguments.length; _i++) {
  793. funcs[_i - 0] = arguments[_i];
  794. }
  795. return compose.apply(null, [].slice.call(arguments).reverse());
  796. }
  797. exports.pipe = pipe;
  798. /**
  799. * Given a property name, returns a function that returns that property from an object
  800. * let obj = { foo: 1, name: "blarg" };
  801. * let getName = prop("name");
  802. * getName(obj) === "blarg"
  803. */
  804. exports.prop = function (name) {
  805. return function (obj) { return obj && obj[name]; };
  806. };
  807. /**
  808. * Given a property name and a value, returns a function that returns a boolean based on whether
  809. * the passed object has a property that matches the value
  810. * let obj = { foo: 1, name: "blarg" };
  811. * let getName = propEq("name", "blarg");
  812. * getName(obj) === true
  813. */
  814. exports.propEq = curry(function (name, val, obj) { return obj && obj[name] === val; });
  815. /**
  816. * Given a dotted property name, returns a function that returns a nested property from an object, or undefined
  817. * let obj = { id: 1, nestedObj: { foo: 1, name: "blarg" }, };
  818. * let getName = prop("nestedObj.name");
  819. * getName(obj) === "blarg"
  820. * let propNotFound = prop("this.property.doesnt.exist");
  821. * propNotFound(obj) === undefined
  822. */
  823. exports.parse = function (name) {
  824. return pipe.apply(null, name.split(".").map(exports.prop));
  825. };
  826. /**
  827. * Given a function that returns a truthy or falsey value, returns a
  828. * function that returns the opposite (falsey or truthy) value given the same inputs
  829. */
  830. exports.not = function (fn) {
  831. return function () {
  832. var args = [];
  833. for (var _i = 0; _i < arguments.length; _i++) {
  834. args[_i - 0] = arguments[_i];
  835. }
  836. return !fn.apply(null, args);
  837. };
  838. };
  839. /**
  840. * Given two functions that return truthy or falsey values, returns a function that returns truthy
  841. * if both functions return truthy for the given arguments
  842. */
  843. function and(fn1, fn2) {
  844. return function () {
  845. var args = [];
  846. for (var _i = 0; _i < arguments.length; _i++) {
  847. args[_i - 0] = arguments[_i];
  848. }
  849. return fn1.apply(null, args) && fn2.apply(null, args);
  850. };
  851. }
  852. exports.and = and;
  853. /**
  854. * Given two functions that return truthy or falsey values, returns a function that returns truthy
  855. * if at least one of the functions returns truthy for the given arguments
  856. */
  857. function or(fn1, fn2) {
  858. return function () {
  859. var args = [];
  860. for (var _i = 0; _i < arguments.length; _i++) {
  861. args[_i - 0] = arguments[_i];
  862. }
  863. return fn1.apply(null, args) || fn2.apply(null, args);
  864. };
  865. }
  866. exports.or = or;
  867. /**
  868. * Check if all the elements of an array match a predicate function
  869. *
  870. * @param fn1 a predicate function `fn1`
  871. * @returns a function which takes an array and returns true if `fn1` is true for all elements of the array
  872. */
  873. exports.all = function (fn1) {
  874. return function (arr) { return arr.reduce(function (b, x) { return b && !!fn1(x); }, true); };
  875. };
  876. exports.any = function (fn1) {
  877. return function (arr) { return arr.reduce(function (b, x) { return b || !!fn1(x); }, false); };
  878. };
  879. /** Given a class, returns a Predicate function that returns true if the object is of that class */
  880. exports.is = function (ctor) { return function (obj) {
  881. return (obj != null && obj.constructor === ctor || obj instanceof ctor);
  882. }; };
  883. /** Given a value, returns a Predicate function that returns true if another value is === equal to the original value */
  884. exports.eq = function (val) { return function (other) {
  885. return val === other;
  886. }; };
  887. /** Given a value, returns a function which returns the value */
  888. exports.val = function (v) { return function () { return v; }; };
  889. function invoke(fnName, args) {
  890. return function (obj) {
  891. return obj[fnName].apply(obj, args);
  892. };
  893. }
  894. exports.invoke = invoke;
  895. /**
  896. * Sorta like Pattern Matching (a functional programming conditional construct)
  897. *
  898. * See http://c2.com/cgi/wiki?PatternMatching
  899. *
  900. * This is a conditional construct which allows a series of predicates and output functions
  901. * to be checked and then applied. Each predicate receives the input. If the predicate
  902. * returns truthy, then its matching output function (mapping function) is provided with
  903. * the input and, then the result is returned.
  904. *
  905. * Each combination (2-tuple) of predicate + output function should be placed in an array
  906. * of size 2: [ predicate, mapFn ]
  907. *
  908. * These 2-tuples should be put in an outer array.
  909. *
  910. * @example
  911. * ```
  912. *
  913. * // Here's a 2-tuple where the first element is the isString predicate
  914. * // and the second element is a function that returns a description of the input
  915. * let firstTuple = [ angular.isString, (input) => `Heres your string ${input}` ];
  916. *
  917. * // Second tuple: predicate "isNumber", mapfn returns a description
  918. * let secondTuple = [ angular.isNumber, (input) => `(${input}) That's a number!` ];
  919. *
  920. * let third = [ (input) => input === null, (input) => `Oh, null...` ];
  921. *
  922. * let fourth = [ (input) => input === undefined, (input) => `notdefined` ];
  923. *
  924. * let descriptionOf = pattern([ firstTuple, secondTuple, third, fourth ]);
  925. *
  926. * console.log(descriptionOf(undefined)); // 'notdefined'
  927. * console.log(descriptionOf(55)); // '(55) That's a number!'
  928. * console.log(descriptionOf("foo")); // 'Here's your string foo'
  929. * ```
  930. *
  931. * @param struct A 2D array. Each element of the array should be an array, a 2-tuple,
  932. * with a Predicate and a mapping/output function
  933. * @returns {function(any): *}
  934. */
  935. function pattern(struct) {
  936. return function (x) {
  937. for (var i = 0; i < struct.length; i++) {
  938. if (struct[i][0](x))
  939. return struct[i][1](x);
  940. }
  941. };
  942. }
  943. exports.pattern = pattern;
  944. /***/ },
  945. /* 6 */
  946. /***/ function(module, exports) {
  947. "use strict";
  948. var notImplemented = function (fnname) { return function () {
  949. throw new Error(fnname + "(): No coreservices implementation for UI-Router is loaded. You should include one of: ['angular1.js']");
  950. }; };
  951. var services = {
  952. $q: undefined,
  953. $injector: undefined,
  954. location: {},
  955. locationConfig: {},
  956. template: {}
  957. };
  958. exports.services = services;
  959. ["setUrl", "path", "search", "hash", "onChange"]
  960. .forEach(function (key) { return services.location[key] = notImplemented(key); });
  961. ["port", "protocol", "host", "baseHref", "html5Mode", "hashPrefix"]
  962. .forEach(function (key) { return services.locationConfig[key] = notImplemented(key); });
  963. /***/ },
  964. /* 7 */
  965. /***/ function(module, exports) {
  966. "use strict";
  967. /** @module common */
  968. /**
  969. * Matches state names using glob-like pattern strings.
  970. *
  971. * Globs can be used in specific APIs including:
  972. *
  973. * - [[StateService.is]]
  974. * - [[StateService.includes]]
  975. * - [[HookMatchCriteria.to]]
  976. * - [[HookMatchCriteria.from]]
  977. * - [[HookMatchCriteria.exiting]]
  978. * - [[HookMatchCriteria.retained]]
  979. * - [[HookMatchCriteria.entering]]
  980. *
  981. * A `Glob` string is a pattern which matches state names.
  982. * Nested state names are split into segments (separated by a dot) when processing.
  983. * The state named `foo.bar.baz` is split into three segments ['foo', 'bar', 'baz']
  984. *
  985. * Globs work according to the following rules:
  986. *
  987. * ### Exact match:
  988. *
  989. * The glob `'A.B'` matches the state named exactly `'A.B'`.
  990. *
  991. * | Glob |Matches states named|Does not match state named|
  992. * |:------------|:--------------------|:---------------------|
  993. * | `'A'` | `'A'` | `'B'` , `'A.C'` |
  994. * | `'A.B'` | `'A.B'` | `'A'` , `'A.B.C'` |
  995. * | `'foo'` | `'foo'` | `'FOO'` , `'foo.bar'`|
  996. *
  997. * ### Single star (`*`)
  998. *
  999. * A single star (`*`) is a wildcard that matches exactly one segment.
  1000. *
  1001. * | Glob |Matches states named |Does not match state named |
  1002. * |:------------|:---------------------|:--------------------------|
  1003. * | `'*'` | `'A'` , `'Z'` | `'A.B'` , `'Z.Y.X'` |
  1004. * | `'A.*'` | `'A.B'` , `'A.C'` | `'A'` , `'A.B.C'` |
  1005. * | `'A.*.*'` | `'A.B.C'` , `'A.X.Y'`| `'A'`, `'A.B'` , `'Z.Y.X'`|
  1006. *
  1007. * ### Double star (`**`)
  1008. *
  1009. * A double star (`'**'`) is a wildcard that matches *zero or more segments*
  1010. *
  1011. * | Glob |Matches states named |Does not match state named |
  1012. * |:------------|:----------------------------------------------|:----------------------------------|
  1013. * | `'**'` | `'A'` , `'A.B'`, `'Z.Y.X'` | (matches all states) |
  1014. * | `'A.**'` | `'A'` , `'A.B'` , `'A.C.X'` | `'Z.Y.X'` |
  1015. * | `'**.X'` | `'X'` , `'A.X'` , `'Z.Y.X'` | `'A'` , `'A.login.Z'` |
  1016. * | `'A.**.X'` | `'A.X'` , `'A.B.X'` , `'A.B.C.X'` | `'A'` , `'A.B.C'` |
  1017. *
  1018. */
  1019. var Glob = (function () {
  1020. function Glob(text) {
  1021. this.text = text;
  1022. this.glob = text.split('.');
  1023. var regexpString = this.text.split('.')
  1024. .map(function (seg) {
  1025. if (seg === '**')
  1026. return '(?:|(?:\\.[^.]*)*)';
  1027. if (seg === '*')
  1028. return '\\.[^.]*';
  1029. return '\\.' + seg;
  1030. }).join('');
  1031. this.regexp = new RegExp("^" + regexpString + "$");
  1032. }
  1033. Glob.prototype.matches = function (name) {
  1034. return this.regexp.test('.' + name);
  1035. };
  1036. /** @deprecated whats the point? */
  1037. Glob.is = function (text) {
  1038. return text.indexOf('*') > -1;
  1039. };
  1040. /** @deprecated whats the point? */
  1041. Glob.fromString = function (text) {
  1042. if (!this.is(text))
  1043. return null;
  1044. return new Glob(text);
  1045. };
  1046. return Glob;
  1047. }());
  1048. exports.Glob = Glob;
  1049. /***/ },
  1050. /* 8 */
  1051. /***/ function(module, exports) {
  1052. /** @module common */ /** for typedoc */
  1053. "use strict";
  1054. var Queue = (function () {
  1055. function Queue(_items, _limit) {
  1056. if (_items === void 0) { _items = []; }
  1057. if (_limit === void 0) { _limit = null; }
  1058. this._items = _items;
  1059. this._limit = _limit;
  1060. }
  1061. Queue.prototype.enqueue = function (item) {
  1062. var items = this._items;
  1063. items.push(item);
  1064. if (this._limit && items.length > this._limit)
  1065. items.shift();
  1066. return item;
  1067. };
  1068. Queue.prototype.dequeue = function () {
  1069. if (this.size())
  1070. return this._items.splice(0, 1)[0];
  1071. };
  1072. Queue.prototype.clear = function () {
  1073. var current = this._items;
  1074. this._items = [];
  1075. return current;
  1076. };
  1077. Queue.prototype.size = function () {
  1078. return this._items.length;
  1079. };
  1080. Queue.prototype.remove = function (item) {
  1081. var idx = this._items.indexOf(item);
  1082. return idx > -1 && this._items.splice(idx, 1)[0];
  1083. };
  1084. Queue.prototype.peekTail = function () {
  1085. return this._items[this._items.length - 1];
  1086. };
  1087. Queue.prototype.peekHead = function () {
  1088. if (this.size())
  1089. return this._items[0];
  1090. };
  1091. return Queue;
  1092. }());
  1093. exports.Queue = Queue;
  1094. /***/ },
  1095. /* 9 */
  1096. /***/ function(module, exports, __webpack_require__) {
  1097. /** @module common_strings */ /** */
  1098. "use strict";
  1099. var predicates_1 = __webpack_require__(4);
  1100. var rejectFactory_1 = __webpack_require__(10);
  1101. var common_1 = __webpack_require__(3);
  1102. var hof_1 = __webpack_require__(5);
  1103. var transition_1 = __webpack_require__(11);
  1104. var resolvable_1 = __webpack_require__(19);
  1105. /**
  1106. * Returns a string shortened to a maximum length
  1107. *
  1108. * If the string is already less than the `max` length, return the string.
  1109. * Else return the string, shortened to `max - 3` and append three dots ("...").
  1110. *
  1111. * @param max the maximum length of the string to return
  1112. * @param str the input string
  1113. */
  1114. function maxLength(max, str) {
  1115. if (str.length <= max)
  1116. return str;
  1117. return str.substr(0, max - 3) + "...";
  1118. }
  1119. exports.maxLength = maxLength;
  1120. /**
  1121. * Returns a string, with spaces added to the end, up to a desired str length
  1122. *
  1123. * If the string is already longer than the desired length, return the string.
  1124. * Else returns the string, with extra spaces on the end, such that it reaches `length` characters.
  1125. *
  1126. * @param length the desired length of the string to return
  1127. * @param str the input string
  1128. */
  1129. function padString(length, str) {
  1130. while (str.length < length)
  1131. str += " ";
  1132. return str;
  1133. }
  1134. exports.padString = padString;
  1135. function kebobString(camelCase) {
  1136. return camelCase
  1137. .replace(/^([A-Z])/, function ($1) { return $1.toLowerCase(); }) // replace first char
  1138. .replace(/([A-Z])/g, function ($1) { return "-" + $1.toLowerCase(); }); // replace rest
  1139. }
  1140. exports.kebobString = kebobString;
  1141. function _toJson(obj) {
  1142. return JSON.stringify(obj);
  1143. }
  1144. function _fromJson(json) {
  1145. return predicates_1.isString(json) ? JSON.parse(json) : json;
  1146. }
  1147. function promiseToString(p) {
  1148. return "Promise(" + JSON.stringify(p) + ")";
  1149. }
  1150. function functionToString(fn) {
  1151. var fnStr = fnToString(fn);
  1152. var namedFunctionMatch = fnStr.match(/^(function [^ ]+\([^)]*\))/);
  1153. var toStr = namedFunctionMatch ? namedFunctionMatch[1] : fnStr;
  1154. var fnName = fn['name'] || "";
  1155. if (fnName && toStr.match(/function \(/)) {
  1156. return 'function ' + fnName + toStr.substr(9);
  1157. }
  1158. return toStr;
  1159. }
  1160. exports.functionToString = functionToString;
  1161. function fnToString(fn) {
  1162. var _fn = predicates_1.isArray(fn) ? fn.slice(-1)[0] : fn;
  1163. return _fn && _fn.toString() || "undefined";
  1164. }
  1165. exports.fnToString = fnToString;
  1166. var stringifyPatternFn = null;
  1167. var stringifyPattern = function (value) {
  1168. var isTransitionRejectionPromise = rejectFactory_1.Rejection.isTransitionRejectionPromise;
  1169. stringifyPatternFn = stringifyPatternFn || hof_1.pattern([
  1170. [hof_1.not(predicates_1.isDefined), hof_1.val("undefined")],
  1171. [predicates_1.isNull, hof_1.val("null")],
  1172. [predicates_1.isPromise, hof_1.val("[Promise]")],
  1173. [isTransitionRejectionPromise, function (x) { return x._transitionRejection.toString(); }],
  1174. [hof_1.is(rejectFactory_1.Rejection), hof_1.invoke("toString")],
  1175. [hof_1.is(transition_1.Transition), hof_1.invoke("toString")],
  1176. [hof_1.is(resolvable_1.Resolvable), hof_1.invoke("toString")],
  1177. [predicates_1.isInjectable, functionToString],
  1178. [hof_1.val(true), common_1.identity]
  1179. ]);
  1180. return stringifyPatternFn(value);
  1181. };
  1182. function stringify(o) {
  1183. var seen = [];
  1184. function format(val) {
  1185. if (predicates_1.isObject(val)) {
  1186. if (seen.indexOf(val) !== -1)
  1187. return '[circular ref]';
  1188. seen.push(val);
  1189. }
  1190. return stringifyPattern(val);
  1191. }
  1192. return JSON.stringify(o, function (key, val) { return format(val); }).replace(/\\"/g, '"');
  1193. }
  1194. exports.stringify = stringify;
  1195. /** Returns a function that splits a string on a character or substring */
  1196. exports.beforeAfterSubstr = function (char) { return function (str) {
  1197. if (!str)
  1198. return ["", ""];
  1199. var idx = str.indexOf(char);
  1200. if (idx === -1)
  1201. return [str, ""];
  1202. return [str.substr(0, idx), str.substr(idx + 1)];
  1203. }; };
  1204. /***/ },
  1205. /* 10 */
  1206. /***/ function(module, exports, __webpack_require__) {
  1207. /** @module transition */ /** for typedoc */
  1208. "use strict";
  1209. var common_1 = __webpack_require__(3);
  1210. var strings_1 = __webpack_require__(9);
  1211. (function (RejectType) {
  1212. RejectType[RejectType["SUPERSEDED"] = 2] = "SUPERSEDED";
  1213. RejectType[RejectType["ABORTED"] = 3] = "ABORTED";
  1214. RejectType[RejectType["INVALID"] = 4] = "INVALID";
  1215. RejectType[RejectType["IGNORED"] = 5] = "IGNORED";
  1216. RejectType[RejectType["ERROR"] = 6] = "ERROR";
  1217. })(exports.RejectType || (exports.RejectType = {}));
  1218. var RejectType = exports.RejectType;
  1219. var Rejection = (function () {
  1220. function Rejection(type, message, detail) {
  1221. this.type = type;
  1222. this.message = message;
  1223. this.detail = detail;
  1224. }
  1225. Rejection.prototype.toString = function () {
  1226. var detailString = function (d) {
  1227. return d && d.toString !== Object.prototype.toString ? d.toString() : strings_1.stringify(d);
  1228. };
  1229. var type = this.type, message = this.message, detail = detailString(this.detail);
  1230. return "TransitionRejection(type: " + type + ", message: " + message + ", detail: " + detail + ")";
  1231. };
  1232. Rejection.prototype.toPromise = function () {
  1233. return common_1.extend(common_1.silentRejection(this), { _transitionRejection: this });
  1234. };
  1235. /** Returns true if the obj is a rejected promise created from the `asPromise` factory */
  1236. Rejection.isTransitionRejectionPromise = function (obj) {
  1237. return obj && (typeof obj.then === 'function') && obj._transitionRejection instanceof Rejection;
  1238. };
  1239. /** Returns a TransitionRejection due to transition superseded */
  1240. Rejection.superseded = function (detail, options) {
  1241. var message = "The transition has been superseded by a different transition";
  1242. var rejection = new Rejection(RejectType.SUPERSEDED, message, detail);
  1243. if (options && options.redirected) {
  1244. rejection.redirected = true;
  1245. }
  1246. return rejection;
  1247. };
  1248. /** Returns a TransitionRejection due to redirected transition */
  1249. Rejection.redirected = function (detail) {
  1250. return Rejection.superseded(detail, { redirected: true });
  1251. };
  1252. /** Returns a TransitionRejection due to invalid transition */
  1253. Rejection.invalid = function (detail) {
  1254. var message = "This transition is invalid";
  1255. return new Rejection(RejectType.INVALID, message, detail);
  1256. };
  1257. /** Returns a TransitionRejection due to ignored transition */
  1258. Rejection.ignored = function (detail) {
  1259. var message = "The transition was ignored";
  1260. return new Rejection(RejectType.IGNORED, message, detail);
  1261. };
  1262. /** Returns a TransitionRejection due to aborted transition */
  1263. Rejection.aborted = function (detail) {
  1264. // TODO think about how to encapsulate an Error() object
  1265. var message = "The transition has been aborted";
  1266. return new Rejection(RejectType.ABORTED, message, detail);
  1267. };
  1268. /** Returns a TransitionRejection due to aborted transition */
  1269. Rejection.errored = function (detail) {
  1270. // TODO think about how to encapsulate an Error() object
  1271. var message = "The transition errored";
  1272. return new Rejection(RejectType.ERROR, message, detail);
  1273. };
  1274. return Rejection;
  1275. }());
  1276. exports.Rejection = Rejection;
  1277. /***/ },
  1278. /* 11 */
  1279. /***/ function(module, exports, __webpack_require__) {
  1280. "use strict";
  1281. /** @module transition */ /** for typedoc */
  1282. var strings_1 = __webpack_require__(9);
  1283. var trace_1 = __webpack_require__(12);
  1284. var coreservices_1 = __webpack_require__(6);
  1285. var common_1 = __webpack_require__(3);
  1286. var predicates_1 = __webpack_require__(4);
  1287. var hof_1 = __webpack_require__(5);
  1288. var transitionHook_1 = __webpack_require__(13);
  1289. var hookRegistry_1 = __webpack_require__(15);
  1290. var hookBuilder_1 = __webpack_require__(16);
  1291. var node_1 = __webpack_require__(21);
  1292. var pathFactory_1 = __webpack_require__(20);
  1293. var targetState_1 = __webpack_require__(14);
  1294. var param_1 = __webpack_require__(22);
  1295. var resolvable_1 = __webpack_require__(19);
  1296. var rejectFactory_1 = __webpack_require__(10);
  1297. var resolveContext_1 = __webpack_require__(17);
  1298. var router_1 = __webpack_require__(25);
  1299. var transitionCount = 0;
  1300. var stateSelf = hof_1.prop("self");
  1301. /**
  1302. * Represents a transition between two states.
  1303. *
  1304. * When navigating to a state, we are transitioning **from** the current state **to** the new state.
  1305. *
  1306. * This object contains all contextual information about the to/from states, parameters, resolves.
  1307. * It has information about all states being entered and exited as a result of the transition.
  1308. */
  1309. var Transition = (function () {
  1310. /**
  1311. * Creates a new Transition object.
  1312. *
  1313. * If the target state is not valid, an error is thrown.
  1314. *
  1315. * @param fromPath The path of [[PathNode]]s from which the transition is leaving. The last node in the `fromPath`
  1316. * encapsulates the "from state".
  1317. * @param targetState The target state and parameters being transitioned to (also, the transition options)
  1318. * @param router The [[UIRouter]] instance
  1319. */
  1320. function Transition(fromPath, targetState, router) {
  1321. var _this = this;
  1322. /** @hidden */
  1323. this._deferred = coreservices_1.services.$q.defer();
  1324. /**
  1325. * This promise is resolved or rejected based on the outcome of the Transition.
  1326. *
  1327. * When the transition is successful, the promise is resolved
  1328. * When the transition is unsuccessful, the promise is rejected with the [[TransitionRejection]] or javascript error
  1329. */
  1330. this.promise = this._deferred.promise;
  1331. this.treeChanges = function () { return _this._treeChanges; };
  1332. this.isActive = function () { return _this === _this._options.current(); };
  1333. this.router = router;
  1334. this._targetState = targetState;
  1335. if (!targetState.valid()) {
  1336. throw new Error(targetState.error());
  1337. }
  1338. // Makes the Transition instance a hook registry (onStart, etc)
  1339. hookRegistry_1.HookRegistry.mixin(new hookRegistry_1.HookRegistry(), this);
  1340. // current() is assumed to come from targetState.options, but provide a naive implementation otherwise.
  1341. this._options = common_1.extend({ current: hof_1.val(this) }, targetState.options());
  1342. this.$id = transitionCount++;
  1343. var toPath = pathFactory_1.PathFactory.buildToPath(fromPath, targetState);
  1344. this._treeChanges = pathFactory_1.PathFactory.treeChanges(fromPath, toPath, this._options.reloadState);
  1345. var enteringStates = this._treeChanges.entering.map(function (node) { return node.state; });
  1346. pathFactory_1.PathFactory.applyViewConfigs(router.transitionService.$view, this._treeChanges.to, enteringStates);
  1347. var rootResolvables = [
  1348. new resolvable_1.Resolvable(router_1.UIRouter, function () { return router; }, [], undefined, router),
  1349. new resolvable_1.Resolvable(Transition, function () { return _this; }, [], undefined, this),
  1350. new resolvable_1.Resolvable('$transition$', function () { return _this; }, [], undefined, this),
  1351. new resolvable_1.Resolvable('$stateParams', function () { return _this.params(); }, [], undefined, this.params())
  1352. ];
  1353. var rootNode = this._treeChanges.to[0];
  1354. var context = new resolveContext_1.ResolveContext(this._treeChanges.to);
  1355. context.addResolvables(rootResolvables, rootNode.state);
  1356. }
  1357. /** @inheritdoc */
  1358. Transition.prototype.onBefore = function (matchCriteria, callback, options) { throw ""; };
  1359. ;
  1360. /** @inheritdoc */
  1361. Transition.prototype.onStart = function (matchCriteria, callback, options) { throw ""; };
  1362. ;
  1363. /** @inheritdoc */
  1364. Transition.prototype.onExit = function (matchCriteria, callback, options) { throw ""; };
  1365. ;
  1366. /** @inheritdoc */
  1367. Transition.prototype.onRetain = function (matchCriteria, callback, options) { throw ""; };
  1368. ;
  1369. /** @inheritdoc */
  1370. Transition.prototype.onEnter = function (matchCriteria, callback, options) { throw ""; };
  1371. ;
  1372. /** @inheritdoc */
  1373. Transition.prototype.onFinish = function (matchCriteria, callback, options) { throw ""; };
  1374. ;
  1375. /** @inheritdoc */
  1376. Transition.prototype.onSuccess = function (matchCriteria, callback, options) { throw ""; };
  1377. ;
  1378. /** @inheritdoc */
  1379. Transition.prototype.onError = function (matchCriteria, callback, options) { throw ""; };
  1380. ;
  1381. Transition.prototype.$from = function () {
  1382. return common_1.tail(this._treeChanges.from).state;
  1383. };
  1384. Transition.prototype.$to = function () {
  1385. return common_1.tail(this._treeChanges.to).state;
  1386. };
  1387. /**
  1388. * Returns the "from state"
  1389. *
  1390. * @returns The state object for the Transition's "from state".
  1391. */
  1392. Transition.prototype.from = function () {
  1393. return this.$from().self;
  1394. };
  1395. /**
  1396. * Returns the "to state"
  1397. *
  1398. * @returns The state object for the Transition's target state ("to state").
  1399. */
  1400. Transition.prototype.to = function () {
  1401. return this.$to().self;
  1402. };
  1403. /**
  1404. * Gets the Target State
  1405. *
  1406. * A transition's [[TargetState]] encapsulates the [[to]] state, the [[params]], and the [[options]].
  1407. *
  1408. * @returns the [[TargetState]] of this Transition
  1409. */
  1410. Transition.prototype.targetState = function () {
  1411. return this._targetState;
  1412. };
  1413. /**
  1414. * Determines whether two transitions are equivalent.
  1415. */
  1416. Transition.prototype.is = function (compare) {
  1417. if (compare instanceof Transition) {
  1418. // TODO: Also compare parameters
  1419. return this.is({ to: compare.$to().name, from: compare.$from().name });
  1420. }
  1421. return !((compare.to && !hookRegistry_1.matchState(this.$to(), compare.to)) ||
  1422. (compare.from && !hookRegistry_1.matchState(this.$from(), compare.from)));
  1423. };
  1424. /**
  1425. * Gets transition parameter values
  1426. *
  1427. * @param pathname Pick which treeChanges path to get parameters for:
  1428. * (`'to'`, `'from'`, `'entering'`, `'exiting'`, `'retained'`)
  1429. * @returns transition parameter values for the desired path.
  1430. */
  1431. Transition.prototype.params = function (pathname) {
  1432. if (pathname === void 0) { pathname = "to"; }
  1433. return this._treeChanges[pathname].map(hof_1.prop("paramValues")).reduce(common_1.mergeR, {});
  1434. };
  1435. /**
  1436. * Creates a [[UIInjector]] Dependency Injector
  1437. *
  1438. * Returns a Dependency Injector for the Transition's target state (to state).
  1439. * The injector provides resolve values which the target state has access to.
  1440. *
  1441. * The `UIInjector` can also provide values from the native root/global injector (ng1/ng2).
  1442. *
  1443. * If a `state` is provided, the injector that is returned will be limited to resolve values that the provided state has access to.
  1444. *
  1445. * @param state Limits the resolves provided to only the resolves the provided state has access to.
  1446. * @returns a [[UIInjector]]
  1447. */
  1448. Transition.prototype.injector = function (state) {
  1449. var path = this.treeChanges().to;
  1450. if (state)
  1451. path = pathFactory_1.PathFactory.subPath(path, function (node) { return node.state === state || node.state.name === state; });
  1452. return new resolveContext_1.ResolveContext(path).injector();
  1453. };
  1454. /**
  1455. * Gets all available resolve tokens (keys)
  1456. *
  1457. * This method can be used in conjunction with [[getResolve]] to inspect the resolve values
  1458. * available to the Transition.
  1459. *
  1460. * The returned tokens include those defined on [[StateDeclaration.resolve]] blocks, for the states
  1461. * in the Transition's [[TreeChanges.to]] path.
  1462. *
  1463. * @returns an array of resolve tokens (keys)
  1464. */
  1465. Transition.prototype.getResolveTokens = function () {
  1466. return new resolveContext_1.ResolveContext(this._treeChanges.to).getTokens();
  1467. };
  1468. /**
  1469. * Gets resolved values
  1470. *
  1471. * This method can be used in conjunction with [[getResolveTokens]] to inspect what resolve values
  1472. * are available to the Transition.
  1473. *
  1474. * Given a token, returns the resolved data for that token.
  1475. * Given an array of tokens, returns an array of resolved data for those tokens.
  1476. *
  1477. * If a resolvable hasn't yet been fetched, returns `undefined` for that token
  1478. * If a resolvable doesn't exist for the token, throws an error.
  1479. *
  1480. * @param token the token (or array of tokens)
  1481. *
  1482. * @returns an array of resolve tokens (keys)
  1483. */
  1484. Transition.prototype.getResolveValue = function (token) {
  1485. var resolveContext = new resolveContext_1.ResolveContext(this._treeChanges.to);
  1486. var getData = function (token) {
  1487. var resolvable = resolveContext.getResolvable(token);
  1488. if (resolvable === undefined) {
  1489. throw new Error("Dependency Injection token not found: " + strings_1.stringify(token));
  1490. }
  1491. return resolvable.data;
  1492. };
  1493. if (predicates_1.isArray(token)) {
  1494. return token.map(getData);
  1495. }
  1496. return getData(token);
  1497. };
  1498. /**
  1499. * Gets a [[Resolvable]] primitive
  1500. *
  1501. * This is a lower level API that returns a [[Resolvable]] from the Transition for a given token.
  1502. *
  1503. * @param token the DI token
  1504. *
  1505. * @returns the [[Resolvable]] in the transition's to path, or undefined
  1506. */
  1507. Transition.prototype.getResolvable = function (token) {
  1508. return new resolveContext_1.ResolveContext(this._treeChanges.to).getResolvable(token);
  1509. };
  1510. /**
  1511. * Dynamically adds a new [[Resolvable]] (`resolve`) to this transition.
  1512. *
  1513. * @param resolvable an [[Resolvable]] object
  1514. * @param state the state in the "to path" which should receive the new resolve (otherwise, the root state)
  1515. */
  1516. Transition.prototype.addResolvable = function (resolvable, state) {
  1517. if (state === void 0) { state = ""; }
  1518. var stateName = (typeof state === "string") ? state : state.name;
  1519. var topath = this._treeChanges.to;
  1520. var targetNode = common_1.find(topath, function (node) { return node.state.name === stateName; });
  1521. var resolveContext = new resolveContext_1.ResolveContext(topath);
  1522. resolveContext.addResolvables([resolvable], targetNode.state);
  1523. };
  1524. /**
  1525. * If the current transition is a redirect, returns the transition that was redirected.
  1526. *
  1527. * Gets the transition from which this transition was redirected.
  1528. *
  1529. *
  1530. * @example
  1531. * ```js
  1532. *
  1533. * let transitionA = $state.go('A').transitionA
  1534. * transitionA.onStart({}, () => $state.target('B'));
  1535. * $transitions.onSuccess({ to: 'B' }, (trans) => {
  1536. * trans.to().name === 'B'; // true
  1537. * trans.redirectedFrom() === transitionA; // true
  1538. * });
  1539. * ```
  1540. *
  1541. * @returns The previous Transition, or null if this Transition is not the result of a redirection
  1542. */
  1543. Transition.prototype.redirectedFrom = function () {
  1544. return this._options.redirectedFrom || null;
  1545. };
  1546. /**
  1547. * Get the transition options
  1548. *
  1549. * @returns the options for this Transition.
  1550. */
  1551. Transition.prototype.options = function () {
  1552. return this._options;
  1553. };
  1554. /**
  1555. * Gets the states being entered.
  1556. *
  1557. * @returns an array of states that will be entered during this transition.
  1558. */
  1559. Transition.prototype.entering = function () {
  1560. return common_1.map(this._treeChanges.entering, hof_1.prop('state')).map(stateSelf);
  1561. };
  1562. /**
  1563. * Gets the states being exited.
  1564. *
  1565. * @returns an array of states that will be exited during this transition.
  1566. */
  1567. Transition.prototype.exiting = function () {
  1568. return common_1.map(this._treeChanges.exiting, hof_1.prop('state')).map(stateSelf).reverse();
  1569. };
  1570. /**
  1571. * Gets the states being retained.
  1572. *
  1573. * @returns an array of states that are already entered from a previous Transition, that will not be
  1574. * exited during this Transition
  1575. */
  1576. Transition.prototype.retained = function () {
  1577. return common_1.map(this._treeChanges.retained, hof_1.prop('state')).map(stateSelf);
  1578. };
  1579. /**
  1580. * Get the [[ViewConfig]]s associated with this Transition
  1581. *
  1582. * Each state can define one or more views (template/controller), which are encapsulated as `ViewConfig` objects.
  1583. * This method fetches the `ViewConfigs` for a given path in the Transition (e.g., "to" or "entering").
  1584. *
  1585. * @param pathname the name of the path to fetch views for:
  1586. * (`'to'`, `'from'`, `'entering'`, `'exiting'`, `'retained'`)
  1587. * @param state If provided, only returns the `ViewConfig`s for a single state in the path
  1588. *
  1589. * @returns a list of ViewConfig objects for the given path.
  1590. */
  1591. Transition.prototype.views = function (pathname, state) {
  1592. if (pathname === void 0) { pathname = "entering"; }
  1593. var path = this._treeChanges[pathname];
  1594. path = !state ? path : path.filter(hof_1.propEq('state', state));
  1595. return path.map(hof_1.prop("views")).filter(common_1.identity).reduce(common_1.unnestR, []);
  1596. };
  1597. /**
  1598. * Creates a new transition that is a redirection of the current one.
  1599. *
  1600. * This transition can be returned from a [[TransitionService]] hook to
  1601. * redirect a transition to a new state and/or set of parameters.
  1602. *
  1603. * @returns Returns a new [[Transition]] instance.
  1604. */
  1605. Transition.prototype.redirect = function (targetState) {
  1606. var newOptions = common_1.extend({}, this.options(), targetState.options(), { redirectedFrom: this, source: "redirect" });
  1607. targetState = new targetState_1.TargetState(targetState.identifier(), targetState.$state(), targetState.params(), newOptions);
  1608. var newTransition = this.router.transitionService.create(this._treeChanges.from, targetState);
  1609. var originalEnteringNodes = this.treeChanges().entering;
  1610. var redirectEnteringNodes = newTransition.treeChanges().entering;
  1611. // --- Re-use resolve data from original transition ---
  1612. // When redirecting from a parent state to a child state where the parent parameter values haven't changed
  1613. // (because of the redirect), the resolves fetched by the original transition are still valid in the
  1614. // redirected transition.
  1615. //
  1616. // This allows you to define a redirect on a parent state which depends on an async resolve value.
  1617. // You can wait for the resolve, then redirect to a child state based on the result.
  1618. // The redirected transition does not have to re-fetch the resolve.
  1619. // ---------------------------------------------------------
  1620. var nodeIsReloading = function (reloadState) { return function (node) {
  1621. return reloadState && node.state.includes[reloadState.name];
  1622. }; };
  1623. // Find any "entering" nodes in the redirect path that match the original path and aren't being reloaded
  1624. var matchingEnteringNodes = node_1.PathNode.matching(redirectEnteringNodes, originalEnteringNodes)
  1625. .filter(hof_1.not(nodeIsReloading(targetState.options().reloadState)));
  1626. // Use the existing (possibly pre-resolved) resolvables for the matching entering nodes.
  1627. matchingEnteringNodes.forEach(function (node, idx) {
  1628. node.resolvables = originalEnteringNodes[idx].resolvables;
  1629. });
  1630. return newTransition;
  1631. };
  1632. /** @hidden If a transition doesn't exit/enter any states, returns any [[Param]] whose value changed */
  1633. Transition.prototype._changedParams = function () {
  1634. var _a = this._treeChanges, to = _a.to, from = _a.from;
  1635. if (this._options.reload || common_1.tail(to).state !== common_1.tail(from).state)
  1636. return undefined;
  1637. var nodeSchemas = to.map(function (node) { return node.paramSchema; });
  1638. var _b = [to, from].map(function (path) { return path.map(function (x) { return x.paramValues; }); }), toValues = _b[0], fromValues = _b[1];
  1639. var tuples = common_1.arrayTuples(nodeSchemas, toValues, fromValues);
  1640. return tuples.map(function (_a) {
  1641. var schema = _a[0], toVals = _a[1], fromVals = _a[2];
  1642. return param_1.Param.changed(schema, toVals, fromVals);
  1643. }).reduce(common_1.unnestR, []);
  1644. };
  1645. /**
  1646. * Returns true if the transition is dynamic.
  1647. *
  1648. * A transition is dynamic if no states are entered nor exited, but at least one dynamic parameter has changed.
  1649. *
  1650. * @returns true if the Transition is dynamic
  1651. */
  1652. Transition.prototype.dynamic = function () {
  1653. var changes = this._changedParams();
  1654. return !changes ? false : changes.map(function (x) { return x.dynamic; }).reduce(common_1.anyTrueR, false);
  1655. };
  1656. /**
  1657. * Returns true if the transition is ignored.
  1658. *
  1659. * A transition is ignored if no states are entered nor exited, and no parameter values have changed.
  1660. *
  1661. * @returns true if the Transition is ignored.
  1662. */
  1663. Transition.prototype.ignored = function () {
  1664. var changes = this._changedParams();
  1665. return !changes ? false : changes.length === 0;
  1666. };
  1667. /**
  1668. * @hidden
  1669. */
  1670. Transition.prototype.hookBuilder = function () {
  1671. return new hookBuilder_1.HookBuilder(this.router.transitionService, this, {
  1672. transition: this,
  1673. current: this._options.current
  1674. });
  1675. };
  1676. /**
  1677. * Runs the transition
  1678. *
  1679. * This method is generally called from the [[StateService.transitionTo]]
  1680. *
  1681. * @returns a promise for a successful transition.
  1682. */
  1683. Transition.prototype.run = function () {
  1684. var _this = this;
  1685. var runSynchronousHooks = transitionHook_1.TransitionHook.runSynchronousHooks;
  1686. var hookBuilder = this.hookBuilder();
  1687. var globals = this.router.globals;
  1688. globals.transitionHistory.enqueue(this);
  1689. var syncResult = runSynchronousHooks(hookBuilder.getOnBeforeHooks());
  1690. if (rejectFactory_1.Rejection.isTransitionRejectionPromise(syncResult)) {
  1691. syncResult.catch(function () { return 0; }); // issue #2676
  1692. var rejectReason = syncResult._transitionRejection;
  1693. this._deferred.reject(rejectReason);
  1694. return this.promise;
  1695. }
  1696. if (!this.valid()) {
  1697. var error = new Error(this.error());
  1698. this._deferred.reject(error);
  1699. return this.promise;
  1700. }
  1701. if (this.ignored()) {
  1702. trace_1.trace.traceTransitionIgnored(this);
  1703. this._deferred.reject(rejectFactory_1.Rejection.ignored());
  1704. return this.promise;
  1705. }
  1706. // When the chain is complete, then resolve or reject the deferred
  1707. var transitionSuccess = function () {
  1708. trace_1.trace.traceSuccess(_this.$to(), _this);
  1709. _this.success = true;
  1710. _this._deferred.resolve(_this.to());
  1711. runSynchronousHooks(hookBuilder.getOnSuccessHooks(), true);
  1712. };
  1713. var transitionError = function (reason) {
  1714. trace_1.trace.traceError(reason, _this);
  1715. _this.success = false;
  1716. _this._deferred.reject(reason);
  1717. _this._error = reason;
  1718. runSynchronousHooks(hookBuilder.getOnErrorHooks(), true);
  1719. };
  1720. trace_1.trace.traceTransitionStart(this);
  1721. // Chain the next hook off the previous
  1722. var appendHookToChain = function (prev, nextHook) {
  1723. return prev.then(function () { return nextHook.invokeHook(); });
  1724. };
  1725. // Run the hooks, then resolve or reject the overall deferred in the .then() handler
  1726. hookBuilder.asyncHooks()
  1727. .reduce(appendHookToChain, syncResult)
  1728. .then(transitionSuccess, transitionError);
  1729. return this.promise;
  1730. };
  1731. /**
  1732. * Checks if the Transition is valid
  1733. *
  1734. * @returns true if the Transition is valid
  1735. */
  1736. Transition.prototype.valid = function () {
  1737. return !this.error() || this.success !== undefined;
  1738. };
  1739. /**
  1740. * The Transition error reason.
  1741. *
  1742. * If the transition is invalid (and could not be run), returns the reason the transition is invalid.
  1743. * If the transition was valid and ran, but was not successful, returns the reason the transition failed.
  1744. *
  1745. * @returns an error message explaining why the transition is invalid, or the reason the transition failed.
  1746. */
  1747. Transition.prototype.error = function () {
  1748. var state = this.$to();
  1749. var redirects = 0, trans = this;
  1750. while ((trans = trans.redirectedFrom()) != null) {
  1751. if (++redirects > 20)
  1752. return "Too many Transition redirects (20+)";
  1753. }
  1754. if (state.self.abstract)
  1755. return "Cannot transition to abstract state '" + state.name + "'";
  1756. if (!param_1.Param.validates(state.parameters(), this.params()))
  1757. return "Param values not valid for state '" + state.name + "'";
  1758. if (this.success === false)
  1759. return this._error;
  1760. };
  1761. /**
  1762. * A string representation of the Transition
  1763. *
  1764. * @returns A string representation of the Transition
  1765. */
  1766. Transition.prototype.toString = function () {
  1767. var fromStateOrName = this.from();
  1768. var toStateOrName = this.to();
  1769. var avoidEmptyHash = function (params) {
  1770. return (params["#"] !== null && params["#"] !== undefined) ? params : common_1.omit(params, "#");
  1771. };
  1772. // (X) means the to state is invalid.
  1773. 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()));
  1774. return "Transition#" + id + "( '" + from + "'" + fromParams + " -> " + toValid + "'" + to + "'" + toParams + " )";
  1775. };
  1776. Transition.diToken = Transition;
  1777. return Transition;
  1778. }());
  1779. exports.Transition = Transition;
  1780. /***/ },
  1781. /* 12 */
  1782. /***/ function(module, exports, __webpack_require__) {
  1783. "use strict";
  1784. /**
  1785. * UI-Router Transition Tracing
  1786. *
  1787. * Enable transition tracing to print transition information to the console, in order to help debug your application.
  1788. * Tracing logs detailed information about each Transition to your console.
  1789. *
  1790. * To enable tracing, import the [[trace]] singleton and enable one or more categories.
  1791. *
  1792. * ES6
  1793. * ```
  1794. *
  1795. * import {trace} from "ui-router-ng2"; // or "angular-ui-router"
  1796. * trace.enable(1, 5); // TRANSITION and VIEWCONFIG
  1797. * ```
  1798. *
  1799. * CJS
  1800. * ```
  1801. *
  1802. * let trace = require("angular-ui-router").trace; // or "ui-router-ng2"
  1803. * trace.enable("TRANSITION", "VIEWCONFIG");
  1804. * ```
  1805. *
  1806. * Globals
  1807. * ```
  1808. *
  1809. * let trace = window["angular-ui-router"].trace; // or "ui-router-ng2"
  1810. * trace.enable(); // Trace everything (very verbose)
  1811. * ```
  1812. *
  1813. * @module trace
  1814. */ /** for typedoc */
  1815. var hof_1 = __webpack_require__(5);
  1816. var predicates_1 = __webpack_require__(4);
  1817. var strings_1 = __webpack_require__(9);
  1818. /** @hidden */
  1819. function uiViewString(viewData) {
  1820. if (!viewData)
  1821. return 'ui-view (defunct)';
  1822. return ("[ui-view#" + viewData.id + " tag ") +
  1823. ("in template from '" + (viewData.creationContext && viewData.creationContext.name || '(root)') + "' state]: ") +
  1824. ("fqn: '" + viewData.fqn + "', ") +
  1825. ("name: '" + viewData.name + "@" + viewData.creationContext + "')");
  1826. }
  1827. /** @hidden */
  1828. var viewConfigString = function (viewConfig) {
  1829. return ("[ViewConfig#" + viewConfig.$id + " from '" + (viewConfig.viewDecl.$context.name || '(root)') + "' state]: target ui-view: '" + viewConfig.viewDecl.$uiViewName + "@" + viewConfig.viewDecl.$uiViewContextAnchor + "'");
  1830. };
  1831. /** @hidden */
  1832. function normalizedCat(input) {
  1833. return predicates_1.isNumber(input) ? Category[input] : Category[Category[input]];
  1834. }
  1835. /**
  1836. * Trace categories
  1837. *
  1838. * [[Trace.enable]] or [[Trace.disable]] a category
  1839. *
  1840. * `trace.enable(Category.TRANSITION)`
  1841. *
  1842. * These can also be provided using a matching string, or position ordinal
  1843. *
  1844. * `trace.enable("TRANSITION")`
  1845. *
  1846. * `trace.enable(1)`
  1847. */
  1848. (function (Category) {
  1849. Category[Category["RESOLVE"] = 0] = "RESOLVE";
  1850. Category[Category["TRANSITION"] = 1] = "TRANSITION";
  1851. Category[Category["HOOK"] = 2] = "HOOK";
  1852. Category[Category["UIVIEW"] = 3] = "UIVIEW";
  1853. Category[Category["VIEWCONFIG"] = 4] = "VIEWCONFIG";
  1854. })(exports.Category || (exports.Category = {}));
  1855. var Category = exports.Category;
  1856. /**
  1857. * Prints UI-Router Transition trace information to the console.
  1858. */
  1859. var Trace = (function () {
  1860. function Trace() {
  1861. /** @hidden */
  1862. this._enabled = {};
  1863. this.approximateDigests = 0;
  1864. }
  1865. /** @hidden */
  1866. Trace.prototype._set = function (enabled, categories) {
  1867. var _this = this;
  1868. if (!categories.length) {
  1869. categories = Object.keys(Category)
  1870. .map(function (k) { return parseInt(k, 10); })
  1871. .filter(function (k) { return !isNaN(k); })
  1872. .map(function (key) { return Category[key]; });
  1873. }
  1874. categories.map(normalizedCat).forEach(function (category) { return _this._enabled[category] = enabled; });
  1875. };
  1876. /**
  1877. * Enables a trace [[Category]]
  1878. *
  1879. * ```
  1880. * trace.enable("TRANSITION");
  1881. * ```
  1882. *
  1883. * @param categories categories to enable. If `categories` is omitted, all categories are enabled.
  1884. * Also takes strings (category name) or ordinal (category position)
  1885. */
  1886. Trace.prototype.enable = function () {
  1887. var categories = [];
  1888. for (var _i = 0; _i < arguments.length; _i++) {
  1889. categories[_i - 0] = arguments[_i];
  1890. }
  1891. this._set(true, categories);
  1892. };
  1893. /**
  1894. * Disables a trace [[Category]]
  1895. *
  1896. * ```
  1897. * trace.disable("VIEWCONFIG");
  1898. * ```
  1899. *
  1900. * @param categories categories to disable. If `categories` is omitted, all categories are disabled.
  1901. * Also takes strings (category name) or ordinal (category position)
  1902. */
  1903. Trace.prototype.disable = function () {
  1904. var categories = [];
  1905. for (var _i = 0; _i < arguments.length; _i++) {
  1906. categories[_i - 0] = arguments[_i];
  1907. }
  1908. this._set(false, categories);
  1909. };
  1910. /**
  1911. * Retrieves the enabled stateus of a [[Category]]
  1912. *
  1913. * ```
  1914. * trace.enabled("VIEWCONFIG"); // true or false
  1915. * ```
  1916. *
  1917. * @returns boolean true if the category is enabled
  1918. */
  1919. Trace.prototype.enabled = function (category) {
  1920. return !!this._enabled[normalizedCat(category)];
  1921. };
  1922. /** called by ui-router code */
  1923. Trace.prototype.traceTransitionStart = function (transition) {
  1924. if (!this.enabled(Category.TRANSITION))
  1925. return;
  1926. var tid = transition.$id, digest = this.approximateDigests, transitionStr = strings_1.stringify(transition);
  1927. console.log("Transition #" + tid + " Digest #" + digest + ": Started -> " + transitionStr);
  1928. };
  1929. /** called by ui-router code */
  1930. Trace.prototype.traceTransitionIgnored = function (trans) {
  1931. if (!this.enabled(Category.TRANSITION))
  1932. return;
  1933. var tid = trans && trans.$id, digest = this.approximateDigests, transitionStr = strings_1.stringify(trans);
  1934. console.log("Transition #" + tid + " Digest #" + digest + ": Ignored <> " + transitionStr);
  1935. };
  1936. /** called by ui-router code */
  1937. Trace.prototype.traceHookInvocation = function (step, options) {
  1938. if (!this.enabled(Category.HOOK))
  1939. return;
  1940. 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);
  1941. console.log("Transition #" + tid + " Digest #" + digest + ": Hook -> " + event + " context: " + context + ", " + strings_1.maxLength(200, name));
  1942. };
  1943. /** called by ui-router code */
  1944. Trace.prototype.traceHookResult = function (hookResult, transitionOptions) {
  1945. if (!this.enabled(Category.HOOK))
  1946. return;
  1947. var tid = hof_1.parse("transition.$id")(transitionOptions), digest = this.approximateDigests, hookResultStr = strings_1.stringify(hookResult);
  1948. console.log("Transition #" + tid + " Digest #" + digest + ": <- Hook returned: " + strings_1.maxLength(200, hookResultStr));
  1949. };
  1950. /** called by ui-router code */
  1951. Trace.prototype.traceResolvePath = function (path, when, trans) {
  1952. if (!this.enabled(Category.RESOLVE))
  1953. return;
  1954. var tid = trans && trans.$id, digest = this.approximateDigests, pathStr = path && path.toString();
  1955. console.log("Transition #" + tid + " Digest #" + digest + ": Resolving " + pathStr + " (" + when + ")");
  1956. };
  1957. /** called by ui-router code */
  1958. Trace.prototype.traceResolvableResolved = function (resolvable, trans) {
  1959. if (!this.enabled(Category.RESOLVE))
  1960. return;
  1961. var tid = trans && trans.$id, digest = this.approximateDigests, resolvableStr = resolvable && resolvable.toString(), result = strings_1.stringify(resolvable.data);
  1962. console.log("Transition #" + tid + " Digest #" + digest + ": <- Resolved " + resolvableStr + " to: " + strings_1.maxLength(200, result));
  1963. };
  1964. /** called by ui-router code */
  1965. Trace.prototype.traceError = function (reason, trans) {
  1966. if (!this.enabled(Category.TRANSITION))
  1967. return;
  1968. var tid = trans && trans.$id, digest = this.approximateDigests, transitionStr = strings_1.stringify(trans);
  1969. console.log("Transition #" + tid + " Digest #" + digest + ": <- Rejected " + transitionStr + ", reason: " + reason);
  1970. };
  1971. /** called by ui-router code */
  1972. Trace.prototype.traceSuccess = function (finalState, trans) {
  1973. if (!this.enabled(Category.TRANSITION))
  1974. return;
  1975. var tid = trans && trans.$id, digest = this.approximateDigests, state = finalState.name, transitionStr = strings_1.stringify(trans);
  1976. console.log("Transition #" + tid + " Digest #" + digest + ": <- Success " + transitionStr + ", final state: " + state);
  1977. };
  1978. /** called by ui-router code */
  1979. Trace.prototype.traceUIViewEvent = function (event, viewData, extra) {
  1980. if (extra === void 0) { extra = ""; }
  1981. if (!this.enabled(Category.UIVIEW))
  1982. return;
  1983. console.log("ui-view: " + strings_1.padString(30, event) + " " + uiViewString(viewData) + extra);
  1984. };
  1985. /** called by ui-router code */
  1986. Trace.prototype.traceUIViewConfigUpdated = function (viewData, context) {
  1987. if (!this.enabled(Category.UIVIEW))
  1988. return;
  1989. this.traceUIViewEvent("Updating", viewData, " with ViewConfig from context='" + context + "'");
  1990. };
  1991. /** called by ui-router code */
  1992. Trace.prototype.traceUIViewFill = function (viewData, html) {
  1993. if (!this.enabled(Category.UIVIEW))
  1994. return;
  1995. this.traceUIViewEvent("Fill", viewData, " with: " + strings_1.maxLength(200, html));
  1996. };
  1997. /** called by ui-router code */
  1998. Trace.prototype.traceViewServiceEvent = function (event, viewConfig) {
  1999. if (!this.enabled(Category.VIEWCONFIG))
  2000. return;
  2001. console.log("VIEWCONFIG: " + event + " " + viewConfigString(viewConfig));
  2002. };
  2003. /** called by ui-router code */
  2004. Trace.prototype.traceViewServiceUIViewEvent = function (event, viewData) {
  2005. if (!this.enabled(Category.VIEWCONFIG))
  2006. return;
  2007. console.log("VIEWCONFIG: " + event + " " + uiViewString(viewData));
  2008. };
  2009. return Trace;
  2010. }());
  2011. exports.Trace = Trace;
  2012. /**
  2013. * The [[Trace]] singleton
  2014. *
  2015. * @example
  2016. * ```js
  2017. *
  2018. * import {trace} from "angular-ui-router";
  2019. * trace.enable(1, 5);
  2020. * ```
  2021. */
  2022. var trace = new Trace();
  2023. exports.trace = trace;
  2024. /***/ },
  2025. /* 13 */
  2026. /***/ function(module, exports, __webpack_require__) {
  2027. "use strict";
  2028. var common_1 = __webpack_require__(3);
  2029. var strings_1 = __webpack_require__(9);
  2030. var predicates_1 = __webpack_require__(4);
  2031. var hof_1 = __webpack_require__(5);
  2032. var trace_1 = __webpack_require__(12);
  2033. var coreservices_1 = __webpack_require__(6);
  2034. var rejectFactory_1 = __webpack_require__(10);
  2035. var targetState_1 = __webpack_require__(14);
  2036. var defaultOptions = {
  2037. async: true,
  2038. rejectIfSuperseded: true,
  2039. current: common_1.noop,
  2040. transition: null,
  2041. traceData: {},
  2042. bind: null
  2043. };
  2044. /** @hidden */
  2045. var TransitionHook = (function () {
  2046. function TransitionHook(transition, stateContext, eventHook, options) {
  2047. var _this = this;
  2048. this.transition = transition;
  2049. this.stateContext = stateContext;
  2050. this.eventHook = eventHook;
  2051. this.options = options;
  2052. this.isSuperseded = function () {
  2053. return _this.options.current() !== _this.options.transition;
  2054. };
  2055. this.options = common_1.defaults(options, defaultOptions);
  2056. }
  2057. TransitionHook.prototype.invokeHook = function () {
  2058. var _a = this, options = _a.options, eventHook = _a.eventHook;
  2059. trace_1.trace.traceHookInvocation(this, options);
  2060. if (options.rejectIfSuperseded && this.isSuperseded()) {
  2061. return rejectFactory_1.Rejection.superseded(options.current()).toPromise();
  2062. }
  2063. var synchronousHookResult = !eventHook._deregistered
  2064. ? eventHook.callback.call(options.bind, this.transition, this.stateContext)
  2065. : undefined;
  2066. return this.handleHookResult(synchronousHookResult);
  2067. };
  2068. /**
  2069. * This method handles the return value of a Transition Hook.
  2070. *
  2071. * A hook can return false (cancel), a TargetState (redirect),
  2072. * or a promise (which may later resolve to false or a redirect)
  2073. *
  2074. * This also handles "transition superseded" -- when a new transition
  2075. * was started while the hook was still running
  2076. */
  2077. TransitionHook.prototype.handleHookResult = function (result) {
  2078. // This transition is no longer current.
  2079. // Another transition started while this hook was still running.
  2080. if (this.isSuperseded()) {
  2081. // Abort this transition
  2082. return rejectFactory_1.Rejection.superseded(this.options.current()).toPromise();
  2083. }
  2084. // Hook returned a promise
  2085. if (predicates_1.isPromise(result)) {
  2086. // Wait for the promise, then reprocess the resolved value
  2087. return result.then(this.handleHookResult.bind(this));
  2088. }
  2089. trace_1.trace.traceHookResult(result, this.options);
  2090. // Hook returned false
  2091. if (result === false) {
  2092. // Abort this Transition
  2093. return rejectFactory_1.Rejection.aborted("Hook aborted transition").toPromise();
  2094. }
  2095. var isTargetState = hof_1.is(targetState_1.TargetState);
  2096. // hook returned a TargetState
  2097. if (isTargetState(result)) {
  2098. // Halt the current Transition and start a redirected Transition (to the TargetState).
  2099. return rejectFactory_1.Rejection.redirected(result).toPromise();
  2100. }
  2101. };
  2102. TransitionHook.prototype.toString = function () {
  2103. var _a = this, options = _a.options, eventHook = _a.eventHook;
  2104. 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);
  2105. return event + " context: " + context + ", " + strings_1.maxLength(200, name);
  2106. };
  2107. /**
  2108. * Given an array of TransitionHooks, runs each one synchronously and sequentially.
  2109. *
  2110. * Returns a promise chain composed of any promises returned from each hook.invokeStep() call
  2111. */
  2112. TransitionHook.runSynchronousHooks = function (hooks, swallowExceptions) {
  2113. if (swallowExceptions === void 0) { swallowExceptions = false; }
  2114. var results = [];
  2115. for (var i = 0; i < hooks.length; i++) {
  2116. var hook = hooks[i];
  2117. try {
  2118. results.push(hook.invokeHook());
  2119. }
  2120. catch (exception) {
  2121. if (!swallowExceptions) {
  2122. return rejectFactory_1.Rejection.errored(exception).toPromise();
  2123. }
  2124. var errorHandler = hook.transition.router.stateService.defaultErrorHandler();
  2125. errorHandler(exception);
  2126. }
  2127. }
  2128. var rejections = results.filter(rejectFactory_1.Rejection.isTransitionRejectionPromise);
  2129. if (rejections.length)
  2130. return rejections[0];
  2131. return results
  2132. .filter(predicates_1.isPromise)
  2133. .reduce(function (chain, promise) { return chain.then(hof_1.val(promise)); }, coreservices_1.services.$q.when());
  2134. };
  2135. return TransitionHook;
  2136. }());
  2137. exports.TransitionHook = TransitionHook;
  2138. /***/ },
  2139. /* 14 */
  2140. /***/ function(module, exports, __webpack_require__) {
  2141. /** @module state */ /** for typedoc */
  2142. "use strict";
  2143. var common_1 = __webpack_require__(3);
  2144. /**
  2145. * @ngdoc object
  2146. * @name ui.router.state.type:TargetState
  2147. *
  2148. * @description
  2149. * Encapsulate the desired target of a transition.
  2150. * Wraps an identifier for a state, a set of parameters, and transition options with the definition of the state.
  2151. *
  2152. * @param {StateOrName} _identifier An identifier for a state. Either a fully-qualified path, or the object
  2153. * used to define the state.
  2154. * @param {IState} _definition The `State` object definition.
  2155. * @param {ParamsOrArray} _params Parameters for the target state
  2156. * @param {TransitionOptions} _options Transition options.
  2157. */
  2158. var TargetState = (function () {
  2159. function TargetState(_identifier, _definition, _params, _options) {
  2160. if (_params === void 0) { _params = {}; }
  2161. if (_options === void 0) { _options = {}; }
  2162. this._identifier = _identifier;
  2163. this._definition = _definition;
  2164. this._options = _options;
  2165. this._params = _params || {};
  2166. }
  2167. TargetState.prototype.name = function () {
  2168. return this._definition && this._definition.name || this._identifier;
  2169. };
  2170. TargetState.prototype.identifier = function () {
  2171. return this._identifier;
  2172. };
  2173. TargetState.prototype.params = function () {
  2174. return this._params;
  2175. };
  2176. TargetState.prototype.$state = function () {
  2177. return this._definition;
  2178. };
  2179. TargetState.prototype.state = function () {
  2180. return this._definition && this._definition.self;
  2181. };
  2182. TargetState.prototype.options = function () {
  2183. return this._options;
  2184. };
  2185. TargetState.prototype.exists = function () {
  2186. return !!(this._definition && this._definition.self);
  2187. };
  2188. TargetState.prototype.valid = function () {
  2189. return !this.error();
  2190. };
  2191. TargetState.prototype.error = function () {
  2192. var base = this.options().relative;
  2193. if (!this._definition && !!base) {
  2194. var stateName = base.name ? base.name : base;
  2195. return "Could not resolve '" + this.name() + "' from state '" + stateName + "'";
  2196. }
  2197. if (!this._definition)
  2198. return "No such state '" + this.name() + "'";
  2199. if (!this._definition.self)
  2200. return "State '" + this.name() + "' has an invalid definition";
  2201. };
  2202. TargetState.prototype.toString = function () {
  2203. return "'" + this.name() + "'" + common_1.toJson(this.params());
  2204. };
  2205. return TargetState;
  2206. }());
  2207. exports.TargetState = TargetState;
  2208. /***/ },
  2209. /* 15 */
  2210. /***/ function(module, exports, __webpack_require__) {
  2211. "use strict";
  2212. /** @module transition */ /** for typedoc */
  2213. var common_1 = __webpack_require__(3);
  2214. var predicates_1 = __webpack_require__(4);
  2215. var glob_1 = __webpack_require__(7);
  2216. /**
  2217. * Determines if the given state matches the matchCriteria
  2218. *
  2219. * @hidden
  2220. *
  2221. * @param state a State Object to test against
  2222. * @param criterion
  2223. * - If a string, matchState uses the string as a glob-matcher against the state name
  2224. * - If an array (of strings), matchState uses each string in the array as a glob-matchers against the state name
  2225. * and returns a positive match if any of the globs match.
  2226. * - If a function, matchState calls the function with the state and returns true if the function's result is truthy.
  2227. * @returns {boolean}
  2228. */
  2229. function matchState(state, criterion) {
  2230. var toMatch = predicates_1.isString(criterion) ? [criterion] : criterion;
  2231. function matchGlobs(_state) {
  2232. var globStrings = toMatch;
  2233. for (var i = 0; i < globStrings.length; i++) {
  2234. var glob = glob_1.Glob.fromString(globStrings[i]);
  2235. if ((glob && glob.matches(_state.name)) || (!glob && globStrings[i] === _state.name)) {
  2236. return true;
  2237. }
  2238. }
  2239. return false;
  2240. }
  2241. var matchFn = (predicates_1.isFunction(toMatch) ? toMatch : matchGlobs);
  2242. return !!matchFn(state);
  2243. }
  2244. exports.matchState = matchState;
  2245. /** @hidden */
  2246. var EventHook = (function () {
  2247. function EventHook(matchCriteria, callback, options) {
  2248. if (options === void 0) { options = {}; }
  2249. this.callback = callback;
  2250. this.matchCriteria = common_1.extend({ to: true, from: true, exiting: true, retained: true, entering: true }, matchCriteria);
  2251. this.priority = options.priority || 0;
  2252. this.bind = options.bind || null;
  2253. this._deregistered = false;
  2254. }
  2255. EventHook._matchingNodes = function (nodes, criterion) {
  2256. if (criterion === true)
  2257. return nodes;
  2258. var matching = nodes.filter(function (node) { return matchState(node.state, criterion); });
  2259. return matching.length ? matching : null;
  2260. };
  2261. /**
  2262. * Determines if this hook's [[matchCriteria]] match the given [[TreeChanges]]
  2263. *
  2264. * @returns an IMatchingNodes object, or null. If an IMatchingNodes object is returned, its values
  2265. * are the matching [[PathNode]]s for each [[HookMatchCriterion]] (to, from, exiting, retained, entering)
  2266. */
  2267. EventHook.prototype.matches = function (treeChanges) {
  2268. var mc = this.matchCriteria, _matchingNodes = EventHook._matchingNodes;
  2269. var matches = {
  2270. to: _matchingNodes([common_1.tail(treeChanges.to)], mc.to),
  2271. from: _matchingNodes([common_1.tail(treeChanges.from)], mc.from),
  2272. exiting: _matchingNodes(treeChanges.exiting, mc.exiting),
  2273. retained: _matchingNodes(treeChanges.retained, mc.retained),
  2274. entering: _matchingNodes(treeChanges.entering, mc.entering),
  2275. };
  2276. // Check if all the criteria matched the TreeChanges object
  2277. var allMatched = ["to", "from", "exiting", "retained", "entering"]
  2278. .map(function (prop) { return matches[prop]; })
  2279. .reduce(common_1.allTrueR, true);
  2280. return allMatched ? matches : null;
  2281. };
  2282. return EventHook;
  2283. }());
  2284. exports.EventHook = EventHook;
  2285. /** @hidden Return a registration function of the requested type. */
  2286. function makeHookRegistrationFn(hooks, name) {
  2287. return function (matchObject, callback, options) {
  2288. if (options === void 0) { options = {}; }
  2289. var eventHook = new EventHook(matchObject, callback, options);
  2290. hooks[name].push(eventHook);
  2291. return function deregisterEventHook() {
  2292. eventHook._deregistered = true;
  2293. common_1.removeFrom(hooks[name])(eventHook);
  2294. };
  2295. };
  2296. }
  2297. /**
  2298. * Mixin class acts as a Transition Hook registry.
  2299. *
  2300. * Holds the registered [[HookFn]] objects.
  2301. * Exposes functions to register new hooks.
  2302. *
  2303. * This is a Mixin class which can be applied to other objects.
  2304. *
  2305. * The hook registration functions are [[onBefore]], [[onStart]], [[onEnter]], [[onRetain]], [[onExit]], [[onFinish]], [[onSuccess]], [[onError]].
  2306. *
  2307. * This class is mixed into both the [[TransitionService]] and every [[Transition]] object.
  2308. * Global hooks are added to the [[TransitionService]].
  2309. * Since each [[Transition]] is itself a `HookRegistry`, hooks can also be added to individual Transitions
  2310. * (note: the hook criteria still must match the Transition).
  2311. */
  2312. var HookRegistry = (function () {
  2313. function HookRegistry() {
  2314. var _this = this;
  2315. this._transitionEvents = {
  2316. onBefore: [], onStart: [], onEnter: [], onRetain: [], onExit: [], onFinish: [], onSuccess: [], onError: []
  2317. };
  2318. this.getHooks = function (name) { return _this._transitionEvents[name]; };
  2319. /** @inheritdoc */
  2320. this.onBefore = makeHookRegistrationFn(this._transitionEvents, "onBefore");
  2321. /** @inheritdoc */
  2322. this.onStart = makeHookRegistrationFn(this._transitionEvents, "onStart");
  2323. /** @inheritdoc */
  2324. this.onEnter = makeHookRegistrationFn(this._transitionEvents, "onEnter");
  2325. /** @inheritdoc */
  2326. this.onRetain = makeHookRegistrationFn(this._transitionEvents, "onRetain");
  2327. /** @inheritdoc */
  2328. this.onExit = makeHookRegistrationFn(this._transitionEvents, "onExit");
  2329. /** @inheritdoc */
  2330. this.onFinish = makeHookRegistrationFn(this._transitionEvents, "onFinish");
  2331. /** @inheritdoc */
  2332. this.onSuccess = makeHookRegistrationFn(this._transitionEvents, "onSuccess");
  2333. /** @inheritdoc */
  2334. this.onError = makeHookRegistrationFn(this._transitionEvents, "onError");
  2335. }
  2336. HookRegistry.mixin = function (source, target) {
  2337. Object.keys(source._transitionEvents).concat(["getHooks"]).forEach(function (key) { return target[key] = source[key]; });
  2338. };
  2339. return HookRegistry;
  2340. }());
  2341. exports.HookRegistry = HookRegistry;
  2342. /***/ },
  2343. /* 16 */
  2344. /***/ function(module, exports, __webpack_require__) {
  2345. /** @module transition */ /** for typedoc */
  2346. "use strict";
  2347. var common_1 = __webpack_require__(3);
  2348. var predicates_1 = __webpack_require__(4);
  2349. var transitionHook_1 = __webpack_require__(13);
  2350. var resolveContext_1 = __webpack_require__(17);
  2351. /**
  2352. * This class returns applicable TransitionHooks for a specific Transition instance.
  2353. *
  2354. * Hooks (IEventHook) may be registered globally, e.g., $transitions.onEnter(...), or locally, e.g.
  2355. * myTransition.onEnter(...). The HookBuilder finds matching IEventHooks (where the match criteria is
  2356. * determined by the type of hook)
  2357. *
  2358. * The HookBuilder also converts IEventHooks objects to TransitionHook objects, which are used to run a Transition.
  2359. *
  2360. * The HookBuilder constructor is given the $transitions service and a Transition instance. Thus, a HookBuilder
  2361. * instance may only be used for one specific Transition object. (side note: the _treeChanges accessor is private
  2362. * in the Transition class, so we must also provide the Transition's _treeChanges)
  2363. *
  2364. */
  2365. var HookBuilder = (function () {
  2366. function HookBuilder($transitions, transition, baseHookOptions) {
  2367. var _this = this;
  2368. this.$transitions = $transitions;
  2369. this.transition = transition;
  2370. this.baseHookOptions = baseHookOptions;
  2371. this.getOnBeforeHooks = function () { return _this._buildNodeHooks("onBefore", "to", tupleSort(), { async: false }); };
  2372. this.getOnStartHooks = function () { return _this._buildNodeHooks("onStart", "to", tupleSort()); };
  2373. this.getOnExitHooks = function () { return _this._buildNodeHooks("onExit", "exiting", tupleSort(true), { stateHook: true }); };
  2374. this.getOnRetainHooks = function () { return _this._buildNodeHooks("onRetain", "retained", tupleSort(false), { stateHook: true }); };
  2375. this.getOnEnterHooks = function () { return _this._buildNodeHooks("onEnter", "entering", tupleSort(false), { stateHook: true }); };
  2376. this.getOnFinishHooks = function () { return _this._buildNodeHooks("onFinish", "to", tupleSort()); };
  2377. this.getOnSuccessHooks = function () { return _this._buildNodeHooks("onSuccess", "to", tupleSort(), { async: false, rejectIfSuperseded: false }); };
  2378. this.getOnErrorHooks = function () { return _this._buildNodeHooks("onError", "to", tupleSort(), { async: false, rejectIfSuperseded: false }); };
  2379. this.treeChanges = transition.treeChanges();
  2380. this.toState = common_1.tail(this.treeChanges.to).state;
  2381. this.fromState = common_1.tail(this.treeChanges.from).state;
  2382. this.transitionOptions = transition.options();
  2383. }
  2384. HookBuilder.prototype.asyncHooks = function () {
  2385. var onStartHooks = this.getOnStartHooks();
  2386. var onExitHooks = this.getOnExitHooks();
  2387. var onRetainHooks = this.getOnRetainHooks();
  2388. var onEnterHooks = this.getOnEnterHooks();
  2389. var onFinishHooks = this.getOnFinishHooks();
  2390. var asyncHooks = [onStartHooks, onExitHooks, onRetainHooks, onEnterHooks, onFinishHooks];
  2391. return asyncHooks.reduce(common_1.unnestR, []).filter(common_1.identity);
  2392. };
  2393. /**
  2394. * Returns an array of newly built TransitionHook objects.
  2395. *
  2396. * - Finds all IEventHooks registered for the given `hookType` which matched the transition's [[TreeChanges]].
  2397. * - Finds [[PathNode]] (or `PathNode[]`) to use as the TransitionHook context(s)
  2398. * - For each of the [[PathNode]]s, creates a TransitionHook
  2399. *
  2400. * @param hookType the name of the hook registration function, e.g., 'onEnter', 'onFinish'.
  2401. * @param matchingNodesProp selects which [[PathNode]]s from the [[IMatchingNodes]] object to create hooks for.
  2402. * @param getLocals a function which accepts a [[PathNode]] and returns additional locals to provide to the hook as injectables
  2403. * @param sortHooksFn a function which compares two HookTuple and returns <1, 0, or >1
  2404. * @param options any specific Transition Hook Options
  2405. */
  2406. HookBuilder.prototype._buildNodeHooks = function (hookType, matchingNodesProp, sortHooksFn, options) {
  2407. var _this = this;
  2408. // Find all the matching registered hooks for a given hook type
  2409. var matchingHooks = this._matchingHooks(hookType, this.treeChanges);
  2410. if (!matchingHooks)
  2411. return [];
  2412. var makeTransitionHooks = function (hook) {
  2413. // Fetch the Nodes that caused this hook to match.
  2414. var matches = hook.matches(_this.treeChanges);
  2415. // Select the PathNode[] that will be used as TransitionHook context objects
  2416. var matchingNodes = matches[matchingNodesProp];
  2417. // When invoking 'exiting' hooks, give them the "from path" for resolve data.
  2418. // Everything else gets the "to path"
  2419. var resolvePath = matchingNodesProp === 'exiting' ? _this.treeChanges.from : _this.treeChanges.to;
  2420. var resolveContext = new resolveContext_1.ResolveContext(resolvePath);
  2421. // Return an array of HookTuples
  2422. return matchingNodes.map(function (node) {
  2423. var _options = common_1.extend({ bind: hook.bind, traceData: { hookType: hookType, context: node } }, _this.baseHookOptions, options);
  2424. var state = _options.stateHook ? node.state : null;
  2425. var transitionHook = new transitionHook_1.TransitionHook(_this.transition, state, hook, _options);
  2426. return { hook: hook, node: node, transitionHook: transitionHook };
  2427. });
  2428. };
  2429. return matchingHooks.map(makeTransitionHooks)
  2430. .reduce(common_1.unnestR, [])
  2431. .sort(sortHooksFn)
  2432. .map(function (tuple) { return tuple.transitionHook; });
  2433. };
  2434. /**
  2435. * Finds all IEventHooks from:
  2436. * - The Transition object instance hook registry
  2437. * - The TransitionService ($transitions) global hook registry
  2438. *
  2439. * which matched:
  2440. * - the eventType
  2441. * - the matchCriteria (to, from, exiting, retained, entering)
  2442. *
  2443. * @returns an array of matched [[IEventHook]]s
  2444. */
  2445. HookBuilder.prototype._matchingHooks = function (hookName, treeChanges) {
  2446. return [this.transition, this.$transitions] // Instance and Global hook registries
  2447. .map(function (reg) { return reg.getHooks(hookName); }) // Get named hooks from registries
  2448. .filter(common_1.assertPredicate(predicates_1.isArray, "broken event named: " + hookName)) // Sanity check
  2449. .reduce(common_1.unnestR, []) // Un-nest IEventHook[][] to IEventHook[] array
  2450. .filter(function (hook) { return hook.matches(treeChanges); }); // Only those satisfying matchCriteria
  2451. };
  2452. return HookBuilder;
  2453. }());
  2454. exports.HookBuilder = HookBuilder;
  2455. /**
  2456. * A factory for a sort function for HookTuples.
  2457. *
  2458. * The sort function first compares the PathNode depth (how deep in the state tree a node is), then compares
  2459. * the EventHook priority.
  2460. *
  2461. * @param reverseDepthSort a boolean, when true, reverses the sort order for the node depth
  2462. * @returns a tuple sort function
  2463. */
  2464. function tupleSort(reverseDepthSort) {
  2465. if (reverseDepthSort === void 0) { reverseDepthSort = false; }
  2466. return function nodeDepthThenPriority(l, r) {
  2467. var factor = reverseDepthSort ? -1 : 1;
  2468. var depthDelta = (l.node.state.path.length - r.node.state.path.length) * factor;
  2469. return depthDelta !== 0 ? depthDelta : r.hook.priority - l.hook.priority;
  2470. };
  2471. }
  2472. /***/ },
  2473. /* 17 */
  2474. /***/ function(module, exports, __webpack_require__) {
  2475. "use strict";
  2476. /** @module resolve */ /** for typedoc */
  2477. var common_1 = __webpack_require__(3);
  2478. var hof_1 = __webpack_require__(5);
  2479. var trace_1 = __webpack_require__(12);
  2480. var coreservices_1 = __webpack_require__(6);
  2481. var interface_1 = __webpack_require__(18);
  2482. var resolvable_1 = __webpack_require__(19);
  2483. var pathFactory_1 = __webpack_require__(20);
  2484. var strings_1 = __webpack_require__(9);
  2485. var when = interface_1.resolvePolicies.when;
  2486. var ALL_WHENS = [when.EAGER, when.LAZY];
  2487. var EAGER_WHENS = [when.EAGER];
  2488. exports.NATIVE_INJECTOR_TOKEN = "Native Injector";
  2489. /**
  2490. * Encapsulates Depenency Injection for a path of nodes
  2491. *
  2492. * UI-Router states are organized as a tree.
  2493. * A nested state has a path of ancestors to the root of the tree.
  2494. * When a state is being activated, each element in the path is wrapped as a [[PathNode]].
  2495. * A `PathNode` is a stateful object that holds things like parameters and resolvables for the state being activated.
  2496. *
  2497. * The ResolveContext closes over the [[PathNode]]s, and provides DI for the last node in the path.
  2498. */
  2499. var ResolveContext = (function () {
  2500. function ResolveContext(_path) {
  2501. this._path = _path;
  2502. }
  2503. /** Gets all the tokens found in the resolve context, de-duplicated */
  2504. ResolveContext.prototype.getTokens = function () {
  2505. return this._path.reduce(function (acc, node) { return acc.concat(node.resolvables.map(function (r) { return r.token; })); }, []).reduce(common_1.uniqR, []);
  2506. };
  2507. /**
  2508. * Gets the Resolvable that matches the token
  2509. *
  2510. * Gets the last Resolvable that matches the token in this context, or undefined.
  2511. * Throws an error if it doesn't exist in the ResolveContext
  2512. */
  2513. ResolveContext.prototype.getResolvable = function (token) {
  2514. var matching = this._path.map(function (node) { return node.resolvables; })
  2515. .reduce(common_1.unnestR, [])
  2516. .filter(function (r) { return r.token === token; });
  2517. return common_1.tail(matching);
  2518. };
  2519. /**
  2520. * Returns a ResolveContext that includes a portion of this one
  2521. *
  2522. * Given a state, this method creates a new ResolveContext from this one.
  2523. * The new context starts at the first node (root) and stops at the node for the `state` parameter.
  2524. *
  2525. * #### Why
  2526. *
  2527. * When a transition is created, the nodes in the "To Path" are injected from a ResolveContext.
  2528. * A ResolveContext closes over a path of [[PathNode]]s and processes the resolvables.
  2529. * The "To State" can inject values from its own resolvables, as well as those from all its ancestor state's (node's).
  2530. * This method is used to create a narrower context when injecting ancestor nodes.
  2531. *
  2532. * @example
  2533. * `let ABCD = new ResolveContext([A, B, C, D]);`
  2534. *
  2535. * Given a path `[A, B, C, D]`, where `A`, `B`, `C` and `D` are nodes for states `a`, `b`, `c`, `d`:
  2536. * When injecting `D`, `D` should have access to all resolvables from `A`, `B`, `C`, `D`.
  2537. * However, `B` should only be able to access resolvables from `A`, `B`.
  2538. *
  2539. * When resolving for the `B` node, first take the full "To Path" Context `[A,B,C,D]` and limit to the subpath `[A,B]`.
  2540. * `let AB = ABCD.subcontext(a)`
  2541. */
  2542. ResolveContext.prototype.subContext = function (state) {
  2543. return new ResolveContext(pathFactory_1.PathFactory.subPath(this._path, function (node) { return node.state === state; }));
  2544. };
  2545. /**
  2546. * Adds Resolvables to the node that matches the state
  2547. *
  2548. * This adds a [[Resolvable]] (generally one created on the fly; not declared on a [[StateDeclaration.resolve]] block).
  2549. * The resolvable is added to the node matching the `state` parameter.
  2550. *
  2551. * These new resolvables are not automatically fetched.
  2552. * The calling code should either fetch them, fetch something that depends on them,
  2553. * or rely on [[resolvePath]] being called when some state is being entered.
  2554. *
  2555. * Note: each resolvable's [[ResolvePolicy]] is merged with the state's policy, and the global default.
  2556. *
  2557. * @param newResolvables the new Resolvables
  2558. * @param state Used to find the node to put the resolvable on
  2559. */
  2560. ResolveContext.prototype.addResolvables = function (newResolvables, state) {
  2561. var node = common_1.find(this._path, hof_1.propEq('state', state));
  2562. var keys = newResolvables.map(function (r) { return r.token; });
  2563. node.resolvables = node.resolvables.filter(function (r) { return keys.indexOf(r.token) === -1; }).concat(newResolvables);
  2564. };
  2565. /**
  2566. * Returns a promise for an array of resolved path Element promises
  2567. *
  2568. * @param when
  2569. * @param trans
  2570. * @returns {Promise<any>|any}
  2571. */
  2572. ResolveContext.prototype.resolvePath = function (when, trans) {
  2573. var _this = this;
  2574. if (when === void 0) { when = "LAZY"; }
  2575. // This option determines which 'when' policy Resolvables we are about to fetch.
  2576. var whenOption = common_1.inArray(ALL_WHENS, when) ? when : "LAZY";
  2577. // If the caller specified EAGER, only the EAGER Resolvables are fetched.
  2578. // if the caller specified LAZY, both EAGER and LAZY Resolvables are fetched.`
  2579. var matchedWhens = whenOption === interface_1.resolvePolicies.when.EAGER ? EAGER_WHENS : ALL_WHENS;
  2580. // get the subpath to the state argument, if provided
  2581. trace_1.trace.traceResolvePath(this._path, when, trans);
  2582. var promises = this._path.reduce(function (acc, node) {
  2583. var matchesRequestedPolicy = function (resolvable) {
  2584. return common_1.inArray(matchedWhens, resolvable.getPolicy(node.state).when);
  2585. };
  2586. var nodeResolvables = node.resolvables.filter(matchesRequestedPolicy);
  2587. var subContext = _this.subContext(node.state);
  2588. // For the matching Resolvables, start their async fetch process.
  2589. var getResult = function (r) { return r.get(subContext, trans)
  2590. .then(function (value) { return ({ token: r.token, value: value }); }); };
  2591. return acc.concat(nodeResolvables.map(getResult));
  2592. }, []);
  2593. return coreservices_1.services.$q.all(promises);
  2594. };
  2595. ResolveContext.prototype.injector = function () {
  2596. return this._injector || (this._injector = new UIInjectorImpl(this));
  2597. };
  2598. ResolveContext.prototype.findNode = function (resolvable) {
  2599. return common_1.find(this._path, function (node) { return common_1.inArray(node.resolvables, resolvable); });
  2600. };
  2601. /**
  2602. * Gets the async dependencies of a Resolvable
  2603. *
  2604. * Given a Resolvable, returns its dependencies as a Resolvable[]
  2605. */
  2606. ResolveContext.prototype.getDependencies = function (resolvable) {
  2607. var _this = this;
  2608. var node = this.findNode(resolvable);
  2609. // Find which other resolvables are "visible" to the `resolvable` argument
  2610. // subpath stopping at resolvable's node, or the whole path (if the resolvable isn't in the path)
  2611. var subPath = pathFactory_1.PathFactory.subPath(this._path, function (x) { return x === node; }) || this._path;
  2612. var availableResolvables = subPath
  2613. .reduce(function (acc, node) { return acc.concat(node.resolvables); }, []) //all of subpath's resolvables
  2614. .filter(function (res) { return res !== resolvable; }); // filter out the `resolvable` argument
  2615. var getDependency = function (token) {
  2616. var matching = availableResolvables.filter(function (r) { return r.token === token; });
  2617. if (matching.length)
  2618. return common_1.tail(matching);
  2619. var fromInjector = _this.injector().getNative(token);
  2620. if (!fromInjector) {
  2621. throw new Error("Could not find Dependency Injection token: " + strings_1.stringify(token));
  2622. }
  2623. return new resolvable_1.Resolvable(token, function () { return fromInjector; }, [], fromInjector);
  2624. };
  2625. return resolvable.deps.map(getDependency);
  2626. };
  2627. return ResolveContext;
  2628. }());
  2629. exports.ResolveContext = ResolveContext;
  2630. var UIInjectorImpl = (function () {
  2631. function UIInjectorImpl(context) {
  2632. this.context = context;
  2633. this.native = this.get(exports.NATIVE_INJECTOR_TOKEN) || coreservices_1.services.$injector;
  2634. }
  2635. UIInjectorImpl.prototype.get = function (token) {
  2636. var resolvable = this.context.getResolvable(token);
  2637. if (resolvable) {
  2638. if (!resolvable.resolved) {
  2639. throw new Error("Resolvable async .get() not complete:" + strings_1.stringify(resolvable.token));
  2640. }
  2641. return resolvable.data;
  2642. }
  2643. return this.native && this.native.get(token);
  2644. };
  2645. UIInjectorImpl.prototype.getAsync = function (token) {
  2646. var resolvable = this.context.getResolvable(token);
  2647. if (resolvable)
  2648. return resolvable.get(this.context);
  2649. return coreservices_1.services.$q.when(this.native.get(token));
  2650. };
  2651. UIInjectorImpl.prototype.getNative = function (token) {
  2652. return this.native.get(token);
  2653. };
  2654. return UIInjectorImpl;
  2655. }());
  2656. /***/ },
  2657. /* 18 */
  2658. /***/ function(module, exports) {
  2659. "use strict";
  2660. exports.resolvePolicies = {
  2661. when: {
  2662. LAZY: "LAZY",
  2663. EAGER: "EAGER"
  2664. },
  2665. async: {
  2666. WAIT: "WAIT",
  2667. NOWAIT: "NOWAIT",
  2668. RXWAIT: "RXWAIT"
  2669. }
  2670. };
  2671. /***/ },
  2672. /* 19 */
  2673. /***/ function(module, exports, __webpack_require__) {
  2674. "use strict";
  2675. /** @module resolve */ /** for typedoc */
  2676. var common_1 = __webpack_require__(3);
  2677. var coreservices_1 = __webpack_require__(6);
  2678. var trace_1 = __webpack_require__(12);
  2679. var strings_1 = __webpack_require__(9);
  2680. var predicates_1 = __webpack_require__(4);
  2681. // TODO: explicitly make this user configurable
  2682. exports.defaultResolvePolicy = {
  2683. when: "LAZY",
  2684. async: "WAIT"
  2685. };
  2686. /**
  2687. * The basic building block for the resolve system.
  2688. *
  2689. * Resolvables encapsulate a state's resolve's resolveFn, the resolveFn's declared dependencies, the wrapped (.promise),
  2690. * and the unwrapped-when-complete (.data) result of the resolveFn.
  2691. *
  2692. * Resolvable.get() either retrieves the Resolvable's existing promise, or else invokes resolve() (which invokes the
  2693. * resolveFn) and returns the resulting promise.
  2694. *
  2695. * Resolvable.get() and Resolvable.resolve() both execute within a context path, which is passed as the first
  2696. * parameter to those fns.
  2697. */
  2698. var Resolvable = (function () {
  2699. function Resolvable(arg1, resolveFn, deps, policy, data) {
  2700. this.resolved = false;
  2701. this.promise = undefined;
  2702. if (arg1 instanceof Resolvable) {
  2703. common_1.extend(this, arg1);
  2704. }
  2705. else if (predicates_1.isFunction(resolveFn)) {
  2706. if (arg1 == null || arg1 == undefined)
  2707. throw new Error("new Resolvable(): token argument is required");
  2708. if (!predicates_1.isFunction(resolveFn))
  2709. throw new Error("new Resolvable(): resolveFn argument must be a function");
  2710. this.token = arg1;
  2711. this.policy = policy;
  2712. this.resolveFn = resolveFn;
  2713. this.deps = deps || [];
  2714. this.data = data;
  2715. this.resolved = data !== undefined;
  2716. this.promise = this.resolved ? coreservices_1.services.$q.when(this.data) : undefined;
  2717. }
  2718. else if (predicates_1.isObject(arg1) && arg1.token && predicates_1.isFunction(arg1.resolveFn)) {
  2719. var literal = arg1;
  2720. return new Resolvable(literal.token, literal.resolveFn, literal.deps, literal.policy, literal.data);
  2721. }
  2722. }
  2723. Resolvable.prototype.getPolicy = function (state) {
  2724. var thisPolicy = this.policy || {};
  2725. var statePolicy = state && state.resolvePolicy || {};
  2726. return {
  2727. when: thisPolicy.when || statePolicy.when || exports.defaultResolvePolicy.when,
  2728. async: thisPolicy.async || statePolicy.async || exports.defaultResolvePolicy.async,
  2729. };
  2730. };
  2731. /**
  2732. * Asynchronously resolve this Resolvable's data
  2733. *
  2734. * Given a ResolveContext that this Resolvable is found in:
  2735. * Wait for this Resolvable's dependencies, then invoke this Resolvable's function
  2736. * and update the Resolvable's state
  2737. */
  2738. Resolvable.prototype.resolve = function (resolveContext, trans) {
  2739. var _this = this;
  2740. var $q = coreservices_1.services.$q;
  2741. // Gets all dependencies from ResolveContext and wait for them to be resolved
  2742. var getResolvableDependencies = function () {
  2743. return $q.all(resolveContext.getDependencies(_this).map(function (r) {
  2744. return r.get(resolveContext, trans);
  2745. }));
  2746. };
  2747. // Invokes the resolve function passing the resolved dependencies as arguments
  2748. var invokeResolveFn = function (resolvedDeps) {
  2749. return _this.resolveFn.apply(null, resolvedDeps);
  2750. };
  2751. /**
  2752. * For RXWAIT policy:
  2753. *
  2754. * Given an observable returned from a resolve function:
  2755. * - enables .cache() mode (this allows multicast subscribers)
  2756. * - then calls toPromise() (this triggers subscribe() and thus fetches)
  2757. * - Waits for the promise, then return the cached observable (not the first emitted value).
  2758. */
  2759. var waitForRx = function (observable$) {
  2760. var cached = observable$.cache(1);
  2761. return cached.take(1).toPromise().then(function () { return cached; });
  2762. };
  2763. // If the resolve policy is RXWAIT, wait for the observable to emit something. otherwise pass through.
  2764. var node = resolveContext.findNode(this);
  2765. var state = node && node.state;
  2766. var maybeWaitForRx = this.getPolicy(state).async === "RXWAIT" ? waitForRx : common_1.identity;
  2767. // After the final value has been resolved, update the state of the Resolvable
  2768. var applyResolvedValue = function (resolvedValue) {
  2769. _this.data = resolvedValue;
  2770. _this.resolved = true;
  2771. trace_1.trace.traceResolvableResolved(_this, trans);
  2772. return _this.data;
  2773. };
  2774. // Sets the promise property first, then getsResolvableDependencies in the context of the promise chain. Always waits one tick.
  2775. return this.promise = $q.when()
  2776. .then(getResolvableDependencies)
  2777. .then(invokeResolveFn)
  2778. .then(maybeWaitForRx)
  2779. .then(applyResolvedValue);
  2780. };
  2781. /**
  2782. * Gets a promise for this Resolvable's data.
  2783. *
  2784. * Fetches the data and returns a promise.
  2785. * Returns the existing promise if it has already been fetched once.
  2786. */
  2787. Resolvable.prototype.get = function (resolveContext, trans) {
  2788. return this.promise || this.resolve(resolveContext, trans);
  2789. };
  2790. Resolvable.prototype.toString = function () {
  2791. return "Resolvable(token: " + strings_1.stringify(this.token) + ", requires: [" + this.deps.map(strings_1.stringify) + "])";
  2792. };
  2793. Resolvable.prototype.clone = function () {
  2794. return new Resolvable(this);
  2795. };
  2796. Resolvable.fromData = function (token, data) {
  2797. return new Resolvable(token, function () { return data; }, null, null, data);
  2798. };
  2799. return Resolvable;
  2800. }());
  2801. exports.Resolvable = Resolvable;
  2802. /***/ },
  2803. /* 20 */
  2804. /***/ function(module, exports, __webpack_require__) {
  2805. /** @module path */ /** for typedoc */
  2806. "use strict";
  2807. var common_1 = __webpack_require__(3);
  2808. var hof_1 = __webpack_require__(5);
  2809. var targetState_1 = __webpack_require__(14);
  2810. var node_1 = __webpack_require__(21);
  2811. /**
  2812. * This class contains functions which convert TargetStates, Nodes and paths from one type to another.
  2813. */
  2814. var PathFactory = (function () {
  2815. function PathFactory() {
  2816. }
  2817. /** Given a PathNode[], create an TargetState */
  2818. PathFactory.makeTargetState = function (path) {
  2819. var state = common_1.tail(path).state;
  2820. return new targetState_1.TargetState(state, state, path.map(hof_1.prop("paramValues")).reduce(common_1.mergeR, {}));
  2821. };
  2822. PathFactory.buildPath = function (targetState) {
  2823. var toParams = targetState.params();
  2824. return targetState.$state().path.map(function (state) { return new node_1.PathNode(state).applyRawParams(toParams); });
  2825. };
  2826. /** Given a fromPath: PathNode[] and a TargetState, builds a toPath: PathNode[] */
  2827. PathFactory.buildToPath = function (fromPath, targetState) {
  2828. var toPath = PathFactory.buildPath(targetState);
  2829. if (targetState.options().inherit) {
  2830. return PathFactory.inheritParams(fromPath, toPath, Object.keys(targetState.params()));
  2831. }
  2832. return toPath;
  2833. };
  2834. /**
  2835. * Creates ViewConfig objects and adds to nodes.
  2836. *
  2837. * On each [[PathNode]], creates ViewConfig objects from the views: property of the node's state
  2838. */
  2839. PathFactory.applyViewConfigs = function ($view, path, states) {
  2840. // Only apply the viewConfigs to the nodes for the given states
  2841. path.filter(function (node) { return common_1.inArray(states, node.state); }).forEach(function (node) {
  2842. var viewDecls = common_1.values(node.state.views || {});
  2843. var subPath = PathFactory.subPath(path, function (n) { return n === node; });
  2844. var viewConfigs = viewDecls.map(function (view) { return $view.createViewConfig(subPath, view); });
  2845. node.views = viewConfigs.reduce(common_1.unnestR, []);
  2846. });
  2847. };
  2848. /**
  2849. * Given a fromPath and a toPath, returns a new to path which inherits parameters from the fromPath
  2850. *
  2851. * For a parameter in a node to be inherited from the from path:
  2852. * - The toPath's node must have a matching node in the fromPath (by state).
  2853. * - The parameter name must not be found in the toKeys parameter array.
  2854. *
  2855. * Note: the keys provided in toKeys are intended to be those param keys explicitly specified by some
  2856. * caller, for instance, $state.transitionTo(..., toParams). If a key was found in toParams,
  2857. * it is not inherited from the fromPath.
  2858. */
  2859. PathFactory.inheritParams = function (fromPath, toPath, toKeys) {
  2860. if (toKeys === void 0) { toKeys = []; }
  2861. function nodeParamVals(path, state) {
  2862. var node = common_1.find(path, hof_1.propEq('state', state));
  2863. return common_1.extend({}, node && node.paramValues);
  2864. }
  2865. /**
  2866. * Given an [[PathNode]] "toNode", return a new [[PathNode]] with param values inherited from the
  2867. * matching node in fromPath. Only inherit keys that aren't found in "toKeys" from the node in "fromPath""
  2868. */
  2869. function makeInheritedParamsNode(toNode) {
  2870. // All param values for the node (may include default key/vals, when key was not found in toParams)
  2871. var toParamVals = common_1.extend({}, toNode && toNode.paramValues);
  2872. // limited to only those keys found in toParams
  2873. var incomingParamVals = common_1.pick(toParamVals, toKeys);
  2874. toParamVals = common_1.omit(toParamVals, toKeys);
  2875. var fromParamVals = nodeParamVals(fromPath, toNode.state) || {};
  2876. // extend toParamVals with any fromParamVals, then override any of those those with incomingParamVals
  2877. var ownParamVals = common_1.extend(toParamVals, fromParamVals, incomingParamVals);
  2878. return new node_1.PathNode(toNode.state).applyRawParams(ownParamVals);
  2879. }
  2880. // The param keys specified by the incoming toParams
  2881. return toPath.map(makeInheritedParamsNode);
  2882. };
  2883. /**
  2884. * Computes the tree changes (entering, exiting) between a fromPath and toPath.
  2885. */
  2886. PathFactory.treeChanges = function (fromPath, toPath, reloadState) {
  2887. var keep = 0, max = Math.min(fromPath.length, toPath.length);
  2888. var staticParams = function (state) {
  2889. return state.parameters({ inherit: false }).filter(hof_1.not(hof_1.prop('dynamic'))).map(hof_1.prop('id'));
  2890. };
  2891. var nodesMatch = function (node1, node2) {
  2892. return node1.equals(node2, staticParams(node1.state));
  2893. };
  2894. while (keep < max && fromPath[keep].state !== reloadState && nodesMatch(fromPath[keep], toPath[keep])) {
  2895. keep++;
  2896. }
  2897. /** Given a retained node, return a new node which uses the to node's param values */
  2898. function applyToParams(retainedNode, idx) {
  2899. var cloned = node_1.PathNode.clone(retainedNode);
  2900. cloned.paramValues = toPath[idx].paramValues;
  2901. return cloned;
  2902. }
  2903. var from, retained, exiting, entering, to;
  2904. from = fromPath;
  2905. retained = from.slice(0, keep);
  2906. exiting = from.slice(keep);
  2907. // Create a new retained path (with shallow copies of nodes) which have the params of the toPath mapped
  2908. var retainedWithToParams = retained.map(applyToParams);
  2909. entering = toPath.slice(keep);
  2910. to = (retainedWithToParams).concat(entering);
  2911. return { from: from, to: to, retained: retained, exiting: exiting, entering: entering };
  2912. };
  2913. /**
  2914. * Return a subpath of a path, which stops at the first matching node
  2915. *
  2916. * Given an array of nodes, returns a subset of the array starting from the first node,
  2917. * stopping when the first node matches the predicate.
  2918. *
  2919. * @param path a path of [[PathNode]]s
  2920. * @param predicate a [[Predicate]] fn that matches [[PathNode]]s
  2921. * @returns a subpath up to the matching node, or undefined if no match is found
  2922. */
  2923. PathFactory.subPath = function (path, predicate) {
  2924. var node = common_1.find(path, predicate);
  2925. var elementIdx = path.indexOf(node);
  2926. return elementIdx === -1 ? undefined : path.slice(0, elementIdx + 1);
  2927. };
  2928. /** Gets the raw parameter values from a path */
  2929. PathFactory.paramValues = function (path) { return path.reduce(function (acc, node) { return common_1.extend(acc, node.paramValues); }, {}); };
  2930. return PathFactory;
  2931. }());
  2932. exports.PathFactory = PathFactory;
  2933. /***/ },
  2934. /* 21 */
  2935. /***/ function(module, exports, __webpack_require__) {
  2936. "use strict";
  2937. /** @module path */ /** for typedoc */
  2938. var common_1 = __webpack_require__(3);
  2939. var hof_1 = __webpack_require__(5);
  2940. var param_1 = __webpack_require__(22);
  2941. /**
  2942. * A node in a [[TreeChanges]] path
  2943. *
  2944. * For a [[TreeChanges]] path, this class holds the stateful information for a single node in the path.
  2945. * Each PathNode corresponds to a state being entered, exited, or retained.
  2946. * The stateful information includes parameter values and resolve data.
  2947. */
  2948. var PathNode = (function () {
  2949. function PathNode(stateOrPath) {
  2950. if (stateOrPath instanceof PathNode) {
  2951. var node = stateOrPath;
  2952. this.state = node.state;
  2953. this.paramSchema = node.paramSchema.slice();
  2954. this.paramValues = common_1.extend({}, node.paramValues);
  2955. this.resolvables = node.resolvables.slice();
  2956. this.views = node.views && node.views.slice();
  2957. }
  2958. else {
  2959. var state = stateOrPath;
  2960. this.state = state;
  2961. this.paramSchema = state.parameters({ inherit: false });
  2962. this.paramValues = {};
  2963. this.resolvables = state.resolvables.map(function (res) { return res.clone(); });
  2964. }
  2965. }
  2966. /** Sets [[paramValues]] for the node, from the values of an object hash */
  2967. PathNode.prototype.applyRawParams = function (params) {
  2968. var getParamVal = function (paramDef) { return [paramDef.id, paramDef.value(params[paramDef.id])]; };
  2969. this.paramValues = this.paramSchema.reduce(function (memo, pDef) { return common_1.applyPairs(memo, getParamVal(pDef)); }, {});
  2970. return this;
  2971. };
  2972. /** Gets a specific [[Param]] metadata that belongs to the node */
  2973. PathNode.prototype.parameter = function (name) {
  2974. return common_1.find(this.paramSchema, hof_1.propEq("id", name));
  2975. };
  2976. /**
  2977. * @returns true if the state and parameter values for another PathNode are
  2978. * equal to the state and param values for this PathNode
  2979. */
  2980. PathNode.prototype.equals = function (node, keys) {
  2981. var _this = this;
  2982. if (keys === void 0) { keys = this.paramSchema.map(function (p) { return p.id; }); }
  2983. var paramValsEq = function (key) {
  2984. return _this.parameter(key).type.equals(_this.paramValues[key], node.paramValues[key]);
  2985. };
  2986. return this.state === node.state && keys.map(paramValsEq).reduce(common_1.allTrueR, true);
  2987. };
  2988. /** Returns a clone of the PathNode */
  2989. PathNode.clone = function (node) {
  2990. return new PathNode(node);
  2991. };
  2992. /**
  2993. * Returns a new path which is a subpath of the first path which matched the second path.
  2994. *
  2995. * The new path starts from root and contains any nodes that match the nodes in the second path.
  2996. * Nodes are compared using their state property and parameter values.
  2997. *
  2998. * @param pathA the first path
  2999. * @param pathB the second path
  3000. * @param ignoreDynamicParams don't compare dynamic parameter values
  3001. */
  3002. PathNode.matching = function (pathA, pathB, ignoreDynamicParams) {
  3003. if (ignoreDynamicParams === void 0) { ignoreDynamicParams = true; }
  3004. var matching = [];
  3005. for (var i = 0; i < pathA.length && i < pathB.length; i++) {
  3006. var a = pathA[i], b = pathB[i];
  3007. if (a.state !== b.state)
  3008. break;
  3009. var changedParams = param_1.Param.changed(a.paramSchema, a.paramValues, b.paramValues)
  3010. .filter(function (param) { return !(ignoreDynamicParams && param.dynamic); });
  3011. if (changedParams.length)
  3012. break;
  3013. matching.push(a);
  3014. }
  3015. return matching;
  3016. };
  3017. return PathNode;
  3018. }());
  3019. exports.PathNode = PathNode;
  3020. /***/ },
  3021. /* 22 */
  3022. /***/ function(module, exports, __webpack_require__) {
  3023. "use strict";
  3024. /** @module params */ /** for typedoc */
  3025. var common_1 = __webpack_require__(3);
  3026. var hof_1 = __webpack_require__(5);
  3027. var predicates_1 = __webpack_require__(4);
  3028. var coreservices_1 = __webpack_require__(6);
  3029. var urlMatcherConfig_1 = __webpack_require__(23);
  3030. var type_1 = __webpack_require__(24);
  3031. var hasOwn = Object.prototype.hasOwnProperty;
  3032. var isShorthand = function (cfg) {
  3033. return ["value", "type", "squash", "array", "dynamic"].filter(hasOwn.bind(cfg || {})).length === 0;
  3034. };
  3035. (function (DefType) {
  3036. DefType[DefType["PATH"] = 0] = "PATH";
  3037. DefType[DefType["SEARCH"] = 1] = "SEARCH";
  3038. DefType[DefType["CONFIG"] = 2] = "CONFIG";
  3039. })(exports.DefType || (exports.DefType = {}));
  3040. var DefType = exports.DefType;
  3041. function unwrapShorthand(cfg) {
  3042. cfg = isShorthand(cfg) && { value: cfg } || cfg;
  3043. return common_1.extend(cfg, {
  3044. $$fn: predicates_1.isInjectable(cfg.value) ? cfg.value : function () { return cfg.value; }
  3045. });
  3046. }
  3047. function getType(cfg, urlType, location, id, paramTypes) {
  3048. if (cfg.type && urlType && urlType.name !== 'string')
  3049. throw new Error("Param '" + id + "' has two type configurations.");
  3050. if (cfg.type && urlType && urlType.name === 'string' && paramTypes.type(cfg.type))
  3051. return paramTypes.type(cfg.type);
  3052. if (urlType)
  3053. return urlType;
  3054. if (!cfg.type)
  3055. return (location === DefType.CONFIG ? paramTypes.type("any") : paramTypes.type("string"));
  3056. return cfg.type instanceof type_1.ParamType ? cfg.type : paramTypes.type(cfg.type);
  3057. }
  3058. /**
  3059. * returns false, true, or the squash value to indicate the "default parameter url squash policy".
  3060. */
  3061. function getSquashPolicy(config, isOptional) {
  3062. var squash = config.squash;
  3063. if (!isOptional || squash === false)
  3064. return false;
  3065. if (!predicates_1.isDefined(squash) || squash == null)
  3066. return urlMatcherConfig_1.matcherConfig.defaultSquashPolicy();
  3067. if (squash === true || predicates_1.isString(squash))
  3068. return squash;
  3069. throw new Error("Invalid squash policy: '" + squash + "'. Valid policies: false, true, or arbitrary string");
  3070. }
  3071. function getReplace(config, arrayMode, isOptional, squash) {
  3072. var replace, configuredKeys, defaultPolicy = [
  3073. { from: "", to: (isOptional || arrayMode ? undefined : "") },
  3074. { from: null, to: (isOptional || arrayMode ? undefined : "") }
  3075. ];
  3076. replace = predicates_1.isArray(config.replace) ? config.replace : [];
  3077. if (predicates_1.isString(squash))
  3078. replace.push({ from: squash, to: undefined });
  3079. configuredKeys = common_1.map(replace, hof_1.prop("from"));
  3080. return common_1.filter(defaultPolicy, function (item) { return configuredKeys.indexOf(item.from) === -1; }).concat(replace);
  3081. }
  3082. var Param = (function () {
  3083. function Param(id, type, config, location, paramTypes) {
  3084. config = unwrapShorthand(config);
  3085. type = getType(config, type, location, id, paramTypes);
  3086. var arrayMode = getArrayMode();
  3087. type = arrayMode ? type.$asArray(arrayMode, location === DefType.SEARCH) : type;
  3088. var isOptional = config.value !== undefined;
  3089. var dynamic = predicates_1.isDefined(config.dynamic) ? !!config.dynamic : !!type.dynamic;
  3090. var squash = getSquashPolicy(config, isOptional);
  3091. var replace = getReplace(config, arrayMode, isOptional, squash);
  3092. // array config: param name (param[]) overrides default settings. explicit config overrides param name.
  3093. function getArrayMode() {
  3094. var arrayDefaults = { array: (location === DefType.SEARCH ? "auto" : false) };
  3095. var arrayParamNomenclature = id.match(/\[\]$/) ? { array: true } : {};
  3096. return common_1.extend(arrayDefaults, arrayParamNomenclature, config).array;
  3097. }
  3098. common_1.extend(this, { id: id, type: type, location: location, squash: squash, replace: replace, isOptional: isOptional, dynamic: dynamic, config: config, array: arrayMode });
  3099. }
  3100. Param.prototype.isDefaultValue = function (value) {
  3101. return this.isOptional && this.type.equals(this.value(), value);
  3102. };
  3103. /**
  3104. * [Internal] Gets the decoded representation of a value if the value is defined, otherwise, returns the
  3105. * default value, which may be the result of an injectable function.
  3106. */
  3107. Param.prototype.value = function (value) {
  3108. var _this = this;
  3109. /**
  3110. * [Internal] Get the default value of a parameter, which may be an injectable function.
  3111. */
  3112. var $$getDefaultValue = function () {
  3113. if (!coreservices_1.services.$injector)
  3114. throw new Error("Injectable functions cannot be called at configuration time");
  3115. var defaultValue = coreservices_1.services.$injector.invoke(_this.config.$$fn);
  3116. if (defaultValue !== null && defaultValue !== undefined && !_this.type.is(defaultValue))
  3117. throw new Error("Default value (" + defaultValue + ") for parameter '" + _this.id + "' is not an instance of ParamType (" + _this.type.name + ")");
  3118. return defaultValue;
  3119. };
  3120. var $replace = function (val) {
  3121. var replacement = common_1.map(common_1.filter(_this.replace, hof_1.propEq('from', val)), hof_1.prop("to"));
  3122. return replacement.length ? replacement[0] : val;
  3123. };
  3124. value = $replace(value);
  3125. return !predicates_1.isDefined(value) ? $$getDefaultValue() : this.type.$normalize(value);
  3126. };
  3127. Param.prototype.isSearch = function () {
  3128. return this.location === DefType.SEARCH;
  3129. };
  3130. Param.prototype.validates = function (value) {
  3131. // There was no parameter value, but the param is optional
  3132. if ((!predicates_1.isDefined(value) || value === null) && this.isOptional)
  3133. return true;
  3134. // The value was not of the correct ParamType, and could not be decoded to the correct ParamType
  3135. var normalized = this.type.$normalize(value);
  3136. if (!this.type.is(normalized))
  3137. return false;
  3138. // The value was of the correct type, but when encoded, did not match the ParamType's regexp
  3139. var encoded = this.type.encode(normalized);
  3140. return !(predicates_1.isString(encoded) && !this.type.pattern.exec(encoded));
  3141. };
  3142. Param.prototype.toString = function () {
  3143. return "{Param:" + this.id + " " + this.type + " squash: '" + this.squash + "' optional: " + this.isOptional + "}";
  3144. };
  3145. /** Creates a new [[Param]] from a CONFIG block */
  3146. Param.fromConfig = function (id, type, config, paramTypes) {
  3147. return new Param(id, type, config, DefType.CONFIG, paramTypes);
  3148. };
  3149. /** Creates a new [[Param]] from a url PATH */
  3150. Param.fromPath = function (id, type, config, paramTypes) {
  3151. return new Param(id, type, config, DefType.PATH, paramTypes);
  3152. };
  3153. /** Creates a new [[Param]] from a url SEARCH */
  3154. Param.fromSearch = function (id, type, config, paramTypes) {
  3155. return new Param(id, type, config, DefType.SEARCH, paramTypes);
  3156. };
  3157. Param.values = function (params, values) {
  3158. if (values === void 0) { values = {}; }
  3159. return params.map(function (param) { return [param.id, param.value(values[param.id])]; }).reduce(common_1.applyPairs, {});
  3160. };
  3161. /**
  3162. * Finds [[Param]] objects which have different param values
  3163. *
  3164. * Filters a list of [[Param]] objects to only those whose parameter values differ in two param value objects
  3165. *
  3166. * @param params: The list of Param objects to filter
  3167. * @param values1: The first set of parameter values
  3168. * @param values2: the second set of parameter values
  3169. *
  3170. * @returns any Param objects whose values were different between values1 and values2
  3171. */
  3172. Param.changed = function (params, values1, values2) {
  3173. if (values1 === void 0) { values1 = {}; }
  3174. if (values2 === void 0) { values2 = {}; }
  3175. return params.filter(function (param) { return !param.type.equals(values1[param.id], values2[param.id]); });
  3176. };
  3177. /**
  3178. * Checks if two param value objects are equal (for a set of [[Param]] objects)
  3179. *
  3180. * @param params The list of [[Param]] objects to check
  3181. * @param values1 The first set of param values
  3182. * @param values2 The second set of param values
  3183. *
  3184. * @returns true if the param values in values1 and values2 are equal
  3185. */
  3186. Param.equals = function (params, values1, values2) {
  3187. if (values1 === void 0) { values1 = {}; }
  3188. if (values2 === void 0) { values2 = {}; }
  3189. return Param.changed(params, values1, values2).length === 0;
  3190. };
  3191. /** Returns true if a the parameter values are valid, according to the Param definitions */
  3192. Param.validates = function (params, values) {
  3193. if (values === void 0) { values = {}; }
  3194. return params.map(function (param) { return param.validates(values[param.id]); }).reduce(common_1.allTrueR, true);
  3195. };
  3196. return Param;
  3197. }());
  3198. exports.Param = Param;
  3199. /***/ },
  3200. /* 23 */
  3201. /***/ function(module, exports, __webpack_require__) {
  3202. "use strict";
  3203. /** @module url */ /** for typedoc */
  3204. var predicates_1 = __webpack_require__(4);
  3205. var MatcherConfig = (function () {
  3206. function MatcherConfig() {
  3207. this._isCaseInsensitive = false;
  3208. this._isStrictMode = true;
  3209. this._defaultSquashPolicy = false;
  3210. }
  3211. MatcherConfig.prototype.caseInsensitive = function (value) {
  3212. return this._isCaseInsensitive = predicates_1.isDefined(value) ? value : this._isCaseInsensitive;
  3213. };
  3214. MatcherConfig.prototype.strictMode = function (value) {
  3215. return this._isStrictMode = predicates_1.isDefined(value) ? value : this._isStrictMode;
  3216. };
  3217. MatcherConfig.prototype.defaultSquashPolicy = function (value) {
  3218. if (predicates_1.isDefined(value) && value !== true && value !== false && !predicates_1.isString(value))
  3219. throw new Error("Invalid squash policy: " + value + ". Valid policies: false, true, arbitrary-string");
  3220. return this._defaultSquashPolicy = predicates_1.isDefined(value) ? value : this._defaultSquashPolicy;
  3221. };
  3222. return MatcherConfig;
  3223. }());
  3224. exports.MatcherConfig = MatcherConfig;
  3225. // TODO: Do not export global instance; create one in UIRouter() constructor
  3226. exports.matcherConfig = new MatcherConfig();
  3227. /***/ },
  3228. /* 24 */
  3229. /***/ function(module, exports, __webpack_require__) {
  3230. "use strict";
  3231. /** @module params */ /** for typedoc */
  3232. var common_1 = __webpack_require__(3);
  3233. var predicates_1 = __webpack_require__(4);
  3234. /**
  3235. * Wraps up a `ParamType` object to handle array values.
  3236. */
  3237. function ArrayType(type, mode) {
  3238. var _this = this;
  3239. // Wrap non-array value as array
  3240. function arrayWrap(val) {
  3241. return predicates_1.isArray(val) ? val : (predicates_1.isDefined(val) ? [val] : []);
  3242. }
  3243. // Unwrap array value for "auto" mode. Return undefined for empty array.
  3244. function arrayUnwrap(val) {
  3245. switch (val.length) {
  3246. case 0: return undefined;
  3247. case 1: return mode === "auto" ? val[0] : val;
  3248. default: return val;
  3249. }
  3250. }
  3251. // Wraps type (.is/.encode/.decode) functions to operate on each value of an array
  3252. function arrayHandler(callback, allTruthyMode) {
  3253. return function handleArray(val) {
  3254. if (predicates_1.isArray(val) && val.length === 0)
  3255. return val;
  3256. var arr = arrayWrap(val);
  3257. var result = common_1.map(arr, callback);
  3258. return (allTruthyMode === true) ? common_1.filter(result, function (x) { return !x; }).length === 0 : arrayUnwrap(result);
  3259. };
  3260. }
  3261. // Wraps type (.equals) functions to operate on each value of an array
  3262. function arrayEqualsHandler(callback) {
  3263. return function handleArray(val1, val2) {
  3264. var left = arrayWrap(val1), right = arrayWrap(val2);
  3265. if (left.length !== right.length)
  3266. return false;
  3267. for (var i = 0; i < left.length; i++) {
  3268. if (!callback(left[i], right[i]))
  3269. return false;
  3270. }
  3271. return true;
  3272. };
  3273. }
  3274. ['encode', 'decode', 'equals', '$normalize'].forEach(function (name) {
  3275. var paramTypeFn = type[name].bind(type);
  3276. var wrapperFn = name === 'equals' ? arrayEqualsHandler : arrayHandler;
  3277. _this[name] = wrapperFn(paramTypeFn);
  3278. });
  3279. common_1.extend(this, {
  3280. dynamic: type.dynamic,
  3281. name: type.name,
  3282. pattern: type.pattern,
  3283. is: arrayHandler(type.is.bind(type), true),
  3284. $arrayMode: mode
  3285. });
  3286. }
  3287. /**
  3288. * A class that implements Custom Parameter Type functionality.
  3289. *
  3290. * This class has naive implementations for all the [[ParamTypeDefinition]] methods.
  3291. *
  3292. * An instance of this class is created when a custom [[ParamTypeDefinition]] object is registered with the [[UrlMatcherFactory.type]].
  3293. *
  3294. * Used by [[UrlMatcher]] when matching or formatting URLs, or comparing and validating parameter values.
  3295. *
  3296. * @example
  3297. * ```
  3298. *
  3299. * {
  3300. * decode: function(val) { return parseInt(val, 10); },
  3301. * encode: function(val) { return val && val.toString(); },
  3302. * equals: function(a, b) { return this.is(a) && a === b; },
  3303. * is: function(val) { return angular.isNumber(val) && isFinite(val) && val % 1 === 0; },
  3304. * pattern: /\d+/
  3305. * }
  3306. * ```
  3307. */
  3308. var ParamType = (function () {
  3309. /**
  3310. * @param def A configuration object which contains the custom type definition. The object's
  3311. * properties will override the default methods and/or pattern in `ParamType`'s public interface.
  3312. * @returns a new ParamType object
  3313. */
  3314. function ParamType(def) {
  3315. this.pattern = /.*/;
  3316. common_1.extend(this, def);
  3317. }
  3318. // consider these four methods to be "abstract methods" that should be overridden
  3319. /** @inheritdoc */
  3320. ParamType.prototype.is = function (val, key) { return true; };
  3321. /** @inheritdoc */
  3322. ParamType.prototype.encode = function (val, key) { return val; };
  3323. /** @inheritdoc */
  3324. ParamType.prototype.decode = function (val, key) { return val; };
  3325. /** @inheritdoc */
  3326. ParamType.prototype.equals = function (a, b) { return a == b; };
  3327. ParamType.prototype.$subPattern = function () {
  3328. var sub = this.pattern.toString();
  3329. return sub.substr(1, sub.length - 2);
  3330. };
  3331. ParamType.prototype.toString = function () {
  3332. return "{ParamType:" + this.name + "}";
  3333. };
  3334. /** Given an encoded string, or a decoded object, returns a decoded object */
  3335. ParamType.prototype.$normalize = function (val) {
  3336. return this.is(val) ? val : this.decode(val);
  3337. };
  3338. /**
  3339. * Wraps an existing custom ParamType as an array of ParamType, depending on 'mode'.
  3340. * e.g.:
  3341. * - urlmatcher pattern "/path?{queryParam[]:int}"
  3342. * - url: "/path?queryParam=1&queryParam=2
  3343. * - $stateParams.queryParam will be [1, 2]
  3344. * if `mode` is "auto", then
  3345. * - url: "/path?queryParam=1 will create $stateParams.queryParam: 1
  3346. * - url: "/path?queryParam=1&queryParam=2 will create $stateParams.queryParam: [1, 2]
  3347. */
  3348. ParamType.prototype.$asArray = function (mode, isSearch) {
  3349. if (!mode)
  3350. return this;
  3351. if (mode === "auto" && !isSearch)
  3352. throw new Error("'auto' array mode is for query parameters only");
  3353. return new ArrayType(this, mode);
  3354. };
  3355. return ParamType;
  3356. }());
  3357. exports.ParamType = ParamType;
  3358. /***/ },
  3359. /* 25 */
  3360. /***/ function(module, exports, __webpack_require__) {
  3361. "use strict";
  3362. /** @module core */ /** */
  3363. var urlMatcherFactory_1 = __webpack_require__(26);
  3364. var urlRouter_1 = __webpack_require__(29);
  3365. var urlRouter_2 = __webpack_require__(29);
  3366. var transitionService_1 = __webpack_require__(30);
  3367. var view_1 = __webpack_require__(37);
  3368. var stateRegistry_1 = __webpack_require__(38);
  3369. var stateService_1 = __webpack_require__(43);
  3370. var globals_1 = __webpack_require__(44);
  3371. /**
  3372. * The master class used to instantiate an instance of UI-Router.
  3373. *
  3374. * This class instantiates and wires the global UI-Router services.
  3375. *
  3376. * After instantiating a new instance of the Router class, configure it for your app. For instance, register
  3377. * your app states with the [[stateRegistry]] (and set url options using ...). Then, tell UI-Router to monitor
  3378. * the URL by calling `urlRouter.listen()` ([[URLRouter.listen]])
  3379. */
  3380. var UIRouter = (function () {
  3381. function UIRouter() {
  3382. this.viewService = new view_1.ViewService();
  3383. this.transitionService = new transitionService_1.TransitionService(this);
  3384. this.globals = new globals_1.Globals(this.transitionService);
  3385. this.urlMatcherFactory = new urlMatcherFactory_1.UrlMatcherFactory();
  3386. this.urlRouterProvider = new urlRouter_1.UrlRouterProvider(this.urlMatcherFactory, this.globals.params);
  3387. this.urlRouter = new urlRouter_2.UrlRouter(this.urlRouterProvider);
  3388. this.stateRegistry = new stateRegistry_1.StateRegistry(this.urlMatcherFactory, this.urlRouterProvider);
  3389. this.stateService = new stateService_1.StateService(this);
  3390. this.viewService.rootContext(this.stateRegistry.root());
  3391. this.globals.$current = this.stateRegistry.root();
  3392. this.globals.current = this.globals.$current.self;
  3393. }
  3394. return UIRouter;
  3395. }());
  3396. exports.UIRouter = UIRouter;
  3397. /***/ },
  3398. /* 26 */
  3399. /***/ function(module, exports, __webpack_require__) {
  3400. "use strict";
  3401. /** @module url */ /** for typedoc */
  3402. var common_1 = __webpack_require__(3);
  3403. var predicates_1 = __webpack_require__(4);
  3404. var urlMatcher_1 = __webpack_require__(27);
  3405. var urlMatcherConfig_1 = __webpack_require__(23);
  3406. var param_1 = __webpack_require__(22);
  3407. var paramTypes_1 = __webpack_require__(28);
  3408. /** @hidden */
  3409. function getDefaultConfig() {
  3410. return {
  3411. strict: urlMatcherConfig_1.matcherConfig.strictMode(),
  3412. caseInsensitive: urlMatcherConfig_1.matcherConfig.caseInsensitive()
  3413. };
  3414. }
  3415. /**
  3416. * Factory for [[UrlMatcher]] instances.
  3417. *
  3418. * The factory is available to ng1 services as
  3419. * `$urlMatcherFactor` or ng1 providers as `$urlMatcherFactoryProvider`.
  3420. */
  3421. var UrlMatcherFactory = (function () {
  3422. function UrlMatcherFactory() {
  3423. this.paramTypes = new paramTypes_1.ParamTypes();
  3424. common_1.extend(this, { UrlMatcher: urlMatcher_1.UrlMatcher, Param: param_1.Param });
  3425. }
  3426. /**
  3427. * Defines whether URL matching should be case sensitive (the default behavior), or not.
  3428. *
  3429. * @param value `false` to match URL in a case sensitive manner; otherwise `true`;
  3430. * @returns the current value of caseInsensitive
  3431. */
  3432. UrlMatcherFactory.prototype.caseInsensitive = function (value) {
  3433. return urlMatcherConfig_1.matcherConfig.caseInsensitive(value);
  3434. };
  3435. /**
  3436. * Defines whether URLs should match trailing slashes, or not (the default behavior).
  3437. *
  3438. * @param value `false` to match trailing slashes in URLs, otherwise `true`.
  3439. * @returns the current value of strictMode
  3440. */
  3441. UrlMatcherFactory.prototype.strictMode = function (value) {
  3442. return urlMatcherConfig_1.matcherConfig.strictMode(value);
  3443. };
  3444. /**
  3445. * Sets the default behavior when generating or matching URLs with default parameter values.
  3446. *
  3447. * @param value A string that defines the default parameter URL squashing behavior.
  3448. * - `nosquash`: When generating an href with a default parameter value, do not squash the parameter value from the URL
  3449. * - `slash`: When generating an href with a default parameter value, squash (remove) the parameter value, and, if the
  3450. * parameter is surrounded by slashes, squash (remove) one slash from the URL
  3451. * - any other string, e.g. "~": When generating an href with a default parameter value, squash (remove)
  3452. * the parameter value from the URL and replace it with this string.
  3453. * @returns the current value of defaultSquashPolicy
  3454. */
  3455. UrlMatcherFactory.prototype.defaultSquashPolicy = function (value) {
  3456. return urlMatcherConfig_1.matcherConfig.defaultSquashPolicy(value);
  3457. };
  3458. /**
  3459. * Creates a [[UrlMatcher]] for the specified pattern.
  3460. *
  3461. * @param pattern The URL pattern.
  3462. * @param config The config object hash.
  3463. * @returns The UrlMatcher.
  3464. */
  3465. UrlMatcherFactory.prototype.compile = function (pattern, config) {
  3466. return new urlMatcher_1.UrlMatcher(pattern, this.paramTypes, common_1.extend(getDefaultConfig(), config));
  3467. };
  3468. /**
  3469. * Returns true if the specified object is a [[UrlMatcher]], or false otherwise.
  3470. *
  3471. * @param object The object to perform the type check against.
  3472. * @returns `true` if the object matches the `UrlMatcher` interface, by
  3473. * implementing all the same methods.
  3474. */
  3475. UrlMatcherFactory.prototype.isMatcher = function (object) {
  3476. // TODO: typeof?
  3477. if (!predicates_1.isObject(object))
  3478. return false;
  3479. var result = true;
  3480. common_1.forEach(urlMatcher_1.UrlMatcher.prototype, function (val, name) {
  3481. if (predicates_1.isFunction(val))
  3482. result = result && (predicates_1.isDefined(object[name]) && predicates_1.isFunction(object[name]));
  3483. });
  3484. return result;
  3485. };
  3486. ;
  3487. /**
  3488. * Creates and registers a custom [[ParamType]] object
  3489. *
  3490. * A [[ParamType]] can be used to generate URLs with typed parameters.
  3491. *
  3492. * @param name The type name.
  3493. * @param definition The type definition. See [[ParamTypeDefinition]] for information on the values accepted.
  3494. * @param definitionFn A function that is injected before the app runtime starts.
  3495. * The result of this function should be a [[ParamTypeDefinition]].
  3496. * The result is merged into the existing `definition`.
  3497. * See [[ParamType]] for information on the values accepted.
  3498. *
  3499. * @returns - if a type was registered: the [[UrlMatcherFactory]]
  3500. * - if only the `name` parameter was specified: the currently registered [[ParamType]] object, or undefined
  3501. *
  3502. * Note: Register custom types *before using them* in a state definition.
  3503. *
  3504. * See [[ParamTypeDefinition]] for examples
  3505. */
  3506. UrlMatcherFactory.prototype.type = function (name, definition, definitionFn) {
  3507. var type = this.paramTypes.type(name, definition, definitionFn);
  3508. return !predicates_1.isDefined(definition) ? type : this;
  3509. };
  3510. ;
  3511. /** @hidden */
  3512. UrlMatcherFactory.prototype.$get = function () {
  3513. this.paramTypes.enqueue = false;
  3514. this.paramTypes._flushTypeQueue();
  3515. return this;
  3516. };
  3517. ;
  3518. return UrlMatcherFactory;
  3519. }());
  3520. exports.UrlMatcherFactory = UrlMatcherFactory;
  3521. /***/ },
  3522. /* 27 */
  3523. /***/ function(module, exports, __webpack_require__) {
  3524. "use strict";
  3525. /** @module url */ /** for typedoc */
  3526. var common_1 = __webpack_require__(3);
  3527. var hof_1 = __webpack_require__(5);
  3528. var predicates_1 = __webpack_require__(4);
  3529. var param_1 = __webpack_require__(22);
  3530. var predicates_2 = __webpack_require__(4);
  3531. var param_2 = __webpack_require__(22);
  3532. var common_2 = __webpack_require__(3);
  3533. var common_3 = __webpack_require__(3);
  3534. /** @hidden */
  3535. function quoteRegExp(string, param) {
  3536. var surroundPattern = ['', ''], result = string.replace(/[\\\[\]\^$*+?.()|{}]/g, "\\$&");
  3537. if (!param)
  3538. return result;
  3539. switch (param.squash) {
  3540. case false:
  3541. surroundPattern = ['(', ')' + (param.isOptional ? '?' : '')];
  3542. break;
  3543. case true:
  3544. result = result.replace(/\/$/, '');
  3545. surroundPattern = ['(?:\/(', ')|\/)?'];
  3546. break;
  3547. default:
  3548. surroundPattern = [("(" + param.squash + "|"), ')?'];
  3549. break;
  3550. }
  3551. return result + surroundPattern[0] + param.type.pattern.source + surroundPattern[1];
  3552. }
  3553. /** @hidden */
  3554. var memoizeTo = function (obj, prop, fn) {
  3555. return obj[prop] = obj[prop] || fn();
  3556. };
  3557. /**
  3558. * Matches URLs against patterns.
  3559. *
  3560. * Matches URLs against patterns and extracts named parameters from the path or the search
  3561. * part of the URL.
  3562. *
  3563. * A URL pattern consists of a path pattern, optionally followed by '?' and a list of search (query)
  3564. * parameters. Multiple search parameter names are separated by '&'. Search parameters
  3565. * do not influence whether or not a URL is matched, but their values are passed through into
  3566. * the matched parameters returned by [[UrlMatcher.exec]].
  3567. *
  3568. * - *Path parameters* are defined using curly brace placeholders (`/somepath/{param}`)
  3569. * or colon placeholders (`/somePath/:param`).
  3570. *
  3571. * - *A parameter RegExp* may be defined for a param after a colon
  3572. * (`/somePath/{param:[a-zA-Z0-9]+}`) in a curly brace placeholder.
  3573. * The regexp must match for the url to be matched.
  3574. * Should the regexp itself contain curly braces, they must be in matched pairs or escaped with a backslash.
  3575. *
  3576. * - *Custom parameter types* may also be specified after a colon (`/somePath/{param:int}`)
  3577. * in curly brace parameters. See [[UrlMatcherFactory.type]] for more information.
  3578. *
  3579. * - *Catch-all parameters* are defined using an asterisk placeholder (`/somepath/*catchallparam`). A catch-all
  3580. * parameter value will contain the remainder of the URL.
  3581. *
  3582. * ---
  3583. *
  3584. * Parameter names may contain only word characters (latin letters, digits, and underscore) and
  3585. * must be unique within the pattern (across both path and search parameters).
  3586. * A path parameter matches any number of characters other than '/'. For catch-all
  3587. * placeholders the path parameter matches any number of characters.
  3588. *
  3589. * Examples:
  3590. *
  3591. * * `'/hello/'` - Matches only if the path is exactly '/hello/'. There is no special treatment for
  3592. * trailing slashes, and patterns have to match the entire path, not just a prefix.
  3593. * * `'/user/:id'` - Matches '/user/bob' or '/user/1234!!!' or even '/user/' but not '/user' or
  3594. * '/user/bob/details'. The second path segment will be captured as the parameter 'id'.
  3595. * * `'/user/{id}'` - Same as the previous example, but using curly brace syntax.
  3596. * * `'/user/{id:[^/]*}'` - Same as the previous example.
  3597. * * `'/user/{id:[0-9a-fA-F]{1,8}}'` - Similar to the previous example, but only matches if the id
  3598. * parameter consists of 1 to 8 hex digits.
  3599. * * `'/files/{path:.*}'` - Matches any URL starting with '/files/' and captures the rest of the
  3600. * path into the parameter 'path'.
  3601. * * `'/files/*path'` - ditto.
  3602. * * `'/calendar/{start:date}'` - Matches "/calendar/2014-11-12" (because the pattern defined
  3603. * in the built-in `date` ParamType matches `2014-11-12`) and provides a Date object in $stateParams.start
  3604. *
  3605. */
  3606. var UrlMatcher = (function () {
  3607. /**
  3608. * @param pattern The pattern to compile into a matcher.
  3609. * @param paramTypes The [[ParamTypes]] registry
  3610. * @param config A configuration object
  3611. * - `caseInsensitive` - `true` if URL matching should be case insensitive, otherwise `false`, the default value (for backward compatibility) is `false`.
  3612. * - `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`.
  3613. */
  3614. function UrlMatcher(pattern, paramTypes, config) {
  3615. var _this = this;
  3616. this.config = config;
  3617. /** @hidden */
  3618. this._cache = { path: [], pattern: null };
  3619. /** @hidden */
  3620. this._children = [];
  3621. /** @hidden */
  3622. this._params = [];
  3623. /** @hidden */
  3624. this._segments = [];
  3625. /** @hidden */
  3626. this._compiled = [];
  3627. this.pattern = pattern;
  3628. this.config = common_1.defaults(this.config, {
  3629. params: {},
  3630. strict: true,
  3631. caseInsensitive: false,
  3632. paramMap: common_1.identity
  3633. });
  3634. // Find all placeholders and create a compiled pattern, using either classic or curly syntax:
  3635. // '*' name
  3636. // ':' name
  3637. // '{' name '}'
  3638. // '{' name ':' regexp '}'
  3639. // The regular expression is somewhat complicated due to the need to allow curly braces
  3640. // inside the regular expression. The placeholder regexp breaks down as follows:
  3641. // ([:*])([\w\[\]]+) - classic placeholder ($1 / $2) (search version has - for snake-case)
  3642. // \{([\w\[\]]+)(?:\:\s*( ... ))?\} - curly brace placeholder ($3) with optional regexp/type ... ($4) (search version has - for snake-case
  3643. // (?: ... | ... | ... )+ - the regexp consists of any number of atoms, an atom being either
  3644. // [^{}\\]+ - anything other than curly braces or backslash
  3645. // \\. - a backslash escape
  3646. // \{(?:[^{}\\]+|\\.)*\} - a matched set of curly braces containing other atoms
  3647. var placeholder = /([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g, searchPlaceholder = /([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g, last = 0, m, patterns = [];
  3648. var checkParamErrors = function (id) {
  3649. if (!UrlMatcher.nameValidator.test(id))
  3650. throw new Error("Invalid parameter name '" + id + "' in pattern '" + pattern + "'");
  3651. if (common_1.find(_this._params, hof_1.propEq('id', id)))
  3652. throw new Error("Duplicate parameter name '" + id + "' in pattern '" + pattern + "'");
  3653. };
  3654. // Split into static segments separated by path parameter placeholders.
  3655. // The number of segments is always 1 more than the number of parameters.
  3656. var matchDetails = function (m, isSearch) {
  3657. // IE[78] returns '' for unmatched groups instead of null
  3658. var id = m[2] || m[3], regexp = isSearch ? m[4] : m[4] || (m[1] === '*' ? '.*' : null);
  3659. return {
  3660. id: id,
  3661. regexp: regexp,
  3662. cfg: _this.config.params[id],
  3663. segment: pattern.substring(last, m.index),
  3664. type: !regexp ? null : paramTypes.type(regexp || "string") || common_1.inherit(paramTypes.type("string"), {
  3665. pattern: new RegExp(regexp, _this.config.caseInsensitive ? 'i' : undefined)
  3666. })
  3667. };
  3668. };
  3669. var p, segment;
  3670. while ((m = placeholder.exec(pattern))) {
  3671. p = matchDetails(m, false);
  3672. if (p.segment.indexOf('?') >= 0)
  3673. break; // we're into the search part
  3674. checkParamErrors(p.id);
  3675. this._params.push(param_1.Param.fromPath(p.id, p.type, this.config.paramMap(p.cfg, false), paramTypes));
  3676. this._segments.push(p.segment);
  3677. patterns.push([p.segment, common_1.tail(this._params)]);
  3678. last = placeholder.lastIndex;
  3679. }
  3680. segment = pattern.substring(last);
  3681. // Find any search parameter names and remove them from the last segment
  3682. var i = segment.indexOf('?');
  3683. if (i >= 0) {
  3684. var search = segment.substring(i);
  3685. segment = segment.substring(0, i);
  3686. if (search.length > 0) {
  3687. last = 0;
  3688. while ((m = searchPlaceholder.exec(search))) {
  3689. p = matchDetails(m, true);
  3690. checkParamErrors(p.id);
  3691. this._params.push(param_1.Param.fromSearch(p.id, p.type, this.config.paramMap(p.cfg, true), paramTypes));
  3692. last = placeholder.lastIndex;
  3693. }
  3694. }
  3695. }
  3696. this._segments.push(segment);
  3697. common_1.extend(this, {
  3698. _compiled: patterns.map(function (pattern) { return quoteRegExp.apply(null, pattern); }).concat(quoteRegExp(segment)),
  3699. prefix: this._segments[0]
  3700. });
  3701. Object.freeze(this);
  3702. }
  3703. /**
  3704. * Creates a new concatenated UrlMatcher
  3705. *
  3706. * Builds a new UrlMatcher by appending another UrlMatcher to this one.
  3707. *
  3708. * @param url A `UrlMatcher` instance to append as a child of the current `UrlMatcher`.
  3709. */
  3710. UrlMatcher.prototype.append = function (url) {
  3711. this._children.push(url);
  3712. common_1.forEach(url._cache, function (val, key) { return url._cache[key] = predicates_1.isArray(val) ? [] : null; });
  3713. url._cache.path = this._cache.path.concat(this);
  3714. return url;
  3715. };
  3716. /** @hidden */
  3717. UrlMatcher.prototype.isRoot = function () {
  3718. return this._cache.path.length === 0;
  3719. };
  3720. /** Returns the input pattern string */
  3721. UrlMatcher.prototype.toString = function () {
  3722. return this.pattern;
  3723. };
  3724. /**
  3725. * Tests the specified url/path against this matcher.
  3726. *
  3727. * Tests if the given url matches this matcher's pattern, and returns an object containing the captured
  3728. * parameter values. Returns null if the path does not match.
  3729. *
  3730. * The returned object contains the values
  3731. * of any search parameters that are mentioned in the pattern, but their value may be null if
  3732. * they are not present in `search`. This means that search parameters are always treated
  3733. * as optional.
  3734. *
  3735. * @example
  3736. * ```js
  3737. *
  3738. * new UrlMatcher('/user/{id}?q&r').exec('/user/bob', {
  3739. * x: '1', q: 'hello'
  3740. * });
  3741. * // returns { id: 'bob', q: 'hello', r: null }
  3742. * ```
  3743. *
  3744. * @param path The URL path to match, e.g. `$location.path()`.
  3745. * @param search URL search parameters, e.g. `$location.search()`.
  3746. * @param hash URL hash e.g. `$location.hash()`.
  3747. * @param options
  3748. *
  3749. * @returns The captured parameter values.
  3750. */
  3751. UrlMatcher.prototype.exec = function (path, search, hash, options) {
  3752. var _this = this;
  3753. if (search === void 0) { search = {}; }
  3754. if (options === void 0) { options = {}; }
  3755. var match = memoizeTo(this._cache, 'pattern', function () {
  3756. return new RegExp([
  3757. '^',
  3758. common_1.unnest(_this._cache.path.concat(_this).map(hof_1.prop('_compiled'))).join(''),
  3759. _this.config.strict === false ? '\/?' : '',
  3760. '$'
  3761. ].join(''), _this.config.caseInsensitive ? 'i' : undefined);
  3762. }).exec(path);
  3763. if (!match)
  3764. return null;
  3765. //options = defaults(options, { isolate: false });
  3766. 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 = {};
  3767. if (nPathSegments !== match.length - 1)
  3768. throw new Error("Unbalanced capture group in route '" + this.pattern + "'");
  3769. function decodePathArray(string) {
  3770. var reverseString = function (str) { return str.split("").reverse().join(""); };
  3771. var unquoteDashes = function (str) { return str.replace(/\\-/g, "-"); };
  3772. var split = reverseString(string).split(/-(?!\\)/);
  3773. var allReversed = common_1.map(split, reverseString);
  3774. return common_1.map(allReversed, unquoteDashes).reverse();
  3775. }
  3776. for (var i = 0; i < nPathSegments; i++) {
  3777. var param = pathParams[i];
  3778. var value = match[i + 1];
  3779. // if the param value matches a pre-replace pair, replace the value before decoding.
  3780. for (var j = 0; j < param.replace.length; j++) {
  3781. if (param.replace[j].from === value)
  3782. value = param.replace[j].to;
  3783. }
  3784. if (value && param.array === true)
  3785. value = decodePathArray(value);
  3786. if (predicates_2.isDefined(value))
  3787. value = param.type.decode(value);
  3788. values[param.id] = param.value(value);
  3789. }
  3790. searchParams.forEach(function (param) {
  3791. var value = search[param.id];
  3792. for (var j = 0; j < param.replace.length; j++) {
  3793. if (param.replace[j].from === value)
  3794. value = param.replace[j].to;
  3795. }
  3796. if (predicates_2.isDefined(value))
  3797. value = param.type.decode(value);
  3798. values[param.id] = param.value(value);
  3799. });
  3800. if (hash)
  3801. values["#"] = hash;
  3802. return values;
  3803. };
  3804. /**
  3805. * @hidden
  3806. * Returns all the [[Param]] objects of all path and search parameters of this pattern in order of appearance.
  3807. *
  3808. * @returns {Array.<Param>} An array of [[Param]] objects. Must be treated as read-only. If the
  3809. * pattern has no parameters, an empty array is returned.
  3810. */
  3811. UrlMatcher.prototype.parameters = function (opts) {
  3812. if (opts === void 0) { opts = {}; }
  3813. if (opts.inherit === false)
  3814. return this._params;
  3815. return common_1.unnest(this._cache.path.concat(this).map(hof_1.prop('_params')));
  3816. };
  3817. /**
  3818. * @hidden
  3819. * Returns a single parameter from this UrlMatcher by id
  3820. *
  3821. * @param id
  3822. * @param opts
  3823. * @returns {T|Param|any|boolean|UrlMatcher|null}
  3824. */
  3825. UrlMatcher.prototype.parameter = function (id, opts) {
  3826. if (opts === void 0) { opts = {}; }
  3827. var parent = common_1.tail(this._cache.path);
  3828. return (common_1.find(this._params, hof_1.propEq('id', id)) ||
  3829. (opts.inherit !== false && parent && parent.parameter(id)) ||
  3830. null);
  3831. };
  3832. /**
  3833. * Validates the input parameter values against this UrlMatcher
  3834. *
  3835. * Checks an object hash of parameters to validate their correctness according to the parameter
  3836. * types of this `UrlMatcher`.
  3837. *
  3838. * @param params The object hash of parameters to validate.
  3839. * @returns Returns `true` if `params` validates, otherwise `false`.
  3840. */
  3841. UrlMatcher.prototype.validates = function (params) {
  3842. var _this = this;
  3843. var validParamVal = function (param, val) {
  3844. return !param || param.validates(val);
  3845. };
  3846. return common_1.pairs(params || {}).map(function (_a) {
  3847. var key = _a[0], val = _a[1];
  3848. return validParamVal(_this.parameter(key), val);
  3849. }).reduce(common_1.allTrueR, true);
  3850. };
  3851. /**
  3852. * Given a set of parameter values, creates a URL from this UrlMatcher.
  3853. *
  3854. * Creates a URL that matches this pattern by substituting the specified values
  3855. * for the path and search parameters.
  3856. *
  3857. * @example
  3858. * ```js
  3859. *
  3860. * new UrlMatcher('/user/{id}?q').format({ id:'bob', q:'yes' });
  3861. * // returns '/user/bob?q=yes'
  3862. * ```
  3863. *
  3864. * @param values the values to substitute for the parameters in this pattern.
  3865. * @returns the formatted URL (path and optionally search part).
  3866. */
  3867. UrlMatcher.prototype.format = function (values) {
  3868. if (values === void 0) { values = {}; }
  3869. if (!this.validates(values))
  3870. return null;
  3871. // Build the full path of UrlMatchers (including all parent UrlMatchers)
  3872. var urlMatchers = this._cache.path.slice().concat(this);
  3873. // Extract all the static segments and Params into an ordered array
  3874. var pathSegmentsAndParams = urlMatchers.map(UrlMatcher.pathSegmentsAndParams).reduce(common_2.unnestR, []);
  3875. // Extract the query params into a separate array
  3876. var queryParams = urlMatchers.map(UrlMatcher.queryParams).reduce(common_2.unnestR, []);
  3877. /**
  3878. * Given a Param,
  3879. * Applies the parameter value, then returns details about it
  3880. */
  3881. function getDetails(param) {
  3882. // Normalize to typed value
  3883. var value = param.value(values[param.id]);
  3884. var isDefaultValue = param.isDefaultValue(value);
  3885. // Check if we're in squash mode for the parameter
  3886. var squash = isDefaultValue ? param.squash : false;
  3887. // Allow the Parameter's Type to encode the value
  3888. var encoded = param.type.encode(value);
  3889. return { param: param, value: value, isDefaultValue: isDefaultValue, squash: squash, encoded: encoded };
  3890. }
  3891. // Build up the path-portion from the list of static segments and parameters
  3892. var pathString = pathSegmentsAndParams.reduce(function (acc, x) {
  3893. // The element is a static segment (a raw string); just append it
  3894. if (predicates_1.isString(x))
  3895. return acc + x;
  3896. // Otherwise, it's a Param. Fetch details about the parameter value
  3897. var _a = getDetails(x), squash = _a.squash, encoded = _a.encoded, param = _a.param;
  3898. // If squash is === true, try to remove a slash from the path
  3899. if (squash === true)
  3900. return (acc.match(/\/$/)) ? acc.slice(0, -1) : acc;
  3901. // If squash is a string, use the string for the param value
  3902. if (predicates_1.isString(squash))
  3903. return acc + squash;
  3904. if (squash !== false)
  3905. return acc; // ?
  3906. if (encoded == null)
  3907. return acc;
  3908. // If this parameter value is an array, encode the value using encodeDashes
  3909. if (predicates_1.isArray(encoded))
  3910. return acc + common_1.map(encoded, UrlMatcher.encodeDashes).join("-");
  3911. // If the parameter type is "raw", then do not encodeURIComponent
  3912. if (param.type.raw)
  3913. return acc + encoded;
  3914. // Encode the value
  3915. return acc + encodeURIComponent(encoded);
  3916. }, "");
  3917. // Build the query string by applying parameter values (array or regular)
  3918. // then mapping to key=value, then flattening and joining using "&"
  3919. var queryString = queryParams.map(function (param) {
  3920. var _a = getDetails(param), squash = _a.squash, encoded = _a.encoded, isDefaultValue = _a.isDefaultValue;
  3921. if (encoded == null || (isDefaultValue && squash !== false))
  3922. return;
  3923. if (!predicates_1.isArray(encoded))
  3924. encoded = [encoded];
  3925. if (encoded.length === 0)
  3926. return;
  3927. if (!param.type.raw)
  3928. encoded = common_1.map(encoded, encodeURIComponent);
  3929. return encoded.map(function (val) { return (param.id + "=" + val); });
  3930. }).filter(common_1.identity).reduce(common_2.unnestR, []).join("&");
  3931. // Concat the pathstring with the queryString (if exists) and the hashString (if exists)
  3932. return pathString + (queryString ? "?" + queryString : "") + (values["#"] ? "#" + values["#"] : "");
  3933. };
  3934. /** @hidden */
  3935. UrlMatcher.encodeDashes = function (str) {
  3936. return encodeURIComponent(str).replace(/-/g, function (c) { return ("%5C%" + c.charCodeAt(0).toString(16).toUpperCase()); });
  3937. };
  3938. /** @hidden Given a matcher, return an array with the matcher's path segments and path params, in order */
  3939. UrlMatcher.pathSegmentsAndParams = function (matcher) {
  3940. var staticSegments = matcher._segments;
  3941. var pathParams = matcher._params.filter(function (p) { return p.location === param_2.DefType.PATH; });
  3942. return common_3.arrayTuples(staticSegments, pathParams.concat(undefined)).reduce(common_2.unnestR, []).filter(function (x) { return x !== "" && predicates_2.isDefined(x); });
  3943. };
  3944. /** @hidden Given a matcher, return an array with the matcher's query params */
  3945. UrlMatcher.queryParams = function (matcher) {
  3946. return matcher._params.filter(function (p) { return p.location === param_2.DefType.SEARCH; });
  3947. };
  3948. /** @hidden */
  3949. UrlMatcher.nameValidator = /^\w+([-.]+\w+)*(?:\[\])?$/;
  3950. return UrlMatcher;
  3951. }());
  3952. exports.UrlMatcher = UrlMatcher;
  3953. /***/ },
  3954. /* 28 */
  3955. /***/ function(module, exports, __webpack_require__) {
  3956. "use strict";
  3957. /** @module params */ /** for typedoc */
  3958. var common_1 = __webpack_require__(3);
  3959. var predicates_1 = __webpack_require__(4);
  3960. var hof_1 = __webpack_require__(5);
  3961. var coreservices_1 = __webpack_require__(6);
  3962. var type_1 = __webpack_require__(24);
  3963. // Use tildes to pre-encode slashes.
  3964. // If the slashes are simply URLEncoded, the browser can choose to pre-decode them,
  3965. // and bidirectional encoding/decoding fails.
  3966. // Tilde was chosen because it's not a RFC 3986 section 2.2 Reserved Character
  3967. function valToString(val) { return val != null ? val.toString().replace(/(~|\/)/g, function (m) { return ({ '~': '~~', '/': '~2F' }[m]); }) : val; }
  3968. function valFromString(val) { return val != null ? val.toString().replace(/(~~|~2F)/g, function (m) { return ({ '~~': '~', '~2F': '/' }[m]); }) : val; }
  3969. var ParamTypes = (function () {
  3970. function ParamTypes() {
  3971. this.enqueue = true;
  3972. this.typeQueue = [];
  3973. this.defaultTypes = {
  3974. "hash": {
  3975. encode: valToString,
  3976. decode: valFromString,
  3977. is: hof_1.is(String),
  3978. pattern: /.*/,
  3979. equals: function (a, b) { return a == b; } // allow coersion for null/undefined/""
  3980. },
  3981. "string": {
  3982. encode: valToString,
  3983. decode: valFromString,
  3984. is: hof_1.is(String),
  3985. pattern: /[^/]*/
  3986. },
  3987. "int": {
  3988. encode: valToString,
  3989. decode: function (val) { return parseInt(val, 10); },
  3990. is: function (val) { return predicates_1.isDefined(val) && this.decode(val.toString()) === val; },
  3991. pattern: /-?\d+/
  3992. },
  3993. "bool": {
  3994. encode: function (val) { return val && 1 || 0; },
  3995. decode: function (val) { return parseInt(val, 10) !== 0; },
  3996. is: hof_1.is(Boolean),
  3997. pattern: /0|1/
  3998. },
  3999. "date": {
  4000. encode: function (val) {
  4001. return !this.is(val) ? undefined : [
  4002. val.getFullYear(),
  4003. ('0' + (val.getMonth() + 1)).slice(-2),
  4004. ('0' + val.getDate()).slice(-2)
  4005. ].join("-");
  4006. },
  4007. decode: function (val) {
  4008. if (this.is(val))
  4009. return val;
  4010. var match = this.capture.exec(val);
  4011. return match ? new Date(match[1], match[2] - 1, match[3]) : undefined;
  4012. },
  4013. is: function (val) { return val instanceof Date && !isNaN(val.valueOf()); },
  4014. equals: function (l, r) {
  4015. return ['getFullYear', 'getMonth', 'getDate']
  4016. .reduce(function (acc, fn) { return acc && l[fn]() === r[fn](); }, true);
  4017. },
  4018. pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,
  4019. capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/
  4020. },
  4021. "json": {
  4022. encode: common_1.toJson,
  4023. decode: common_1.fromJson,
  4024. is: hof_1.is(Object),
  4025. equals: common_1.equals,
  4026. pattern: /[^/]*/
  4027. },
  4028. "any": {
  4029. encode: common_1.identity,
  4030. decode: common_1.identity,
  4031. equals: common_1.equals,
  4032. pattern: /.*/
  4033. }
  4034. };
  4035. // Register default types. Store them in the prototype of this.types.
  4036. var makeType = function (definition, name) { return new type_1.ParamType(common_1.extend({ name: name }, definition)); };
  4037. this.types = common_1.inherit(common_1.map(this.defaultTypes, makeType), {});
  4038. }
  4039. ParamTypes.prototype.type = function (name, definition, definitionFn) {
  4040. if (!predicates_1.isDefined(definition))
  4041. return this.types[name];
  4042. if (this.types.hasOwnProperty(name))
  4043. throw new Error("A type named '" + name + "' has already been defined.");
  4044. this.types[name] = new type_1.ParamType(common_1.extend({ name: name }, definition));
  4045. if (definitionFn) {
  4046. this.typeQueue.push({ name: name, def: definitionFn });
  4047. if (!this.enqueue)
  4048. this._flushTypeQueue();
  4049. }
  4050. return this;
  4051. };
  4052. ParamTypes.prototype._flushTypeQueue = function () {
  4053. while (this.typeQueue.length) {
  4054. var type = this.typeQueue.shift();
  4055. if (type.pattern)
  4056. throw new Error("You cannot override a type's .pattern at runtime.");
  4057. common_1.extend(this.types[type.name], coreservices_1.services.$injector.invoke(type.def));
  4058. }
  4059. };
  4060. return ParamTypes;
  4061. }());
  4062. exports.ParamTypes = ParamTypes;
  4063. /***/ },
  4064. /* 29 */
  4065. /***/ function(module, exports, __webpack_require__) {
  4066. "use strict";
  4067. /** @module url */ /** for typedoc */
  4068. var common_1 = __webpack_require__(3);
  4069. var predicates_1 = __webpack_require__(4);
  4070. var coreservices_1 = __webpack_require__(6);
  4071. /** @hidden */
  4072. var $location = coreservices_1.services.location;
  4073. /** @hidden Returns a string that is a prefix of all strings matching the RegExp */
  4074. function regExpPrefix(re) {
  4075. var prefix = /^\^((?:\\[^a-zA-Z0-9]|[^\\\[\]\^$*+?.()|{}]+)*)/.exec(re.source);
  4076. return (prefix != null) ? prefix[1].replace(/\\(.)/g, "$1") : '';
  4077. }
  4078. /** @hidden Interpolates matched values into a String.replace()-style pattern */
  4079. function interpolate(pattern, match) {
  4080. return pattern.replace(/\$(\$|\d{1,2})/, function (m, what) {
  4081. return match[what === '$' ? 0 : Number(what)];
  4082. });
  4083. }
  4084. /** @hidden */
  4085. function handleIfMatch($injector, $stateParams, handler, match) {
  4086. if (!match)
  4087. return false;
  4088. var result = $injector.invoke(handler, handler, { $match: match, $stateParams: $stateParams });
  4089. return predicates_1.isDefined(result) ? result : true;
  4090. }
  4091. /** @hidden */
  4092. function appendBasePath(url, isHtml5, absolute) {
  4093. var baseHref = coreservices_1.services.locationConfig.baseHref();
  4094. if (baseHref === '/')
  4095. return url;
  4096. if (isHtml5)
  4097. return baseHref.slice(0, -1) + url;
  4098. if (absolute)
  4099. return baseHref.slice(1) + url;
  4100. return url;
  4101. }
  4102. // TODO: Optimize groups of rules with non-empty prefix into some sort of decision tree
  4103. /** @hidden */
  4104. function update(rules, otherwiseFn, evt) {
  4105. if (evt && evt.defaultPrevented)
  4106. return;
  4107. function check(rule) {
  4108. var handled = rule(coreservices_1.services.$injector, $location);
  4109. if (!handled)
  4110. return false;
  4111. if (predicates_1.isString(handled)) {
  4112. $location.setUrl(handled, true);
  4113. }
  4114. return true;
  4115. }
  4116. var n = rules.length;
  4117. for (var i = 0; i < n; i++) {
  4118. if (check(rules[i]))
  4119. return;
  4120. }
  4121. // always check otherwise last to allow dynamic updates to the set of rules
  4122. if (otherwiseFn)
  4123. check(otherwiseFn);
  4124. }
  4125. /**
  4126. * Manages rules for client-side URL
  4127. *
  4128. * This class manages the router rules for what to do when the URL changes.
  4129. */
  4130. var UrlRouterProvider = (function () {
  4131. function UrlRouterProvider($urlMatcherFactory, $stateParams) {
  4132. /** @hidden */
  4133. this.rules = [];
  4134. /** @hidden */
  4135. this.interceptDeferred = false;
  4136. this.$urlMatcherFactory = $urlMatcherFactory;
  4137. this.$stateParams = $stateParams;
  4138. }
  4139. /**
  4140. * Registers a url handler function.
  4141. *
  4142. * Registers a low level url handler (a `rule`). A rule detects specific URL patterns and returns
  4143. * a redirect, or performs some action.
  4144. *
  4145. * If a rule returns a string, the URL is replaced with the string, and all rules are fired again.
  4146. *
  4147. * @example
  4148. * ```js
  4149. *
  4150. * var app = angular.module('app', ['ui.router.router']);
  4151. *
  4152. * app.config(function ($urlRouterProvider) {
  4153. * // Here's an example of how you might allow case insensitive urls
  4154. * $urlRouterProvider.rule(function ($injector, $location) {
  4155. * var path = $location.path(),
  4156. * normalized = path.toLowerCase();
  4157. *
  4158. * if (path !== normalized) {
  4159. * return normalized;
  4160. * }
  4161. * });
  4162. * });
  4163. * ```
  4164. *
  4165. * @param rule
  4166. * Handler function that takes `$injector` and `$location` services as arguments.
  4167. * You can use them to detect a url and return a different url as a string.
  4168. *
  4169. * @return [[$urlRouterProvider]] (`this`)
  4170. */
  4171. UrlRouterProvider.prototype.rule = function (rule) {
  4172. if (!predicates_1.isFunction(rule))
  4173. throw new Error("'rule' must be a function");
  4174. this.rules.push(rule);
  4175. return this;
  4176. };
  4177. ;
  4178. /**
  4179. * Remove a rule previously registered
  4180. *
  4181. * @param rule the matcher rule that was previously registered using [[rule]]
  4182. * @return true if the rule was found (and removed)
  4183. */
  4184. UrlRouterProvider.prototype.removeRule = function (rule) {
  4185. return this.rules.length !== common_1.removeFrom(this.rules, rule).length;
  4186. };
  4187. /**
  4188. * Defines the path or behavior to use when no url can be matched.
  4189. *
  4190. * @example
  4191. * ```js
  4192. *
  4193. * var app = angular.module('app', ['ui.router.router']);
  4194. *
  4195. * app.config(function ($urlRouterProvider) {
  4196. * // if the path doesn't match any of the urls you configured
  4197. * // otherwise will take care of routing the user to the
  4198. * // specified url
  4199. * $urlRouterProvider.otherwise('/index');
  4200. *
  4201. * // Example of using function rule as param
  4202. * $urlRouterProvider.otherwise(function ($injector, $location) {
  4203. * return '/a/valid/url';
  4204. * });
  4205. * });
  4206. * ```
  4207. *
  4208. * @param rule
  4209. * The url path you want to redirect to or a function rule that returns the url path or performs a `$state.go()`.
  4210. * The function version is passed two params: `$injector` and `$location` services, and should return a url string.
  4211. *
  4212. * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
  4213. */
  4214. UrlRouterProvider.prototype.otherwise = function (rule) {
  4215. if (!predicates_1.isFunction(rule) && !predicates_1.isString(rule))
  4216. throw new Error("'rule' must be a string or function");
  4217. this.otherwiseFn = predicates_1.isString(rule) ? function () { return rule; } : rule;
  4218. return this;
  4219. };
  4220. ;
  4221. /**
  4222. * Registers a handler for a given url matching.
  4223. *
  4224. * If the handler is a string, it is
  4225. * treated as a redirect, and is interpolated according to the syntax of match
  4226. * (i.e. like `String.replace()` for `RegExp`, or like a `UrlMatcher` pattern otherwise).
  4227. *
  4228. * If the handler is a function, it is injectable.
  4229. * It gets invoked if `$location` matches.
  4230. * You have the option of inject the match object as `$match`.
  4231. *
  4232. * The handler can return
  4233. *
  4234. * - **falsy** to indicate that the rule didn't match after all, then `$urlRouter`
  4235. * will continue trying to find another one that matches.
  4236. * - **string** which is treated as a redirect and passed to `$location.url()`
  4237. * - **void** or any **truthy** value tells `$urlRouter` that the url was handled.
  4238. *
  4239. * @example
  4240. * ```js
  4241. *
  4242. * var app = angular.module('app', ['ui.router.router']);
  4243. *
  4244. * app.config(function ($urlRouterProvider) {
  4245. * $urlRouterProvider.when($state.url, function ($match, $stateParams) {
  4246. * if ($state.$current.navigable !== state ||
  4247. * !equalForKeys($match, $stateParams) {
  4248. * $state.transitionTo(state, $match, false);
  4249. * }
  4250. * });
  4251. * });
  4252. * ```
  4253. *
  4254. * @param what A pattern string to match, compiled as a [[UrlMatcher]].
  4255. * @param handler The path (or function that returns a path) that you want to redirect your user to.
  4256. * @param ruleCallback [optional] A callback that receives the `rule` registered with [[UrlMatcher.rule]]
  4257. *
  4258. * Note: the handler may also invoke arbitrary code, such as `$state.go()`
  4259. */
  4260. UrlRouterProvider.prototype.when = function (what, handler, ruleCallback) {
  4261. if (ruleCallback === void 0) { ruleCallback = function (rule) { }; }
  4262. var _a = this, $urlMatcherFactory = _a.$urlMatcherFactory, $stateParams = _a.$stateParams;
  4263. var redirect, handlerIsString = predicates_1.isString(handler);
  4264. // @todo Queue this
  4265. if (predicates_1.isString(what))
  4266. what = $urlMatcherFactory.compile(what);
  4267. if (!handlerIsString && !predicates_1.isFunction(handler) && !predicates_1.isArray(handler))
  4268. throw new Error("invalid 'handler' in when()");
  4269. var strategies = {
  4270. matcher: function (_what, _handler) {
  4271. if (handlerIsString) {
  4272. redirect = $urlMatcherFactory.compile(_handler);
  4273. _handler = ['$match', redirect.format.bind(redirect)];
  4274. }
  4275. return common_1.extend(function () {
  4276. return handleIfMatch(coreservices_1.services.$injector, $stateParams, _handler, _what.exec($location.path(), $location.search(), $location.hash()));
  4277. }, {
  4278. prefix: predicates_1.isString(_what.prefix) ? _what.prefix : ''
  4279. });
  4280. },
  4281. regex: function (_what, _handler) {
  4282. if (_what.global || _what.sticky)
  4283. throw new Error("when() RegExp must not be global or sticky");
  4284. if (handlerIsString) {
  4285. redirect = _handler;
  4286. _handler = ['$match', function ($match) { return interpolate(redirect, $match); }];
  4287. }
  4288. return common_1.extend(function () {
  4289. return handleIfMatch(coreservices_1.services.$injector, $stateParams, _handler, _what.exec($location.path()));
  4290. }, {
  4291. prefix: regExpPrefix(_what)
  4292. });
  4293. }
  4294. };
  4295. var check = {
  4296. matcher: $urlMatcherFactory.isMatcher(what),
  4297. regex: what instanceof RegExp
  4298. };
  4299. for (var n in check) {
  4300. if (check[n]) {
  4301. var rule = strategies[n](what, handler);
  4302. ruleCallback(rule);
  4303. return this.rule(rule);
  4304. }
  4305. }
  4306. throw new Error("invalid 'what' in when()");
  4307. };
  4308. ;
  4309. /**
  4310. * Disables monitoring of the URL.
  4311. *
  4312. * Call this method before UI-Router has bootstrapped.
  4313. * It will stop UI-Router from performing the initial url sync.
  4314. *
  4315. * This can be useful to perform some asynchronous initialization before the router starts.
  4316. * Once the initialization is complete, call [[listen]] to tell UI-Router to start watching and synchronizing the URL.
  4317. *
  4318. * @example
  4319. * ```js
  4320. *
  4321. * var app = angular.module('app', ['ui.router']);
  4322. *
  4323. * app.config(function ($urlRouterProvider) {
  4324. * // Prevent $urlRouter from automatically intercepting URL changes;
  4325. * $urlRouterProvider.deferIntercept();
  4326. * })
  4327. *
  4328. * app.run(function (MyService, $urlRouter, $http) {
  4329. * $http.get("/stuff").then(function(resp) {
  4330. * MyService.doStuff(resp.data);
  4331. * $urlRouter.listen();
  4332. * $urlRouter.sync();
  4333. * });
  4334. * });
  4335. * ```
  4336. *
  4337. * @param defer Indicates whether to defer location change interception. Passing
  4338. * no parameter is equivalent to `true`.
  4339. */
  4340. UrlRouterProvider.prototype.deferIntercept = function (defer) {
  4341. if (defer === undefined)
  4342. defer = true;
  4343. this.interceptDeferred = defer;
  4344. };
  4345. ;
  4346. return UrlRouterProvider;
  4347. }());
  4348. exports.UrlRouterProvider = UrlRouterProvider;
  4349. var UrlRouter = (function () {
  4350. /** @hidden */
  4351. function UrlRouter(urlRouterProvider) {
  4352. this.urlRouterProvider = urlRouterProvider;
  4353. common_1.bindFunctions(UrlRouter.prototype, this, this);
  4354. }
  4355. /**
  4356. * Checks the current URL for a matching rule
  4357. *
  4358. * Triggers an update; the same update that happens when the address bar url changes, aka `$locationChangeSuccess`.
  4359. * This method is useful when you need to use `preventDefault()` on the `$locationChangeSuccess` event,
  4360. * perform some custom logic (route protection, auth, config, redirection, etc) and then finally proceed
  4361. * with the transition by calling `$urlRouter.sync()`.
  4362. *
  4363. * @example
  4364. * ```js
  4365. *
  4366. * angular.module('app', ['ui.router'])
  4367. * .run(function($rootScope, $urlRouter) {
  4368. * $rootScope.$on('$locationChangeSuccess', function(evt) {
  4369. * // Halt state change from even starting
  4370. * evt.preventDefault();
  4371. * // Perform custom logic
  4372. * var meetsRequirement = ...
  4373. * // Continue with the update and state transition if logic allows
  4374. * if (meetsRequirement) $urlRouter.sync();
  4375. * });
  4376. * });
  4377. * ```
  4378. */
  4379. UrlRouter.prototype.sync = function () {
  4380. update(this.urlRouterProvider.rules, this.urlRouterProvider.otherwiseFn);
  4381. };
  4382. /**
  4383. * Starts listening for URL changes
  4384. *
  4385. * Call this sometime after calling [[deferIntercept]] to start monitoring the url.
  4386. * This causes [[UrlRouter]] to start listening for changes to the URL, if it wasn't already listening.
  4387. */
  4388. UrlRouter.prototype.listen = function () {
  4389. var _this = this;
  4390. return this.listener = this.listener || $location.onChange(function (evt) { return update(_this.urlRouterProvider.rules, _this.urlRouterProvider.otherwiseFn, evt); });
  4391. };
  4392. /**
  4393. * Internal API.
  4394. */
  4395. UrlRouter.prototype.update = function (read) {
  4396. if (read) {
  4397. this.location = $location.path();
  4398. return;
  4399. }
  4400. if ($location.path() === this.location)
  4401. return;
  4402. $location.setUrl(this.location, true);
  4403. };
  4404. /**
  4405. * Internal API.
  4406. *
  4407. * Pushes a new location to the browser history.
  4408. *
  4409. * @param urlMatcher
  4410. * @param params
  4411. * @param options
  4412. */
  4413. UrlRouter.prototype.push = function (urlMatcher, params, options) {
  4414. var replace = options && !!options.replace;
  4415. $location.setUrl(urlMatcher.format(params || {}), replace);
  4416. };
  4417. /**
  4418. * Builds and returns a URL with interpolated parameters
  4419. *
  4420. * @example
  4421. * ```js
  4422. *
  4423. * $bob = $urlRouter.href(new UrlMatcher("/about/:person"), {
  4424. * person: "bob"
  4425. * });
  4426. * // $bob == "/about/bob";
  4427. * ```
  4428. *
  4429. * @param urlMatcher The [[UrlMatcher]] object which is used as the template of the URL to generate.
  4430. * @param params An object of parameter values to fill the matcher's required parameters.
  4431. * @param options Options object. The options are:
  4432. *
  4433. * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
  4434. *
  4435. * @returns Returns the fully compiled URL, or `null` if `params` fail validation against `urlMatcher`
  4436. */
  4437. UrlRouter.prototype.href = function (urlMatcher, params, options) {
  4438. if (!urlMatcher.validates(params))
  4439. return null;
  4440. var url = urlMatcher.format(params);
  4441. options = options || { absolute: false };
  4442. var cfg = coreservices_1.services.locationConfig;
  4443. var isHtml5 = cfg.html5Mode();
  4444. if (!isHtml5 && url !== null) {
  4445. url = "#" + cfg.hashPrefix() + url;
  4446. }
  4447. url = appendBasePath(url, isHtml5, options.absolute);
  4448. if (!options.absolute || !url) {
  4449. return url;
  4450. }
  4451. var slash = (!isHtml5 && url ? '/' : ''), port = cfg.port();
  4452. port = (port === 80 || port === 443 ? '' : ':' + port);
  4453. return [cfg.protocol(), '://', cfg.host(), port, slash, url].join('');
  4454. };
  4455. return UrlRouter;
  4456. }());
  4457. exports.UrlRouter = UrlRouter;
  4458. /***/ },
  4459. /* 30 */
  4460. /***/ function(module, exports, __webpack_require__) {
  4461. "use strict";
  4462. var transition_1 = __webpack_require__(11);
  4463. var hookRegistry_1 = __webpack_require__(15);
  4464. var resolve_1 = __webpack_require__(31);
  4465. var views_1 = __webpack_require__(32);
  4466. var url_1 = __webpack_require__(33);
  4467. var redirectTo_1 = __webpack_require__(34);
  4468. var onEnterExitRetain_1 = __webpack_require__(35);
  4469. var lazyLoadStates_1 = __webpack_require__(36);
  4470. /**
  4471. * The default [[Transition]] options.
  4472. *
  4473. * Include this object when applying custom defaults:
  4474. * let reloadOpts = { reload: true, notify: true }
  4475. * let options = defaults(theirOpts, customDefaults, defaultOptions);
  4476. */
  4477. exports.defaultTransOpts = {
  4478. location: true,
  4479. relative: null,
  4480. inherit: false,
  4481. notify: true,
  4482. reload: false,
  4483. custom: {},
  4484. current: function () { return null; },
  4485. source: "unknown"
  4486. };
  4487. /**
  4488. * This class provides services related to Transitions.
  4489. *
  4490. * - Most importantly, it allows global Transition Hooks to be registered.
  4491. * - It allows the default transition error handler to be set.
  4492. * - It also has a factory function for creating new [[Transition]] objects, (used internally by the [[StateService]]).
  4493. *
  4494. * At bootstrap, [[UIRouter]] creates a single instance (singleton) of this class.
  4495. */
  4496. var TransitionService = (function () {
  4497. function TransitionService(_router) {
  4498. this._router = _router;
  4499. this.$view = _router.viewService;
  4500. hookRegistry_1.HookRegistry.mixin(new hookRegistry_1.HookRegistry(), this);
  4501. this._deregisterHookFns = {};
  4502. this.registerTransitionHooks();
  4503. }
  4504. /** @hidden */
  4505. TransitionService.prototype.registerTransitionHooks = function () {
  4506. var fns = this._deregisterHookFns;
  4507. // Wire up redirectTo hook
  4508. fns.redirectTo = redirectTo_1.registerRedirectToHook(this);
  4509. // Wire up onExit/Retain/Enter state hooks
  4510. fns.onExit = onEnterExitRetain_1.registerOnExitHook(this);
  4511. fns.onRetain = onEnterExitRetain_1.registerOnRetainHook(this);
  4512. fns.onEnter = onEnterExitRetain_1.registerOnEnterHook(this);
  4513. // Wire up Resolve hooks
  4514. fns.eagerResolve = resolve_1.registerEagerResolvePath(this);
  4515. fns.lazyResolve = resolve_1.registerLazyResolveState(this);
  4516. // Wire up the View management hooks
  4517. fns.loadViews = views_1.registerLoadEnteringViews(this);
  4518. fns.activateViews = views_1.registerActivateViews(this);
  4519. // After globals.current is updated at priority: 10000
  4520. fns.updateUrl = url_1.registerUpdateUrl(this);
  4521. // Lazy load state trees
  4522. fns.lazyLoad = lazyLoadStates_1.registerLazyLoadHook(this);
  4523. };
  4524. /** @inheritdoc */
  4525. TransitionService.prototype.onBefore = function (matchCriteria, callback, options) { throw ""; };
  4526. ;
  4527. /** @inheritdoc */
  4528. TransitionService.prototype.onStart = function (matchCriteria, callback, options) { throw ""; };
  4529. ;
  4530. /** @inheritdoc */
  4531. TransitionService.prototype.onExit = function (matchCriteria, callback, options) { throw ""; };
  4532. ;
  4533. /** @inheritdoc */
  4534. TransitionService.prototype.onRetain = function (matchCriteria, callback, options) { throw ""; };
  4535. ;
  4536. /** @inheritdoc */
  4537. TransitionService.prototype.onEnter = function (matchCriteria, callback, options) { throw ""; };
  4538. ;
  4539. /** @inheritdoc */
  4540. TransitionService.prototype.onFinish = function (matchCriteria, callback, options) { throw ""; };
  4541. ;
  4542. /** @inheritdoc */
  4543. TransitionService.prototype.onSuccess = function (matchCriteria, callback, options) { throw ""; };
  4544. ;
  4545. /** @inheritdoc */
  4546. TransitionService.prototype.onError = function (matchCriteria, callback, options) { throw ""; };
  4547. ;
  4548. /**
  4549. * Creates a new [[Transition]] object
  4550. *
  4551. * This is a factory function for creating new Transition objects.
  4552. * It is used internally by the [[StateService]] and should generally not be called by application code.
  4553. *
  4554. * @param fromPath the path to the current state (the from state)
  4555. * @param targetState the target state (destination)
  4556. * @returns a Transition
  4557. */
  4558. TransitionService.prototype.create = function (fromPath, targetState) {
  4559. return new transition_1.Transition(fromPath, targetState, this._router);
  4560. };
  4561. return TransitionService;
  4562. }());
  4563. exports.TransitionService = TransitionService;
  4564. /***/ },
  4565. /* 31 */
  4566. /***/ function(module, exports, __webpack_require__) {
  4567. "use strict";
  4568. /** @module hooks */ /** for typedoc */
  4569. var common_1 = __webpack_require__(3);
  4570. var resolveContext_1 = __webpack_require__(17);
  4571. var hof_1 = __webpack_require__(5);
  4572. /**
  4573. * A [[TransitionHookFn]] which resolves all EAGER Resolvables in the To Path
  4574. *
  4575. * Registered using `transitionService.onStart({}, eagerResolvePath);`
  4576. *
  4577. * When a Transition starts, this hook resolves all the EAGER Resolvables, which the transition then waits for.
  4578. *
  4579. * See [[StateDeclaration.resolve]]
  4580. */
  4581. var eagerResolvePath = function (trans) {
  4582. return new resolveContext_1.ResolveContext(trans.treeChanges().to)
  4583. .resolvePath("EAGER", trans)
  4584. .then(common_1.noop);
  4585. };
  4586. exports.registerEagerResolvePath = function (transitionService) {
  4587. return transitionService.onStart({}, eagerResolvePath, { priority: 1000 });
  4588. };
  4589. /**
  4590. * A [[TransitionHookFn]] which resolves all LAZY Resolvables for the state (and all its ancestors) in the To Path
  4591. *
  4592. * Registered using `transitionService.onEnter({ entering: () => true }, lazyResolveState);`
  4593. *
  4594. * When a State is being entered, this hook resolves all the Resolvables for this state, which the transition then waits for.
  4595. *
  4596. * See [[StateDeclaration.resolve]]
  4597. */
  4598. var lazyResolveState = function (trans, state) {
  4599. return new resolveContext_1.ResolveContext(trans.treeChanges().to)
  4600. .subContext(state)
  4601. .resolvePath("LAZY", trans)
  4602. .then(common_1.noop);
  4603. };
  4604. exports.registerLazyResolveState = function (transitionService) {
  4605. return transitionService.onEnter({ entering: hof_1.val(true) }, lazyResolveState, { priority: 1000 });
  4606. };
  4607. /***/ },
  4608. /* 32 */
  4609. /***/ function(module, exports, __webpack_require__) {
  4610. "use strict";
  4611. /** @module hooks */ /** for typedoc */
  4612. var common_1 = __webpack_require__(3);
  4613. var coreservices_1 = __webpack_require__(6);
  4614. /**
  4615. * A [[TransitionHookFn]] which waits for the views to load
  4616. *
  4617. * Registered using `transitionService.onStart({}, loadEnteringViews);`
  4618. *
  4619. * Allows the views to do async work in [[ViewConfig.load]] before the transition continues.
  4620. * In angular 1, this includes loading the templates.
  4621. */
  4622. var loadEnteringViews = function (transition) {
  4623. var enteringViews = transition.views("entering");
  4624. if (!enteringViews.length)
  4625. return;
  4626. return coreservices_1.services.$q.all(enteringViews.map(function (view) { return view.load(); })).then(common_1.noop);
  4627. };
  4628. exports.registerLoadEnteringViews = function (transitionService) {
  4629. return transitionService.onStart({}, loadEnteringViews);
  4630. };
  4631. /**
  4632. * A [[TransitionHookFn]] which activates the new views when a transition is successful.
  4633. *
  4634. * Registered using `transitionService.onSuccess({}, activateViews);`
  4635. *
  4636. * After a transition is complete, this hook deactivates the old views from the previous state,
  4637. * and activates the new views from the destination state.
  4638. *
  4639. * See [[ViewService]]
  4640. */
  4641. var activateViews = function (transition) {
  4642. var enteringViews = transition.views("entering");
  4643. var exitingViews = transition.views("exiting");
  4644. if (!enteringViews.length && !exitingViews.length)
  4645. return;
  4646. var $view = transition.router.viewService;
  4647. exitingViews.forEach(function (vc) { return $view.deactivateViewConfig(vc); });
  4648. enteringViews.forEach(function (vc) { return $view.activateViewConfig(vc); });
  4649. $view.sync();
  4650. };
  4651. exports.registerActivateViews = function (transitionService) {
  4652. return transitionService.onSuccess({}, activateViews);
  4653. };
  4654. /***/ },
  4655. /* 33 */
  4656. /***/ function(module, exports) {
  4657. "use strict";
  4658. /**
  4659. * A [[TransitionHookFn]] which updates the URL after a successful transition
  4660. *
  4661. * Registered using `transitionService.onSuccess({}, updateUrl);`
  4662. */
  4663. var updateUrl = function (transition) {
  4664. var options = transition.options();
  4665. var $state = transition.router.stateService;
  4666. var $urlRouter = transition.router.urlRouter;
  4667. // Dont update the url in these situations:
  4668. // The transition was triggered by a URL sync (options.source === 'url')
  4669. // The user doesn't want the url to update (options.location === false)
  4670. // The destination state, and all parents have no navigable url
  4671. if (options.source !== 'url' && options.location && $state.$current.navigable) {
  4672. var urlOptions = { replace: options.location === 'replace' };
  4673. $urlRouter.push($state.$current.navigable.url, $state.params, urlOptions);
  4674. }
  4675. $urlRouter.update(true);
  4676. };
  4677. exports.registerUpdateUrl = function (transitionService) {
  4678. return transitionService.onSuccess({}, updateUrl, { priority: 9999 });
  4679. };
  4680. /***/ },
  4681. /* 34 */
  4682. /***/ function(module, exports, __webpack_require__) {
  4683. "use strict";
  4684. /** @module hooks */ /** */
  4685. var predicates_1 = __webpack_require__(4);
  4686. var coreservices_1 = __webpack_require__(6);
  4687. var targetState_1 = __webpack_require__(14);
  4688. /**
  4689. * A [[TransitionHookFn]] that redirects to a different state or params
  4690. *
  4691. * Registered using `transitionService.onStart({ to: (state) => !!state.redirectTo }, redirectHook);`
  4692. *
  4693. * See [[StateDeclaration.redirectTo]]
  4694. */
  4695. var redirectToHook = function (trans) {
  4696. var redirect = trans.to().redirectTo;
  4697. if (!redirect)
  4698. return;
  4699. function handleResult(result) {
  4700. var $state = trans.router.stateService;
  4701. if (result instanceof targetState_1.TargetState)
  4702. return result;
  4703. if (predicates_1.isString(result))
  4704. return $state.target(result, trans.params(), trans.options());
  4705. if (result['state'] || result['params'])
  4706. return $state.target(result['state'] || trans.to(), result['params'] || trans.params(), trans.options());
  4707. }
  4708. if (predicates_1.isFunction(redirect)) {
  4709. return coreservices_1.services.$q.when(redirect(trans)).then(handleResult);
  4710. }
  4711. return handleResult(redirect);
  4712. };
  4713. exports.registerRedirectToHook = function (transitionService) {
  4714. return transitionService.onStart({ to: function (state) { return !!state.redirectTo; } }, redirectToHook);
  4715. };
  4716. /***/ },
  4717. /* 35 */
  4718. /***/ function(module, exports) {
  4719. "use strict";
  4720. /**
  4721. * A factory which creates an onEnter, onExit or onRetain transition hook function
  4722. *
  4723. * The returned function invokes the (for instance) state.onEnter hook when the
  4724. * state is being entered.
  4725. *
  4726. * @hidden
  4727. */
  4728. function makeEnterExitRetainHook(hookName) {
  4729. return function (transition, state) {
  4730. var hookFn = state[hookName];
  4731. return hookFn(transition, state);
  4732. };
  4733. }
  4734. /**
  4735. * The [[TransitionStateHookFn]] for onExit
  4736. *
  4737. * When the state is being exited, the state's .onExit function is invoked.
  4738. *
  4739. * Registered using `transitionService.onExit({ exiting: (state) => !!state.onExit }, onExitHook);`
  4740. *
  4741. * See: [[IHookRegistry.onExit]]
  4742. */
  4743. var onExitHook = makeEnterExitRetainHook('onExit');
  4744. exports.registerOnExitHook = function (transitionService) {
  4745. return transitionService.onExit({ exiting: function (state) { return !!state.onExit; } }, onExitHook);
  4746. };
  4747. /**
  4748. * The [[TransitionStateHookFn]] for onRetain
  4749. *
  4750. * When the state was already entered, and is not being exited or re-entered, the state's .onRetain function is invoked.
  4751. *
  4752. * Registered using `transitionService.onRetain({ retained: (state) => !!state.onRetain }, onRetainHook);`
  4753. *
  4754. * See: [[IHookRegistry.onRetain]]
  4755. */
  4756. var onRetainHook = makeEnterExitRetainHook('onRetain');
  4757. exports.registerOnRetainHook = function (transitionService) {
  4758. return transitionService.onRetain({ retained: function (state) { return !!state.onRetain; } }, onRetainHook);
  4759. };
  4760. /**
  4761. * The [[TransitionStateHookFn]] for onEnter
  4762. *
  4763. * When the state is being entered, the state's .onEnter function is invoked.
  4764. *
  4765. * Registered using `transitionService.onEnter({ entering: (state) => !!state.onEnter }, onEnterHook);`
  4766. *
  4767. * See: [[IHookRegistry.onEnter]]
  4768. */
  4769. var onEnterHook = makeEnterExitRetainHook('onEnter');
  4770. exports.registerOnEnterHook = function (transitionService) {
  4771. return transitionService.onEnter({ entering: function (state) { return !!state.onEnter; } }, onEnterHook);
  4772. };
  4773. /***/ },
  4774. /* 36 */
  4775. /***/ function(module, exports, __webpack_require__) {
  4776. "use strict";
  4777. var coreservices_1 = __webpack_require__(6);
  4778. /**
  4779. * A [[TransitionHookFn]] that lazy loads a state tree.
  4780. *
  4781. * When transitioning to a state "abc" which has a `lazyLoad` function defined:
  4782. * - Invoke the `lazyLoad` function
  4783. * - The function should return a promise for an array of lazy loaded [[StateDeclaration]]s
  4784. * - Wait for the promise to resolve
  4785. * - Deregister the original state "abc"
  4786. * - The original state definition is a placeholder for the lazy loaded states
  4787. * - Register the new states
  4788. * - Retry the transition
  4789. *
  4790. * See [[StateDeclaration.lazyLoad]]
  4791. */
  4792. var lazyLoadHook = function (transition) {
  4793. var toState = transition.to();
  4794. var registry = transition.router.stateRegistry;
  4795. function retryOriginalTransition() {
  4796. if (transition.options().source === 'url') {
  4797. var loc = coreservices_1.services.location, path_1 = loc.path(), search_1 = loc.search(), hash_1 = loc.hash();
  4798. var matchState = function (state) { return [state, state.url && state.url.exec(path_1, search_1, hash_1)]; };
  4799. var matches = registry.get().map(function (s) { return s.$$state(); }).map(matchState).filter(function (_a) {
  4800. var state = _a[0], params = _a[1];
  4801. return !!params;
  4802. });
  4803. if (matches.length) {
  4804. var _a = matches[0], state = _a[0], params = _a[1];
  4805. return transition.router.stateService.target(state, params, transition.options());
  4806. }
  4807. transition.router.urlRouter.sync();
  4808. }
  4809. // The original transition was not triggered via url sync
  4810. // The lazy state should be loaded now, so re-try the original transition
  4811. var orig = transition.targetState();
  4812. return transition.router.stateService.target(orig.identifier(), orig.params(), orig.options());
  4813. }
  4814. /**
  4815. * Replace the placeholder state with the newly loaded states from the NgModule.
  4816. */
  4817. function updateStateRegistry(result) {
  4818. // deregister placeholder state
  4819. registry.deregister(transition.$to());
  4820. if (result && Array.isArray(result.states)) {
  4821. result.states.forEach(function (state) { return registry.register(state); });
  4822. }
  4823. }
  4824. var hook = toState.lazyLoad;
  4825. // Store/get the lazy load promise on/from the hookfn so it doesn't get re-invoked
  4826. var promise = hook['_promise'];
  4827. if (!promise) {
  4828. promise = hook['_promise'] = hook(transition).then(updateStateRegistry);
  4829. var cleanup = function () { return delete hook['_promise']; };
  4830. promise.then(cleanup, cleanup);
  4831. }
  4832. return promise.then(retryOriginalTransition);
  4833. };
  4834. exports.registerLazyLoadHook = function (transitionService) {
  4835. return transitionService.onBefore({ to: function (state) { return !!state.lazyLoad; } }, lazyLoadHook);
  4836. };
  4837. /***/ },
  4838. /* 37 */
  4839. /***/ function(module, exports, __webpack_require__) {
  4840. "use strict";
  4841. /** @module view */ /** for typedoc */
  4842. var common_1 = __webpack_require__(3);
  4843. var hof_1 = __webpack_require__(5);
  4844. var predicates_1 = __webpack_require__(4);
  4845. var trace_1 = __webpack_require__(12);
  4846. /**
  4847. * The View service
  4848. */
  4849. var ViewService = (function () {
  4850. function ViewService() {
  4851. var _this = this;
  4852. this.uiViews = [];
  4853. this.viewConfigs = [];
  4854. this._viewConfigFactories = {};
  4855. this.sync = function () {
  4856. var uiViewsByFqn = _this.uiViews.map(function (uiv) { return [uiv.fqn, uiv]; }).reduce(common_1.applyPairs, {});
  4857. /**
  4858. * Given a ui-view and a ViewConfig, determines if they "match".
  4859. *
  4860. * A ui-view has a fully qualified name (fqn) and a context object. The fqn is built from its overall location in
  4861. * the DOM, describing its nesting relationship to any parent ui-view tags it is nested inside of.
  4862. *
  4863. * A ViewConfig has a target ui-view name and a context anchor. The ui-view name can be a simple name, or
  4864. * can be a segmented ui-view path, describing a portion of a ui-view fqn.
  4865. *
  4866. * In order for a ui-view to match ViewConfig, ui-view's $type must match the ViewConfig's $type
  4867. *
  4868. * If the ViewConfig's target ui-view name is a simple name (no dots), then a ui-view matches if:
  4869. * - the ui-view's name matches the ViewConfig's target name
  4870. * - the ui-view's context matches the ViewConfig's anchor
  4871. *
  4872. * If the ViewConfig's target ui-view name is a segmented name (with dots), then a ui-view matches if:
  4873. * - There exists a parent ui-view where:
  4874. * - the parent ui-view's name matches the first segment (index 0) of the ViewConfig's target name
  4875. * - the parent ui-view's context matches the ViewConfig's anchor
  4876. * - And the remaining segments (index 1..n) of the ViewConfig's target name match the tail of the ui-view's fqn
  4877. *
  4878. * Example:
  4879. *
  4880. * DOM:
  4881. * <div ui-view> <!-- created in the root context (name: "") -->
  4882. * <div ui-view="foo"> <!-- created in the context named: "A" -->
  4883. * <div ui-view> <!-- created in the context named: "A.B" -->
  4884. * <div ui-view="bar"> <!-- created in the context named: "A.B.C" -->
  4885. * </div>
  4886. * </div>
  4887. * </div>
  4888. * </div>
  4889. *
  4890. * uiViews: [
  4891. * { fqn: "$default", creationContext: { name: "" } },
  4892. * { fqn: "$default.foo", creationContext: { name: "A" } },
  4893. * { fqn: "$default.foo.$default", creationContext: { name: "A.B" } }
  4894. * { fqn: "$default.foo.$default.bar", creationContext: { name: "A.B.C" } }
  4895. * ]
  4896. *
  4897. * These four view configs all match the ui-view with the fqn: "$default.foo.$default.bar":
  4898. *
  4899. * - ViewConfig1: { uiViewName: "bar", uiViewContextAnchor: "A.B.C" }
  4900. * - ViewConfig2: { uiViewName: "$default.bar", uiViewContextAnchor: "A.B" }
  4901. * - ViewConfig3: { uiViewName: "foo.$default.bar", uiViewContextAnchor: "A" }
  4902. * - ViewConfig4: { uiViewName: "$default.foo.$default.bar", uiViewContextAnchor: "" }
  4903. *
  4904. * Using ViewConfig3 as an example, it matches the ui-view with fqn "$default.foo.$default.bar" because:
  4905. * - The ViewConfig's segmented target name is: [ "foo", "$default", "bar" ]
  4906. * - There exists a parent ui-view (which has fqn: "$default.foo") where:
  4907. * - the parent ui-view's name "foo" matches the first segment "foo" of the ViewConfig's target name
  4908. * - the parent ui-view's context "A" matches the ViewConfig's anchor context "A"
  4909. * - And the remaining segments [ "$default", "bar" ].join("."_ of the ViewConfig's target name match
  4910. * the tail of the ui-view's fqn "default.bar"
  4911. */
  4912. var matches = function (uiView) { return function (viewConfig) {
  4913. // Don't supply an ng1 ui-view with an ng2 ViewConfig, etc
  4914. if (uiView.$type !== viewConfig.viewDecl.$type)
  4915. return false;
  4916. // Split names apart from both viewConfig and uiView into segments
  4917. var vc = viewConfig.viewDecl;
  4918. var vcSegments = vc.$uiViewName.split(".");
  4919. var uivSegments = uiView.fqn.split(".");
  4920. // Check if the tails of the segment arrays match. ex, these arrays' tails match:
  4921. // vc: ["foo", "bar"], uiv fqn: ["$default", "foo", "bar"]
  4922. if (!common_1.equals(vcSegments, uivSegments.slice(0 - vcSegments.length)))
  4923. return false;
  4924. // Now check if the fqn ending at the first segment of the viewConfig matches the context:
  4925. // ["$default", "foo"].join(".") == "$default.foo", does the ui-view $default.foo context match?
  4926. var negOffset = (1 - vcSegments.length) || undefined;
  4927. var fqnToFirstSegment = uivSegments.slice(0, negOffset).join(".");
  4928. var uiViewContext = uiViewsByFqn[fqnToFirstSegment].creationContext;
  4929. return vc.$uiViewContextAnchor === (uiViewContext && uiViewContext.name);
  4930. }; };
  4931. // Return the number of dots in the fully qualified name
  4932. function uiViewDepth(uiView) {
  4933. return uiView.fqn.split(".").length;
  4934. }
  4935. // Return the ViewConfig's context's depth in the context tree.
  4936. function viewConfigDepth(config) {
  4937. var context = config.viewDecl.$context, count = 0;
  4938. while (++count && context.parent)
  4939. context = context.parent;
  4940. return count;
  4941. }
  4942. // Given a depth function, returns a compare function which can return either ascending or descending order
  4943. var depthCompare = hof_1.curry(function (depthFn, posNeg, left, right) { return posNeg * (depthFn(left) - depthFn(right)); });
  4944. var matchingConfigPair = function (uiView) {
  4945. var matchingConfigs = _this.viewConfigs.filter(matches(uiView));
  4946. if (matchingConfigs.length > 1)
  4947. matchingConfigs.sort(depthCompare(viewConfigDepth, -1)); // descending
  4948. return [uiView, matchingConfigs[0]];
  4949. };
  4950. var configureUIView = function (_a) {
  4951. var uiView = _a[0], viewConfig = _a[1];
  4952. // If a parent ui-view is reconfigured, it could destroy child ui-views.
  4953. // Before configuring a child ui-view, make sure it's still in the active uiViews array.
  4954. if (_this.uiViews.indexOf(uiView) !== -1)
  4955. uiView.configUpdated(viewConfig);
  4956. };
  4957. _this.uiViews.sort(depthCompare(uiViewDepth, 1)).map(matchingConfigPair).forEach(configureUIView);
  4958. };
  4959. }
  4960. ViewService.prototype.rootContext = function (context) {
  4961. return this._rootContext = context || this._rootContext;
  4962. };
  4963. ;
  4964. ViewService.prototype.viewConfigFactory = function (viewType, factory) {
  4965. this._viewConfigFactories[viewType] = factory;
  4966. };
  4967. ViewService.prototype.createViewConfig = function (path, decl) {
  4968. var cfgFactory = this._viewConfigFactories[decl.$type];
  4969. if (!cfgFactory)
  4970. throw new Error("ViewService: No view config factory registered for type " + decl.$type);
  4971. var cfgs = cfgFactory(path, decl);
  4972. return predicates_1.isArray(cfgs) ? cfgs : [cfgs];
  4973. };
  4974. /**
  4975. * De-registers a ViewConfig.
  4976. *
  4977. * @param viewConfig The ViewConfig view to deregister.
  4978. */
  4979. ViewService.prototype.deactivateViewConfig = function (viewConfig) {
  4980. trace_1.trace.traceViewServiceEvent("<- Removing", viewConfig);
  4981. common_1.removeFrom(this.viewConfigs, viewConfig);
  4982. };
  4983. ;
  4984. ViewService.prototype.activateViewConfig = function (viewConfig) {
  4985. trace_1.trace.traceViewServiceEvent("-> Registering", viewConfig);
  4986. this.viewConfigs.push(viewConfig);
  4987. };
  4988. ;
  4989. /**
  4990. * Allows a `ui-view` element to register its canonical name with a callback that allows it to
  4991. * be updated with a template, controller, and local variables.
  4992. *
  4993. * @param {String} name The fully-qualified name of the `ui-view` object being registered.
  4994. * @param {Function} configUpdatedCallback A callback that receives updates to the content & configuration
  4995. * of the view.
  4996. * @return {Function} Returns a de-registration function used when the view is destroyed.
  4997. */
  4998. ViewService.prototype.registerUIView = function (uiView) {
  4999. trace_1.trace.traceViewServiceUIViewEvent("-> Registering", uiView);
  5000. var uiViews = this.uiViews;
  5001. var fqnMatches = function (uiv) { return uiv.fqn === uiView.fqn; };
  5002. if (uiViews.filter(fqnMatches).length)
  5003. trace_1.trace.traceViewServiceUIViewEvent("!!!! duplicate uiView named:", uiView);
  5004. uiViews.push(uiView);
  5005. this.sync();
  5006. return function () {
  5007. var idx = uiViews.indexOf(uiView);
  5008. if (idx === -1) {
  5009. trace_1.trace.traceViewServiceUIViewEvent("Tried removing non-registered uiView", uiView);
  5010. return;
  5011. }
  5012. trace_1.trace.traceViewServiceUIViewEvent("<- Deregistering", uiView);
  5013. common_1.removeFrom(uiViews)(uiView);
  5014. };
  5015. };
  5016. ;
  5017. /**
  5018. * Returns the list of views currently available on the page, by fully-qualified name.
  5019. *
  5020. * @return {Array} Returns an array of fully-qualified view names.
  5021. */
  5022. ViewService.prototype.available = function () {
  5023. return this.uiViews.map(hof_1.prop("fqn"));
  5024. };
  5025. /**
  5026. * Returns the list of views on the page containing loaded content.
  5027. *
  5028. * @return {Array} Returns an array of fully-qualified view names.
  5029. */
  5030. ViewService.prototype.active = function () {
  5031. return this.uiViews.filter(hof_1.prop("$config")).map(hof_1.prop("name"));
  5032. };
  5033. /**
  5034. * Normalizes a view's name from a state.views configuration block.
  5035. *
  5036. * @param context the context object (state declaration) that the view belongs to
  5037. * @param rawViewName the name of the view, as declared in the [[StateDeclaration.views]]
  5038. *
  5039. * @returns the normalized uiViewName and uiViewContextAnchor that the view targets
  5040. */
  5041. ViewService.normalizeUIViewTarget = function (context, rawViewName) {
  5042. if (rawViewName === void 0) { rawViewName = ""; }
  5043. // TODO: Validate incoming view name with a regexp to allow:
  5044. // ex: "view.name@foo.bar" , "^.^.view.name" , "view.name@^.^" , "" ,
  5045. // "@" , "$default@^" , "!$default.$default" , "!foo.bar"
  5046. var viewAtContext = rawViewName.split("@");
  5047. var uiViewName = viewAtContext[0] || "$default"; // default to unnamed view
  5048. var uiViewContextAnchor = predicates_1.isString(viewAtContext[1]) ? viewAtContext[1] : "^"; // default to parent context
  5049. // Handle relative view-name sugar syntax.
  5050. // Matches rawViewName "^.^.^.foo.bar" into array: ["^.^.^.foo.bar", "^.^.^", "foo.bar"],
  5051. var relativeViewNameSugar = /^(\^(?:\.\^)*)\.(.*$)/.exec(uiViewName);
  5052. if (relativeViewNameSugar) {
  5053. // Clobbers existing contextAnchor (rawViewName validation will fix this)
  5054. uiViewContextAnchor = relativeViewNameSugar[1]; // set anchor to "^.^.^"
  5055. uiViewName = relativeViewNameSugar[2]; // set view-name to "foo.bar"
  5056. }
  5057. if (uiViewName.charAt(0) === '!') {
  5058. uiViewName = uiViewName.substr(1);
  5059. uiViewContextAnchor = ""; // target absolutely from root
  5060. }
  5061. // handle parent relative targeting "^.^.^"
  5062. var relativeMatch = /^(\^(?:\.\^)*)$/;
  5063. if (relativeMatch.exec(uiViewContextAnchor)) {
  5064. var anchor = uiViewContextAnchor.split(".").reduce((function (anchor, x) { return anchor.parent; }), context);
  5065. uiViewContextAnchor = anchor.name;
  5066. }
  5067. return { uiViewName: uiViewName, uiViewContextAnchor: uiViewContextAnchor };
  5068. };
  5069. return ViewService;
  5070. }());
  5071. exports.ViewService = ViewService;
  5072. /***/ },
  5073. /* 38 */
  5074. /***/ function(module, exports, __webpack_require__) {
  5075. /** @module state */ /** for typedoc */
  5076. "use strict";
  5077. var stateMatcher_1 = __webpack_require__(39);
  5078. var stateBuilder_1 = __webpack_require__(40);
  5079. var stateQueueManager_1 = __webpack_require__(41);
  5080. var common_1 = __webpack_require__(3);
  5081. var StateRegistry = (function () {
  5082. function StateRegistry(urlMatcherFactory, urlRouterProvider) {
  5083. this.urlRouterProvider = urlRouterProvider;
  5084. this.states = {};
  5085. this.listeners = [];
  5086. this.matcher = new stateMatcher_1.StateMatcher(this.states);
  5087. this.builder = new stateBuilder_1.StateBuilder(this.matcher, urlMatcherFactory);
  5088. this.stateQueue = new stateQueueManager_1.StateQueueManager(this.states, this.builder, urlRouterProvider, this.listeners);
  5089. var rootStateDef = {
  5090. name: '',
  5091. url: '^',
  5092. views: null,
  5093. params: {
  5094. '#': { value: null, type: 'hash', dynamic: true }
  5095. },
  5096. abstract: true
  5097. };
  5098. var _root = this._root = this.stateQueue.register(rootStateDef);
  5099. _root.navigable = null;
  5100. }
  5101. /**
  5102. * Listen for a State Registry events
  5103. *
  5104. * Adds a callback that is invoked when states are registered or deregistered with the StateRegistry.
  5105. *
  5106. * @example
  5107. * ```js
  5108. *
  5109. * let allStates = registry.get();
  5110. *
  5111. * // Later, invoke deregisterFn() to remove the listener
  5112. * let deregisterFn = registry.onStatesChanged((event, states) => {
  5113. * switch(event) {
  5114. * case: 'registered':
  5115. * states.forEach(state => allStates.push(state));
  5116. * break;
  5117. * case: 'deregistered':
  5118. * states.forEach(state => {
  5119. * let idx = allStates.indexOf(state);
  5120. * if (idx !== -1) allStates.splice(idx, 1);
  5121. * });
  5122. * break;
  5123. * }
  5124. * });
  5125. * ```
  5126. *
  5127. * @param listener a callback function invoked when the registered states changes.
  5128. * The function receives two parameters, `event` and `state`.
  5129. * See [[StateRegistryListener]]
  5130. * @return a function that deregisters the listener
  5131. */
  5132. StateRegistry.prototype.onStatesChanged = function (listener) {
  5133. this.listeners.push(listener);
  5134. return function deregisterListener() {
  5135. common_1.removeFrom(this.listeners)(listener);
  5136. }.bind(this);
  5137. };
  5138. /**
  5139. * Gets the implicit root state
  5140. *
  5141. * Gets the root of the state tree.
  5142. * The root state is implicitly created by UI-Router.
  5143. * Note: this returns the internal [[State]] representation, not a [[StateDeclaration]]
  5144. *
  5145. * @return the root [[State]]
  5146. */
  5147. StateRegistry.prototype.root = function () {
  5148. return this._root;
  5149. };
  5150. /**
  5151. * Adds a state to the registry
  5152. *
  5153. * Registers a [[StateDefinition]] or queues it for registration.
  5154. *
  5155. * Note: a state will be queued if the state's parent isn't yet registered.
  5156. * It will also be queued if the queue is not yet in [[StateQueueManager.autoFlush]] mode.
  5157. *
  5158. * @param stateDefinition the definition of the state to register.
  5159. * @returns the internal [[State]] object.
  5160. * If the state was successfully registered, then the object is fully built (See: [[StateBuilder]]).
  5161. * If the state was only queued, then the object is not fully built.
  5162. */
  5163. StateRegistry.prototype.register = function (stateDefinition) {
  5164. return this.stateQueue.register(stateDefinition);
  5165. };
  5166. /** @hidden */
  5167. StateRegistry.prototype._deregisterTree = function (state) {
  5168. var _this = this;
  5169. var all = this.get().map(function (s) { return s.$$state(); });
  5170. var getChildren = function (states) {
  5171. var children = all.filter(function (s) { return states.indexOf(s.parent) !== -1; });
  5172. return children.length === 0 ? children : children.concat(getChildren(children));
  5173. };
  5174. var children = getChildren([state]);
  5175. var deregistered = [state].concat(children).reverse();
  5176. deregistered.forEach(function (state) {
  5177. _this.urlRouterProvider.removeRule(state._urlRule);
  5178. delete _this.states[state.name];
  5179. });
  5180. return deregistered;
  5181. };
  5182. /**
  5183. * Removes a state from the registry
  5184. *
  5185. * This removes a state from the registry.
  5186. * If the state has children, they are are also removed from the registry.
  5187. *
  5188. * @param stateOrName the state's name or object representation
  5189. * @returns {State[]} a list of removed states
  5190. */
  5191. StateRegistry.prototype.deregister = function (stateOrName) {
  5192. var _state = this.get(stateOrName);
  5193. if (!_state)
  5194. throw new Error("Can't deregister state; not found: " + stateOrName);
  5195. var deregisteredStates = this._deregisterTree(_state.$$state());
  5196. this.listeners.forEach(function (listener) { return listener("deregistered", deregisteredStates.map(function (s) { return s.self; })); });
  5197. return deregisteredStates;
  5198. };
  5199. StateRegistry.prototype.get = function (stateOrName, base) {
  5200. var _this = this;
  5201. if (arguments.length === 0)
  5202. return Object.keys(this.states).map(function (name) { return _this.states[name].self; });
  5203. var found = this.matcher.find(stateOrName, base);
  5204. return found && found.self || null;
  5205. };
  5206. StateRegistry.prototype.decorator = function (name, func) {
  5207. return this.builder.builder(name, func);
  5208. };
  5209. return StateRegistry;
  5210. }());
  5211. exports.StateRegistry = StateRegistry;
  5212. /***/ },
  5213. /* 39 */
  5214. /***/ function(module, exports, __webpack_require__) {
  5215. "use strict";
  5216. /** @module state */ /** for typedoc */
  5217. var predicates_1 = __webpack_require__(4);
  5218. var glob_1 = __webpack_require__(7);
  5219. var common_1 = __webpack_require__(3);
  5220. var StateMatcher = (function () {
  5221. function StateMatcher(_states) {
  5222. this._states = _states;
  5223. }
  5224. StateMatcher.prototype.isRelative = function (stateName) {
  5225. stateName = stateName || "";
  5226. return stateName.indexOf(".") === 0 || stateName.indexOf("^") === 0;
  5227. };
  5228. StateMatcher.prototype.find = function (stateOrName, base) {
  5229. if (!stateOrName && stateOrName !== "")
  5230. return undefined;
  5231. var isStr = predicates_1.isString(stateOrName);
  5232. var name = isStr ? stateOrName : stateOrName.name;
  5233. if (this.isRelative(name))
  5234. name = this.resolvePath(name, base);
  5235. var state = this._states[name];
  5236. if (state && (isStr || (!isStr && (state === stateOrName || state.self === stateOrName)))) {
  5237. return state;
  5238. }
  5239. else if (isStr) {
  5240. var matches = common_1.values(this._states)
  5241. .filter(function (state) { return new glob_1.Glob(state.name).matches(name); });
  5242. if (matches.length > 1) {
  5243. console.log("stateMatcher.find: Found multiple matches for " + name + " using glob: ", matches.map(function (match) { return match.name; }));
  5244. }
  5245. return matches[0];
  5246. }
  5247. return undefined;
  5248. };
  5249. StateMatcher.prototype.resolvePath = function (name, base) {
  5250. if (!base)
  5251. throw new Error("No reference point given for path '" + name + "'");
  5252. var baseState = this.find(base);
  5253. var splitName = name.split("."), i = 0, pathLength = splitName.length, current = baseState;
  5254. for (; i < pathLength; i++) {
  5255. if (splitName[i] === "" && i === 0) {
  5256. current = baseState;
  5257. continue;
  5258. }
  5259. if (splitName[i] === "^") {
  5260. if (!current.parent)
  5261. throw new Error("Path '" + name + "' not valid for state '" + baseState.name + "'");
  5262. current = current.parent;
  5263. continue;
  5264. }
  5265. break;
  5266. }
  5267. var relName = splitName.slice(i).join(".");
  5268. return current.name + (current.name && relName ? "." : "") + relName;
  5269. };
  5270. return StateMatcher;
  5271. }());
  5272. exports.StateMatcher = StateMatcher;
  5273. /***/ },
  5274. /* 40 */
  5275. /***/ function(module, exports, __webpack_require__) {
  5276. "use strict";
  5277. /** @module state */ /** for typedoc */
  5278. var common_1 = __webpack_require__(3);
  5279. var predicates_1 = __webpack_require__(4);
  5280. var strings_1 = __webpack_require__(9);
  5281. var hof_1 = __webpack_require__(5);
  5282. var param_1 = __webpack_require__(22);
  5283. var resolvable_1 = __webpack_require__(19);
  5284. var coreservices_1 = __webpack_require__(6);
  5285. var parseUrl = function (url) {
  5286. if (!predicates_1.isString(url))
  5287. return false;
  5288. var root = url.charAt(0) === '^';
  5289. return { val: root ? url.substring(1) : url, root: root };
  5290. };
  5291. function nameBuilder(state) {
  5292. if (state.lazyLoad)
  5293. state.name = state.self.name + ".**";
  5294. return state.name;
  5295. }
  5296. function selfBuilder(state) {
  5297. state.self.$$state = function () { return state; };
  5298. return state.self;
  5299. }
  5300. function dataBuilder(state) {
  5301. if (state.parent && state.parent.data) {
  5302. state.data = state.self.data = common_1.inherit(state.parent.data, state.data);
  5303. }
  5304. return state.data;
  5305. }
  5306. var getUrlBuilder = function ($urlMatcherFactoryProvider, root) {
  5307. return function urlBuilder(state) {
  5308. var stateDec = state;
  5309. if (stateDec && stateDec.url && stateDec.lazyLoad) {
  5310. stateDec.url += "{remainder:any}"; // match any path (.*)
  5311. }
  5312. var parsed = parseUrl(stateDec.url), parent = state.parent;
  5313. var url = !parsed ? stateDec.url : $urlMatcherFactoryProvider.compile(parsed.val, {
  5314. params: state.params || {},
  5315. paramMap: function (paramConfig, isSearch) {
  5316. if (stateDec.reloadOnSearch === false && isSearch)
  5317. paramConfig = common_1.extend(paramConfig || {}, { dynamic: true });
  5318. return paramConfig;
  5319. }
  5320. });
  5321. if (!url)
  5322. return null;
  5323. if (!$urlMatcherFactoryProvider.isMatcher(url))
  5324. throw new Error("Invalid url '" + url + "' in state '" + state + "'");
  5325. return (parsed && parsed.root) ? url : ((parent && parent.navigable) || root()).url.append(url);
  5326. };
  5327. };
  5328. var getNavigableBuilder = function (isRoot) {
  5329. return function navigableBuilder(state) {
  5330. return !isRoot(state) && state.url ? state : (state.parent ? state.parent.navigable : null);
  5331. };
  5332. };
  5333. var getParamsBuilder = function (paramTypes) {
  5334. return function paramsBuilder(state) {
  5335. var makeConfigParam = function (config, id) { return param_1.Param.fromConfig(id, null, config, paramTypes); };
  5336. var urlParams = (state.url && state.url.parameters({ inherit: false })) || [];
  5337. var nonUrlParams = common_1.values(common_1.mapObj(common_1.omit(state.params || {}, urlParams.map(hof_1.prop('id'))), makeConfigParam));
  5338. return urlParams.concat(nonUrlParams).map(function (p) { return [p.id, p]; }).reduce(common_1.applyPairs, {});
  5339. };
  5340. };
  5341. function pathBuilder(state) {
  5342. return state.parent ? state.parent.path.concat(state) : [state];
  5343. }
  5344. function includesBuilder(state) {
  5345. var includes = state.parent ? common_1.extend({}, state.parent.includes) : {};
  5346. includes[state.name] = true;
  5347. return includes;
  5348. }
  5349. /**
  5350. * This is a [[StateBuilder.builder]] function for the `resolve:` block on a [[StateDeclaration]].
  5351. *
  5352. * When the [[StateBuilder]] builds a [[State]] object from a raw [[StateDeclaration]], this builder
  5353. * validates the `resolve` property and converts it to a [[Resolvable]] array.
  5354. *
  5355. * resolve: input value can be:
  5356. *
  5357. * {
  5358. * // analyzed but not injected
  5359. * myFooResolve: function() { return "myFooData"; },
  5360. *
  5361. * // function.toString() parsed, "DependencyName" dep as string (not min-safe)
  5362. * myBarResolve: function(DependencyName) { return DependencyName.fetchSomethingAsPromise() },
  5363. *
  5364. * // Array split; "DependencyName" dep as string
  5365. * myBazResolve: [ "DependencyName", function(dep) { return dep.fetchSomethingAsPromise() },
  5366. *
  5367. * // Array split; DependencyType dep as token (compared using ===)
  5368. * myQuxResolve: [ DependencyType, function(dep) { return dep.fetchSometingAsPromise() },
  5369. *
  5370. * // val.$inject used as deps
  5371. * // where:
  5372. * // corgeResolve.$inject = ["DependencyName"];
  5373. * // function corgeResolve(dep) { dep.fetchSometingAsPromise() }
  5374. * // then "DependencyName" dep as string
  5375. * myCorgeResolve: corgeResolve,
  5376. *
  5377. * // inject service by name
  5378. * // When a string is found, desugar creating a resolve that injects the named service
  5379. * myGraultResolve: "SomeService"
  5380. * }
  5381. *
  5382. * or:
  5383. *
  5384. * [
  5385. * new Resolvable("myFooResolve", function() { return "myFooData" }),
  5386. * new Resolvable("myBarResolve", function(dep) { return dep.fetchSomethingAsPromise() }, [ "DependencyName" ]),
  5387. * { provide: "myBazResolve", useFactory: function(dep) { dep.fetchSomethingAsPromise() }, deps: [ "DependencyName" ] }
  5388. * ]
  5389. */
  5390. function resolvablesBuilder(state) {
  5391. /** convert resolve: {} and resolvePolicy: {} objects to an array of tuples */
  5392. var objects2Tuples = function (resolveObj, resolvePolicies) {
  5393. return Object.keys(resolveObj || {}).map(function (token) { return ({ token: token, val: resolveObj[token], deps: undefined, policy: resolvePolicies[token] }); });
  5394. };
  5395. /** fetch DI annotations from a function or ng1-style array */
  5396. var annotate = function (fn) {
  5397. return fn['$inject'] || coreservices_1.services.$injector.annotate(fn, coreservices_1.services.$injector.strictDi);
  5398. };
  5399. /** true if the object has both `token` and `resolveFn`, and is probably a [[ResolveLiteral]] */
  5400. var isResolveLiteral = function (obj) { return !!(obj.token && obj.resolveFn); };
  5401. /** true if the object looks like a provide literal, or a ng2 Provider */
  5402. var isLikeNg2Provider = function (obj) { return !!((obj.provide || obj.token) && (obj.useValue || obj.useFactory || obj.useExisting || obj.useClass)); };
  5403. /** true if the object looks like a tuple from obj2Tuples */
  5404. var isTupleFromObj = function (obj) { return !!(obj && obj.val && (predicates_1.isString(obj.val) || predicates_1.isArray(obj.val) || predicates_1.isFunction(obj.val))); };
  5405. /** extracts the token from a Provider or provide literal */
  5406. var token = function (p) { return p.provide || p.token; };
  5407. /** Given a literal resolve or provider object, returns a Resolvable */
  5408. var literal2Resolvable = hof_1.pattern([
  5409. [hof_1.prop('resolveFn'), function (p) { return new resolvable_1.Resolvable(token(p), p.resolveFn, p.deps, p.policy); }],
  5410. [hof_1.prop('useFactory'), function (p) { return new resolvable_1.Resolvable(token(p), p.useFactory, (p.deps || p.dependencies), p.policy); }],
  5411. [hof_1.prop('useClass'), function (p) { return new resolvable_1.Resolvable(token(p), function () { return new p.useClass(); }, [], p.policy); }],
  5412. [hof_1.prop('useValue'), function (p) { return new resolvable_1.Resolvable(token(p), function () { return p.useValue; }, [], p.policy, p.useValue); }],
  5413. [hof_1.prop('useExisting'), function (p) { return new resolvable_1.Resolvable(token(p), common_1.identity, [p.useExisting], p.policy); }],
  5414. ]);
  5415. var tuple2Resolvable = hof_1.pattern([
  5416. [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); }],
  5417. [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); }],
  5418. [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); }],
  5419. ]);
  5420. var item2Resolvable = hof_1.pattern([
  5421. [hof_1.is(resolvable_1.Resolvable), function (r) { return r; }],
  5422. [isResolveLiteral, literal2Resolvable],
  5423. [isLikeNg2Provider, literal2Resolvable],
  5424. [isTupleFromObj, tuple2Resolvable],
  5425. [hof_1.val(true), function (obj) { throw new Error("Invalid resolve value: " + strings_1.stringify(obj)); }]
  5426. ]);
  5427. // If resolveBlock is already an array, use it as-is.
  5428. // Otherwise, assume it's an object and convert to an Array of tuples
  5429. var decl = state.resolve;
  5430. var items = predicates_1.isArray(decl) ? decl : objects2Tuples(decl, state.resolvePolicy || {});
  5431. return items.map(item2Resolvable);
  5432. }
  5433. exports.resolvablesBuilder = resolvablesBuilder;
  5434. /**
  5435. * @internalapi A internal global service
  5436. *
  5437. * StateBuilder is a factory for the internal [[State]] objects.
  5438. *
  5439. * When you register a state with the [[StateRegistry]], you register a plain old javascript object which
  5440. * conforms to the [[StateDeclaration]] interface. This factory takes that object and builds the corresponding
  5441. * [[State]] object, which has an API and is used internally.
  5442. *
  5443. * Custom properties or API may be added to the internal [[State]] object by registering a decorator function
  5444. * using the [[builder]] method.
  5445. */
  5446. var StateBuilder = (function () {
  5447. function StateBuilder(matcher, $urlMatcherFactoryProvider) {
  5448. this.matcher = matcher;
  5449. var self = this;
  5450. var root = function () { return matcher.find(""); };
  5451. var isRoot = function (state) { return state.name === ""; };
  5452. function parentBuilder(state) {
  5453. if (isRoot(state))
  5454. return null;
  5455. return matcher.find(self.parentName(state)) || root();
  5456. }
  5457. this.builders = {
  5458. name: [nameBuilder],
  5459. self: [selfBuilder],
  5460. parent: [parentBuilder],
  5461. data: [dataBuilder],
  5462. // Build a URLMatcher if necessary, either via a relative or absolute URL
  5463. url: [getUrlBuilder($urlMatcherFactoryProvider, root)],
  5464. // Keep track of the closest ancestor state that has a URL (i.e. is navigable)
  5465. navigable: [getNavigableBuilder(isRoot)],
  5466. params: [getParamsBuilder($urlMatcherFactoryProvider.paramTypes)],
  5467. // Each framework-specific ui-router implementation should define its own `views` builder
  5468. // e.g., src/ng1/statebuilders/views.ts
  5469. views: [],
  5470. // Keep a full path from the root down to this state as this is needed for state activation.
  5471. path: [pathBuilder],
  5472. // Speed up $state.includes() as it's used a lot
  5473. includes: [includesBuilder],
  5474. resolvables: [resolvablesBuilder]
  5475. };
  5476. }
  5477. /**
  5478. * Registers a [[BuilderFunction]] for a specific [[State]] property (e.g., `parent`, `url`, or `path`).
  5479. * More than one BuilderFunction can be registered for a given property.
  5480. *
  5481. * The BuilderFunction(s) will be used to define the property on any subsequently built [[State]] objects.
  5482. *
  5483. * @param name The name of the State property being registered for.
  5484. * @param fn The BuilderFunction which will be used to build the State property
  5485. * @returns a function which deregisters the BuilderFunction
  5486. */
  5487. StateBuilder.prototype.builder = function (name, fn) {
  5488. var builders = this.builders;
  5489. var array = builders[name] || [];
  5490. // Backwards compat: if only one builder exists, return it, else return whole arary.
  5491. if (predicates_1.isString(name) && !predicates_1.isDefined(fn))
  5492. return array.length > 1 ? array : array[0];
  5493. if (!predicates_1.isString(name) || !predicates_1.isFunction(fn))
  5494. return;
  5495. builders[name] = array;
  5496. builders[name].push(fn);
  5497. return function () { return builders[name].splice(builders[name].indexOf(fn, 1)) && null; };
  5498. };
  5499. /**
  5500. * Builds all of the properties on an essentially blank State object, returning a State object which has all its
  5501. * properties and API built.
  5502. *
  5503. * @param state an uninitialized State object
  5504. * @returns the built State object
  5505. */
  5506. StateBuilder.prototype.build = function (state) {
  5507. var _a = this, matcher = _a.matcher, builders = _a.builders;
  5508. var parent = this.parentName(state);
  5509. if (parent && !matcher.find(parent))
  5510. return null;
  5511. for (var key in builders) {
  5512. if (!builders.hasOwnProperty(key))
  5513. continue;
  5514. var chain = builders[key].reduce(function (parentFn, step) { return function (_state) { return step(_state, parentFn); }; }, common_1.noop);
  5515. state[key] = chain(state);
  5516. }
  5517. return state;
  5518. };
  5519. StateBuilder.prototype.parentName = function (state) {
  5520. var name = state.name || "";
  5521. var segments = name.split('.');
  5522. if (segments.length > 1) {
  5523. if (state.parent) {
  5524. throw new Error("States that specify the 'parent:' property should not have a '.' in their name (" + name + ")");
  5525. }
  5526. var lastSegment = segments.pop();
  5527. if (lastSegment === '**')
  5528. segments.pop();
  5529. return segments.join(".");
  5530. }
  5531. if (!state.parent)
  5532. return "";
  5533. return predicates_1.isString(state.parent) ? state.parent : state.parent.name;
  5534. };
  5535. StateBuilder.prototype.name = function (state) {
  5536. var name = state.name;
  5537. if (name.indexOf('.') !== -1 || !state.parent)
  5538. return name;
  5539. var parentName = predicates_1.isString(state.parent) ? state.parent : state.parent.name;
  5540. return parentName ? parentName + "." + name : name;
  5541. };
  5542. return StateBuilder;
  5543. }());
  5544. exports.StateBuilder = StateBuilder;
  5545. /***/ },
  5546. /* 41 */
  5547. /***/ function(module, exports, __webpack_require__) {
  5548. "use strict";
  5549. /** @module state */ /** for typedoc */
  5550. var common_1 = __webpack_require__(3);
  5551. var predicates_1 = __webpack_require__(4);
  5552. var stateObject_1 = __webpack_require__(42);
  5553. var StateQueueManager = (function () {
  5554. function StateQueueManager(states, builder, $urlRouterProvider, listeners) {
  5555. this.states = states;
  5556. this.builder = builder;
  5557. this.$urlRouterProvider = $urlRouterProvider;
  5558. this.listeners = listeners;
  5559. this.queue = [];
  5560. }
  5561. StateQueueManager.prototype.register = function (config) {
  5562. var _a = this, states = _a.states, queue = _a.queue, $state = _a.$state;
  5563. // Wrap a new object around the state so we can store our private details easily.
  5564. // @TODO: state = new State(extend({}, config, { ... }))
  5565. var state = common_1.inherit(new stateObject_1.State(), common_1.extend({}, config, {
  5566. self: config,
  5567. resolve: config.resolve || [],
  5568. toString: function () { return config.name; }
  5569. }));
  5570. if (!predicates_1.isString(state.name))
  5571. throw new Error("State must have a valid name");
  5572. if (states.hasOwnProperty(state.name) || common_1.pluck(queue, 'name').indexOf(state.name) !== -1)
  5573. throw new Error("State '" + state.name + "' is already defined");
  5574. queue.push(state);
  5575. if (this.$state) {
  5576. this.flush($state);
  5577. }
  5578. return state;
  5579. };
  5580. StateQueueManager.prototype.flush = function ($state) {
  5581. var _a = this, queue = _a.queue, states = _a.states, builder = _a.builder;
  5582. var registered = [], // states that got registered
  5583. orphans = [], // states that dodn't yet have a parent registered
  5584. previousQueueLength = {}; // keep track of how long the queue when an orphan was first encountered
  5585. while (queue.length > 0) {
  5586. var state = queue.shift();
  5587. var result = builder.build(state);
  5588. var orphanIdx = orphans.indexOf(state);
  5589. if (result) {
  5590. if (states.hasOwnProperty(state.name))
  5591. throw new Error("State '" + name + "' is already defined");
  5592. states[state.name] = state;
  5593. this.attachRoute($state, state);
  5594. if (orphanIdx >= 0)
  5595. orphans.splice(orphanIdx, 1);
  5596. registered.push(state);
  5597. continue;
  5598. }
  5599. var prev = previousQueueLength[state.name];
  5600. previousQueueLength[state.name] = queue.length;
  5601. if (orphanIdx >= 0 && prev === queue.length) {
  5602. // Wait until two consecutive iterations where no additional states were dequeued successfully.
  5603. // throw new Error(`Cannot register orphaned state '${state.name}'`);
  5604. queue.push(state);
  5605. return states;
  5606. }
  5607. else if (orphanIdx < 0) {
  5608. orphans.push(state);
  5609. }
  5610. queue.push(state);
  5611. }
  5612. if (registered.length) {
  5613. this.listeners.forEach(function (listener) { return listener("registered", registered.map(function (s) { return s.self; })); });
  5614. }
  5615. return states;
  5616. };
  5617. StateQueueManager.prototype.autoFlush = function ($state) {
  5618. this.$state = $state;
  5619. this.flush($state);
  5620. };
  5621. StateQueueManager.prototype.attachRoute = function ($state, state) {
  5622. var $urlRouterProvider = this.$urlRouterProvider;
  5623. if (state.abstract || !state.url)
  5624. return;
  5625. $urlRouterProvider.when(state.url, ['$match', '$stateParams', function ($match, $stateParams) {
  5626. if ($state.$current.navigable !== state || !common_1.equalForKeys($match, $stateParams)) {
  5627. $state.transitionTo(state, $match, { inherit: true, source: "url" });
  5628. }
  5629. }], function (rule) { return state._urlRule = rule; });
  5630. };
  5631. return StateQueueManager;
  5632. }());
  5633. exports.StateQueueManager = StateQueueManager;
  5634. /***/ },
  5635. /* 42 */
  5636. /***/ function(module, exports, __webpack_require__) {
  5637. /** @module state */ /** for typedoc */
  5638. "use strict";
  5639. var common_1 = __webpack_require__(3);
  5640. var hof_1 = __webpack_require__(5);
  5641. /**
  5642. * @ngdoc object
  5643. * @name ui.router.state.type:State
  5644. *
  5645. * @description
  5646. * Definition object for states. Includes methods for manipulating the state heirarchy.
  5647. *
  5648. * @param {Object} config A configuration object hash that includes the results of user-supplied
  5649. * values, as well as values from `StateBuilder`.
  5650. *
  5651. * @returns {Object} Returns a new `State` object.
  5652. */
  5653. var State = (function () {
  5654. function State(config) {
  5655. common_1.extend(this, config);
  5656. // Object.freeze(this);
  5657. }
  5658. /**
  5659. * @ngdoc function
  5660. * @name ui.router.state.type:State#is
  5661. * @methodOf ui.router.state.type:State
  5662. *
  5663. * @description
  5664. * Compares the identity of the state against the passed value, which is either an object
  5665. * reference to the actual `State` instance, the original definition object passed to
  5666. * `$stateProvider.state()`, or the fully-qualified name.
  5667. *
  5668. * @param {Object} ref Can be one of (a) a `State` instance, (b) an object that was passed
  5669. * into `$stateProvider.state()`, (c) the fully-qualified name of a state as a string.
  5670. * @returns {boolean} Returns `true` if `ref` matches the current `State` instance.
  5671. */
  5672. State.prototype.is = function (ref) {
  5673. return this === ref || this.self === ref || this.fqn() === ref;
  5674. };
  5675. /**
  5676. * @ngdoc function
  5677. * @name ui.router.state.type:State#fqn
  5678. * @methodOf ui.router.state.type:State
  5679. *
  5680. * @description
  5681. * Returns the fully-qualified name of the state, based on its current position in the tree.
  5682. *
  5683. * @returns {string} Returns a dot-separated name of the state.
  5684. */
  5685. State.prototype.fqn = function () {
  5686. if (!this.parent || !(this.parent instanceof this.constructor))
  5687. return this.name;
  5688. var name = this.parent.fqn();
  5689. return name ? name + "." + this.name : this.name;
  5690. };
  5691. /**
  5692. * @ngdoc function
  5693. * @name ui.router.state.type:State#root
  5694. * @methodOf ui.router.state.type:State
  5695. *
  5696. * @description
  5697. * Returns the root node of this state's tree.
  5698. *
  5699. * @returns {State} The root of this state's tree.
  5700. */
  5701. State.prototype.root = function () {
  5702. return this.parent && this.parent.root() || this;
  5703. };
  5704. State.prototype.parameters = function (opts) {
  5705. opts = common_1.defaults(opts, { inherit: true });
  5706. var inherited = opts.inherit && this.parent && this.parent.parameters() || [];
  5707. return inherited.concat(common_1.values(this.params));
  5708. };
  5709. State.prototype.parameter = function (id, opts) {
  5710. if (opts === void 0) { opts = {}; }
  5711. return (this.url && this.url.parameter(id, opts) ||
  5712. common_1.find(common_1.values(this.params), hof_1.propEq('id', id)) ||
  5713. opts.inherit && this.parent && this.parent.parameter(id));
  5714. };
  5715. State.prototype.toString = function () {
  5716. return this.fqn();
  5717. };
  5718. return State;
  5719. }());
  5720. exports.State = State;
  5721. /***/ },
  5722. /* 43 */
  5723. /***/ function(module, exports, __webpack_require__) {
  5724. "use strict";
  5725. /** @module state */ /** */
  5726. var common_1 = __webpack_require__(3);
  5727. var predicates_1 = __webpack_require__(4);
  5728. var queue_1 = __webpack_require__(8);
  5729. var coreservices_1 = __webpack_require__(6);
  5730. var pathFactory_1 = __webpack_require__(20);
  5731. var node_1 = __webpack_require__(21);
  5732. var transitionService_1 = __webpack_require__(30);
  5733. var rejectFactory_1 = __webpack_require__(10);
  5734. var targetState_1 = __webpack_require__(14);
  5735. var param_1 = __webpack_require__(22);
  5736. var glob_1 = __webpack_require__(7);
  5737. var common_2 = __webpack_require__(3);
  5738. var common_3 = __webpack_require__(3);
  5739. var resolveContext_1 = __webpack_require__(17);
  5740. var StateService = (function () {
  5741. /** @hidden */
  5742. function StateService(router) {
  5743. this.router = router;
  5744. this.invalidCallbacks = [];
  5745. /** @hidden */
  5746. this._defaultErrorHandler = function $defaultErrorHandler($error$) {
  5747. if ($error$ instanceof Error && $error$.stack) {
  5748. console.error($error$);
  5749. console.error($error$.stack);
  5750. }
  5751. else if ($error$ instanceof rejectFactory_1.Rejection) {
  5752. console.error($error$.toString());
  5753. if ($error$.detail && $error$.detail.stack)
  5754. console.error($error$.detail.stack);
  5755. }
  5756. else {
  5757. console.error($error$);
  5758. }
  5759. };
  5760. var getters = ['current', '$current', 'params', 'transition'];
  5761. var boundFns = Object.keys(StateService.prototype).filter(function (key) { return getters.indexOf(key) === -1; });
  5762. common_3.bindFunctions(StateService.prototype, this, this, boundFns);
  5763. }
  5764. Object.defineProperty(StateService.prototype, "transition", {
  5765. get: function () { return this.router.globals.transition; },
  5766. enumerable: true,
  5767. configurable: true
  5768. });
  5769. Object.defineProperty(StateService.prototype, "params", {
  5770. get: function () { return this.router.globals.params; },
  5771. enumerable: true,
  5772. configurable: true
  5773. });
  5774. Object.defineProperty(StateService.prototype, "current", {
  5775. get: function () { return this.router.globals.current; },
  5776. enumerable: true,
  5777. configurable: true
  5778. });
  5779. Object.defineProperty(StateService.prototype, "$current", {
  5780. get: function () { return this.router.globals.$current; },
  5781. enumerable: true,
  5782. configurable: true
  5783. });
  5784. /**
  5785. * Handler for when [[transitionTo]] is called with an invalid state.
  5786. *
  5787. * Invokes the [[onInvalid]] callbacks, in natural order.
  5788. * Each callback's return value is checked in sequence until one of them returns an instance of TargetState.
  5789. * The results of the callbacks are wrapped in $q.when(), so the callbacks may return promises.
  5790. *
  5791. * If a callback returns an TargetState, then it is used as arguments to $state.transitionTo() and the result returned.
  5792. */
  5793. StateService.prototype._handleInvalidTargetState = function (fromPath, toState) {
  5794. var _this = this;
  5795. var fromState = pathFactory_1.PathFactory.makeTargetState(fromPath);
  5796. var globals = this.router.globals;
  5797. var latestThing = function () { return globals.transitionHistory.peekTail(); };
  5798. var latest = latestThing();
  5799. var callbackQueue = new queue_1.Queue(this.invalidCallbacks.slice());
  5800. var injector = new resolveContext_1.ResolveContext(fromPath).injector();
  5801. var checkForRedirect = function (result) {
  5802. if (!(result instanceof targetState_1.TargetState)) {
  5803. return;
  5804. }
  5805. var target = result;
  5806. // Recreate the TargetState, in case the state is now defined.
  5807. target = _this.target(target.identifier(), target.params(), target.options());
  5808. if (!target.valid())
  5809. return rejectFactory_1.Rejection.invalid(target.error()).toPromise();
  5810. if (latestThing() !== latest)
  5811. return rejectFactory_1.Rejection.superseded().toPromise();
  5812. return _this.transitionTo(target.identifier(), target.params(), target.options());
  5813. };
  5814. function invokeNextCallback() {
  5815. var nextCallback = callbackQueue.dequeue();
  5816. if (nextCallback === undefined)
  5817. return rejectFactory_1.Rejection.invalid(toState.error()).toPromise();
  5818. var callbackResult = coreservices_1.services.$q.when(nextCallback(toState, fromState, injector));
  5819. return callbackResult.then(checkForRedirect).then(function (result) { return result || invokeNextCallback(); });
  5820. }
  5821. return invokeNextCallback();
  5822. };
  5823. /**
  5824. * Registers an Invalid State handler
  5825. *
  5826. * Registers a [[OnInvalidCallback]] function to be invoked when [[StateService.transitionTo]]
  5827. * has been called with an invalid state reference parameter
  5828. *
  5829. * Example:
  5830. * ```js
  5831. * stateService.onInvalid(function(to, from, injector) {
  5832. * if (to.name() === 'foo') {
  5833. * let lazyLoader = injector.get('LazyLoadService');
  5834. * return lazyLoader.load('foo')
  5835. * .then(() => stateService.target('foo'));
  5836. * }
  5837. * });
  5838. * ```
  5839. *
  5840. * @param {function} callback invoked when the toState is invalid
  5841. * This function receives the (invalid) toState, the fromState, and an injector.
  5842. * The function may optionally return a [[TargetState]] or a Promise for a TargetState.
  5843. * If one is returned, it is treated as a redirect.
  5844. *
  5845. * @returns a function which deregisters the callback
  5846. */
  5847. StateService.prototype.onInvalid = function (callback) {
  5848. this.invalidCallbacks.push(callback);
  5849. return function deregisterListener() {
  5850. common_1.removeFrom(this.invalidCallbacks)(callback);
  5851. }.bind(this);
  5852. };
  5853. /**
  5854. * @ngdoc function
  5855. * @name ui.router.state.$state#reload
  5856. * @methodOf ui.router.state.$state
  5857. *
  5858. * @description
  5859. * A method that force reloads the current state, or a partial state hierarchy. All resolves are re-resolved,
  5860. * controllers reinstantiated, and events re-fired.
  5861. *
  5862. * @example
  5863. * <pre>
  5864. * let app angular.module('app', ['ui.router']);
  5865. *
  5866. * app.controller('ctrl', function ($scope, $state) {
  5867. * $scope.reload = function(){
  5868. * $state.reload();
  5869. * }
  5870. * });
  5871. * </pre>
  5872. *
  5873. * `reload()` is just an alias for:
  5874. * <pre>
  5875. * $state.transitionTo($state.current, $stateParams, {
  5876. * reload: true, inherit: false, notify: true
  5877. * });
  5878. * </pre>
  5879. *
  5880. * @param {string=|object=} reloadState - A state name or a state object, which is the root of the resolves to be re-resolved.
  5881. * @example
  5882. * <pre>
  5883. * //assuming app application consists of 3 states: 'contacts', 'contacts.detail', 'contacts.detail.item'
  5884. * //and current state is 'contacts.detail.item'
  5885. * let app angular.module('app', ['ui.router']);
  5886. *
  5887. * app.controller('ctrl', function ($scope, $state) {
  5888. * $scope.reload = function(){
  5889. * //will reload 'contact.detail' and nested 'contact.detail.item' states
  5890. * $state.reload('contact.detail');
  5891. * }
  5892. * });
  5893. * </pre>
  5894. *
  5895. * @returns {promise} A promise representing the state of the new transition. See
  5896. * {@link ui.router.state.$state#methods_go $state.go}.
  5897. */
  5898. StateService.prototype.reload = function (reloadState) {
  5899. return this.transitionTo(this.current, this.params, {
  5900. reload: predicates_1.isDefined(reloadState) ? reloadState : true,
  5901. inherit: false,
  5902. notify: false
  5903. });
  5904. };
  5905. ;
  5906. /**
  5907. * @ngdoc function
  5908. * @name ui.router.state.$state#go
  5909. * @methodOf ui.router.state.$state
  5910. *
  5911. * @description
  5912. * Convenience method for transitioning to a new state. `$state.go` calls
  5913. * `$state.transitionTo` internally but automatically sets options to
  5914. * `{ location: true, inherit: true, relative: $state.$current, notify: true }`.
  5915. * This allows you to easily use an absolute or relative to path and specify
  5916. * only the parameters you'd like to update (while letting unspecified parameters
  5917. * inherit from the currently active ancestor states).
  5918. *
  5919. * @example
  5920. * <pre>
  5921. * let app = angular.module('app', ['ui.router']);
  5922. *
  5923. * app.controller('ctrl', function ($scope, $state) {
  5924. * $scope.changeState = function () {
  5925. * $state.go('contact.detail');
  5926. * };
  5927. * });
  5928. * </pre>
  5929. * <img src='../ngdoc_assets/StateGoExamples.png'/>
  5930. *
  5931. * @param {string|object} to Absolute state name, state object, or relative state path. Some examples:
  5932. *
  5933. * - `$state.go('contact.detail')` - will go to the `contact.detail` state
  5934. * - `$state.go('^')` - will go to a parent state
  5935. * - `$state.go('^.sibling')` - will go to a sibling state
  5936. * - `$state.go('.child.grandchild')` - will go to grandchild state
  5937. *
  5938. * @param {object=} params A map of the parameters that will be sent to the state,
  5939. * will populate $stateParams. Any parameters that are not specified will be inherited from currently
  5940. * defined parameters. This allows, for example, going to a sibling state that shares parameters
  5941. * specified in a parent state. Parameter inheritance only works between common ancestor states, I.e.
  5942. * transitioning to a sibling will get you the parameters for all parents, transitioning to a child
  5943. * will get you all current parameters, etc.
  5944. * @param {object=} options Options object. The options are:
  5945. *
  5946. * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false`
  5947. * will not. If string, must be `"replace"`, which will update url and also replace last history record.
  5948. * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url.
  5949. * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'),
  5950. * defines which state to be relative from.
  5951. * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events.
  5952. * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params
  5953. * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd
  5954. * use this when you want to force a reload when *everything* is the same, including search params.
  5955. *
  5956. * @returns {promise} A promise representing the state of the new transition.
  5957. *
  5958. * Possible success values:
  5959. *
  5960. * - $state.current
  5961. *
  5962. * <br/>Possible rejection values:
  5963. *
  5964. * - 'transition superseded' - when a newer transition has been started after this one
  5965. * - 'transition prevented' - when `event.preventDefault()` has been called in a `$stateChangeStart` listener
  5966. * - 'transition aborted' - when `event.preventDefault()` has been called in a `$stateNotFound` listener or
  5967. * when a `$stateNotFound` `event.retry` promise errors.
  5968. * - 'transition failed' - when a state has been unsuccessfully found after 2 tries.
  5969. * - *resolve error* - when an error has occurred with a `resolve`
  5970. *
  5971. */
  5972. StateService.prototype.go = function (to, params, options) {
  5973. var defautGoOpts = { relative: this.$current, inherit: true };
  5974. var transOpts = common_1.defaults(options, defautGoOpts, transitionService_1.defaultTransOpts);
  5975. return this.transitionTo(to, params, transOpts);
  5976. };
  5977. ;
  5978. /** Factory method for creating a TargetState */
  5979. StateService.prototype.target = function (identifier, params, options) {
  5980. if (options === void 0) { options = {}; }
  5981. // If we're reloading, find the state object to reload from
  5982. if (predicates_1.isObject(options.reload) && !options.reload.name)
  5983. throw new Error('Invalid reload state object');
  5984. var reg = this.router.stateRegistry;
  5985. options.reloadState = options.reload === true ? reg.root() : reg.matcher.find(options.reload, options.relative);
  5986. if (options.reload && !options.reloadState)
  5987. throw new Error("No such reload state '" + (predicates_1.isString(options.reload) ? options.reload : options.reload.name) + "'");
  5988. var stateDefinition = reg.matcher.find(identifier, options.relative);
  5989. return new targetState_1.TargetState(identifier, stateDefinition, params, options);
  5990. };
  5991. ;
  5992. /**
  5993. * @ngdoc function
  5994. * @name ui.router.state.$state#transitionTo
  5995. * @methodOf ui.router.state.$state
  5996. *
  5997. * @description
  5998. * Low-level method for transitioning to a new state. {@link ui.router.state.$state#methods_go $state.go}
  5999. * uses `transitionTo` internally. `$state.go` is recommended in most situations.
  6000. *
  6001. * @example
  6002. * <pre>
  6003. * let app = angular.module('app', ['ui.router']);
  6004. *
  6005. * app.controller('ctrl', function ($scope, $state) {
  6006. * $scope.changeState = function () {
  6007. * $state.transitionTo('contact.detail');
  6008. * };
  6009. * });
  6010. * </pre>
  6011. *
  6012. * @param {string|object} to State name or state object.
  6013. * @param {object=} toParams A map of the parameters that will be sent to the state,
  6014. * will populate $stateParams.
  6015. * @param {object=} options Options object. The options are:
  6016. *
  6017. * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false`
  6018. * will not. If string, must be `"replace"`, which will update url and also replace last history record.
  6019. * - **`inherit`** - {boolean=false}, If `true` will inherit url parameters from current url.
  6020. * - **`relative`** - {object=}, When transitioning with relative path (e.g '^'),
  6021. * defines which state to be relative from.
  6022. * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events.
  6023. * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params
  6024. * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd
  6025. * use this when you want to force a reload when *everything* is the same, including search params.
  6026. *
  6027. * @returns {promise} A promise representing the state of the new transition. See
  6028. * {@link ui.router.state.$state#methods_go $state.go}.
  6029. */
  6030. StateService.prototype.transitionTo = function (to, toParams, options) {
  6031. var _this = this;
  6032. if (toParams === void 0) { toParams = {}; }
  6033. if (options === void 0) { options = {}; }
  6034. var router = this.router;
  6035. var globals = router.globals;
  6036. var transHistory = globals.transitionHistory;
  6037. options = common_1.defaults(options, transitionService_1.defaultTransOpts);
  6038. options = common_1.extend(options, { current: transHistory.peekTail.bind(transHistory) });
  6039. var ref = this.target(to, toParams, options);
  6040. var latestSuccess = globals.successfulTransitions.peekTail();
  6041. var rootPath = function () { return [new node_1.PathNode(_this.router.stateRegistry.root())]; };
  6042. var currentPath = latestSuccess ? latestSuccess.treeChanges().to : rootPath();
  6043. if (!ref.exists())
  6044. return this._handleInvalidTargetState(currentPath, ref);
  6045. if (!ref.valid())
  6046. return common_1.silentRejection(ref.error());
  6047. /**
  6048. * Special handling for Ignored, Aborted, and Redirected transitions
  6049. *
  6050. * The semantics for the transition.run() promise and the StateService.transitionTo()
  6051. * promise differ. For instance, the run() promise may be rejected because it was
  6052. * IGNORED, but the transitionTo() promise is resolved because from the user perspective
  6053. * no error occurred. Likewise, the transition.run() promise may be rejected because of
  6054. * a Redirect, but the transitionTo() promise is chained to the new Transition's promise.
  6055. */
  6056. var rejectedTransitionHandler = function (transition) { return function (error) {
  6057. if (error instanceof rejectFactory_1.Rejection) {
  6058. if (error.type === rejectFactory_1.RejectType.IGNORED) {
  6059. // Consider ignored `Transition.run()` as a successful `transitionTo`
  6060. router.urlRouter.update();
  6061. return coreservices_1.services.$q.when(globals.current);
  6062. }
  6063. var detail = error.detail;
  6064. if (error.type === rejectFactory_1.RejectType.SUPERSEDED && error.redirected && detail instanceof targetState_1.TargetState) {
  6065. // If `Transition.run()` was redirected, allow the `transitionTo()` promise to resolve successfully
  6066. // by returning the promise for the new (redirect) `Transition.run()`.
  6067. var redirect = transition.redirect(detail);
  6068. return redirect.run().catch(rejectedTransitionHandler(redirect));
  6069. }
  6070. if (error.type === rejectFactory_1.RejectType.ABORTED) {
  6071. router.urlRouter.update();
  6072. }
  6073. }
  6074. var errorHandler = _this.defaultErrorHandler();
  6075. errorHandler(error);
  6076. return coreservices_1.services.$q.reject(error);
  6077. }; };
  6078. var transition = this.router.transitionService.create(currentPath, ref);
  6079. var transitionToPromise = transition.run().catch(rejectedTransitionHandler(transition));
  6080. common_1.silenceUncaughtInPromise(transitionToPromise); // issue #2676
  6081. // Return a promise for the transition, which also has the transition object on it.
  6082. return common_1.extend(transitionToPromise, { transition: transition });
  6083. };
  6084. ;
  6085. /**
  6086. * @ngdoc function
  6087. * @name ui.router.state.$state#is
  6088. * @methodOf ui.router.state.$state
  6089. *
  6090. * @description
  6091. * Similar to {@link ui.router.state.$state#methods_includes $state.includes},
  6092. * but only checks for the full state name. If params is supplied then it will be
  6093. * tested for strict equality against the current active params object, so all params
  6094. * must match with none missing and no extras.
  6095. *
  6096. * @example
  6097. * <pre>
  6098. * $state.$current.name = 'contacts.details.item';
  6099. *
  6100. * // absolute name
  6101. * $state.is('contact.details.item'); // returns true
  6102. * $state.is(contactDetailItemStateObject); // returns true
  6103. *
  6104. * // relative name (. and ^), typically from a template
  6105. * // E.g. from the 'contacts.details' template
  6106. * <div ng-class="{highlighted: $state.is('.item')}">Item</div>
  6107. * </pre>
  6108. *
  6109. * @param {string|object} stateOrName The state name (absolute or relative) or state object you'd like to check.
  6110. * @param {object=} params A param object, e.g. `{sectionId: section.id}`, that you'd like
  6111. * to test against the current active state.
  6112. * @param {object=} options An options object. The options are:
  6113. *
  6114. * - **`relative`** - {string|object} - If `stateOrName` is a relative state name and `options.relative` is set, .is will
  6115. * test relative to `options.relative` state (or name).
  6116. *
  6117. * @returns {boolean} Returns true if it is the state.
  6118. */
  6119. StateService.prototype.is = function (stateOrName, params, options) {
  6120. options = common_1.defaults(options, { relative: this.$current });
  6121. var state = this.router.stateRegistry.matcher.find(stateOrName, options.relative);
  6122. if (!predicates_1.isDefined(state))
  6123. return undefined;
  6124. if (this.$current !== state)
  6125. return false;
  6126. return predicates_1.isDefined(params) && params !== null ? param_1.Param.equals(state.parameters(), this.params, params) : true;
  6127. };
  6128. ;
  6129. /**
  6130. * @ngdoc function
  6131. * @name ui.router.state.$state#includes
  6132. * @methodOf ui.router.state.$state
  6133. *
  6134. * @description
  6135. * A method to determine if the current active state is equal to or is the child of the
  6136. * state stateName. If any params are passed then they will be tested for a match as well.
  6137. * Not all the parameters need to be passed, just the ones you'd like to test for equality.
  6138. *
  6139. * @example
  6140. * Partial and relative names
  6141. * <pre>
  6142. * $state.$current.name = 'contacts.details.item';
  6143. *
  6144. * // Using partial names
  6145. * $state.includes("contacts"); // returns true
  6146. * $state.includes("contacts.details"); // returns true
  6147. * $state.includes("contacts.details.item"); // returns true
  6148. * $state.includes("contacts.list"); // returns false
  6149. * $state.includes("about"); // returns false
  6150. *
  6151. * // Using relative names (. and ^), typically from a template
  6152. * // E.g. from the 'contacts.details' template
  6153. * <div ng-class="{highlighted: $state.includes('.item')}">Item</div>
  6154. * </pre>
  6155. *
  6156. * Basic globbing patterns
  6157. * <pre>
  6158. * $state.$current.name = 'contacts.details.item.url';
  6159. *
  6160. * $state.includes("*.details.*.*"); // returns true
  6161. * $state.includes("*.details.**"); // returns true
  6162. * $state.includes("**.item.**"); // returns true
  6163. * $state.includes("*.details.item.url"); // returns true
  6164. * $state.includes("*.details.*.url"); // returns true
  6165. * $state.includes("*.details.*"); // returns false
  6166. * $state.includes("item.**"); // returns false
  6167. * </pre>
  6168. *
  6169. * @param {string|object} stateOrName A partial name, relative name, glob pattern,
  6170. * or state object to be searched for within the current state name.
  6171. * @param {object=} params A param object, e.g. `{sectionId: section.id}`,
  6172. * that you'd like to test against the current active state.
  6173. * @param {object=} options An options object. The options are:
  6174. *
  6175. * - **`relative`** - {string|object=} - If `stateOrName` is a relative state reference and `options.relative` is set,
  6176. * .includes will test relative to `options.relative` state (or name).
  6177. *
  6178. * @returns {boolean} Returns true if it does include the state
  6179. */
  6180. StateService.prototype.includes = function (stateOrName, params, options) {
  6181. options = common_1.defaults(options, { relative: this.$current });
  6182. var glob = predicates_1.isString(stateOrName) && glob_1.Glob.fromString(stateOrName);
  6183. if (glob) {
  6184. if (!glob.matches(this.$current.name))
  6185. return false;
  6186. stateOrName = this.$current.name;
  6187. }
  6188. var state = this.router.stateRegistry.matcher.find(stateOrName, options.relative), include = this.$current.includes;
  6189. if (!predicates_1.isDefined(state))
  6190. return undefined;
  6191. if (!predicates_1.isDefined(include[state.name]))
  6192. return false;
  6193. // @TODO Replace with Param.equals() ?
  6194. return params ? common_2.equalForKeys(param_1.Param.values(state.parameters(), params), this.params, Object.keys(params)) : true;
  6195. };
  6196. ;
  6197. /**
  6198. * @ngdoc function
  6199. * @name ui.router.state.$state#href
  6200. * @methodOf ui.router.state.$state
  6201. *
  6202. * @description
  6203. * A url generation method that returns the compiled url for the given state populated with the given params.
  6204. *
  6205. * @example
  6206. * <pre>
  6207. * expect($state.href("about.person", { person: "bob" })).toEqual("/about/bob");
  6208. * </pre>
  6209. *
  6210. * @param {string|object} stateOrName The state name or state object you'd like to generate a url from.
  6211. * @param {object=} params An object of parameter values to fill the state's required parameters.
  6212. * @param {object=} options Options object. The options are:
  6213. *
  6214. * - **`lossy`** - {boolean=true} - If true, and if there is no url associated with the state provided in the
  6215. * first parameter, then the constructed href url will be built from the first navigable ancestor (aka
  6216. * ancestor with a valid url).
  6217. * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url.
  6218. * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'),
  6219. * defines which state to be relative from.
  6220. * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
  6221. *
  6222. * @returns {string} compiled state url
  6223. */
  6224. StateService.prototype.href = function (stateOrName, params, options) {
  6225. var defaultHrefOpts = {
  6226. lossy: true,
  6227. inherit: true,
  6228. absolute: false,
  6229. relative: this.$current
  6230. };
  6231. options = common_1.defaults(options, defaultHrefOpts);
  6232. params = params || {};
  6233. var state = this.router.stateRegistry.matcher.find(stateOrName, options.relative);
  6234. if (!predicates_1.isDefined(state))
  6235. return null;
  6236. if (options.inherit)
  6237. params = this.params.$inherit(params, this.$current, state);
  6238. var nav = (state && options.lossy) ? state.navigable : state;
  6239. if (!nav || nav.url === undefined || nav.url === null) {
  6240. return null;
  6241. }
  6242. return this.router.urlRouter.href(nav.url, param_1.Param.values(state.parameters(), params), {
  6243. absolute: options.absolute
  6244. });
  6245. };
  6246. ;
  6247. /**
  6248. * Sets or gets the default [[transitionTo]] error handler.
  6249. *
  6250. * The error handler is called when a [[Transition]] is rejected or when any error occurred during the Transition.
  6251. * This includes errors caused by resolves and transition hooks.
  6252. *
  6253. * Note:
  6254. * This handler does not receive certain Transition rejections.
  6255. * Redirected and Ignored Transitions are not considered to be errors by [[StateService.transitionTo]].
  6256. *
  6257. * The built-in default error handler logs the error to the console.
  6258. *
  6259. * You can provide your own custom handler.
  6260. *
  6261. * @example
  6262. * ```js
  6263. *
  6264. * stateService.defaultErrorHandler(function() {
  6265. * // Do not log transitionTo errors
  6266. * });
  6267. * ```
  6268. *
  6269. * @param handler a global error handler function
  6270. * @returns the current global error handler
  6271. */
  6272. StateService.prototype.defaultErrorHandler = function (handler) {
  6273. return this._defaultErrorHandler = handler || this._defaultErrorHandler;
  6274. };
  6275. StateService.prototype.get = function (stateOrName, base) {
  6276. var reg = this.router.stateRegistry;
  6277. if (arguments.length === 0)
  6278. return reg.get();
  6279. return reg.get(stateOrName, base || this.$current);
  6280. };
  6281. return StateService;
  6282. }());
  6283. exports.StateService = StateService;
  6284. /***/ },
  6285. /* 44 */
  6286. /***/ function(module, exports, __webpack_require__) {
  6287. "use strict";
  6288. /** @module core */ /** */
  6289. var stateParams_1 = __webpack_require__(45);
  6290. var queue_1 = __webpack_require__(8);
  6291. var common_1 = __webpack_require__(3);
  6292. /**
  6293. * Global mutable state
  6294. */
  6295. var Globals = (function () {
  6296. function Globals(transitionService) {
  6297. var _this = this;
  6298. this.params = new stateParams_1.StateParams();
  6299. this.transitionHistory = new queue_1.Queue([], 1);
  6300. this.successfulTransitions = new queue_1.Queue([], 1);
  6301. var beforeNewTransition = function ($transition$) {
  6302. _this.transition = $transition$;
  6303. _this.transitionHistory.enqueue($transition$);
  6304. var updateGlobalState = function () {
  6305. _this.successfulTransitions.enqueue($transition$);
  6306. _this.$current = $transition$.$to();
  6307. _this.current = _this.$current.self;
  6308. common_1.copy($transition$.params(), _this.params);
  6309. };
  6310. $transition$.onSuccess({}, updateGlobalState, { priority: 10000 });
  6311. var clearCurrentTransition = function () { if (_this.transition === $transition$)
  6312. _this.transition = null; };
  6313. $transition$.promise.then(clearCurrentTransition, clearCurrentTransition);
  6314. };
  6315. transitionService.onBefore({}, beforeNewTransition);
  6316. }
  6317. return Globals;
  6318. }());
  6319. exports.Globals = Globals;
  6320. /***/ },
  6321. /* 45 */
  6322. /***/ function(module, exports, __webpack_require__) {
  6323. "use strict";
  6324. /** @module params */ /** for typedoc */
  6325. var common_1 = __webpack_require__(3);
  6326. var StateParams = (function () {
  6327. function StateParams(params) {
  6328. if (params === void 0) { params = {}; }
  6329. common_1.extend(this, params);
  6330. }
  6331. /**
  6332. * Merges a set of parameters with all parameters inherited between the common parents of the
  6333. * current state and a given destination state.
  6334. *
  6335. * @param {Object} newParams The set of parameters which will be composited with inherited params.
  6336. * @param {Object} $current Internal definition of object representing the current state.
  6337. * @param {Object} $to Internal definition of object representing state to transition to.
  6338. */
  6339. StateParams.prototype.$inherit = function (newParams, $current, $to) {
  6340. var parents = common_1.ancestors($current, $to), parentParams, inherited = {}, inheritList = [];
  6341. for (var i in parents) {
  6342. if (!parents[i] || !parents[i].params)
  6343. continue;
  6344. parentParams = Object.keys(parents[i].params);
  6345. if (!parentParams.length)
  6346. continue;
  6347. for (var j in parentParams) {
  6348. if (inheritList.indexOf(parentParams[j]) >= 0)
  6349. continue;
  6350. inheritList.push(parentParams[j]);
  6351. inherited[parentParams[j]] = this[parentParams[j]];
  6352. }
  6353. }
  6354. return common_1.extend({}, inherited, newParams);
  6355. };
  6356. ;
  6357. return StateParams;
  6358. }());
  6359. exports.StateParams = StateParams;
  6360. /***/ },
  6361. /* 46 */
  6362. /***/ function(module, exports, __webpack_require__) {
  6363. "use strict";
  6364. function __export(m) {
  6365. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6366. }
  6367. /**
  6368. * This module contains code for State Parameters.
  6369. *
  6370. * See [[ParamDeclaration]]
  6371. * @module params
  6372. * @preferred doc
  6373. */
  6374. /** for typedoc */
  6375. __export(__webpack_require__(22));
  6376. __export(__webpack_require__(28));
  6377. __export(__webpack_require__(45));
  6378. __export(__webpack_require__(24));
  6379. /***/ },
  6380. /* 47 */
  6381. /***/ function(module, exports, __webpack_require__) {
  6382. "use strict";
  6383. function __export(m) {
  6384. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6385. }
  6386. /** @module path */ /** for typedoc */
  6387. __export(__webpack_require__(21));
  6388. __export(__webpack_require__(20));
  6389. /***/ },
  6390. /* 48 */
  6391. /***/ function(module, exports, __webpack_require__) {
  6392. "use strict";
  6393. function __export(m) {
  6394. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6395. }
  6396. /** @module resolve */ /** for typedoc */
  6397. __export(__webpack_require__(18));
  6398. __export(__webpack_require__(19));
  6399. __export(__webpack_require__(17));
  6400. /***/ },
  6401. /* 49 */
  6402. /***/ function(module, exports, __webpack_require__) {
  6403. "use strict";
  6404. function __export(m) {
  6405. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6406. }
  6407. /** @module state */ /** for typedoc */
  6408. __export(__webpack_require__(40));
  6409. __export(__webpack_require__(42));
  6410. __export(__webpack_require__(39));
  6411. __export(__webpack_require__(41));
  6412. __export(__webpack_require__(38));
  6413. __export(__webpack_require__(43));
  6414. __export(__webpack_require__(14));
  6415. /***/ },
  6416. /* 50 */
  6417. /***/ function(module, exports, __webpack_require__) {
  6418. "use strict";
  6419. function __export(m) {
  6420. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6421. }
  6422. /**
  6423. * This module contains APIs related to a Transition.
  6424. *
  6425. * See [[Transition]], [[$transitions]]
  6426. *
  6427. * @module transition
  6428. * @preferred
  6429. */
  6430. /** for typedoc */
  6431. __export(__webpack_require__(16));
  6432. __export(__webpack_require__(15));
  6433. __export(__webpack_require__(10));
  6434. __export(__webpack_require__(11));
  6435. __export(__webpack_require__(13));
  6436. __export(__webpack_require__(30));
  6437. /***/ },
  6438. /* 51 */
  6439. /***/ function(module, exports, __webpack_require__) {
  6440. "use strict";
  6441. function __export(m) {
  6442. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6443. }
  6444. /** @module url */ /** for typedoc */
  6445. __export(__webpack_require__(27));
  6446. __export(__webpack_require__(23));
  6447. __export(__webpack_require__(26));
  6448. __export(__webpack_require__(29));
  6449. /***/ },
  6450. /* 52 */
  6451. /***/ function(module, exports, __webpack_require__) {
  6452. "use strict";
  6453. function __export(m) {
  6454. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6455. }
  6456. /** @module view */ /** for typedoc */
  6457. __export(__webpack_require__(37));
  6458. /***/ },
  6459. /* 53 */
  6460. /***/ function(module, exports, __webpack_require__) {
  6461. /**
  6462. * # UI-Router for Angular 1
  6463. *
  6464. * - Provides an implementation for the [[CoreServices]] API, based on angular 1 services.
  6465. * - Also registers some services with the angular 1 injector.
  6466. * - Creates and bootstraps a new [[UIRouter]] object. Ties it to the the angular 1 lifecycle.
  6467. *
  6468. * @module ng1
  6469. * @preferred
  6470. */
  6471. "use strict";
  6472. /** for typedoc */
  6473. var router_1 = __webpack_require__(25);
  6474. var coreservices_1 = __webpack_require__(6);
  6475. var common_1 = __webpack_require__(3);
  6476. var hof_1 = __webpack_require__(5);
  6477. var predicates_1 = __webpack_require__(4);
  6478. var resolveService_1 = __webpack_require__(54);
  6479. var trace_1 = __webpack_require__(12);
  6480. var views_1 = __webpack_require__(55);
  6481. var templateFactory_1 = __webpack_require__(56);
  6482. var stateProvider_1 = __webpack_require__(58);
  6483. var onEnterExitRetain_1 = __webpack_require__(59);
  6484. var angular = __webpack_require__(57);
  6485. /** @hidden */
  6486. var app = angular.module("ui.router.angular1", []);
  6487. /**
  6488. * @ngdoc overview
  6489. * @name ui.router.util
  6490. *
  6491. * @description
  6492. * # ui.router.util sub-module
  6493. *
  6494. * This module is a dependency of other sub-modules. Do not include this module as a dependency
  6495. * in your angular app (use {@link ui.router} module instead).
  6496. *
  6497. */
  6498. angular.module('ui.router.util', ['ng', 'ui.router.init']);
  6499. /**
  6500. * @ngdoc overview
  6501. * @name ui.router.router
  6502. *
  6503. * @requires ui.router.util
  6504. *
  6505. * @description
  6506. * # ui.router.router sub-module
  6507. *
  6508. * This module is a dependency of other sub-modules. Do not include this module as a dependency
  6509. * in your angular app (use {@link ui.router} module instead).
  6510. */
  6511. angular.module('ui.router.router', ['ui.router.util']);
  6512. /**
  6513. * @ngdoc overview
  6514. * @name ui.router.state
  6515. *
  6516. * @requires ui.router.router
  6517. * @requires ui.router.util
  6518. *
  6519. * @description
  6520. * # ui.router.state sub-module
  6521. *
  6522. * This module is a dependency of the main ui.router module. Do not include this module as a dependency
  6523. * in your angular app (use {@link ui.router} module instead).
  6524. *
  6525. */
  6526. angular.module('ui.router.state', ['ui.router.router', 'ui.router.util', 'ui.router.angular1']);
  6527. /**
  6528. * @ngdoc overview
  6529. * @name ui.router
  6530. *
  6531. * @requires ui.router.state
  6532. *
  6533. * @description
  6534. * # ui.router
  6535. *
  6536. * ## The main module for ui.router
  6537. * There are several sub-modules included with the ui.router module, however only this module is needed
  6538. * as a dependency within your angular app. The other modules are for organization purposes.
  6539. *
  6540. * The modules are:
  6541. * * ui.router - the main "umbrella" module
  6542. * * ui.router.router -
  6543. *
  6544. * *You'll need to include **only** this module as the dependency within your angular app.*
  6545. *
  6546. * <pre>
  6547. * <!doctype html>
  6548. * <html ng-app="myApp">
  6549. * <head>
  6550. * <script src="js/angular.js"></script>
  6551. * <!-- Include the ui-router script -->
  6552. * <script src="js/angular-ui-router.min.js"></script>
  6553. * <script>
  6554. * // ...and add 'ui.router' as a dependency
  6555. * var myApp = angular.module('myApp', ['ui.router']);
  6556. * </script>
  6557. * </head>
  6558. * <body>
  6559. * </body>
  6560. * </html>
  6561. * </pre>
  6562. */
  6563. angular.module('ui.router', ['ui.router.init', 'ui.router.state', 'ui.router.angular1']);
  6564. angular.module('ui.router.compat', ['ui.router']);
  6565. /**
  6566. * Annotates a controller expression (may be a controller function(), a "controllername",
  6567. * or "controllername as name")
  6568. *
  6569. * - Temporarily decorates $injector.instantiate.
  6570. * - Invokes $controller() service
  6571. * - Calls $injector.instantiate with controller constructor
  6572. * - Annotate constructor
  6573. * - Undecorate $injector
  6574. *
  6575. * returns an array of strings, which are the arguments of the controller expression
  6576. */
  6577. function annotateController(controllerExpression) {
  6578. var $injector = coreservices_1.services.$injector;
  6579. var $controller = $injector.get("$controller");
  6580. var oldInstantiate = $injector.instantiate;
  6581. try {
  6582. var deps_1;
  6583. $injector.instantiate = function fakeInstantiate(constructorFunction) {
  6584. $injector.instantiate = oldInstantiate; // Un-decorate ASAP
  6585. deps_1 = $injector.annotate(constructorFunction);
  6586. };
  6587. $controller(controllerExpression, { $scope: {} });
  6588. return deps_1;
  6589. }
  6590. finally {
  6591. $injector.instantiate = oldInstantiate;
  6592. }
  6593. }
  6594. exports.annotateController = annotateController;
  6595. var router = null;
  6596. $uiRouter.$inject = ['$locationProvider'];
  6597. /** This angular 1 provider instantiates a Router and exposes its services via the angular injector */
  6598. function $uiRouter($locationProvider) {
  6599. // Create a new instance of the Router when the $uiRouterProvider is initialized
  6600. router = new router_1.UIRouter();
  6601. router.stateProvider = new stateProvider_1.StateProvider(router.stateRegistry, router.stateService);
  6602. // Apply ng1 specific StateBuilder code for `views`, `resolve`, and `onExit/Retain/Enter` properties
  6603. router.stateRegistry.decorator("views", views_1.ng1ViewsBuilder);
  6604. router.stateRegistry.decorator("onExit", onEnterExitRetain_1.getStateHookBuilder("onExit"));
  6605. router.stateRegistry.decorator("onRetain", onEnterExitRetain_1.getStateHookBuilder("onRetain"));
  6606. router.stateRegistry.decorator("onEnter", onEnterExitRetain_1.getStateHookBuilder("onEnter"));
  6607. router.viewService.viewConfigFactory('ng1', views_1.ng1ViewConfigFactory);
  6608. // Bind LocationConfig.hashPrefix to $locationProvider.hashPrefix
  6609. common_1.bindFunctions($locationProvider, coreservices_1.services.locationConfig, $locationProvider, ['hashPrefix']);
  6610. // Create a LocationService.onChange registry
  6611. var urlListeners = [];
  6612. coreservices_1.services.location.onChange = function (callback) {
  6613. urlListeners.push(callback);
  6614. return function () { return common_1.removeFrom(urlListeners)(callback); };
  6615. };
  6616. this.$get = $get;
  6617. $get.$inject = ['$location', '$browser', '$sniffer', '$rootScope', '$http', '$templateCache'];
  6618. function $get($location, $browser, $sniffer, $rootScope, $http, $templateCache) {
  6619. // Bind $locationChangeSuccess to the listeners registered in LocationService.onChange
  6620. $rootScope.$on("$locationChangeSuccess", function (evt) { return urlListeners.forEach(function (fn) { return fn(evt); }); });
  6621. // Bind LocationConfig.html5Mode to $locationProvider.html5Mode and $sniffer.history
  6622. coreservices_1.services.locationConfig.html5Mode = function () {
  6623. var html5Mode = $locationProvider.html5Mode();
  6624. html5Mode = predicates_1.isObject(html5Mode) ? html5Mode.enabled : html5Mode;
  6625. return html5Mode && $sniffer.history;
  6626. };
  6627. coreservices_1.services.location.setUrl = function (newUrl, replace) {
  6628. if (replace === void 0) { replace = false; }
  6629. $location.url(newUrl);
  6630. if (replace)
  6631. $location.replace();
  6632. };
  6633. coreservices_1.services.template.get = function (url) {
  6634. return $http.get(url, { cache: $templateCache, headers: { Accept: 'text/html' } }).then(hof_1.prop("data"));
  6635. };
  6636. // Bind these LocationService functions to $location
  6637. common_1.bindFunctions($location, coreservices_1.services.location, $location, ["replace", "url", "path", "search", "hash"]);
  6638. // Bind these LocationConfig functions to $location
  6639. common_1.bindFunctions($location, coreservices_1.services.locationConfig, $location, ['port', 'protocol', 'host']);
  6640. // Bind these LocationConfig functions to $browser
  6641. common_1.bindFunctions($browser, coreservices_1.services.locationConfig, $browser, ['baseHref']);
  6642. return router;
  6643. }
  6644. }
  6645. // The 'ui.router' ng1 module depends on 'ui.router.init' module.
  6646. angular.module('ui.router.init', []).provider("$uiRouter", $uiRouter);
  6647. runBlock.$inject = ['$injector', '$q'];
  6648. function runBlock($injector, $q) {
  6649. coreservices_1.services.$injector = $injector;
  6650. coreservices_1.services.$q = $q;
  6651. }
  6652. angular.module('ui.router.init').run(runBlock);
  6653. // This effectively calls $get() to init when we enter runtime
  6654. angular.module('ui.router.init').run(['$uiRouter', function ($uiRouter) { }]);
  6655. // $urlMatcherFactory service and $urlMatcherFactoryProvider
  6656. angular.module('ui.router.util').provider('$urlMatcherFactory', ['$uiRouterProvider', function () { return router.urlMatcherFactory; }]);
  6657. angular.module('ui.router.util').run(['$urlMatcherFactory', function ($urlMatcherFactory) { }]);
  6658. // $urlRouter service and $urlRouterProvider
  6659. function getUrlRouterProvider() {
  6660. router.urlRouterProvider["$get"] = function () {
  6661. router.urlRouter.update(true);
  6662. if (!this.interceptDeferred)
  6663. router.urlRouter.listen();
  6664. return router.urlRouter;
  6665. };
  6666. return router.urlRouterProvider;
  6667. }
  6668. angular.module('ui.router.router').provider('$urlRouter', ['$uiRouterProvider', getUrlRouterProvider]);
  6669. angular.module('ui.router.router').run(['$urlRouter', function ($urlRouter) { }]);
  6670. // $state service and $stateProvider
  6671. // $urlRouter service and $urlRouterProvider
  6672. function getStateProvider() {
  6673. router.stateProvider["$get"] = function () {
  6674. // Autoflush once we are in runtime
  6675. router.stateRegistry.stateQueue.autoFlush(router.stateService);
  6676. return router.stateService;
  6677. };
  6678. return router.stateProvider;
  6679. }
  6680. angular.module('ui.router.state').provider('$state', ['$uiRouterProvider', getStateProvider]);
  6681. angular.module('ui.router.state').run(['$state', function ($state) { }]);
  6682. // $stateParams service
  6683. angular.module('ui.router.state').factory('$stateParams', ['$uiRouter', function ($uiRouter) {
  6684. return $uiRouter.globals.params;
  6685. }]);
  6686. // $transitions service and $transitionsProvider
  6687. function getTransitionsProvider() {
  6688. router.transitionService["$get"] = function () { return router.transitionService; };
  6689. return router.transitionService;
  6690. }
  6691. angular.module('ui.router.state').provider('$transitions', ['$uiRouterProvider', getTransitionsProvider]);
  6692. // $templateFactory service
  6693. angular.module('ui.router.util').factory('$templateFactory', ['$uiRouter', function () { return new templateFactory_1.TemplateFactory(); }]);
  6694. // The $view service
  6695. angular.module('ui.router').factory('$view', function () { return router.viewService; });
  6696. // The old $resolve service
  6697. angular.module('ui.router').factory('$resolve', resolveService_1.resolveFactory);
  6698. // $trace service
  6699. angular.module("ui.router").service("$trace", function () { return trace_1.trace; });
  6700. watchDigests.$inject = ['$rootScope'];
  6701. function watchDigests($rootScope) {
  6702. $rootScope.$watch(function () { trace_1.trace.approximateDigests++; });
  6703. }
  6704. exports.watchDigests = watchDigests;
  6705. angular.module("ui.router").run(watchDigests);
  6706. exports.getLocals = function (ctx) {
  6707. var tokens = ctx.getTokens().filter(predicates_1.isString);
  6708. var tuples = tokens.map(function (key) { return [key, ctx.getResolvable(key).data]; });
  6709. return tuples.reduce(common_1.applyPairs, {});
  6710. };
  6711. /** Injectable services */
  6712. /**
  6713. * An injectable service object which has the current state parameters
  6714. *
  6715. * This angular service (singleton object) holds the current state parameters.
  6716. * The values in `$stateParams` are not updated until *after* a [[Transition]] successfully completes.
  6717. *
  6718. * This object can be injected into other services.
  6719. *
  6720. * @example
  6721. * ```js
  6722. *
  6723. * SomeService.$inject = ['$http', '$stateParams'];
  6724. * function SomeService($http, $stateParams) {
  6725. * return {
  6726. * getUser: function() {
  6727. * return $http.get('/api/users/' + $stateParams.username);
  6728. * }
  6729. * }
  6730. * };
  6731. * angular.service('SomeService', SomeService);
  6732. * ```
  6733. *
  6734. * ### Deprecation warning:
  6735. *
  6736. * When `$stateParams` is injected into transition hooks, resolves and view controllers, they receive a different
  6737. * object than this global service object. In those cases, the injected object has the parameter values for the
  6738. * *pending* Transition.
  6739. *
  6740. * Because of these confusing details, this service is deprecated.
  6741. *
  6742. * @deprecated Instead of using `$stateParams, inject the current [[Transition]] as `$transition$` and use [[Transition.params]]
  6743. * ```js
  6744. * MyController.$inject = ['$transition$'];
  6745. * function MyController($transition$) {
  6746. * var username = $transition$.params().username;
  6747. * // .. do something with username
  6748. * }
  6749. * ```
  6750. */
  6751. var $stateParams;
  6752. /**
  6753. * An injectable service primarily used to register transition hooks
  6754. *
  6755. * This angular service exposes the [[TransitionService]] singleton, which is primarily used to add transition hooks.
  6756. *
  6757. * The same object is also exposed as [[$transitionsProvider]] for injection during angular config time.
  6758. */
  6759. var $transitions;
  6760. /**
  6761. * A config-time injectable provider primarily used to register transition hooks
  6762. *
  6763. * This angular provider exposes the [[TransitionService]] singleton, which is primarily used to add transition hooks.
  6764. *
  6765. * The same object is also exposed as [[$transitions]] for injection at runtime.
  6766. */
  6767. var $transitionsProvider;
  6768. /**
  6769. * An injectable service used to query for current state information.
  6770. *
  6771. * This angular service exposes the [[StateService]] singleton.
  6772. */
  6773. var $state;
  6774. /**
  6775. * A config-time injectable provider used to register states.
  6776. *
  6777. * This angular service exposes the [[StateProvider]] singleton.
  6778. */
  6779. var $stateProvider;
  6780. /**
  6781. * A config-time injectable provider used to manage the URL.
  6782. *
  6783. * This angular service exposes the [[UrlRouterProvider]] singleton.
  6784. */
  6785. var $urlRouterProvider;
  6786. /**
  6787. * An injectable service used to configure URL redirects.
  6788. *
  6789. * This angular service exposes the [[UrlRouter]] singleton.
  6790. */
  6791. var $urlRouter;
  6792. /**
  6793. * An injectable service used to configure the URL.
  6794. *
  6795. * This service is used to set url mapping options, and create [[UrlMatcher]] objects.
  6796. *
  6797. * This angular service exposes the [[UrlMatcherFactory]] singleton.
  6798. * The singleton is also exposed at config-time as the [[$urlMatcherFactoryProvider]].
  6799. */
  6800. var $urlMatcherFactory;
  6801. /**
  6802. * An injectable service used to configure the URL.
  6803. *
  6804. * This service is used to set url mapping options, and create [[UrlMatcher]] objects.
  6805. *
  6806. * This angular service exposes the [[UrlMatcherFactory]] singleton at config-time.
  6807. * The singleton is also exposed at runtime as the [[$urlMatcherFactory]].
  6808. */
  6809. var $urlMatcherFactoryProvider;
  6810. /***/ },
  6811. /* 54 */
  6812. /***/ function(module, exports, __webpack_require__) {
  6813. "use strict";
  6814. /** @module ng1 */ /** */
  6815. var stateObject_1 = __webpack_require__(42);
  6816. var node_1 = __webpack_require__(21);
  6817. var resolveContext_1 = __webpack_require__(17);
  6818. var common_1 = __webpack_require__(3);
  6819. var stateBuilder_1 = __webpack_require__(40);
  6820. /**
  6821. * Implementation of the legacy `$resolve` service for angular 1.
  6822. */
  6823. var $resolve = {
  6824. /**
  6825. * Asynchronously injects a resolve block.
  6826. *
  6827. * This emulates most of the behavior of the ui-router 0.2.x $resolve.resolve() service API.
  6828. *
  6829. * Given an object `invocables`, where keys are strings and values are injectable functions,
  6830. * injects each function, and waits for the resulting promise to resolve.
  6831. * When all resulting promises are resolved, returns the results as an object.
  6832. *
  6833. * @example
  6834. * ```js
  6835. *
  6836. * let invocables = {
  6837. * foo: [ '$http', ($http) =>
  6838. * $http.get('/api/foo').then(resp => resp.data) ],
  6839. * bar: [ 'foo', '$http', (foo, $http) =>
  6840. * $http.get('/api/bar/' + foo.barId).then(resp => resp.data) ]
  6841. * }
  6842. * $resolve.resolve(invocables)
  6843. * .then(results => console.log(results.foo, results.bar))
  6844. * // Logs foo and bar:
  6845. * // { id: 123, barId: 456, fooData: 'foo data' }
  6846. * // { id: 456, barData: 'bar data' }
  6847. * ```
  6848. *
  6849. * @param invocables an object which looks like an [[StateDefinition.resolve]] object; keys are resolve names and values are injectable functions
  6850. * @param locals key/value pre-resolved data (locals)
  6851. * @param parent a promise for a "parent resolve"
  6852. */
  6853. resolve: function (invocables, locals, parent) {
  6854. if (locals === void 0) { locals = {}; }
  6855. var parentNode = new node_1.PathNode(new stateObject_1.State({ params: {}, resolvables: [] }));
  6856. var node = new node_1.PathNode(new stateObject_1.State({ params: {}, resolvables: [] }));
  6857. var context = new resolveContext_1.ResolveContext([parentNode, node]);
  6858. context.addResolvables(stateBuilder_1.resolvablesBuilder({ resolve: invocables }), node.state);
  6859. var resolveData = function (parentLocals) {
  6860. var rewrap = function (_locals) { return stateBuilder_1.resolvablesBuilder({ resolve: common_1.mapObj(_locals, function (local) { return function () { return local; }; }) }); };
  6861. context.addResolvables(rewrap(parentLocals), parentNode.state);
  6862. context.addResolvables(rewrap(locals), node.state);
  6863. var tuples2ObjR = function (acc, tuple) {
  6864. acc[tuple.token] = tuple.value;
  6865. return acc;
  6866. };
  6867. return context.resolvePath().then(function (results) { return results.reduce(tuples2ObjR, {}); });
  6868. };
  6869. return parent ? parent.then(resolveData) : resolveData({});
  6870. }
  6871. };
  6872. /** @hidden */
  6873. exports.resolveFactory = function () { return $resolve; };
  6874. /***/ },
  6875. /* 55 */
  6876. /***/ function(module, exports, __webpack_require__) {
  6877. "use strict";
  6878. var common_1 = __webpack_require__(3);
  6879. var strings_1 = __webpack_require__(9);
  6880. var view_1 = __webpack_require__(37);
  6881. var predicates_1 = __webpack_require__(4);
  6882. var coreservices_1 = __webpack_require__(6);
  6883. var trace_1 = __webpack_require__(12);
  6884. var templateFactory_1 = __webpack_require__(56);
  6885. var resolveContext_1 = __webpack_require__(17);
  6886. var resolvable_1 = __webpack_require__(19);
  6887. var angular = __webpack_require__(57);
  6888. exports.ng1ViewConfigFactory = function (path, view) {
  6889. return [new Ng1ViewConfig(path, view)];
  6890. };
  6891. /**
  6892. * This is a [[StateBuilder.builder]] function for angular1 `views`.
  6893. *
  6894. * When the [[StateBuilder]] builds a [[State]] object from a raw [[StateDeclaration]], this builder
  6895. * handles the `views` property with logic specific to angular-ui-router (ng1).
  6896. *
  6897. * If no `views: {}` property exists on the [[StateDeclaration]], then it creates the `views` object
  6898. * and applies the state-level configuration to a view named `$default`.
  6899. */
  6900. function ng1ViewsBuilder(state) {
  6901. var tplKeys = ['templateProvider', 'templateUrl', 'template', 'notify', 'async'], ctrlKeys = ['controller', 'controllerProvider', 'controllerAs', 'resolveAs'], compKeys = ['component', 'bindings'], nonCompKeys = tplKeys.concat(ctrlKeys), allKeys = compKeys.concat(nonCompKeys);
  6902. var views = {}, viewsObject = state.views || { "$default": common_1.pick(state, allKeys) };
  6903. common_1.forEach(viewsObject, function (config, name) {
  6904. // Account for views: { "": { template... } }
  6905. name = name || "$default";
  6906. // Account for views: { header: "headerComponent" }
  6907. if (predicates_1.isString(config))
  6908. config = { component: config };
  6909. if (!Object.keys(config).length)
  6910. return;
  6911. // Configure this view for routing to an angular 1.5+ style .component (or any directive, really)
  6912. if (config.component) {
  6913. if (nonCompKeys.map(function (key) { return predicates_1.isDefined(config[key]); }).reduce(common_1.anyTrueR, false)) {
  6914. throw new Error("Cannot combine: " + compKeys.join("|") + " with: " + nonCompKeys.join("|") + " in stateview: 'name@" + state.name + "'");
  6915. }
  6916. // Dynamically build a template like "<component-name input1='::$resolve.foo'></component-name>"
  6917. config.templateProvider = ['$injector', function ($injector) {
  6918. var resolveFor = function (key) {
  6919. return config.bindings && config.bindings[key] || key;
  6920. };
  6921. var prefix = angular.version.minor >= 3 ? "::" : "";
  6922. var attributeTpl = function (input) {
  6923. var attrName = strings_1.kebobString(input.name);
  6924. var resolveName = resolveFor(input.name);
  6925. if (input.type === '@')
  6926. return attrName + "='{{" + prefix + "$resolve." + resolveName + "}}'";
  6927. return attrName + "='" + prefix + "$resolve." + resolveName + "'";
  6928. };
  6929. var attrs = getComponentInputs($injector, config.component).map(attributeTpl).join(" ");
  6930. var kebobName = strings_1.kebobString(config.component);
  6931. return "<" + kebobName + " " + attrs + "></" + kebobName + ">";
  6932. }];
  6933. }
  6934. config.resolveAs = config.resolveAs || '$resolve';
  6935. config.$type = "ng1";
  6936. config.$context = state;
  6937. config.$name = name;
  6938. var normalized = view_1.ViewService.normalizeUIViewTarget(config.$context, config.$name);
  6939. config.$uiViewName = normalized.uiViewName;
  6940. config.$uiViewContextAnchor = normalized.uiViewContextAnchor;
  6941. views[name] = config;
  6942. });
  6943. return views;
  6944. }
  6945. exports.ng1ViewsBuilder = ng1ViewsBuilder;
  6946. // for ng 1.2 style, process the scope: { input: "=foo" }
  6947. // for ng 1.3 through ng 1.5, process the component's bindToController: { input: "=foo" } object
  6948. var scopeBindings = function (bindingsObj) { return Object.keys(bindingsObj || {})
  6949. .map(function (key) { return [key, /^([=<@])[?]?(.*)/.exec(bindingsObj[key])]; })
  6950. .filter(function (tuple) { return predicates_1.isDefined(tuple) && predicates_1.isDefined(tuple[1]); })
  6951. .map(function (tuple) { return ({ name: tuple[1][2] || tuple[0], type: tuple[1][1] }); }); };
  6952. // Given a directive definition, find its object input attributes
  6953. // Use different properties, depending on the type of directive (component, bindToController, normal)
  6954. var getBindings = function (def) {
  6955. if (predicates_1.isObject(def.bindToController))
  6956. return scopeBindings(def.bindToController);
  6957. return scopeBindings(def.scope);
  6958. };
  6959. // Gets all the directive(s)' inputs ('@', '=', and '<')
  6960. function getComponentInputs($injector, name) {
  6961. var cmpDefs = $injector.get(name + "Directive"); // could be multiple
  6962. if (!cmpDefs || !cmpDefs.length)
  6963. throw new Error("Unable to find component named '" + name + "'");
  6964. return cmpDefs.map(getBindings).reduce(common_1.unnestR, []);
  6965. }
  6966. var id = 0;
  6967. var Ng1ViewConfig = (function () {
  6968. function Ng1ViewConfig(path, viewDecl) {
  6969. this.path = path;
  6970. this.viewDecl = viewDecl;
  6971. this.$id = id++;
  6972. this.loaded = false;
  6973. }
  6974. Ng1ViewConfig.prototype.load = function () {
  6975. var _this = this;
  6976. var $q = coreservices_1.services.$q;
  6977. if (!this.hasTemplate())
  6978. throw new Error("No template configuration specified for '" + this.viewDecl.$uiViewName + "@" + this.viewDecl.$uiViewContextAnchor + "'");
  6979. var context = new resolveContext_1.ResolveContext(this.path);
  6980. var params = this.path.reduce(function (acc, node) { return common_1.extend(acc, node.paramValues); }, {});
  6981. var promises = {
  6982. template: $q.when(this.getTemplate(params, new templateFactory_1.TemplateFactory(), context)),
  6983. controller: $q.when(this.getController(context))
  6984. };
  6985. return $q.all(promises).then(function (results) {
  6986. trace_1.trace.traceViewServiceEvent("Loaded", _this);
  6987. _this.controller = results.controller;
  6988. _this.template = results.template;
  6989. return _this;
  6990. });
  6991. };
  6992. /**
  6993. * Checks a view configuration to ensure that it specifies a template.
  6994. *
  6995. * @return {boolean} Returns `true` if the configuration contains a valid template, otherwise `false`.
  6996. */
  6997. Ng1ViewConfig.prototype.hasTemplate = function () {
  6998. return !!(this.viewDecl.template || this.viewDecl.templateUrl || this.viewDecl.templateProvider);
  6999. };
  7000. Ng1ViewConfig.prototype.getTemplate = function (params, $factory, context) {
  7001. return $factory.fromConfig(this.viewDecl, params, context);
  7002. };
  7003. /**
  7004. * Gets the controller for a view configuration.
  7005. *
  7006. * @returns {Function|Promise.<Function>} Returns a controller, or a promise that resolves to a controller.
  7007. */
  7008. Ng1ViewConfig.prototype.getController = function (context) {
  7009. var provider = this.viewDecl.controllerProvider;
  7010. if (!predicates_1.isInjectable(provider))
  7011. return this.viewDecl.controller;
  7012. var deps = coreservices_1.services.$injector.annotate(provider);
  7013. var providerFn = predicates_1.isArray(provider) ? common_1.tail(provider) : provider;
  7014. var resolvable = new resolvable_1.Resolvable("", providerFn, deps);
  7015. return resolvable.get(context);
  7016. };
  7017. return Ng1ViewConfig;
  7018. }());
  7019. exports.Ng1ViewConfig = Ng1ViewConfig;
  7020. /***/ },
  7021. /* 56 */
  7022. /***/ function(module, exports, __webpack_require__) {
  7023. "use strict";
  7024. /** @module view */ /** for typedoc */
  7025. var predicates_1 = __webpack_require__(4);
  7026. var coreservices_1 = __webpack_require__(6);
  7027. var common_1 = __webpack_require__(3);
  7028. var resolvable_1 = __webpack_require__(19);
  7029. /**
  7030. * Service which manages loading of templates from a ViewConfig.
  7031. */
  7032. var TemplateFactory = (function () {
  7033. function TemplateFactory() {
  7034. }
  7035. /**
  7036. * Creates a template from a configuration object.
  7037. *
  7038. * @param config Configuration object for which to load a template.
  7039. * The following properties are search in the specified order, and the first one
  7040. * that is defined is used to create the template:
  7041. *
  7042. * @param params Parameters to pass to the template function.
  7043. * @param context The resolve context associated with the template's view
  7044. *
  7045. * @return {string|object} The template html as a string, or a promise for
  7046. * that string,or `null` if no template is configured.
  7047. */
  7048. TemplateFactory.prototype.fromConfig = function (config, params, context) {
  7049. return (predicates_1.isDefined(config.template) ? this.fromString(config.template, params) :
  7050. predicates_1.isDefined(config.templateUrl) ? this.fromUrl(config.templateUrl, params) :
  7051. predicates_1.isDefined(config.templateProvider) ? this.fromProvider(config.templateProvider, params, context) :
  7052. null);
  7053. };
  7054. ;
  7055. /**
  7056. * Creates a template from a string or a function returning a string.
  7057. *
  7058. * @param template html template as a string or function that returns an html template as a string.
  7059. * @param params Parameters to pass to the template function.
  7060. *
  7061. * @return {string|object} The template html as a string, or a promise for that
  7062. * string.
  7063. */
  7064. TemplateFactory.prototype.fromString = function (template, params) {
  7065. return predicates_1.isFunction(template) ? template(params) : template;
  7066. };
  7067. ;
  7068. /**
  7069. * Loads a template from the a URL via `$http` and `$templateCache`.
  7070. *
  7071. * @param {string|Function} url url of the template to load, or a function
  7072. * that returns a url.
  7073. * @param {Object} params Parameters to pass to the url function.
  7074. * @return {string|Promise.<string>} The template html as a string, or a promise
  7075. * for that string.
  7076. */
  7077. TemplateFactory.prototype.fromUrl = function (url, params) {
  7078. if (predicates_1.isFunction(url))
  7079. url = url(params);
  7080. if (url == null)
  7081. return null;
  7082. return coreservices_1.services.template.get(url);
  7083. };
  7084. ;
  7085. /**
  7086. * Creates a template by invoking an injectable provider function.
  7087. *
  7088. * @param provider Function to invoke via `locals`
  7089. * @param {Function} injectFn a function used to invoke the template provider
  7090. * @return {string|Promise.<string>} The template html as a string, or a promise
  7091. * for that string.
  7092. */
  7093. TemplateFactory.prototype.fromProvider = function (provider, params, context) {
  7094. var deps = coreservices_1.services.$injector.annotate(provider);
  7095. var providerFn = predicates_1.isArray(provider) ? common_1.tail(provider) : provider;
  7096. var resolvable = new resolvable_1.Resolvable("", providerFn, deps);
  7097. return resolvable.get(context);
  7098. };
  7099. ;
  7100. return TemplateFactory;
  7101. }());
  7102. exports.TemplateFactory = TemplateFactory;
  7103. /***/ },
  7104. /* 57 */
  7105. /***/ function(module, exports) {
  7106. module.exports = __WEBPACK_EXTERNAL_MODULE_57__;
  7107. /***/ },
  7108. /* 58 */
  7109. /***/ function(module, exports, __webpack_require__) {
  7110. "use strict";
  7111. /** @module ng1 */ /** for typedoc */
  7112. var predicates_1 = __webpack_require__(4);
  7113. var common_1 = __webpack_require__(3);
  7114. /**
  7115. * @ngdoc object
  7116. * @name ui.router.state.$stateProvider
  7117. *
  7118. * @requires ui.router.router.$urlRouterProvider
  7119. * @requires ui.router.util.$urlMatcherFactoryProvider
  7120. *
  7121. * @description
  7122. * The new `$stateProvider` works similar to Angular's v1 router, but it focuses purely
  7123. * on state.
  7124. *
  7125. * A state corresponds to a "place" in the application in terms of the overall UI and
  7126. * navigation. A state describes (via the controller / template / view properties) what
  7127. * the UI looks like and does at that place.
  7128. *
  7129. * States often have things in common, and the primary way of factoring out these
  7130. * commonalities in this model is via the state hierarchy, i.e. parent/child states aka
  7131. * nested states.
  7132. *
  7133. * The `$stateProvider` provides interfaces to declare these states for your app.
  7134. */
  7135. var StateProvider = (function () {
  7136. function StateProvider(stateRegistry, stateService) {
  7137. this.stateRegistry = stateRegistry;
  7138. this.stateService = stateService;
  7139. common_1.bindFunctions(StateProvider.prototype, this, this);
  7140. }
  7141. /**
  7142. * @ngdoc function
  7143. * @name ui.router.state.$stateProvider#decorator
  7144. * @methodOf ui.router.state.$stateProvider
  7145. *
  7146. * @description
  7147. * Allows you to extend (carefully) or override (at your own peril) the
  7148. * `stateBuilder` object used internally by `$stateProvider`. This can be used
  7149. * to add custom functionality to ui-router, for example inferring templateUrl
  7150. * based on the state name.
  7151. *
  7152. * When passing only a name, it returns the current (original or decorated) builder
  7153. * function that matches `name`.
  7154. *
  7155. * The builder functions that can be decorated are listed below. Though not all
  7156. * necessarily have a good use case for decoration, that is up to you to decide.
  7157. *
  7158. * In addition, users can attach custom decorators, which will generate new
  7159. * properties within the state's internal definition. There is currently no clear
  7160. * use-case for this beyond accessing internal states (i.e. $state.$current),
  7161. * however, expect this to become increasingly relevant as we introduce additional
  7162. * meta-programming features.
  7163. *
  7164. * **Warning**: Decorators should not be interdependent because the order of
  7165. * execution of the builder functions in non-deterministic. Builder functions
  7166. * should only be dependent on the state definition object and super function.
  7167. *
  7168. *
  7169. * Existing builder functions and current return values:
  7170. *
  7171. * - **parent** `{object}` - returns the parent state object.
  7172. * - **data** `{object}` - returns state data, including any inherited data that is not
  7173. * overridden by own values (if any).
  7174. * - **url** `{object}` - returns a {@link ui.router.util.type:UrlMatcher UrlMatcher}
  7175. * or `null`.
  7176. * - **navigable** `{object}` - returns closest ancestor state that has a URL (aka is
  7177. * navigable).
  7178. * - **params** `{object}` - returns an array of state params that are ensured to
  7179. * be a super-set of parent's params.
  7180. * - **views** `{object}` - returns a views object where each key is an absolute view
  7181. * name (i.e. "viewName@stateName") and each value is the config object
  7182. * (template, controller) for the view. Even when you don't use the views object
  7183. * explicitly on a state config, one is still created for you internally.
  7184. * So by decorating this builder function you have access to decorating template
  7185. * and controller properties.
  7186. * - **ownParams** `{object}` - returns an array of params that belong to the state,
  7187. * not including any params defined by ancestor states.
  7188. * - **path** `{string}` - returns the full path from the root down to this state.
  7189. * Needed for state activation.
  7190. * - **includes** `{object}` - returns an object that includes every state that
  7191. * would pass a `$state.includes()` test.
  7192. *
  7193. * @example
  7194. * <pre>
  7195. * // Override the internal 'views' builder with a function that takes the state
  7196. * // definition, and a reference to the internal function being overridden:
  7197. * $stateProvider.decorator('views', function (state, parent) {
  7198. * let result = {},
  7199. * views = parent(state);
  7200. *
  7201. * angular.forEach(views, function (config, name) {
  7202. * let autoName = (state.name + '.' + name).replace('.', '/');
  7203. * config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html';
  7204. * result[name] = config;
  7205. * });
  7206. * return result;
  7207. * });
  7208. *
  7209. * $stateProvider.state('home', {
  7210. * views: {
  7211. * 'contact.list': { controller: 'ListController' },
  7212. * 'contact.item': { controller: 'ItemController' }
  7213. * }
  7214. * });
  7215. *
  7216. * // ...
  7217. *
  7218. * $state.go('home');
  7219. * // Auto-populates list and item views with /partials/home/contact/list.html,
  7220. * // and /partials/home/contact/item.html, respectively.
  7221. * </pre>
  7222. *
  7223. * @param {string} name The name of the builder function to decorate.
  7224. * @param {object} func A function that is responsible for decorating the original
  7225. * builder function. The function receives two parameters:
  7226. *
  7227. * - `{object}` - state - The state config object.
  7228. * - `{object}` - super - The original builder function.
  7229. *
  7230. * @return {object} $stateProvider - $stateProvider instance
  7231. */
  7232. StateProvider.prototype.decorator = function (name, func) {
  7233. return this.stateRegistry.decorator(name, func) || this;
  7234. };
  7235. StateProvider.prototype.state = function (name, definition) {
  7236. if (predicates_1.isObject(name)) {
  7237. definition = name;
  7238. }
  7239. else {
  7240. definition.name = name;
  7241. }
  7242. this.stateRegistry.register(definition);
  7243. return this;
  7244. };
  7245. /**
  7246. * Registers an invalid state handler
  7247. *
  7248. * This is a passthrough to [[StateService.onInvalid]] for ng1.
  7249. */
  7250. StateProvider.prototype.onInvalid = function (callback) {
  7251. return this.stateService.onInvalid(callback);
  7252. };
  7253. return StateProvider;
  7254. }());
  7255. exports.StateProvider = StateProvider;
  7256. /***/ },
  7257. /* 59 */
  7258. /***/ function(module, exports, __webpack_require__) {
  7259. "use strict";
  7260. var coreservices_1 = __webpack_require__(6);
  7261. var services_1 = __webpack_require__(53);
  7262. var resolveContext_1 = __webpack_require__(17);
  7263. var common_1 = __webpack_require__(3);
  7264. /**
  7265. * This is a [[StateBuilder.builder]] function for angular1 `onEnter`, `onExit`,
  7266. * `onRetain` callback hooks on a [[Ng1StateDeclaration]].
  7267. *
  7268. * When the [[StateBuilder]] builds a [[State]] object from a raw [[StateDeclaration]], this builder
  7269. * ensures that those hooks are injectable for angular-ui-router (ng1).
  7270. */
  7271. exports.getStateHookBuilder = function (hookName) {
  7272. return function stateHookBuilder(state, parentFn) {
  7273. var hook = state[hookName];
  7274. function decoratedNg1Hook(trans, state) {
  7275. var resolveContext = new resolveContext_1.ResolveContext(trans.treeChanges().to);
  7276. return coreservices_1.services.$injector.invoke(hook, this, common_1.extend({ $state$: state }, services_1.getLocals(resolveContext)));
  7277. }
  7278. return hook ? decoratedNg1Hook : undefined;
  7279. };
  7280. };
  7281. /***/ },
  7282. /* 60 */
  7283. /***/ function(module, exports, __webpack_require__) {
  7284. "use strict";
  7285. /**
  7286. * These are the UI-Router angular 1 directives.
  7287. *
  7288. * These directives are used in templates to create viewports and navigate to states
  7289. *
  7290. * @preferred @module ng1_directives
  7291. */ /** for typedoc */
  7292. var angular = __webpack_require__(57);
  7293. var common_1 = __webpack_require__(3);
  7294. var predicates_1 = __webpack_require__(4);
  7295. var hof_1 = __webpack_require__(5);
  7296. /** @hidden */
  7297. function parseStateRef(ref, current) {
  7298. var preparsed = ref.match(/^\s*({[^}]*})\s*$/), parsed;
  7299. if (preparsed)
  7300. ref = current + '(' + preparsed[1] + ')';
  7301. parsed = ref.replace(/\n/g, " ").match(/^([^(]+?)\s*(\((.*)\))?$/);
  7302. if (!parsed || parsed.length !== 4)
  7303. throw new Error("Invalid state ref '" + ref + "'");
  7304. return { state: parsed[1], paramExpr: parsed[3] || null };
  7305. }
  7306. /** @hidden */
  7307. function stateContext(el) {
  7308. var $uiView = el.parent().inheritedData('$uiView');
  7309. var path = hof_1.parse('$cfg.path')($uiView);
  7310. return path ? common_1.tail(path).state.name : undefined;
  7311. }
  7312. /** @hidden */
  7313. function getTypeInfo(el) {
  7314. // SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
  7315. var isSvg = Object.prototype.toString.call(el.prop('href')) === '[object SVGAnimatedString]';
  7316. var isForm = el[0].nodeName === "FORM";
  7317. return {
  7318. attr: isForm ? "action" : (isSvg ? 'xlink:href' : 'href'),
  7319. isAnchor: el.prop("tagName").toUpperCase() === "A",
  7320. clickable: !isForm
  7321. };
  7322. }
  7323. /** @hidden */
  7324. function clickHook(el, $state, $timeout, type, current) {
  7325. return function (e) {
  7326. var button = e.which || e.button, target = current();
  7327. if (!(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || el.attr('target'))) {
  7328. // HACK: This is to allow ng-clicks to be processed before the transition is initiated:
  7329. var transition = $timeout(function () {
  7330. $state.go(target.state, target.params, target.options);
  7331. });
  7332. e.preventDefault();
  7333. // if the state has no URL, ignore one preventDefault from the <a> directive.
  7334. var ignorePreventDefaultCount = type.isAnchor && !target.href ? 1 : 0;
  7335. e.preventDefault = function () {
  7336. if (ignorePreventDefaultCount-- <= 0)
  7337. $timeout.cancel(transition);
  7338. };
  7339. }
  7340. };
  7341. }
  7342. /** @hidden */
  7343. function defaultOpts(el, $state) {
  7344. return {
  7345. relative: stateContext(el) || $state.$current,
  7346. inherit: true,
  7347. source: "sref"
  7348. };
  7349. }
  7350. /**
  7351. * `ui-sref`: A directive for linking to a state
  7352. *
  7353. * A directive that binds a link (`<a>` tag) to a state.
  7354. * If the state has an associated URL, the directive will automatically generate and
  7355. * update the `href` attribute via the [[StateService.href]] method.
  7356. * Clicking the link will trigger a state transition with optional parameters.
  7357. *
  7358. * Also middle-clicking, right-clicking, and ctrl-clicking on the link will be
  7359. * handled natively by the browser.
  7360. *
  7361. * You can also use relative state paths within ui-sref, just like the relative
  7362. * paths passed to `$state.go()`.
  7363. * You just need to be aware that the path is relative to the state that the link lives in.
  7364. * In other words, the state that created the view containing the link.
  7365. *
  7366. * You can specify options to pass to [[StateService.go]] using the `ui-sref-opts` attribute.
  7367. * Options are restricted to `location`, `inherit`, and `reload`.
  7368. *
  7369. * Here's an example of how you'd use ui-sref and how it would compile.
  7370. * If you have the following template:
  7371. *
  7372. * @example
  7373. * ```html
  7374. *
  7375. * <pre>
  7376. * <a ui-sref="home">Home</a> | <a ui-sref="about">About</a> | <a ui-sref="{page: 2}">Next page</a>
  7377. *
  7378. * <ul>
  7379. * <li ng-repeat="contact in contacts">
  7380. * <a ui-sref="contacts.detail({ id: contact.id })">{{ contact.name }}</a>
  7381. * </li>
  7382. * </ul>
  7383. * </pre>
  7384. * ```
  7385. *
  7386. * Then the compiled html would be (assuming Html5Mode is off and current state is contacts):
  7387. *
  7388. * ```html
  7389. *
  7390. * <pre>
  7391. * <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>
  7392. *
  7393. * <ul>
  7394. * <li ng-repeat="contact in contacts">
  7395. * <a href="#/contacts/1" ui-sref="contacts.detail({ id: contact.id })">Joe</a>
  7396. * </li>
  7397. * <li ng-repeat="contact in contacts">
  7398. * <a href="#/contacts/2" ui-sref="contacts.detail({ id: contact.id })">Alice</a>
  7399. * </li>
  7400. * <li ng-repeat="contact in contacts">
  7401. * <a href="#/contacts/3" ui-sref="contacts.detail({ id: contact.id })">Bob</a>
  7402. * </li>
  7403. * </ul>
  7404. *
  7405. * <a ui-sref="home" ui-sref-opts="{reload: true}">Home</a>
  7406. * </pre>
  7407. * ```
  7408. *
  7409. * @param {string} ui-sref 'stateName' can be any valid absolute or relative state
  7410. * @param {Object} ui-sref-opts options to pass to [[StateService.go]]
  7411. */
  7412. var uiSref = ['$state', '$timeout',
  7413. function $StateRefDirective($state, $timeout) {
  7414. return {
  7415. restrict: 'A',
  7416. require: ['?^uiSrefActive', '?^uiSrefActiveEq'],
  7417. link: function (scope, element, attrs, uiSrefActive) {
  7418. var ref = parseStateRef(attrs.uiSref, $state.current.name);
  7419. var def = { state: ref.state, href: null, params: null, options: null };
  7420. var type = getTypeInfo(element);
  7421. var active = uiSrefActive[1] || uiSrefActive[0];
  7422. var unlinkInfoFn = null;
  7423. var hookFn;
  7424. def.options = common_1.extend(defaultOpts(element, $state), attrs.uiSrefOpts ? scope.$eval(attrs.uiSrefOpts) : {});
  7425. var update = function (val) {
  7426. if (val)
  7427. def.params = angular.copy(val);
  7428. def.href = $state.href(ref.state, def.params, def.options);
  7429. if (unlinkInfoFn)
  7430. unlinkInfoFn();
  7431. if (active)
  7432. unlinkInfoFn = active.$$addStateInfo(ref.state, def.params);
  7433. if (def.href !== null)
  7434. attrs.$set(type.attr, def.href);
  7435. };
  7436. if (ref.paramExpr) {
  7437. scope.$watch(ref.paramExpr, function (val) { if (val !== def.params)
  7438. update(val); }, true);
  7439. def.params = angular.copy(scope.$eval(ref.paramExpr));
  7440. }
  7441. update();
  7442. if (!type.clickable)
  7443. return;
  7444. hookFn = clickHook(element, $state, $timeout, type, function () { return def; });
  7445. element.on("click", hookFn);
  7446. scope.$on('$destroy', function () {
  7447. element.off("click", hookFn);
  7448. });
  7449. }
  7450. };
  7451. }];
  7452. /**
  7453. * `ui-state`: A dynamic version of `ui-sref`
  7454. *
  7455. * Much like ui-sref, but will accept named $scope properties to evaluate for a state definition,
  7456. * params and override options.
  7457. *
  7458. * @example
  7459. * ```html
  7460. *
  7461. * <li ng-repeat="nav in navlinks">
  7462. * <a ui-state="nav.statename">{{nav.description}}</a>
  7463. * </li>
  7464. *
  7465. * @param {string} ui-state 'stateName' can be any valid absolute or relative state
  7466. * @param {Object} ui-state-params params to pass to [[StateService.href]]
  7467. * @param {Object} ui-state-opts options to pass to [[StateService.go]]
  7468. */
  7469. var uiState = ['$state', '$timeout',
  7470. function $StateRefDynamicDirective($state, $timeout) {
  7471. return {
  7472. restrict: 'A',
  7473. require: ['?^uiSrefActive', '?^uiSrefActiveEq'],
  7474. link: function (scope, element, attrs, uiSrefActive) {
  7475. var type = getTypeInfo(element);
  7476. var active = uiSrefActive[1] || uiSrefActive[0];
  7477. var group = [attrs.uiState, attrs.uiStateParams || null, attrs.uiStateOpts || null];
  7478. var watch = '[' + group.map(function (val) { return val || 'null'; }).join(', ') + ']';
  7479. var def = { state: null, params: null, options: null, href: null };
  7480. var unlinkInfoFn = null;
  7481. var hookFn;
  7482. function runStateRefLink(group) {
  7483. def.state = group[0];
  7484. def.params = group[1];
  7485. def.options = group[2];
  7486. def.href = $state.href(def.state, def.params, def.options);
  7487. if (unlinkInfoFn)
  7488. unlinkInfoFn();
  7489. if (active)
  7490. unlinkInfoFn = active.$$addStateInfo(def.state, def.params);
  7491. if (def.href)
  7492. attrs.$set(type.attr, def.href);
  7493. }
  7494. scope.$watch(watch, runStateRefLink, true);
  7495. runStateRefLink(scope.$eval(watch));
  7496. if (!type.clickable)
  7497. return;
  7498. hookFn = clickHook(element, $state, $timeout, type, function () { return def; });
  7499. element.on("click", hookFn);
  7500. scope.$on('$destroy', function () {
  7501. element.off("click", hookFn);
  7502. });
  7503. }
  7504. };
  7505. }];
  7506. /**
  7507. * `ui-sref-active` and `ui-sref-active-eq`: A directive that adds a CSS class when a `ui-sref` is active
  7508. *
  7509. * A directive working alongside ui-sref to add classes to an element when the
  7510. * related ui-sref directive's state is active, and removing them when it is inactive.
  7511. * The primary use-case is to simplify the special appearance of navigation menus
  7512. * relying on `ui-sref`, by having the "active" state's menu button appear different,
  7513. * distinguishing it from the inactive menu items.
  7514. *
  7515. * ui-sref-active can live on the same element as ui-sref or on a parent element. The first
  7516. * ui-sref-active found at the same level or above the ui-sref will be used.
  7517. *
  7518. * Will activate when the ui-sref's target state or any child state is active. If you
  7519. * need to activate only when the ui-sref target state is active and *not* any of
  7520. * it's children, then you will use ui-sref-active-eq
  7521. *
  7522. * Given the following template:
  7523. * @example
  7524. * ```html
  7525. *
  7526. * <pre>
  7527. * <ul>
  7528. * <li ui-sref-active="active" class="item">
  7529. * <a href ui-sref="app.user({user: 'bilbobaggins'})">@bilbobaggins</a>
  7530. * </li>
  7531. * </ul>
  7532. * </pre>
  7533. * ```
  7534. *
  7535. *
  7536. * When the app state is "app.user" (or any children states), and contains the state parameter "user" with value "bilbobaggins",
  7537. * the resulting HTML will appear as (note the 'active' class):
  7538. *
  7539. * ```html
  7540. *
  7541. * <pre>
  7542. * <ul>
  7543. * <li ui-sref-active="active" class="item active">
  7544. * <a ui-sref="app.user({user: 'bilbobaggins'})" href="/users/bilbobaggins">@bilbobaggins</a>
  7545. * </li>
  7546. * </ul>
  7547. * </pre>
  7548. * ```
  7549. *
  7550. * The class name is interpolated **once** during the directives link time (any further changes to the
  7551. * interpolated value are ignored).
  7552. *
  7553. * Multiple classes may be specified in a space-separated format:
  7554. *
  7555. * ```html
  7556. * <pre>
  7557. * <ul>
  7558. * <li ui-sref-active='class1 class2 class3'>
  7559. * <a ui-sref="app.user">link</a>
  7560. * </li>
  7561. * </ul>
  7562. * </pre>
  7563. * ```
  7564. *
  7565. * It is also possible to pass ui-sref-active an expression that evaluates
  7566. * to an object hash, whose keys represent active class names and whose
  7567. * values represent the respective state names/globs.
  7568. * ui-sref-active will match if the current active state **includes** any of
  7569. * the specified state names/globs, even the abstract ones.
  7570. *
  7571. * Given the following template, with "admin" being an abstract state:
  7572. * @example
  7573. * ```html
  7574. *
  7575. * <pre>
  7576. * <div ui-sref-active="{'active': 'admin.*'}">
  7577. * <a ui-sref-active="active" ui-sref="admin.roles">Roles</a>
  7578. * </div>
  7579. * </pre>
  7580. * ```
  7581. *
  7582. * When the current state is "admin.roles" the "active" class will be applied
  7583. * to both the <div> and <a> elements. It is important to note that the state
  7584. * names/globs passed to ui-sref-active shadow the state provided by ui-sref.
  7585. */
  7586. var uiSrefActive = ['$state', '$stateParams', '$interpolate', '$transitions', '$uiRouter',
  7587. function $StateRefActiveDirective($state, $stateParams, $interpolate, $transitions, $uiRouter) {
  7588. return {
  7589. restrict: "A",
  7590. controller: ['$scope', '$element', '$attrs', '$timeout',
  7591. function ($scope, $element, $attrs, $timeout) {
  7592. var states = [], activeClasses = {}, activeEqClass, uiSrefActive;
  7593. // There probably isn't much point in $observing this
  7594. // uiSrefActive and uiSrefActiveEq share the same directive object with some
  7595. // slight difference in logic routing
  7596. activeEqClass = $interpolate($attrs.uiSrefActiveEq || '', false)($scope);
  7597. try {
  7598. uiSrefActive = $scope.$eval($attrs.uiSrefActive);
  7599. }
  7600. catch (e) {
  7601. }
  7602. uiSrefActive = uiSrefActive || $interpolate($attrs.uiSrefActive || '', false)($scope);
  7603. if (predicates_1.isObject(uiSrefActive)) {
  7604. common_1.forEach(uiSrefActive, function (stateOrName, activeClass) {
  7605. if (predicates_1.isString(stateOrName)) {
  7606. var ref = parseStateRef(stateOrName, $state.current.name);
  7607. addState(ref.state, $scope.$eval(ref.paramExpr), activeClass);
  7608. }
  7609. });
  7610. }
  7611. // Allow uiSref to communicate with uiSrefActive[Equals]
  7612. this.$$addStateInfo = function (newState, newParams) {
  7613. // we already got an explicit state provided by ui-sref-active, so we
  7614. // shadow the one that comes from ui-sref
  7615. if (predicates_1.isObject(uiSrefActive) && states.length > 0) {
  7616. return;
  7617. }
  7618. var deregister = addState(newState, newParams, uiSrefActive);
  7619. update();
  7620. return deregister;
  7621. };
  7622. function updateAfterTransition(trans) { trans.promise.then(update); }
  7623. $scope.$on('$stateChangeSuccess', update);
  7624. $scope.$on('$destroy', $transitions.onStart({}, updateAfterTransition));
  7625. if ($uiRouter.globals.transition) {
  7626. updateAfterTransition($uiRouter.globals.transition);
  7627. }
  7628. function addState(stateName, stateParams, activeClass) {
  7629. var state = $state.get(stateName, stateContext($element));
  7630. var stateHash = createStateHash(stateName, stateParams);
  7631. var stateInfo = {
  7632. state: state || { name: stateName },
  7633. params: stateParams,
  7634. hash: stateHash
  7635. };
  7636. states.push(stateInfo);
  7637. activeClasses[stateHash] = activeClass;
  7638. return function removeState() {
  7639. var idx = states.indexOf(stateInfo);
  7640. if (idx !== -1)
  7641. states.splice(idx, 1);
  7642. };
  7643. }
  7644. /**
  7645. * @param {string} state
  7646. * @param {Object|string} [params]
  7647. * @return {string}
  7648. */
  7649. function createStateHash(state, params) {
  7650. if (!predicates_1.isString(state)) {
  7651. throw new Error('state should be a string');
  7652. }
  7653. if (predicates_1.isObject(params)) {
  7654. return state + common_1.toJson(params);
  7655. }
  7656. params = $scope.$eval(params);
  7657. if (predicates_1.isObject(params)) {
  7658. return state + common_1.toJson(params);
  7659. }
  7660. return state;
  7661. }
  7662. // Update route state
  7663. function update() {
  7664. for (var i = 0; i < states.length; i++) {
  7665. if (anyMatch(states[i].state, states[i].params)) {
  7666. addClass($element, activeClasses[states[i].hash]);
  7667. }
  7668. else {
  7669. removeClass($element, activeClasses[states[i].hash]);
  7670. }
  7671. if (exactMatch(states[i].state, states[i].params)) {
  7672. addClass($element, activeEqClass);
  7673. }
  7674. else {
  7675. removeClass($element, activeEqClass);
  7676. }
  7677. }
  7678. }
  7679. function addClass(el, className) { $timeout(function () { el.addClass(className); }); }
  7680. function removeClass(el, className) { el.removeClass(className); }
  7681. function anyMatch(state, params) { return $state.includes(state.name, params); }
  7682. function exactMatch(state, params) { return $state.is(state.name, params); }
  7683. update();
  7684. }]
  7685. };
  7686. }];
  7687. angular.module('ui.router.state')
  7688. .directive('uiSref', uiSref)
  7689. .directive('uiSrefActive', uiSrefActive)
  7690. .directive('uiSrefActiveEq', uiSrefActive)
  7691. .directive('uiState', uiState);
  7692. /***/ },
  7693. /* 61 */
  7694. /***/ function(module, exports, __webpack_require__) {
  7695. /** @module state */ /** for typedoc */
  7696. "use strict";
  7697. var angular = __webpack_require__(57);
  7698. /**
  7699. * @ngdoc filter
  7700. * @name ui.router.state.filter:isState
  7701. *
  7702. * @requires ui.router.state.$state
  7703. *
  7704. * @description
  7705. * Translates to {@link ui.router.state.$state#methods_is $state.is("stateName")}.
  7706. */
  7707. $IsStateFilter.$inject = ['$state'];
  7708. function $IsStateFilter($state) {
  7709. var isFilter = function (state, params, options) {
  7710. return $state.is(state, params, options);
  7711. };
  7712. isFilter.$stateful = true;
  7713. return isFilter;
  7714. }
  7715. exports.$IsStateFilter = $IsStateFilter;
  7716. /**
  7717. * @ngdoc filter
  7718. * @name ui.router.state.filter:includedByState
  7719. *
  7720. * @requires ui.router.state.$state
  7721. *
  7722. * @description
  7723. * Translates to {@link ui.router.state.$state#methods_includes $state.includes('fullOrPartialStateName')}.
  7724. */
  7725. $IncludedByStateFilter.$inject = ['$state'];
  7726. function $IncludedByStateFilter($state) {
  7727. var includesFilter = function (state, params, options) {
  7728. return $state.includes(state, params, options);
  7729. };
  7730. includesFilter.$stateful = true;
  7731. return includesFilter;
  7732. }
  7733. exports.$IncludedByStateFilter = $IncludedByStateFilter;
  7734. angular.module('ui.router.state')
  7735. .filter('isState', $IsStateFilter)
  7736. .filter('includedByState', $IncludedByStateFilter);
  7737. /***/ },
  7738. /* 62 */
  7739. /***/ function(module, exports, __webpack_require__) {
  7740. /** @module ng1_directives */ /** for typedoc */
  7741. "use strict";
  7742. var common_1 = __webpack_require__(3);
  7743. var predicates_1 = __webpack_require__(4);
  7744. var trace_1 = __webpack_require__(12);
  7745. var views_1 = __webpack_require__(55);
  7746. var hof_1 = __webpack_require__(5);
  7747. var resolveContext_1 = __webpack_require__(17);
  7748. var strings_1 = __webpack_require__(9);
  7749. var services_1 = __webpack_require__(53);
  7750. var angular = __webpack_require__(57);
  7751. /**
  7752. * `ui-view`: A viewport directive which is filled in by a view from the active state.
  7753. *
  7754. * @param {string=} name A view name. The name should be unique amongst the other views in the
  7755. * same state. You can have views of the same name that live in different states.
  7756. *
  7757. * @param {string=} autoscroll It allows you to set the scroll behavior of the browser window
  7758. * when a view is populated. By default, $anchorScroll is overridden by ui-router's custom scroll
  7759. * service, {@link ui.router.state.$uiViewScroll}. This custom service let's you
  7760. * scroll ui-view elements into view when they are populated during a state activation.
  7761. *
  7762. * *Note: To revert back to old [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll)
  7763. * functionality, call `$uiViewScrollProvider.useAnchorScroll()`.*
  7764. *
  7765. * @param {string=} onload Expression to evaluate whenever the view updates.
  7766. *
  7767. * A view can be unnamed or named.
  7768. * @example
  7769. * ```html
  7770. *
  7771. * <!-- Unnamed -->
  7772. * <div ui-view></div>
  7773. *
  7774. * <!-- Named -->
  7775. * <div ui-view="viewName"></div>
  7776. * ```
  7777. *
  7778. * You can only have one unnamed view within any template (or root html). If you are only using a
  7779. * single view and it is unnamed then you can populate it like so:
  7780. * ```
  7781. *
  7782. * <div ui-view></div>
  7783. * $stateProvider.state("home", {
  7784. * template: "<h1>HELLO!</h1>"
  7785. * })
  7786. * ```
  7787. *
  7788. * The above is a convenient shortcut equivalent to specifying your view explicitly with the {@link ui.router.state.$stateProvider#views `views`}
  7789. * config property, by name, in this case an empty name:
  7790. * ```js
  7791. *
  7792. * $stateProvider.state("home", {
  7793. * views: {
  7794. * "": {
  7795. * template: "<h1>HELLO!</h1>"
  7796. * }
  7797. * }
  7798. * })
  7799. * ```
  7800. *
  7801. * But typically you'll only use the views property if you name your view or have more than one view
  7802. * in the same template. There's not really a compelling reason to name a view if its the only one,
  7803. * but you could if you wanted, like so:
  7804. *
  7805. * ```html
  7806. *
  7807. * <div ui-view="main"></div>
  7808. * ```
  7809. *
  7810. * ```js
  7811. *
  7812. * $stateProvider.state("home", {
  7813. * views: {
  7814. * "main": {
  7815. * template: "<h1>HELLO!</h1>"
  7816. * }
  7817. * }
  7818. * })
  7819. * ```
  7820. *
  7821. * Really though, you'll use views to set up multiple views:
  7822. * ```html
  7823. *
  7824. * <div ui-view></div>
  7825. * <div ui-view="chart"></div>
  7826. * <div ui-view="data"></div>
  7827. * ```
  7828. *
  7829. * ```js
  7830. * $stateProvider.state("home", {
  7831. * views: {
  7832. * "": {
  7833. * template: "<h1>HELLO!</h1>"
  7834. * },
  7835. * "chart": {
  7836. * template: "<chart_thing/>"
  7837. * },
  7838. * "data": {
  7839. * template: "<data_thing/>"
  7840. * }
  7841. * }
  7842. * })
  7843. * ```
  7844. *
  7845. * Examples for `autoscroll`:
  7846. *
  7847. * ```html
  7848. *
  7849. * <!-- If autoscroll present with no expression,
  7850. * then scroll ui-view into view -->
  7851. * <ui-view autoscroll/>
  7852. *
  7853. * <!-- If autoscroll present with valid expression,
  7854. * then scroll ui-view into view if expression evaluates to true -->
  7855. * <ui-view autoscroll='true'/>
  7856. * <ui-view autoscroll='false'/>
  7857. * <ui-view autoscroll='scopeVariable'/>
  7858. * ```
  7859. *
  7860. * Resolve data:
  7861. *
  7862. * The resolved data from the state's `resolve` block is placed on the scope as `$resolve` (this
  7863. * can be customized using [[ViewDeclaration.resolveAs]]). This can be then accessed from the template.
  7864. *
  7865. * Note that when `controllerAs` is being used, `$resolve` is set on the controller instance *after* the
  7866. * controller is instantiated. The `$onInit()` hook can be used to perform initialization code which
  7867. * depends on `$resolve` data.
  7868. *
  7869. * @example
  7870. * ```js
  7871. *
  7872. * $stateProvider.state('home', {
  7873. * template: '<my-component user="$resolve.user"></my-component>',
  7874. * resolve: {
  7875. * user: function(UserService) { return UserService.fetchUser(); }
  7876. * }
  7877. * });
  7878. * ```
  7879. */
  7880. var uiView = ['$view', '$animate', '$uiViewScroll', '$interpolate', '$q',
  7881. function $ViewDirective($view, $animate, $uiViewScroll, $interpolate, $q) {
  7882. function getRenderer(attrs, scope) {
  7883. return {
  7884. enter: function (element, target, cb) {
  7885. if (angular.version.minor > 2) {
  7886. $animate.enter(element, null, target).then(cb);
  7887. }
  7888. else {
  7889. $animate.enter(element, null, target, cb);
  7890. }
  7891. },
  7892. leave: function (element, cb) {
  7893. if (angular.version.minor > 2) {
  7894. $animate.leave(element).then(cb);
  7895. }
  7896. else {
  7897. $animate.leave(element, cb);
  7898. }
  7899. }
  7900. };
  7901. }
  7902. function configsEqual(config1, config2) {
  7903. return config1 === config2;
  7904. }
  7905. var rootData = {
  7906. $cfg: { viewDecl: { $context: $view.rootContext() } },
  7907. $uiView: {}
  7908. };
  7909. var directive = {
  7910. count: 0,
  7911. restrict: 'ECA',
  7912. terminal: true,
  7913. priority: 400,
  7914. transclude: 'element',
  7915. compile: function (tElement, tAttrs, $transclude) {
  7916. return function (scope, $element, attrs) {
  7917. 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';
  7918. var activeUIView = {
  7919. $type: 'ng1',
  7920. id: directive.count++,
  7921. name: name,
  7922. fqn: inherited.$uiView.fqn ? inherited.$uiView.fqn + "." + name : name,
  7923. config: null,
  7924. configUpdated: configUpdatedCallback,
  7925. get creationContext() {
  7926. return hof_1.parse('$cfg.viewDecl.$context')(inherited);
  7927. }
  7928. };
  7929. trace_1.trace.traceUIViewEvent("Linking", activeUIView);
  7930. function configUpdatedCallback(config) {
  7931. if (config && !(config instanceof views_1.Ng1ViewConfig))
  7932. return;
  7933. if (configsEqual(viewConfig, config))
  7934. return;
  7935. trace_1.trace.traceUIViewConfigUpdated(activeUIView, config && config.viewDecl && config.viewDecl.$context);
  7936. viewConfig = config;
  7937. updateView(config);
  7938. }
  7939. $element.data('$uiView', { $uiView: activeUIView });
  7940. updateView();
  7941. unregister = $view.registerUIView(activeUIView);
  7942. scope.$on("$destroy", function () {
  7943. trace_1.trace.traceUIViewEvent("Destroying/Unregistering", activeUIView);
  7944. unregister();
  7945. });
  7946. function cleanupLastView() {
  7947. if (previousEl) {
  7948. trace_1.trace.traceUIViewEvent("Removing (previous) el", previousEl.data('$uiView'));
  7949. previousEl.remove();
  7950. previousEl = null;
  7951. }
  7952. if (currentScope) {
  7953. trace_1.trace.traceUIViewEvent("Destroying scope", activeUIView);
  7954. currentScope.$destroy();
  7955. currentScope = null;
  7956. }
  7957. if (currentEl) {
  7958. var _viewData_1 = currentEl.data('$uiViewAnim');
  7959. trace_1.trace.traceUIViewEvent("Animate out", _viewData_1);
  7960. renderer.leave(currentEl, function () {
  7961. _viewData_1.$$animLeave.resolve();
  7962. previousEl = null;
  7963. });
  7964. previousEl = currentEl;
  7965. currentEl = null;
  7966. }
  7967. }
  7968. function updateView(config) {
  7969. var newScope = scope.$new();
  7970. var animEnter = $q.defer(), animLeave = $q.defer();
  7971. var $uiViewData = {
  7972. $cfg: config,
  7973. $uiView: activeUIView,
  7974. };
  7975. var $uiViewAnim = {
  7976. $animEnter: animEnter.promise,
  7977. $animLeave: animLeave.promise,
  7978. $$animLeave: animLeave
  7979. };
  7980. var cloned = $transclude(newScope, function (clone) {
  7981. clone.data('$uiViewAnim', $uiViewAnim);
  7982. clone.data('$uiView', $uiViewData);
  7983. renderer.enter(clone, $element, function onUIViewEnter() {
  7984. animEnter.resolve();
  7985. if (currentScope)
  7986. currentScope.$emit('$viewContentAnimationEnded');
  7987. if (predicates_1.isDefined(autoScrollExp) && !autoScrollExp || scope.$eval(autoScrollExp)) {
  7988. $uiViewScroll(clone);
  7989. }
  7990. });
  7991. cleanupLastView();
  7992. });
  7993. currentEl = cloned;
  7994. currentScope = newScope;
  7995. /**
  7996. * @ngdoc event
  7997. * @name ui.router.state.directive:ui-view#$viewContentLoaded
  7998. * @eventOf ui.router.state.directive:ui-view
  7999. * @eventType emits on ui-view directive scope
  8000. * @description *
  8001. * Fired once the view is **loaded**, *after* the DOM is rendered.
  8002. *
  8003. * @param {Object} event Event object.
  8004. */
  8005. currentScope.$emit('$viewContentLoaded', config || viewConfig);
  8006. currentScope.$eval(onloadExp);
  8007. }
  8008. };
  8009. }
  8010. };
  8011. return directive;
  8012. }];
  8013. $ViewDirectiveFill.$inject = ['$compile', '$controller', '$transitions', '$view', '$timeout'];
  8014. /** @hidden */
  8015. function $ViewDirectiveFill($compile, $controller, $transitions, $view, $timeout) {
  8016. var getControllerAs = hof_1.parse('viewDecl.controllerAs');
  8017. var getResolveAs = hof_1.parse('viewDecl.resolveAs');
  8018. return {
  8019. restrict: 'ECA',
  8020. priority: -400,
  8021. compile: function (tElement) {
  8022. var initial = tElement.html();
  8023. return function (scope, $element) {
  8024. var data = $element.data('$uiView');
  8025. if (!data)
  8026. return;
  8027. var cfg = data.$cfg || { viewDecl: {} };
  8028. $element.html(cfg.template || initial);
  8029. trace_1.trace.traceUIViewFill(data.$uiView, $element.html());
  8030. var link = $compile($element.contents());
  8031. var controller = cfg.controller;
  8032. var controllerAs = getControllerAs(cfg);
  8033. var resolveAs = getResolveAs(cfg);
  8034. var resolveCtx = cfg.path && new resolveContext_1.ResolveContext(cfg.path);
  8035. var locals = resolveCtx && services_1.getLocals(resolveCtx);
  8036. scope[resolveAs] = locals;
  8037. if (controller) {
  8038. var controllerInstance = $controller(controller, common_1.extend({}, locals, { $scope: scope, $element: $element }));
  8039. if (controllerAs) {
  8040. scope[controllerAs] = controllerInstance;
  8041. scope[controllerAs][resolveAs] = locals;
  8042. }
  8043. // TODO: Use $view service as a central point for registering component-level hooks
  8044. // Then, when a component is created, tell the $view service, so it can invoke hooks
  8045. // $view.componentLoaded(controllerInstance, { $scope: scope, $element: $element });
  8046. // scope.$on('$destroy', () => $view.componentUnloaded(controllerInstance, { $scope: scope, $element: $element }));
  8047. $element.data('$ngControllerController', controllerInstance);
  8048. $element.children().data('$ngControllerController', controllerInstance);
  8049. registerControllerCallbacks($transitions, controllerInstance, scope, cfg);
  8050. }
  8051. // Wait for the component to appear in the DOM
  8052. if (predicates_1.isString(cfg.viewDecl.component)) {
  8053. var cmp_1 = cfg.viewDecl.component;
  8054. var kebobName_1 = strings_1.kebobString(cmp_1);
  8055. var getComponentController = function () {
  8056. var directiveEl = [].slice.call($element[0].children)
  8057. .filter(function (el) { return el && el.tagName && el.tagName.toLowerCase() === kebobName_1; });
  8058. return directiveEl && angular.element(directiveEl).data("$" + cmp_1 + "Controller");
  8059. };
  8060. var deregisterWatch_1 = scope.$watch(getComponentController, function (ctrlInstance) {
  8061. if (!ctrlInstance)
  8062. return;
  8063. registerControllerCallbacks($transitions, ctrlInstance, scope, cfg);
  8064. deregisterWatch_1();
  8065. });
  8066. }
  8067. link(scope);
  8068. };
  8069. }
  8070. };
  8071. }
  8072. /** @hidden */
  8073. var hasComponentImpl = typeof angular.module('ui.router')['component'] === 'function';
  8074. /** @hidden TODO: move these callbacks to $view and/or `/hooks/components.ts` or something */
  8075. function registerControllerCallbacks($transitions, controllerInstance, $scope, cfg) {
  8076. // Call $onInit() ASAP
  8077. if (predicates_1.isFunction(controllerInstance.$onInit) && !(cfg.viewDecl.component && hasComponentImpl))
  8078. controllerInstance.$onInit();
  8079. var viewState = common_1.tail(cfg.path).state.self;
  8080. var hookOptions = { bind: controllerInstance };
  8081. // Add component-level hook for onParamsChange
  8082. if (predicates_1.isFunction(controllerInstance.uiOnParamsChanged)) {
  8083. var resolveContext = new resolveContext_1.ResolveContext(cfg.path);
  8084. var viewCreationTrans_1 = resolveContext.getResolvable('$transition$').data;
  8085. // Fire callback on any successful transition
  8086. var paramsUpdated = function ($transition$) {
  8087. // Exit early if the $transition$ is the same as the view was created within.
  8088. // Exit early if the $transition$ will exit the state the view is for.
  8089. if ($transition$ === viewCreationTrans_1 || $transition$.exiting().indexOf(viewState) !== -1)
  8090. return;
  8091. var toParams = $transition$.params("to");
  8092. var fromParams = $transition$.params("from");
  8093. var toSchema = $transition$.treeChanges().to.map(function (node) { return node.paramSchema; }).reduce(common_1.unnestR, []);
  8094. var fromSchema = $transition$.treeChanges().from.map(function (node) { return node.paramSchema; }).reduce(common_1.unnestR, []);
  8095. // Find the to params that have different values than the from params
  8096. var changedToParams = toSchema.filter(function (param) {
  8097. var idx = fromSchema.indexOf(param);
  8098. return idx === -1 || !fromSchema[idx].type.equals(toParams[param.id], fromParams[param.id]);
  8099. });
  8100. // Only trigger callback if a to param has changed or is new
  8101. if (changedToParams.length) {
  8102. var changedKeys_1 = changedToParams.map(function (x) { return x.id; });
  8103. // Filter the params to only changed/new to params. `$transition$.params()` may be used to get all params.
  8104. controllerInstance.uiOnParamsChanged(common_1.filter(toParams, function (val, key) { return changedKeys_1.indexOf(key) !== -1; }), $transition$);
  8105. }
  8106. };
  8107. $scope.$on('$destroy', $transitions.onSuccess({}, paramsUpdated, hookOptions));
  8108. }
  8109. // Add component-level hook for uiCanExit
  8110. if (predicates_1.isFunction(controllerInstance.uiCanExit)) {
  8111. var criteria = { exiting: viewState.name };
  8112. $scope.$on('$destroy', $transitions.onBefore(criteria, controllerInstance.uiCanExit, hookOptions));
  8113. }
  8114. }
  8115. angular.module('ui.router.state').directive('uiView', uiView);
  8116. angular.module('ui.router.state').directive('uiView', $ViewDirectiveFill);
  8117. /***/ },
  8118. /* 63 */
  8119. /***/ function(module, exports, __webpack_require__) {
  8120. "use strict";
  8121. /** @module ng1 */ /** */
  8122. var angular = __webpack_require__(57);
  8123. /**
  8124. * @ngdoc object
  8125. * @name ui.router.state.$uiViewScrollProvider
  8126. *
  8127. * @description
  8128. * Provider that returns the {@link ui.router.state.$uiViewScroll} service function.
  8129. */
  8130. function $ViewScrollProvider() {
  8131. var useAnchorScroll = false;
  8132. /**
  8133. * @ngdoc function
  8134. * @name ui.router.state.$uiViewScrollProvider#useAnchorScroll
  8135. * @methodOf ui.router.state.$uiViewScrollProvider
  8136. *
  8137. * @description
  8138. * Reverts back to using the core [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll) service for
  8139. * scrolling based on the url anchor.
  8140. */
  8141. this.useAnchorScroll = function () {
  8142. useAnchorScroll = true;
  8143. };
  8144. /**
  8145. * @ngdoc object
  8146. * @name ui.router.state.$uiViewScroll
  8147. *
  8148. * @requires $anchorScroll
  8149. * @requires $timeout
  8150. *
  8151. * @description
  8152. * When called with a jqLite element, it scrolls the element into view (after a
  8153. * `$timeout` so the DOM has time to refresh).
  8154. *
  8155. * If you prefer to rely on `$anchorScroll` to scroll the view to the anchor,
  8156. * this can be enabled by calling {@link ui.router.state.$uiViewScrollProvider#methods_useAnchorScroll `$uiViewScrollProvider.useAnchorScroll()`}.
  8157. */
  8158. this.$get = ['$anchorScroll', '$timeout', function ($anchorScroll, $timeout) {
  8159. if (useAnchorScroll) {
  8160. return $anchorScroll;
  8161. }
  8162. return function ($element) {
  8163. return $timeout(function () {
  8164. $element[0].scrollIntoView();
  8165. }, 0, false);
  8166. };
  8167. }];
  8168. }
  8169. angular.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider);
  8170. /***/ }
  8171. /******/ ])
  8172. });
  8173. ;
  8174. //# sourceMappingURL=angular-ui-router.js.map