angular-ui-router.js 330 KB

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