router.umd.js 227KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351
  1. /**
  2. * @license Angular v6.0.9
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/common'), require('@angular/platform-browser')) :
  8. typeof define === 'function' && define.amd ? define('@angular/router', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/common', '@angular/platform-browser'], factory) :
  9. (factory((global.ng = global.ng || {}, global.ng.router = {}),global.ng.core,global.rxjs,global.rxjs.operators,global.ng.common,global.ng.platformBrowser));
  10. }(this, (function (exports,core,rxjs,operators,common,platformBrowser) { 'use strict';
  11. /*! *****************************************************************************
  12. Copyright (c) Microsoft Corporation. All rights reserved.
  13. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  14. this file except in compliance with the License. You may obtain a copy of the
  15. License at http://www.apache.org/licenses/LICENSE-2.0
  16. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  18. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  19. MERCHANTABLITY OR NON-INFRINGEMENT.
  20. See the Apache Version 2.0 License for specific language governing permissions
  21. and limitations under the License.
  22. ***************************************************************************** */
  23. /* global Reflect, Promise */
  24. var extendStatics = Object.setPrototypeOf ||
  25. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  27. function __extends(d, b) {
  28. extendStatics(d, b);
  29. function __() { this.constructor = d; }
  30. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31. }
  32. var __assign = Object.assign || function __assign(t) {
  33. for (var s, i = 1, n = arguments.length; i < n; i++) {
  34. s = arguments[i];
  35. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  36. }
  37. return t;
  38. };
  39. function __values(o) {
  40. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  41. if (m) return m.call(o);
  42. return {
  43. next: function () {
  44. if (o && i >= o.length) o = void 0;
  45. return { value: o && o[i++], done: !o };
  46. }
  47. };
  48. }
  49. function __read(o, n) {
  50. var m = typeof Symbol === "function" && o[Symbol.iterator];
  51. if (!m) return o;
  52. var i = m.call(o), r, ar = [], e;
  53. try {
  54. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  55. }
  56. catch (error) { e = { error: error }; }
  57. finally {
  58. try {
  59. if (r && !r.done && (m = i["return"])) m.call(i);
  60. }
  61. finally { if (e) throw e.error; }
  62. }
  63. return ar;
  64. }
  65. function __spread() {
  66. for (var ar = [], i = 0; i < arguments.length; i++)
  67. ar = ar.concat(__read(arguments[i]));
  68. return ar;
  69. }
  70. /**
  71. * @license
  72. * Copyright Google Inc. All Rights Reserved.
  73. *
  74. * Use of this source code is governed by an MIT-style license that can be
  75. * found in the LICENSE file at https://angular.io/license
  76. */
  77. /**
  78. * @description
  79. *
  80. * Base for events the Router goes through, as opposed to events tied to a specific
  81. * Route. `RouterEvent`s will only be fired one time for any given navigation.
  82. *
  83. * Example:
  84. *
  85. * ```
  86. * class MyService {
  87. * constructor(public router: Router, logger: Logger) {
  88. * router.events.filter(e => e instanceof RouterEvent).subscribe(e => {
  89. * logger.log(e.id, e.url);
  90. * });
  91. * }
  92. * }
  93. * ```
  94. *
  95. * @experimental
  96. */
  97. var RouterEvent = /** @class */ (function () {
  98. function RouterEvent(
  99. /** @docsNotRequired */
  100. id,
  101. /** @docsNotRequired */
  102. url) {
  103. this.id = id;
  104. this.url = url;
  105. }
  106. return RouterEvent;
  107. }());
  108. /**
  109. * @description
  110. *
  111. * Represents an event triggered when a navigation starts.
  112. *
  113. *
  114. */
  115. var NavigationStart = /** @class */ (function (_super) {
  116. __extends(NavigationStart, _super);
  117. function NavigationStart(
  118. /** @docsNotRequired */
  119. id,
  120. /** @docsNotRequired */
  121. url,
  122. /** @docsNotRequired */
  123. navigationTrigger,
  124. /** @docsNotRequired */
  125. restoredState) {
  126. /** @docsNotRequired */
  127. if (navigationTrigger === void 0) { navigationTrigger = 'imperative'; }
  128. /** @docsNotRequired */
  129. if (restoredState === void 0) { restoredState = null; }
  130. var _this = _super.call(this, id, url) || this;
  131. _this.navigationTrigger = navigationTrigger;
  132. _this.restoredState = restoredState;
  133. return _this;
  134. }
  135. /** @docsNotRequired */
  136. NavigationStart.prototype.toString = function () { return "NavigationStart(id: " + this.id + ", url: '" + this.url + "')"; };
  137. return NavigationStart;
  138. }(RouterEvent));
  139. /**
  140. * @description
  141. *
  142. * Represents an event triggered when a navigation ends successfully.
  143. *
  144. *
  145. */
  146. var NavigationEnd = /** @class */ (function (_super) {
  147. __extends(NavigationEnd, _super);
  148. function NavigationEnd(
  149. /** @docsNotRequired */
  150. id,
  151. /** @docsNotRequired */
  152. url,
  153. /** @docsNotRequired */
  154. urlAfterRedirects) {
  155. var _this = _super.call(this, id, url) || this;
  156. _this.urlAfterRedirects = urlAfterRedirects;
  157. return _this;
  158. }
  159. /** @docsNotRequired */
  160. NavigationEnd.prototype.toString = function () {
  161. return "NavigationEnd(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "')";
  162. };
  163. return NavigationEnd;
  164. }(RouterEvent));
  165. /**
  166. * @description
  167. *
  168. * Represents an event triggered when a navigation is canceled.
  169. *
  170. *
  171. */
  172. var NavigationCancel = /** @class */ (function (_super) {
  173. __extends(NavigationCancel, _super);
  174. function NavigationCancel(
  175. /** @docsNotRequired */
  176. id,
  177. /** @docsNotRequired */
  178. url,
  179. /** @docsNotRequired */
  180. reason) {
  181. var _this = _super.call(this, id, url) || this;
  182. _this.reason = reason;
  183. return _this;
  184. }
  185. /** @docsNotRequired */
  186. NavigationCancel.prototype.toString = function () { return "NavigationCancel(id: " + this.id + ", url: '" + this.url + "')"; };
  187. return NavigationCancel;
  188. }(RouterEvent));
  189. /**
  190. * @description
  191. *
  192. * Represents an event triggered when a navigation fails due to an unexpected error.
  193. *
  194. *
  195. */
  196. var NavigationError = /** @class */ (function (_super) {
  197. __extends(NavigationError, _super);
  198. function NavigationError(
  199. /** @docsNotRequired */
  200. id,
  201. /** @docsNotRequired */
  202. url,
  203. /** @docsNotRequired */
  204. error) {
  205. var _this = _super.call(this, id, url) || this;
  206. _this.error = error;
  207. return _this;
  208. }
  209. /** @docsNotRequired */
  210. NavigationError.prototype.toString = function () {
  211. return "NavigationError(id: " + this.id + ", url: '" + this.url + "', error: " + this.error + ")";
  212. };
  213. return NavigationError;
  214. }(RouterEvent));
  215. /**
  216. * @description
  217. *
  218. * Represents an event triggered when routes are recognized.
  219. *
  220. *
  221. */
  222. var RoutesRecognized = /** @class */ (function (_super) {
  223. __extends(RoutesRecognized, _super);
  224. function RoutesRecognized(
  225. /** @docsNotRequired */
  226. id,
  227. /** @docsNotRequired */
  228. url,
  229. /** @docsNotRequired */
  230. urlAfterRedirects,
  231. /** @docsNotRequired */
  232. state) {
  233. var _this = _super.call(this, id, url) || this;
  234. _this.urlAfterRedirects = urlAfterRedirects;
  235. _this.state = state;
  236. return _this;
  237. }
  238. /** @docsNotRequired */
  239. RoutesRecognized.prototype.toString = function () {
  240. return "RoutesRecognized(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
  241. };
  242. return RoutesRecognized;
  243. }(RouterEvent));
  244. /**
  245. * @description
  246. *
  247. * Represents the start of the Guard phase of routing.
  248. *
  249. * @experimental
  250. */
  251. var GuardsCheckStart = /** @class */ (function (_super) {
  252. __extends(GuardsCheckStart, _super);
  253. function GuardsCheckStart(
  254. /** @docsNotRequired */
  255. id,
  256. /** @docsNotRequired */
  257. url,
  258. /** @docsNotRequired */
  259. urlAfterRedirects,
  260. /** @docsNotRequired */
  261. state) {
  262. var _this = _super.call(this, id, url) || this;
  263. _this.urlAfterRedirects = urlAfterRedirects;
  264. _this.state = state;
  265. return _this;
  266. }
  267. GuardsCheckStart.prototype.toString = function () {
  268. return "GuardsCheckStart(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
  269. };
  270. return GuardsCheckStart;
  271. }(RouterEvent));
  272. /**
  273. * @description
  274. *
  275. * Represents the end of the Guard phase of routing.
  276. *
  277. * @experimental
  278. */
  279. var GuardsCheckEnd = /** @class */ (function (_super) {
  280. __extends(GuardsCheckEnd, _super);
  281. function GuardsCheckEnd(
  282. /** @docsNotRequired */
  283. id,
  284. /** @docsNotRequired */
  285. url,
  286. /** @docsNotRequired */
  287. urlAfterRedirects,
  288. /** @docsNotRequired */
  289. state,
  290. /** @docsNotRequired */
  291. shouldActivate) {
  292. var _this = _super.call(this, id, url) || this;
  293. _this.urlAfterRedirects = urlAfterRedirects;
  294. _this.state = state;
  295. _this.shouldActivate = shouldActivate;
  296. return _this;
  297. }
  298. GuardsCheckEnd.prototype.toString = function () {
  299. return "GuardsCheckEnd(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ", shouldActivate: " + this.shouldActivate + ")";
  300. };
  301. return GuardsCheckEnd;
  302. }(RouterEvent));
  303. /**
  304. * @description
  305. *
  306. * Represents the start of the Resolve phase of routing. The timing of this
  307. * event may change, thus it's experimental. In the current iteration it will run
  308. * in the "resolve" phase whether there's things to resolve or not. In the future this
  309. * behavior may change to only run when there are things to be resolved.
  310. *
  311. * @experimental
  312. */
  313. var ResolveStart = /** @class */ (function (_super) {
  314. __extends(ResolveStart, _super);
  315. function ResolveStart(
  316. /** @docsNotRequired */
  317. id,
  318. /** @docsNotRequired */
  319. url,
  320. /** @docsNotRequired */
  321. urlAfterRedirects,
  322. /** @docsNotRequired */
  323. state) {
  324. var _this = _super.call(this, id, url) || this;
  325. _this.urlAfterRedirects = urlAfterRedirects;
  326. _this.state = state;
  327. return _this;
  328. }
  329. ResolveStart.prototype.toString = function () {
  330. return "ResolveStart(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
  331. };
  332. return ResolveStart;
  333. }(RouterEvent));
  334. /**
  335. * @description
  336. *
  337. * Represents the end of the Resolve phase of routing. See note on
  338. * `ResolveStart` for use of this experimental API.
  339. *
  340. * @experimental
  341. */
  342. var ResolveEnd = /** @class */ (function (_super) {
  343. __extends(ResolveEnd, _super);
  344. function ResolveEnd(
  345. /** @docsNotRequired */
  346. id,
  347. /** @docsNotRequired */
  348. url,
  349. /** @docsNotRequired */
  350. urlAfterRedirects,
  351. /** @docsNotRequired */
  352. state) {
  353. var _this = _super.call(this, id, url) || this;
  354. _this.urlAfterRedirects = urlAfterRedirects;
  355. _this.state = state;
  356. return _this;
  357. }
  358. ResolveEnd.prototype.toString = function () {
  359. return "ResolveEnd(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
  360. };
  361. return ResolveEnd;
  362. }(RouterEvent));
  363. /**
  364. * @description
  365. *
  366. * Represents an event triggered before lazy loading a route config.
  367. *
  368. * @experimental
  369. */
  370. var RouteConfigLoadStart = /** @class */ (function () {
  371. function RouteConfigLoadStart(
  372. /** @docsNotRequired */
  373. route) {
  374. this.route = route;
  375. }
  376. RouteConfigLoadStart.prototype.toString = function () { return "RouteConfigLoadStart(path: " + this.route.path + ")"; };
  377. return RouteConfigLoadStart;
  378. }());
  379. /**
  380. * @description
  381. *
  382. * Represents an event triggered when a route has been lazy loaded.
  383. *
  384. * @experimental
  385. */
  386. var RouteConfigLoadEnd = /** @class */ (function () {
  387. function RouteConfigLoadEnd(
  388. /** @docsNotRequired */
  389. route) {
  390. this.route = route;
  391. }
  392. RouteConfigLoadEnd.prototype.toString = function () { return "RouteConfigLoadEnd(path: " + this.route.path + ")"; };
  393. return RouteConfigLoadEnd;
  394. }());
  395. /**
  396. * @description
  397. *
  398. * Represents the start of end of the Resolve phase of routing. See note on
  399. * `ChildActivationEnd` for use of this experimental API.
  400. *
  401. * @experimental
  402. */
  403. var ChildActivationStart = /** @class */ (function () {
  404. function ChildActivationStart(
  405. /** @docsNotRequired */
  406. snapshot) {
  407. this.snapshot = snapshot;
  408. }
  409. ChildActivationStart.prototype.toString = function () {
  410. var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
  411. return "ChildActivationStart(path: '" + path + "')";
  412. };
  413. return ChildActivationStart;
  414. }());
  415. /**
  416. * @description
  417. *
  418. * Represents the start of end of the Resolve phase of routing. See note on
  419. * `ChildActivationStart` for use of this experimental API.
  420. *
  421. * @experimental
  422. */
  423. var ChildActivationEnd = /** @class */ (function () {
  424. function ChildActivationEnd(
  425. /** @docsNotRequired */
  426. snapshot) {
  427. this.snapshot = snapshot;
  428. }
  429. ChildActivationEnd.prototype.toString = function () {
  430. var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
  431. return "ChildActivationEnd(path: '" + path + "')";
  432. };
  433. return ChildActivationEnd;
  434. }());
  435. /**
  436. * @description
  437. *
  438. * Represents the start of end of the Resolve phase of routing. See note on
  439. * `ActivationEnd` for use of this experimental API.
  440. *
  441. * @experimental
  442. */
  443. var ActivationStart = /** @class */ (function () {
  444. function ActivationStart(
  445. /** @docsNotRequired */
  446. snapshot) {
  447. this.snapshot = snapshot;
  448. }
  449. ActivationStart.prototype.toString = function () {
  450. var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
  451. return "ActivationStart(path: '" + path + "')";
  452. };
  453. return ActivationStart;
  454. }());
  455. /**
  456. * @description
  457. *
  458. * Represents the start of end of the Resolve phase of routing. See note on
  459. * `ActivationStart` for use of this experimental API.
  460. *
  461. * @experimental
  462. */
  463. var ActivationEnd = /** @class */ (function () {
  464. function ActivationEnd(
  465. /** @docsNotRequired */
  466. snapshot) {
  467. this.snapshot = snapshot;
  468. }
  469. ActivationEnd.prototype.toString = function () {
  470. var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
  471. return "ActivationEnd(path: '" + path + "')";
  472. };
  473. return ActivationEnd;
  474. }());
  475. /**
  476. * @license
  477. * Copyright Google Inc. All Rights Reserved.
  478. *
  479. * Use of this source code is governed by an MIT-style license that can be
  480. * found in the LICENSE file at https://angular.io/license
  481. */
  482. /**
  483. * This component is used internally within the router to be a placeholder when an empty
  484. * router-outlet is needed. For example, with a config such as:
  485. *
  486. * `{path: 'parent', outlet: 'nav', children: [...]}`
  487. *
  488. * In order to render, there needs to be a component on this config, which will default
  489. * to this `EmptyOutletComponent`.
  490. */
  491. var EmptyOutletComponent = /** @class */ (function () {
  492. function EmptyOutletComponent() {
  493. }
  494. EmptyOutletComponent.decorators = [
  495. { type: core.Component, args: [{ template: "<router-outlet></router-outlet>" }] }
  496. ];
  497. return EmptyOutletComponent;
  498. }());
  499. /**
  500. * @license
  501. * Copyright Google Inc. All Rights Reserved.
  502. *
  503. * Use of this source code is governed by an MIT-style license that can be
  504. * found in the LICENSE file at https://angular.io/license
  505. */
  506. /**
  507. * @description
  508. *
  509. * Name of the primary outlet.
  510. *
  511. *
  512. */
  513. var PRIMARY_OUTLET = 'primary';
  514. var ParamsAsMap = /** @class */ (function () {
  515. function ParamsAsMap(params) {
  516. this.params = params || {};
  517. }
  518. ParamsAsMap.prototype.has = function (name) { return this.params.hasOwnProperty(name); };
  519. ParamsAsMap.prototype.get = function (name) {
  520. if (this.has(name)) {
  521. var v = this.params[name];
  522. return Array.isArray(v) ? v[0] : v;
  523. }
  524. return null;
  525. };
  526. ParamsAsMap.prototype.getAll = function (name) {
  527. if (this.has(name)) {
  528. var v = this.params[name];
  529. return Array.isArray(v) ? v : [v];
  530. }
  531. return [];
  532. };
  533. Object.defineProperty(ParamsAsMap.prototype, "keys", {
  534. get: function () { return Object.keys(this.params); },
  535. enumerable: true,
  536. configurable: true
  537. });
  538. return ParamsAsMap;
  539. }());
  540. /**
  541. * Convert a `Params` instance to a `ParamMap`.
  542. *
  543. *
  544. */
  545. function convertToParamMap(params) {
  546. return new ParamsAsMap(params);
  547. }
  548. var NAVIGATION_CANCELING_ERROR = 'ngNavigationCancelingError';
  549. function navigationCancelingError(message) {
  550. var error = Error('NavigationCancelingError: ' + message);
  551. error[NAVIGATION_CANCELING_ERROR] = true;
  552. return error;
  553. }
  554. function isNavigationCancelingError(error) {
  555. return error && error[NAVIGATION_CANCELING_ERROR];
  556. }
  557. // Matches the route configuration (`route`) against the actual URL (`segments`).
  558. function defaultUrlMatcher(segments, segmentGroup, route) {
  559. var parts = route.path.split('/');
  560. if (parts.length > segments.length) {
  561. // The actual URL is shorter than the config, no match
  562. return null;
  563. }
  564. if (route.pathMatch === 'full' &&
  565. (segmentGroup.hasChildren() || parts.length < segments.length)) {
  566. // The config is longer than the actual URL but we are looking for a full match, return null
  567. return null;
  568. }
  569. var posParams = {};
  570. // Check each config part against the actual URL
  571. for (var index = 0; index < parts.length; index++) {
  572. var part = parts[index];
  573. var segment = segments[index];
  574. var isParameter = part.startsWith(':');
  575. if (isParameter) {
  576. posParams[part.substring(1)] = segment;
  577. }
  578. else if (part !== segment.path) {
  579. // The actual URL part does not match the config, no match
  580. return null;
  581. }
  582. }
  583. return { consumed: segments.slice(0, parts.length), posParams: posParams };
  584. }
  585. /**
  586. * @license
  587. * Copyright Google Inc. All Rights Reserved.
  588. *
  589. * Use of this source code is governed by an MIT-style license that can be
  590. * found in the LICENSE file at https://angular.io/license
  591. */
  592. var LoadedRouterConfig = /** @class */ (function () {
  593. function LoadedRouterConfig(routes, module) {
  594. this.routes = routes;
  595. this.module = module;
  596. }
  597. return LoadedRouterConfig;
  598. }());
  599. function validateConfig(config, parentPath) {
  600. if (parentPath === void 0) { parentPath = ''; }
  601. // forEach doesn't iterate undefined values
  602. for (var i = 0; i < config.length; i++) {
  603. var route = config[i];
  604. var fullPath = getFullPath(parentPath, route);
  605. validateNode(route, fullPath);
  606. }
  607. }
  608. function validateNode(route, fullPath) {
  609. if (!route) {
  610. throw new Error("\n Invalid configuration of route '" + fullPath + "': Encountered undefined route.\n The reason might be an extra comma.\n\n Example:\n const routes: Routes = [\n { path: '', redirectTo: '/dashboard', pathMatch: 'full' },\n { path: 'dashboard', component: DashboardComponent },, << two commas\n { path: 'detail/:id', component: HeroDetailComponent }\n ];\n ");
  611. }
  612. if (Array.isArray(route)) {
  613. throw new Error("Invalid configuration of route '" + fullPath + "': Array cannot be specified");
  614. }
  615. if (!route.component && !route.children && !route.loadChildren &&
  616. (route.outlet && route.outlet !== PRIMARY_OUTLET)) {
  617. throw new Error("Invalid configuration of route '" + fullPath + "': a componentless route without children or loadChildren cannot have a named outlet set");
  618. }
  619. if (route.redirectTo && route.children) {
  620. throw new Error("Invalid configuration of route '" + fullPath + "': redirectTo and children cannot be used together");
  621. }
  622. if (route.redirectTo && route.loadChildren) {
  623. throw new Error("Invalid configuration of route '" + fullPath + "': redirectTo and loadChildren cannot be used together");
  624. }
  625. if (route.children && route.loadChildren) {
  626. throw new Error("Invalid configuration of route '" + fullPath + "': children and loadChildren cannot be used together");
  627. }
  628. if (route.redirectTo && route.component) {
  629. throw new Error("Invalid configuration of route '" + fullPath + "': redirectTo and component cannot be used together");
  630. }
  631. if (route.path && route.matcher) {
  632. throw new Error("Invalid configuration of route '" + fullPath + "': path and matcher cannot be used together");
  633. }
  634. if (route.redirectTo === void 0 && !route.component && !route.children && !route.loadChildren) {
  635. throw new Error("Invalid configuration of route '" + fullPath + "'. One of the following must be provided: component, redirectTo, children or loadChildren");
  636. }
  637. if (route.path === void 0 && route.matcher === void 0) {
  638. throw new Error("Invalid configuration of route '" + fullPath + "': routes must have either a path or a matcher specified");
  639. }
  640. if (typeof route.path === 'string' && route.path.charAt(0) === '/') {
  641. throw new Error("Invalid configuration of route '" + fullPath + "': path cannot start with a slash");
  642. }
  643. if (route.path === '' && route.redirectTo !== void 0 && route.pathMatch === void 0) {
  644. var exp = "The default value of 'pathMatch' is 'prefix', but often the intent is to use 'full'.";
  645. throw new Error("Invalid configuration of route '{path: \"" + fullPath + "\", redirectTo: \"" + route.redirectTo + "\"}': please provide 'pathMatch'. " + exp);
  646. }
  647. if (route.pathMatch !== void 0 && route.pathMatch !== 'full' && route.pathMatch !== 'prefix') {
  648. throw new Error("Invalid configuration of route '" + fullPath + "': pathMatch can only be set to 'prefix' or 'full'");
  649. }
  650. if (route.children) {
  651. validateConfig(route.children, fullPath);
  652. }
  653. }
  654. function getFullPath(parentPath, currentRoute) {
  655. if (!currentRoute) {
  656. return parentPath;
  657. }
  658. if (!parentPath && !currentRoute.path) {
  659. return '';
  660. }
  661. else if (parentPath && !currentRoute.path) {
  662. return parentPath + "/";
  663. }
  664. else if (!parentPath && currentRoute.path) {
  665. return currentRoute.path;
  666. }
  667. else {
  668. return parentPath + "/" + currentRoute.path;
  669. }
  670. }
  671. /**
  672. * Makes a copy of the config and adds any default required properties.
  673. */
  674. function standardizeConfig(r) {
  675. var children = r.children && r.children.map(standardizeConfig);
  676. var c = children ? __assign({}, r, { children: children }) : __assign({}, r);
  677. if (!c.component && (children || c.loadChildren) && (c.outlet && c.outlet !== PRIMARY_OUTLET)) {
  678. c.component = EmptyOutletComponent;
  679. }
  680. return c;
  681. }
  682. /**
  683. * @license
  684. * Copyright Google Inc. All Rights Reserved.
  685. *
  686. * Use of this source code is governed by an MIT-style license that can be
  687. * found in the LICENSE file at https://angular.io/license
  688. */
  689. function shallowEqualArrays(a, b) {
  690. if (a.length !== b.length)
  691. return false;
  692. for (var i = 0; i < a.length; ++i) {
  693. if (!shallowEqual(a[i], b[i]))
  694. return false;
  695. }
  696. return true;
  697. }
  698. function shallowEqual(a, b) {
  699. var k1 = Object.keys(a);
  700. var k2 = Object.keys(b);
  701. if (k1.length != k2.length) {
  702. return false;
  703. }
  704. var key;
  705. for (var i = 0; i < k1.length; i++) {
  706. key = k1[i];
  707. if (a[key] !== b[key]) {
  708. return false;
  709. }
  710. }
  711. return true;
  712. }
  713. /**
  714. * Flattens single-level nested arrays.
  715. */
  716. function flatten(arr) {
  717. return Array.prototype.concat.apply([], arr);
  718. }
  719. /**
  720. * Return the last element of an array.
  721. */
  722. function last(a) {
  723. return a.length > 0 ? a[a.length - 1] : null;
  724. }
  725. function forEach(map, callback) {
  726. for (var prop in map) {
  727. if (map.hasOwnProperty(prop)) {
  728. callback(map[prop], prop);
  729. }
  730. }
  731. }
  732. function waitForMap(obj, fn) {
  733. if (Object.keys(obj).length === 0) {
  734. return rxjs.of({});
  735. }
  736. var waitHead = [];
  737. var waitTail = [];
  738. var res = {};
  739. forEach(obj, function (a, k) {
  740. var mapped = fn(k, a).pipe(operators.map(function (r) { return res[k] = r; }));
  741. if (k === PRIMARY_OUTLET) {
  742. waitHead.push(mapped);
  743. }
  744. else {
  745. waitTail.push(mapped);
  746. }
  747. });
  748. // Closure compiler has problem with using spread operator here. So just using Array.concat.
  749. return rxjs.of.apply(null, waitHead.concat(waitTail)).pipe(operators.concatAll(), operators.last(), operators.map(function () { return res; }));
  750. }
  751. /**
  752. * ANDs Observables by merging all input observables, reducing to an Observable verifying all
  753. * input Observables return `true`.
  754. */
  755. function andObservables(observables) {
  756. return observables.pipe(operators.mergeAll(), operators.every(function (result) { return result === true; }));
  757. }
  758. function wrapIntoObservable(value) {
  759. if (core.ɵisObservable(value)) {
  760. return value;
  761. }
  762. if (core.ɵisPromise(value)) {
  763. // Use `Promise.resolve()` to wrap promise-like instances.
  764. // Required ie when a Resolver returns a AngularJS `$q` promise to correctly trigger the
  765. // change detection.
  766. return rxjs.from(Promise.resolve(value));
  767. }
  768. return rxjs.of(value);
  769. }
  770. /**
  771. * @license
  772. * Copyright Google Inc. All Rights Reserved.
  773. *
  774. * Use of this source code is governed by an MIT-style license that can be
  775. * found in the LICENSE file at https://angular.io/license
  776. */
  777. function createEmptyUrlTree() {
  778. return new UrlTree(new UrlSegmentGroup([], {}), {}, null);
  779. }
  780. function containsTree(container, containee, exact) {
  781. if (exact) {
  782. return equalQueryParams(container.queryParams, containee.queryParams) &&
  783. equalSegmentGroups(container.root, containee.root);
  784. }
  785. return containsQueryParams(container.queryParams, containee.queryParams) &&
  786. containsSegmentGroup(container.root, containee.root);
  787. }
  788. function equalQueryParams(container, containee) {
  789. return shallowEqual(container, containee);
  790. }
  791. function equalSegmentGroups(container, containee) {
  792. if (!equalPath(container.segments, containee.segments))
  793. return false;
  794. if (container.numberOfChildren !== containee.numberOfChildren)
  795. return false;
  796. for (var c in containee.children) {
  797. if (!container.children[c])
  798. return false;
  799. if (!equalSegmentGroups(container.children[c], containee.children[c]))
  800. return false;
  801. }
  802. return true;
  803. }
  804. function containsQueryParams(container, containee) {
  805. return Object.keys(containee).length <= Object.keys(container).length &&
  806. Object.keys(containee).every(function (key) { return containee[key] === container[key]; });
  807. }
  808. function containsSegmentGroup(container, containee) {
  809. return containsSegmentGroupHelper(container, containee, containee.segments);
  810. }
  811. function containsSegmentGroupHelper(container, containee, containeePaths) {
  812. if (container.segments.length > containeePaths.length) {
  813. var current = container.segments.slice(0, containeePaths.length);
  814. if (!equalPath(current, containeePaths))
  815. return false;
  816. if (containee.hasChildren())
  817. return false;
  818. return true;
  819. }
  820. else if (container.segments.length === containeePaths.length) {
  821. if (!equalPath(container.segments, containeePaths))
  822. return false;
  823. for (var c in containee.children) {
  824. if (!container.children[c])
  825. return false;
  826. if (!containsSegmentGroup(container.children[c], containee.children[c]))
  827. return false;
  828. }
  829. return true;
  830. }
  831. else {
  832. var current = containeePaths.slice(0, container.segments.length);
  833. var next = containeePaths.slice(container.segments.length);
  834. if (!equalPath(container.segments, current))
  835. return false;
  836. if (!container.children[PRIMARY_OUTLET])
  837. return false;
  838. return containsSegmentGroupHelper(container.children[PRIMARY_OUTLET], containee, next);
  839. }
  840. }
  841. /**
  842. * @description
  843. *
  844. * Represents the parsed URL.
  845. *
  846. * Since a router state is a tree, and the URL is nothing but a serialized state, the URL is a
  847. * serialized tree.
  848. * UrlTree is a data structure that provides a lot of affordances in dealing with URLs
  849. *
  850. * ### Example
  851. *
  852. * ```
  853. * @Component({templateUrl:'template.html'})
  854. * class MyComponent {
  855. * constructor(router: Router) {
  856. * const tree: UrlTree =
  857. * router.parseUrl('/team/33/(user/victor//support:help)?debug=true#fragment');
  858. * const f = tree.fragment; // return 'fragment'
  859. * const q = tree.queryParams; // returns {debug: 'true'}
  860. * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
  861. * const s: UrlSegment[] = g.segments; // returns 2 segments 'team' and '33'
  862. * g.children[PRIMARY_OUTLET].segments; // returns 2 segments 'user' and 'victor'
  863. * g.children['support'].segments; // return 1 segment 'help'
  864. * }
  865. * }
  866. * ```
  867. *
  868. *
  869. */
  870. var UrlTree = /** @class */ (function () {
  871. /** @internal */
  872. function UrlTree(
  873. /** The root segment group of the URL tree */
  874. root,
  875. /** The query params of the URL */
  876. queryParams,
  877. /** The fragment of the URL */
  878. fragment) {
  879. this.root = root;
  880. this.queryParams = queryParams;
  881. this.fragment = fragment;
  882. }
  883. Object.defineProperty(UrlTree.prototype, "queryParamMap", {
  884. get: function () {
  885. if (!this._queryParamMap) {
  886. this._queryParamMap = convertToParamMap(this.queryParams);
  887. }
  888. return this._queryParamMap;
  889. },
  890. enumerable: true,
  891. configurable: true
  892. });
  893. /** @docsNotRequired */
  894. UrlTree.prototype.toString = function () { return DEFAULT_SERIALIZER.serialize(this); };
  895. return UrlTree;
  896. }());
  897. /**
  898. * @description
  899. *
  900. * Represents the parsed URL segment group.
  901. *
  902. * See `UrlTree` for more information.
  903. *
  904. *
  905. */
  906. var UrlSegmentGroup = /** @class */ (function () {
  907. function UrlSegmentGroup(
  908. /** The URL segments of this group. See `UrlSegment` for more information */
  909. segments,
  910. /** The list of children of this group */
  911. children) {
  912. var _this = this;
  913. this.segments = segments;
  914. this.children = children;
  915. /** The parent node in the url tree */
  916. this.parent = null;
  917. forEach(children, function (v, k) { return v.parent = _this; });
  918. }
  919. /** Whether the segment has child segments */
  920. UrlSegmentGroup.prototype.hasChildren = function () { return this.numberOfChildren > 0; };
  921. Object.defineProperty(UrlSegmentGroup.prototype, "numberOfChildren", {
  922. /** Number of child segments */
  923. get: function () { return Object.keys(this.children).length; },
  924. enumerable: true,
  925. configurable: true
  926. });
  927. /** @docsNotRequired */
  928. UrlSegmentGroup.prototype.toString = function () { return serializePaths(this); };
  929. return UrlSegmentGroup;
  930. }());
  931. /**
  932. * @description
  933. *
  934. * Represents a single URL segment.
  935. *
  936. * A UrlSegment is a part of a URL between the two slashes. It contains a path and the matrix
  937. * parameters associated with the segment.
  938. *
  939. * ## Example
  940. *
  941. * ```
  942. * @Component({templateUrl:'template.html'})
  943. * class MyComponent {
  944. * constructor(router: Router) {
  945. * const tree: UrlTree = router.parseUrl('/team;id=33');
  946. * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
  947. * const s: UrlSegment[] = g.segments;
  948. * s[0].path; // returns 'team'
  949. * s[0].parameters; // returns {id: 33}
  950. * }
  951. * }
  952. * ```
  953. *
  954. *
  955. */
  956. var UrlSegment = /** @class */ (function () {
  957. function UrlSegment(
  958. /** The path part of a URL segment */
  959. path,
  960. /** The matrix parameters associated with a segment */
  961. parameters) {
  962. this.path = path;
  963. this.parameters = parameters;
  964. }
  965. Object.defineProperty(UrlSegment.prototype, "parameterMap", {
  966. get: function () {
  967. if (!this._parameterMap) {
  968. this._parameterMap = convertToParamMap(this.parameters);
  969. }
  970. return this._parameterMap;
  971. },
  972. enumerable: true,
  973. configurable: true
  974. });
  975. /** @docsNotRequired */
  976. UrlSegment.prototype.toString = function () { return serializePath(this); };
  977. return UrlSegment;
  978. }());
  979. function equalSegments(as, bs) {
  980. return equalPath(as, bs) && as.every(function (a, i) { return shallowEqual(a.parameters, bs[i].parameters); });
  981. }
  982. function equalPath(as, bs) {
  983. if (as.length !== bs.length)
  984. return false;
  985. return as.every(function (a, i) { return a.path === bs[i].path; });
  986. }
  987. function mapChildrenIntoArray(segment, fn) {
  988. var res = [];
  989. forEach(segment.children, function (child, childOutlet) {
  990. if (childOutlet === PRIMARY_OUTLET) {
  991. res = res.concat(fn(child, childOutlet));
  992. }
  993. });
  994. forEach(segment.children, function (child, childOutlet) {
  995. if (childOutlet !== PRIMARY_OUTLET) {
  996. res = res.concat(fn(child, childOutlet));
  997. }
  998. });
  999. return res;
  1000. }
  1001. /**
  1002. * @description
  1003. *
  1004. * Serializes and deserializes a URL string into a URL tree.
  1005. *
  1006. * The url serialization strategy is customizable. You can
  1007. * make all URLs case insensitive by providing a custom UrlSerializer.
  1008. *
  1009. * See `DefaultUrlSerializer` for an example of a URL serializer.
  1010. *
  1011. *
  1012. */
  1013. var UrlSerializer = /** @class */ (function () {
  1014. function UrlSerializer() {
  1015. }
  1016. return UrlSerializer;
  1017. }());
  1018. /**
  1019. * @description
  1020. *
  1021. * A default implementation of the `UrlSerializer`.
  1022. *
  1023. * Example URLs:
  1024. *
  1025. * ```
  1026. * /inbox/33(popup:compose)
  1027. * /inbox/33;open=true/messages/44
  1028. * ```
  1029. *
  1030. * DefaultUrlSerializer uses parentheses to serialize secondary segments (e.g., popup:compose), the
  1031. * colon syntax to specify the outlet, and the ';parameter=value' syntax (e.g., open=true) to
  1032. * specify route specific parameters.
  1033. *
  1034. *
  1035. */
  1036. var DefaultUrlSerializer = /** @class */ (function () {
  1037. function DefaultUrlSerializer() {
  1038. }
  1039. /** Parses a url into a `UrlTree` */
  1040. DefaultUrlSerializer.prototype.parse = function (url) {
  1041. var p = new UrlParser(url);
  1042. return new UrlTree(p.parseRootSegment(), p.parseQueryParams(), p.parseFragment());
  1043. };
  1044. /** Converts a `UrlTree` into a url */
  1045. DefaultUrlSerializer.prototype.serialize = function (tree) {
  1046. var segment = "/" + serializeSegment(tree.root, true);
  1047. var query = serializeQueryParams(tree.queryParams);
  1048. var fragment = typeof tree.fragment === "string" ? "#" + encodeUriFragment(tree.fragment) : '';
  1049. return "" + segment + query + fragment;
  1050. };
  1051. return DefaultUrlSerializer;
  1052. }());
  1053. var DEFAULT_SERIALIZER = new DefaultUrlSerializer();
  1054. function serializePaths(segment) {
  1055. return segment.segments.map(function (p) { return serializePath(p); }).join('/');
  1056. }
  1057. function serializeSegment(segment, root) {
  1058. if (!segment.hasChildren()) {
  1059. return serializePaths(segment);
  1060. }
  1061. if (root) {
  1062. var primary = segment.children[PRIMARY_OUTLET] ?
  1063. serializeSegment(segment.children[PRIMARY_OUTLET], false) :
  1064. '';
  1065. var children_1 = [];
  1066. forEach(segment.children, function (v, k) {
  1067. if (k !== PRIMARY_OUTLET) {
  1068. children_1.push(k + ":" + serializeSegment(v, false));
  1069. }
  1070. });
  1071. return children_1.length > 0 ? primary + "(" + children_1.join('//') + ")" : primary;
  1072. }
  1073. else {
  1074. var children = mapChildrenIntoArray(segment, function (v, k) {
  1075. if (k === PRIMARY_OUTLET) {
  1076. return [serializeSegment(segment.children[PRIMARY_OUTLET], false)];
  1077. }
  1078. return [k + ":" + serializeSegment(v, false)];
  1079. });
  1080. return serializePaths(segment) + "/(" + children.join('//') + ")";
  1081. }
  1082. }
  1083. /**
  1084. * Encodes a URI string with the default encoding. This function will only ever be called from
  1085. * `encodeUriQuery` or `encodeUriSegment` as it's the base set of encodings to be used. We need
  1086. * a custom encoding because encodeURIComponent is too aggressive and encodes stuff that doesn't
  1087. * have to be encoded per https://url.spec.whatwg.org.
  1088. */
  1089. function encodeUriString(s) {
  1090. return encodeURIComponent(s)
  1091. .replace(/%40/g, '@')
  1092. .replace(/%3A/gi, ':')
  1093. .replace(/%24/g, '$')
  1094. .replace(/%2C/gi, ',');
  1095. }
  1096. /**
  1097. * This function should be used to encode both keys and values in a query string key/value. In
  1098. * the following URL, you need to call encodeUriQuery on "k" and "v":
  1099. *
  1100. * http://www.site.org/html;mk=mv?k=v#f
  1101. */
  1102. function encodeUriQuery(s) {
  1103. return encodeUriString(s).replace(/%3B/gi, ';');
  1104. }
  1105. /**
  1106. * This function should be used to encode a URL fragment. In the following URL, you need to call
  1107. * encodeUriFragment on "f":
  1108. *
  1109. * http://www.site.org/html;mk=mv?k=v#f
  1110. */
  1111. function encodeUriFragment(s) {
  1112. return encodeURI(s);
  1113. }
  1114. /**
  1115. * This function should be run on any URI segment as well as the key and value in a key/value
  1116. * pair for matrix params. In the following URL, you need to call encodeUriSegment on "html",
  1117. * "mk", and "mv":
  1118. *
  1119. * http://www.site.org/html;mk=mv?k=v#f
  1120. */
  1121. function encodeUriSegment(s) {
  1122. return encodeUriString(s).replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/%26/gi, '&');
  1123. }
  1124. function decode(s) {
  1125. return decodeURIComponent(s);
  1126. }
  1127. // Query keys/values should have the "+" replaced first, as "+" in a query string is " ".
  1128. // decodeURIComponent function will not decode "+" as a space.
  1129. function decodeQuery(s) {
  1130. return decode(s.replace(/\+/g, '%20'));
  1131. }
  1132. function serializePath(path) {
  1133. return "" + encodeUriSegment(path.path) + serializeMatrixParams(path.parameters);
  1134. }
  1135. function serializeMatrixParams(params) {
  1136. return Object.keys(params)
  1137. .map(function (key) { return ";" + encodeUriSegment(key) + "=" + encodeUriSegment(params[key]); })
  1138. .join('');
  1139. }
  1140. function serializeQueryParams(params) {
  1141. var strParams = Object.keys(params).map(function (name) {
  1142. var value = params[name];
  1143. return Array.isArray(value) ?
  1144. value.map(function (v) { return encodeUriQuery(name) + "=" + encodeUriQuery(v); }).join('&') :
  1145. encodeUriQuery(name) + "=" + encodeUriQuery(value);
  1146. });
  1147. return strParams.length ? "?" + strParams.join("&") : '';
  1148. }
  1149. var SEGMENT_RE = /^[^\/()?;=#]+/;
  1150. function matchSegments(str) {
  1151. var match = str.match(SEGMENT_RE);
  1152. return match ? match[0] : '';
  1153. }
  1154. var QUERY_PARAM_RE = /^[^=?&#]+/;
  1155. // Return the name of the query param at the start of the string or an empty string
  1156. function matchQueryParams(str) {
  1157. var match = str.match(QUERY_PARAM_RE);
  1158. return match ? match[0] : '';
  1159. }
  1160. var QUERY_PARAM_VALUE_RE = /^[^?&#]+/;
  1161. // Return the value of the query param at the start of the string or an empty string
  1162. function matchUrlQueryParamValue(str) {
  1163. var match = str.match(QUERY_PARAM_VALUE_RE);
  1164. return match ? match[0] : '';
  1165. }
  1166. var UrlParser = /** @class */ (function () {
  1167. function UrlParser(url) {
  1168. this.url = url;
  1169. this.remaining = url;
  1170. }
  1171. UrlParser.prototype.parseRootSegment = function () {
  1172. this.consumeOptional('/');
  1173. if (this.remaining === '' || this.peekStartsWith('?') || this.peekStartsWith('#')) {
  1174. return new UrlSegmentGroup([], {});
  1175. }
  1176. // The root segment group never has segments
  1177. return new UrlSegmentGroup([], this.parseChildren());
  1178. };
  1179. UrlParser.prototype.parseQueryParams = function () {
  1180. var params = {};
  1181. if (this.consumeOptional('?')) {
  1182. do {
  1183. this.parseQueryParam(params);
  1184. } while (this.consumeOptional('&'));
  1185. }
  1186. return params;
  1187. };
  1188. UrlParser.prototype.parseFragment = function () {
  1189. return this.consumeOptional('#') ? decodeURIComponent(this.remaining) : null;
  1190. };
  1191. UrlParser.prototype.parseChildren = function () {
  1192. if (this.remaining === '') {
  1193. return {};
  1194. }
  1195. this.consumeOptional('/');
  1196. var segments = [];
  1197. if (!this.peekStartsWith('(')) {
  1198. segments.push(this.parseSegment());
  1199. }
  1200. while (this.peekStartsWith('/') && !this.peekStartsWith('//') && !this.peekStartsWith('/(')) {
  1201. this.capture('/');
  1202. segments.push(this.parseSegment());
  1203. }
  1204. var children = {};
  1205. if (this.peekStartsWith('/(')) {
  1206. this.capture('/');
  1207. children = this.parseParens(true);
  1208. }
  1209. var res = {};
  1210. if (this.peekStartsWith('(')) {
  1211. res = this.parseParens(false);
  1212. }
  1213. if (segments.length > 0 || Object.keys(children).length > 0) {
  1214. res[PRIMARY_OUTLET] = new UrlSegmentGroup(segments, children);
  1215. }
  1216. return res;
  1217. };
  1218. // parse a segment with its matrix parameters
  1219. // ie `name;k1=v1;k2`
  1220. UrlParser.prototype.parseSegment = function () {
  1221. var path = matchSegments(this.remaining);
  1222. if (path === '' && this.peekStartsWith(';')) {
  1223. throw new Error("Empty path url segment cannot have parameters: '" + this.remaining + "'.");
  1224. }
  1225. this.capture(path);
  1226. return new UrlSegment(decode(path), this.parseMatrixParams());
  1227. };
  1228. UrlParser.prototype.parseMatrixParams = function () {
  1229. var params = {};
  1230. while (this.consumeOptional(';')) {
  1231. this.parseParam(params);
  1232. }
  1233. return params;
  1234. };
  1235. UrlParser.prototype.parseParam = function (params) {
  1236. var key = matchSegments(this.remaining);
  1237. if (!key) {
  1238. return;
  1239. }
  1240. this.capture(key);
  1241. var value = '';
  1242. if (this.consumeOptional('=')) {
  1243. var valueMatch = matchSegments(this.remaining);
  1244. if (valueMatch) {
  1245. value = valueMatch;
  1246. this.capture(value);
  1247. }
  1248. }
  1249. params[decode(key)] = decode(value);
  1250. };
  1251. // Parse a single query parameter `name[=value]`
  1252. UrlParser.prototype.parseQueryParam = function (params) {
  1253. var key = matchQueryParams(this.remaining);
  1254. if (!key) {
  1255. return;
  1256. }
  1257. this.capture(key);
  1258. var value = '';
  1259. if (this.consumeOptional('=')) {
  1260. var valueMatch = matchUrlQueryParamValue(this.remaining);
  1261. if (valueMatch) {
  1262. value = valueMatch;
  1263. this.capture(value);
  1264. }
  1265. }
  1266. var decodedKey = decodeQuery(key);
  1267. var decodedVal = decodeQuery(value);
  1268. if (params.hasOwnProperty(decodedKey)) {
  1269. // Append to existing values
  1270. var currentVal = params[decodedKey];
  1271. if (!Array.isArray(currentVal)) {
  1272. currentVal = [currentVal];
  1273. params[decodedKey] = currentVal;
  1274. }
  1275. currentVal.push(decodedVal);
  1276. }
  1277. else {
  1278. // Create a new value
  1279. params[decodedKey] = decodedVal;
  1280. }
  1281. };
  1282. // parse `(a/b//outlet_name:c/d)`
  1283. UrlParser.prototype.parseParens = function (allowPrimary) {
  1284. var segments = {};
  1285. this.capture('(');
  1286. while (!this.consumeOptional(')') && this.remaining.length > 0) {
  1287. var path = matchSegments(this.remaining);
  1288. var next = this.remaining[path.length];
  1289. // if is is not one of these characters, then the segment was unescaped
  1290. // or the group was not closed
  1291. if (next !== '/' && next !== ')' && next !== ';') {
  1292. throw new Error("Cannot parse url '" + this.url + "'");
  1293. }
  1294. var outletName = undefined;
  1295. if (path.indexOf(':') > -1) {
  1296. outletName = path.substr(0, path.indexOf(':'));
  1297. this.capture(outletName);
  1298. this.capture(':');
  1299. }
  1300. else if (allowPrimary) {
  1301. outletName = PRIMARY_OUTLET;
  1302. }
  1303. var children = this.parseChildren();
  1304. segments[outletName] = Object.keys(children).length === 1 ? children[PRIMARY_OUTLET] :
  1305. new UrlSegmentGroup([], children);
  1306. this.consumeOptional('//');
  1307. }
  1308. return segments;
  1309. };
  1310. UrlParser.prototype.peekStartsWith = function (str) { return this.remaining.startsWith(str); };
  1311. // Consumes the prefix when it is present and returns whether it has been consumed
  1312. UrlParser.prototype.consumeOptional = function (str) {
  1313. if (this.peekStartsWith(str)) {
  1314. this.remaining = this.remaining.substring(str.length);
  1315. return true;
  1316. }
  1317. return false;
  1318. };
  1319. UrlParser.prototype.capture = function (str) {
  1320. if (!this.consumeOptional(str)) {
  1321. throw new Error("Expected \"" + str + "\".");
  1322. }
  1323. };
  1324. return UrlParser;
  1325. }());
  1326. /**
  1327. * @license
  1328. * Copyright Google Inc. All Rights Reserved.
  1329. *
  1330. * Use of this source code is governed by an MIT-style license that can be
  1331. * found in the LICENSE file at https://angular.io/license
  1332. */
  1333. var NoMatch = /** @class */ (function () {
  1334. function NoMatch(segmentGroup) {
  1335. this.segmentGroup = segmentGroup || null;
  1336. }
  1337. return NoMatch;
  1338. }());
  1339. var AbsoluteRedirect = /** @class */ (function () {
  1340. function AbsoluteRedirect(urlTree) {
  1341. this.urlTree = urlTree;
  1342. }
  1343. return AbsoluteRedirect;
  1344. }());
  1345. function noMatch(segmentGroup) {
  1346. return new rxjs.Observable(function (obs) { return obs.error(new NoMatch(segmentGroup)); });
  1347. }
  1348. function absoluteRedirect(newTree) {
  1349. return new rxjs.Observable(function (obs) { return obs.error(new AbsoluteRedirect(newTree)); });
  1350. }
  1351. function namedOutletsRedirect(redirectTo) {
  1352. return new rxjs.Observable(function (obs) { return obs.error(new Error("Only absolute redirects can have named outlets. redirectTo: '" + redirectTo + "'")); });
  1353. }
  1354. function canLoadFails(route) {
  1355. return new rxjs.Observable(function (obs) { return obs.error(navigationCancelingError("Cannot load children because the guard of the route \"path: '" + route.path + "'\" returned false")); });
  1356. }
  1357. /**
  1358. * Returns the `UrlTree` with the redirection applied.
  1359. *
  1360. * Lazy modules are loaded along the way.
  1361. */
  1362. function applyRedirects(moduleInjector, configLoader, urlSerializer, urlTree, config) {
  1363. return new ApplyRedirects(moduleInjector, configLoader, urlSerializer, urlTree, config).apply();
  1364. }
  1365. var ApplyRedirects = /** @class */ (function () {
  1366. function ApplyRedirects(moduleInjector, configLoader, urlSerializer, urlTree, config) {
  1367. this.configLoader = configLoader;
  1368. this.urlSerializer = urlSerializer;
  1369. this.urlTree = urlTree;
  1370. this.config = config;
  1371. this.allowRedirects = true;
  1372. this.ngModule = moduleInjector.get(core.NgModuleRef);
  1373. }
  1374. ApplyRedirects.prototype.apply = function () {
  1375. var _this = this;
  1376. var expanded$ = this.expandSegmentGroup(this.ngModule, this.config, this.urlTree.root, PRIMARY_OUTLET);
  1377. var urlTrees$ = expanded$.pipe(operators.map(function (rootSegmentGroup) { return _this.createUrlTree(rootSegmentGroup, _this.urlTree.queryParams, _this.urlTree.fragment); }));
  1378. return urlTrees$.pipe(operators.catchError(function (e) {
  1379. if (e instanceof AbsoluteRedirect) {
  1380. // after an absolute redirect we do not apply any more redirects!
  1381. _this.allowRedirects = false;
  1382. // we need to run matching, so we can fetch all lazy-loaded modules
  1383. return _this.match(e.urlTree);
  1384. }
  1385. if (e instanceof NoMatch) {
  1386. throw _this.noMatchError(e);
  1387. }
  1388. throw e;
  1389. }));
  1390. };
  1391. ApplyRedirects.prototype.match = function (tree) {
  1392. var _this = this;
  1393. var expanded$ = this.expandSegmentGroup(this.ngModule, this.config, tree.root, PRIMARY_OUTLET);
  1394. var mapped$ = expanded$.pipe(operators.map(function (rootSegmentGroup) {
  1395. return _this.createUrlTree(rootSegmentGroup, tree.queryParams, tree.fragment);
  1396. }));
  1397. return mapped$.pipe(operators.catchError(function (e) {
  1398. if (e instanceof NoMatch) {
  1399. throw _this.noMatchError(e);
  1400. }
  1401. throw e;
  1402. }));
  1403. };
  1404. ApplyRedirects.prototype.noMatchError = function (e) {
  1405. return new Error("Cannot match any routes. URL Segment: '" + e.segmentGroup + "'");
  1406. };
  1407. ApplyRedirects.prototype.createUrlTree = function (rootCandidate, queryParams, fragment) {
  1408. var root = rootCandidate.segments.length > 0 ?
  1409. new UrlSegmentGroup([], (_a = {}, _a[PRIMARY_OUTLET] = rootCandidate, _a)) :
  1410. rootCandidate;
  1411. return new UrlTree(root, queryParams, fragment);
  1412. var _a;
  1413. };
  1414. ApplyRedirects.prototype.expandSegmentGroup = function (ngModule, routes, segmentGroup, outlet) {
  1415. if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
  1416. return this.expandChildren(ngModule, routes, segmentGroup)
  1417. .pipe(operators.map(function (children) { return new UrlSegmentGroup([], children); }));
  1418. }
  1419. return this.expandSegment(ngModule, segmentGroup, routes, segmentGroup.segments, outlet, true);
  1420. };
  1421. // Recursively expand segment groups for all the child outlets
  1422. ApplyRedirects.prototype.expandChildren = function (ngModule, routes, segmentGroup) {
  1423. var _this = this;
  1424. return waitForMap(segmentGroup.children, function (childOutlet, child) { return _this.expandSegmentGroup(ngModule, routes, child, childOutlet); });
  1425. };
  1426. ApplyRedirects.prototype.expandSegment = function (ngModule, segmentGroup, routes, segments, outlet, allowRedirects) {
  1427. var _this = this;
  1428. return rxjs.of.apply(void 0, __spread(routes)).pipe(operators.map(function (r) {
  1429. var expanded$ = _this.expandSegmentAgainstRoute(ngModule, segmentGroup, routes, r, segments, outlet, allowRedirects);
  1430. return expanded$.pipe(operators.catchError(function (e) {
  1431. if (e instanceof NoMatch) {
  1432. // TODO(i): this return type doesn't match the declared Observable<UrlSegmentGroup> -
  1433. // talk to Jason
  1434. return rxjs.of(null);
  1435. }
  1436. throw e;
  1437. }));
  1438. }), operators.concatAll(), operators.first(function (s) { return !!s; }), operators.catchError(function (e, _) {
  1439. if (e instanceof rxjs.EmptyError || e.name === 'EmptyError') {
  1440. if (_this.noLeftoversInUrl(segmentGroup, segments, outlet)) {
  1441. return rxjs.of(new UrlSegmentGroup([], {}));
  1442. }
  1443. throw new NoMatch(segmentGroup);
  1444. }
  1445. throw e;
  1446. }));
  1447. };
  1448. ApplyRedirects.prototype.noLeftoversInUrl = function (segmentGroup, segments, outlet) {
  1449. return segments.length === 0 && !segmentGroup.children[outlet];
  1450. };
  1451. ApplyRedirects.prototype.expandSegmentAgainstRoute = function (ngModule, segmentGroup, routes, route, paths, outlet, allowRedirects) {
  1452. if (getOutlet(route) !== outlet) {
  1453. return noMatch(segmentGroup);
  1454. }
  1455. if (route.redirectTo === undefined) {
  1456. return this.matchSegmentAgainstRoute(ngModule, segmentGroup, route, paths);
  1457. }
  1458. if (allowRedirects && this.allowRedirects) {
  1459. return this.expandSegmentAgainstRouteUsingRedirect(ngModule, segmentGroup, routes, route, paths, outlet);
  1460. }
  1461. return noMatch(segmentGroup);
  1462. };
  1463. ApplyRedirects.prototype.expandSegmentAgainstRouteUsingRedirect = function (ngModule, segmentGroup, routes, route, segments, outlet) {
  1464. if (route.path === '**') {
  1465. return this.expandWildCardWithParamsAgainstRouteUsingRedirect(ngModule, routes, route, outlet);
  1466. }
  1467. return this.expandRegularSegmentAgainstRouteUsingRedirect(ngModule, segmentGroup, routes, route, segments, outlet);
  1468. };
  1469. ApplyRedirects.prototype.expandWildCardWithParamsAgainstRouteUsingRedirect = function (ngModule, routes, route, outlet) {
  1470. var _this = this;
  1471. var newTree = this.applyRedirectCommands([], route.redirectTo, {});
  1472. if (route.redirectTo.startsWith('/')) {
  1473. return absoluteRedirect(newTree);
  1474. }
  1475. return this.lineralizeSegments(route, newTree).pipe(operators.mergeMap(function (newSegments) {
  1476. var group = new UrlSegmentGroup(newSegments, {});
  1477. return _this.expandSegment(ngModule, group, routes, newSegments, outlet, false);
  1478. }));
  1479. };
  1480. ApplyRedirects.prototype.expandRegularSegmentAgainstRouteUsingRedirect = function (ngModule, segmentGroup, routes, route, segments, outlet) {
  1481. var _this = this;
  1482. var _a = match(segmentGroup, route, segments), matched = _a.matched, consumedSegments = _a.consumedSegments, lastChild = _a.lastChild, positionalParamSegments = _a.positionalParamSegments;
  1483. if (!matched)
  1484. return noMatch(segmentGroup);
  1485. var newTree = this.applyRedirectCommands(consumedSegments, route.redirectTo, positionalParamSegments);
  1486. if (route.redirectTo.startsWith('/')) {
  1487. return absoluteRedirect(newTree);
  1488. }
  1489. return this.lineralizeSegments(route, newTree).pipe(operators.mergeMap(function (newSegments) {
  1490. return _this.expandSegment(ngModule, segmentGroup, routes, newSegments.concat(segments.slice(lastChild)), outlet, false);
  1491. }));
  1492. };
  1493. ApplyRedirects.prototype.matchSegmentAgainstRoute = function (ngModule, rawSegmentGroup, route, segments) {
  1494. var _this = this;
  1495. if (route.path === '**') {
  1496. if (route.loadChildren) {
  1497. return this.configLoader.load(ngModule.injector, route)
  1498. .pipe(operators.map(function (cfg) {
  1499. route._loadedConfig = cfg;
  1500. return new UrlSegmentGroup(segments, {});
  1501. }));
  1502. }
  1503. return rxjs.of(new UrlSegmentGroup(segments, {}));
  1504. }
  1505. var _a = match(rawSegmentGroup, route, segments), matched = _a.matched, consumedSegments = _a.consumedSegments, lastChild = _a.lastChild;
  1506. if (!matched)
  1507. return noMatch(rawSegmentGroup);
  1508. var rawSlicedSegments = segments.slice(lastChild);
  1509. var childConfig$ = this.getChildConfig(ngModule, route);
  1510. return childConfig$.pipe(operators.mergeMap(function (routerConfig) {
  1511. var childModule = routerConfig.module;
  1512. var childConfig = routerConfig.routes;
  1513. var _a = split(rawSegmentGroup, consumedSegments, rawSlicedSegments, childConfig), segmentGroup = _a.segmentGroup, slicedSegments = _a.slicedSegments;
  1514. if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
  1515. var expanded$_1 = _this.expandChildren(childModule, childConfig, segmentGroup);
  1516. return expanded$_1.pipe(operators.map(function (children) { return new UrlSegmentGroup(consumedSegments, children); }));
  1517. }
  1518. if (childConfig.length === 0 && slicedSegments.length === 0) {
  1519. return rxjs.of(new UrlSegmentGroup(consumedSegments, {}));
  1520. }
  1521. var expanded$ = _this.expandSegment(childModule, segmentGroup, childConfig, slicedSegments, PRIMARY_OUTLET, true);
  1522. return expanded$.pipe(operators.map(function (cs) {
  1523. return new UrlSegmentGroup(consumedSegments.concat(cs.segments), cs.children);
  1524. }));
  1525. }));
  1526. };
  1527. ApplyRedirects.prototype.getChildConfig = function (ngModule, route) {
  1528. var _this = this;
  1529. if (route.children) {
  1530. // The children belong to the same module
  1531. return rxjs.of(new LoadedRouterConfig(route.children, ngModule));
  1532. }
  1533. if (route.loadChildren) {
  1534. // lazy children belong to the loaded module
  1535. if (route._loadedConfig !== undefined) {
  1536. return rxjs.of(route._loadedConfig);
  1537. }
  1538. return runCanLoadGuard(ngModule.injector, route).pipe(operators.mergeMap(function (shouldLoad) {
  1539. if (shouldLoad) {
  1540. return _this.configLoader.load(ngModule.injector, route)
  1541. .pipe(operators.map(function (cfg) {
  1542. route._loadedConfig = cfg;
  1543. return cfg;
  1544. }));
  1545. }
  1546. return canLoadFails(route);
  1547. }));
  1548. }
  1549. return rxjs.of(new LoadedRouterConfig([], ngModule));
  1550. };
  1551. ApplyRedirects.prototype.lineralizeSegments = function (route, urlTree) {
  1552. var res = [];
  1553. var c = urlTree.root;
  1554. while (true) {
  1555. res = res.concat(c.segments);
  1556. if (c.numberOfChildren === 0) {
  1557. return rxjs.of(res);
  1558. }
  1559. if (c.numberOfChildren > 1 || !c.children[PRIMARY_OUTLET]) {
  1560. return namedOutletsRedirect(route.redirectTo);
  1561. }
  1562. c = c.children[PRIMARY_OUTLET];
  1563. }
  1564. };
  1565. ApplyRedirects.prototype.applyRedirectCommands = function (segments, redirectTo, posParams) {
  1566. return this.applyRedirectCreatreUrlTree(redirectTo, this.urlSerializer.parse(redirectTo), segments, posParams);
  1567. };
  1568. ApplyRedirects.prototype.applyRedirectCreatreUrlTree = function (redirectTo, urlTree, segments, posParams) {
  1569. var newRoot = this.createSegmentGroup(redirectTo, urlTree.root, segments, posParams);
  1570. return new UrlTree(newRoot, this.createQueryParams(urlTree.queryParams, this.urlTree.queryParams), urlTree.fragment);
  1571. };
  1572. ApplyRedirects.prototype.createQueryParams = function (redirectToParams, actualParams) {
  1573. var res = {};
  1574. forEach(redirectToParams, function (v, k) {
  1575. var copySourceValue = typeof v === 'string' && v.startsWith(':');
  1576. if (copySourceValue) {
  1577. var sourceName = v.substring(1);
  1578. res[k] = actualParams[sourceName];
  1579. }
  1580. else {
  1581. res[k] = v;
  1582. }
  1583. });
  1584. return res;
  1585. };
  1586. ApplyRedirects.prototype.createSegmentGroup = function (redirectTo, group, segments, posParams) {
  1587. var _this = this;
  1588. var updatedSegments = this.createSegments(redirectTo, group.segments, segments, posParams);
  1589. var children = {};
  1590. forEach(group.children, function (child, name) {
  1591. children[name] = _this.createSegmentGroup(redirectTo, child, segments, posParams);
  1592. });
  1593. return new UrlSegmentGroup(updatedSegments, children);
  1594. };
  1595. ApplyRedirects.prototype.createSegments = function (redirectTo, redirectToSegments, actualSegments, posParams) {
  1596. var _this = this;
  1597. return redirectToSegments.map(function (s) { return s.path.startsWith(':') ? _this.findPosParam(redirectTo, s, posParams) :
  1598. _this.findOrReturn(s, actualSegments); });
  1599. };
  1600. ApplyRedirects.prototype.findPosParam = function (redirectTo, redirectToUrlSegment, posParams) {
  1601. var pos = posParams[redirectToUrlSegment.path.substring(1)];
  1602. if (!pos)
  1603. throw new Error("Cannot redirect to '" + redirectTo + "'. Cannot find '" + redirectToUrlSegment.path + "'.");
  1604. return pos;
  1605. };
  1606. ApplyRedirects.prototype.findOrReturn = function (redirectToUrlSegment, actualSegments) {
  1607. var idx = 0;
  1608. try {
  1609. for (var actualSegments_1 = __values(actualSegments), actualSegments_1_1 = actualSegments_1.next(); !actualSegments_1_1.done; actualSegments_1_1 = actualSegments_1.next()) {
  1610. var s = actualSegments_1_1.value;
  1611. if (s.path === redirectToUrlSegment.path) {
  1612. actualSegments.splice(idx);
  1613. return s;
  1614. }
  1615. idx++;
  1616. }
  1617. }
  1618. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  1619. finally {
  1620. try {
  1621. if (actualSegments_1_1 && !actualSegments_1_1.done && (_a = actualSegments_1.return)) _a.call(actualSegments_1);
  1622. }
  1623. finally { if (e_1) throw e_1.error; }
  1624. }
  1625. return redirectToUrlSegment;
  1626. var e_1, _a;
  1627. };
  1628. return ApplyRedirects;
  1629. }());
  1630. function runCanLoadGuard(moduleInjector, route) {
  1631. var canLoad = route.canLoad;
  1632. if (!canLoad || canLoad.length === 0)
  1633. return rxjs.of(true);
  1634. var obs = rxjs.from(canLoad).pipe(operators.map(function (injectionToken) {
  1635. var guard = moduleInjector.get(injectionToken);
  1636. return wrapIntoObservable(guard.canLoad ? guard.canLoad(route) : guard(route));
  1637. }));
  1638. return andObservables(obs);
  1639. }
  1640. function match(segmentGroup, route, segments) {
  1641. if (route.path === '') {
  1642. if ((route.pathMatch === 'full') && (segmentGroup.hasChildren() || segments.length > 0)) {
  1643. return { matched: false, consumedSegments: [], lastChild: 0, positionalParamSegments: {} };
  1644. }
  1645. return { matched: true, consumedSegments: [], lastChild: 0, positionalParamSegments: {} };
  1646. }
  1647. var matcher = route.matcher || defaultUrlMatcher;
  1648. var res = matcher(segments, segmentGroup, route);
  1649. if (!res) {
  1650. return {
  1651. matched: false,
  1652. consumedSegments: [],
  1653. lastChild: 0,
  1654. positionalParamSegments: {},
  1655. };
  1656. }
  1657. return {
  1658. matched: true,
  1659. consumedSegments: res.consumed,
  1660. lastChild: res.consumed.length,
  1661. positionalParamSegments: res.posParams,
  1662. };
  1663. }
  1664. function split(segmentGroup, consumedSegments, slicedSegments, config) {
  1665. if (slicedSegments.length > 0 &&
  1666. containsEmptyPathRedirectsWithNamedOutlets(segmentGroup, slicedSegments, config)) {
  1667. var s = new UrlSegmentGroup(consumedSegments, createChildrenForEmptySegments(config, new UrlSegmentGroup(slicedSegments, segmentGroup.children)));
  1668. return { segmentGroup: mergeTrivialChildren(s), slicedSegments: [] };
  1669. }
  1670. if (slicedSegments.length === 0 &&
  1671. containsEmptyPathRedirects(segmentGroup, slicedSegments, config)) {
  1672. var s = new UrlSegmentGroup(segmentGroup.segments, addEmptySegmentsToChildrenIfNeeded(segmentGroup, slicedSegments, config, segmentGroup.children));
  1673. return { segmentGroup: mergeTrivialChildren(s), slicedSegments: slicedSegments };
  1674. }
  1675. return { segmentGroup: segmentGroup, slicedSegments: slicedSegments };
  1676. }
  1677. function mergeTrivialChildren(s) {
  1678. if (s.numberOfChildren === 1 && s.children[PRIMARY_OUTLET]) {
  1679. var c = s.children[PRIMARY_OUTLET];
  1680. return new UrlSegmentGroup(s.segments.concat(c.segments), c.children);
  1681. }
  1682. return s;
  1683. }
  1684. function addEmptySegmentsToChildrenIfNeeded(segmentGroup, slicedSegments, routes, children) {
  1685. var res = {};
  1686. try {
  1687. for (var routes_1 = __values(routes), routes_1_1 = routes_1.next(); !routes_1_1.done; routes_1_1 = routes_1.next()) {
  1688. var r = routes_1_1.value;
  1689. if (isEmptyPathRedirect(segmentGroup, slicedSegments, r) && !children[getOutlet(r)]) {
  1690. res[getOutlet(r)] = new UrlSegmentGroup([], {});
  1691. }
  1692. }
  1693. }
  1694. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  1695. finally {
  1696. try {
  1697. if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
  1698. }
  1699. finally { if (e_2) throw e_2.error; }
  1700. }
  1701. return __assign({}, children, res);
  1702. var e_2, _a;
  1703. }
  1704. function createChildrenForEmptySegments(routes, primarySegmentGroup) {
  1705. var res = {};
  1706. res[PRIMARY_OUTLET] = primarySegmentGroup;
  1707. try {
  1708. for (var routes_2 = __values(routes), routes_2_1 = routes_2.next(); !routes_2_1.done; routes_2_1 = routes_2.next()) {
  1709. var r = routes_2_1.value;
  1710. if (r.path === '' && getOutlet(r) !== PRIMARY_OUTLET) {
  1711. res[getOutlet(r)] = new UrlSegmentGroup([], {});
  1712. }
  1713. }
  1714. }
  1715. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  1716. finally {
  1717. try {
  1718. if (routes_2_1 && !routes_2_1.done && (_a = routes_2.return)) _a.call(routes_2);
  1719. }
  1720. finally { if (e_3) throw e_3.error; }
  1721. }
  1722. return res;
  1723. var e_3, _a;
  1724. }
  1725. function containsEmptyPathRedirectsWithNamedOutlets(segmentGroup, segments, routes) {
  1726. return routes.some(function (r) { return isEmptyPathRedirect(segmentGroup, segments, r) && getOutlet(r) !== PRIMARY_OUTLET; });
  1727. }
  1728. function containsEmptyPathRedirects(segmentGroup, segments, routes) {
  1729. return routes.some(function (r) { return isEmptyPathRedirect(segmentGroup, segments, r); });
  1730. }
  1731. function isEmptyPathRedirect(segmentGroup, segments, r) {
  1732. if ((segmentGroup.hasChildren() || segments.length > 0) && r.pathMatch === 'full') {
  1733. return false;
  1734. }
  1735. return r.path === '' && r.redirectTo !== undefined;
  1736. }
  1737. function getOutlet(route) {
  1738. return route.outlet || PRIMARY_OUTLET;
  1739. }
  1740. /**
  1741. * @license
  1742. * Copyright Google Inc. All Rights Reserved.
  1743. *
  1744. * Use of this source code is governed by an MIT-style license that can be
  1745. * found in the LICENSE file at https://angular.io/license
  1746. */
  1747. var Tree = /** @class */ (function () {
  1748. function Tree(root) {
  1749. this._root = root;
  1750. }
  1751. Object.defineProperty(Tree.prototype, "root", {
  1752. get: function () { return this._root.value; },
  1753. enumerable: true,
  1754. configurable: true
  1755. });
  1756. /**
  1757. * @internal
  1758. */
  1759. Tree.prototype.parent = function (t) {
  1760. var p = this.pathFromRoot(t);
  1761. return p.length > 1 ? p[p.length - 2] : null;
  1762. };
  1763. /**
  1764. * @internal
  1765. */
  1766. Tree.prototype.children = function (t) {
  1767. var n = findNode(t, this._root);
  1768. return n ? n.children.map(function (t) { return t.value; }) : [];
  1769. };
  1770. /**
  1771. * @internal
  1772. */
  1773. Tree.prototype.firstChild = function (t) {
  1774. var n = findNode(t, this._root);
  1775. return n && n.children.length > 0 ? n.children[0].value : null;
  1776. };
  1777. /**
  1778. * @internal
  1779. */
  1780. Tree.prototype.siblings = function (t) {
  1781. var p = findPath(t, this._root);
  1782. if (p.length < 2)
  1783. return [];
  1784. var c = p[p.length - 2].children.map(function (c) { return c.value; });
  1785. return c.filter(function (cc) { return cc !== t; });
  1786. };
  1787. /**
  1788. * @internal
  1789. */
  1790. Tree.prototype.pathFromRoot = function (t) { return findPath(t, this._root).map(function (s) { return s.value; }); };
  1791. return Tree;
  1792. }());
  1793. // DFS for the node matching the value
  1794. function findNode(value, node) {
  1795. if (value === node.value)
  1796. return node;
  1797. try {
  1798. for (var _a = __values(node.children), _b = _a.next(); !_b.done; _b = _a.next()) {
  1799. var child = _b.value;
  1800. var node_1 = findNode(value, child);
  1801. if (node_1)
  1802. return node_1;
  1803. }
  1804. }
  1805. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  1806. finally {
  1807. try {
  1808. if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
  1809. }
  1810. finally { if (e_1) throw e_1.error; }
  1811. }
  1812. return null;
  1813. var e_1, _c;
  1814. }
  1815. // Return the path to the node with the given value using DFS
  1816. function findPath(value, node) {
  1817. if (value === node.value)
  1818. return [node];
  1819. try {
  1820. for (var _a = __values(node.children), _b = _a.next(); !_b.done; _b = _a.next()) {
  1821. var child = _b.value;
  1822. var path = findPath(value, child);
  1823. if (path.length) {
  1824. path.unshift(node);
  1825. return path;
  1826. }
  1827. }
  1828. }
  1829. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  1830. finally {
  1831. try {
  1832. if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
  1833. }
  1834. finally { if (e_2) throw e_2.error; }
  1835. }
  1836. return [];
  1837. var e_2, _c;
  1838. }
  1839. var TreeNode = /** @class */ (function () {
  1840. function TreeNode(value, children) {
  1841. this.value = value;
  1842. this.children = children;
  1843. }
  1844. TreeNode.prototype.toString = function () { return "TreeNode(" + this.value + ")"; };
  1845. return TreeNode;
  1846. }());
  1847. // Return the list of T indexed by outlet name
  1848. function nodeChildrenAsMap(node) {
  1849. var map = {};
  1850. if (node) {
  1851. node.children.forEach(function (child) { return map[child.value.outlet] = child; });
  1852. }
  1853. return map;
  1854. }
  1855. /**
  1856. * @license
  1857. * Copyright Google Inc. All Rights Reserved.
  1858. *
  1859. * Use of this source code is governed by an MIT-style license that can be
  1860. * found in the LICENSE file at https://angular.io/license
  1861. */
  1862. /**
  1863. * @description
  1864. *
  1865. * Represents the state of the router.
  1866. *
  1867. * RouterState is a tree of activated routes. Every node in this tree knows about the "consumed" URL
  1868. * segments, the extracted parameters, and the resolved data.
  1869. *
  1870. * ### Example
  1871. *
  1872. * ```
  1873. * @Component({templateUrl:'template.html'})
  1874. * class MyComponent {
  1875. * constructor(router: Router) {
  1876. * const state: RouterState = router.routerState;
  1877. * const root: ActivatedRoute = state.root;
  1878. * const child = root.firstChild;
  1879. * const id: Observable<string> = child.params.map(p => p.id);
  1880. * //...
  1881. * }
  1882. * }
  1883. * ```
  1884. *
  1885. * See `ActivatedRoute` for more information.
  1886. *
  1887. *
  1888. */
  1889. var RouterState = /** @class */ (function (_super) {
  1890. __extends(RouterState, _super);
  1891. /** @internal */
  1892. function RouterState(root,
  1893. /** The current snapshot of the router state */
  1894. snapshot) {
  1895. var _this = _super.call(this, root) || this;
  1896. _this.snapshot = snapshot;
  1897. setRouterState(_this, root);
  1898. return _this;
  1899. }
  1900. RouterState.prototype.toString = function () { return this.snapshot.toString(); };
  1901. return RouterState;
  1902. }(Tree));
  1903. function createEmptyState(urlTree, rootComponent) {
  1904. var snapshot = createEmptyStateSnapshot(urlTree, rootComponent);
  1905. var emptyUrl = new rxjs.BehaviorSubject([new UrlSegment('', {})]);
  1906. var emptyParams = new rxjs.BehaviorSubject({});
  1907. var emptyData = new rxjs.BehaviorSubject({});
  1908. var emptyQueryParams = new rxjs.BehaviorSubject({});
  1909. var fragment = new rxjs.BehaviorSubject('');
  1910. var activated = new ActivatedRoute(emptyUrl, emptyParams, emptyQueryParams, fragment, emptyData, PRIMARY_OUTLET, rootComponent, snapshot.root);
  1911. activated.snapshot = snapshot.root;
  1912. return new RouterState(new TreeNode(activated, []), snapshot);
  1913. }
  1914. function createEmptyStateSnapshot(urlTree, rootComponent) {
  1915. var emptyParams = {};
  1916. var emptyData = {};
  1917. var emptyQueryParams = {};
  1918. var fragment = '';
  1919. var activated = new ActivatedRouteSnapshot([], emptyParams, emptyQueryParams, fragment, emptyData, PRIMARY_OUTLET, rootComponent, null, urlTree.root, -1, {});
  1920. return new RouterStateSnapshot('', new TreeNode(activated, []));
  1921. }
  1922. /**
  1923. * @description
  1924. *
  1925. * Contains the information about a route associated with a component loaded in an
  1926. * outlet. An `ActivatedRoute` can also be used to traverse the router state tree.
  1927. *
  1928. * ```
  1929. * @Component({...})
  1930. * class MyComponent {
  1931. * constructor(route: ActivatedRoute) {
  1932. * const id: Observable<string> = route.params.map(p => p.id);
  1933. * const url: Observable<string> = route.url.map(segments => segments.join(''));
  1934. * // route.data includes both `data` and `resolve`
  1935. * const user = route.data.map(d => d.user);
  1936. * }
  1937. * }
  1938. * ```
  1939. *
  1940. *
  1941. */
  1942. var ActivatedRoute = /** @class */ (function () {
  1943. /** @internal */
  1944. function ActivatedRoute(
  1945. /** An observable of the URL segments matched by this route */
  1946. url,
  1947. /** An observable of the matrix parameters scoped to this route */
  1948. params,
  1949. /** An observable of the query parameters shared by all the routes */
  1950. queryParams,
  1951. /** An observable of the URL fragment shared by all the routes */
  1952. fragment,
  1953. /** An observable of the static and resolved data of this route. */
  1954. data,
  1955. /** The outlet name of the route. It's a constant */
  1956. outlet,
  1957. /** The component of the route. It's a constant */
  1958. // TODO(vsavkin): remove |string
  1959. component, futureSnapshot) {
  1960. this.url = url;
  1961. this.params = params;
  1962. this.queryParams = queryParams;
  1963. this.fragment = fragment;
  1964. this.data = data;
  1965. this.outlet = outlet;
  1966. this.component = component;
  1967. this._futureSnapshot = futureSnapshot;
  1968. }
  1969. Object.defineProperty(ActivatedRoute.prototype, "routeConfig", {
  1970. /** The configuration used to match this route */
  1971. get: function () { return this._futureSnapshot.routeConfig; },
  1972. enumerable: true,
  1973. configurable: true
  1974. });
  1975. Object.defineProperty(ActivatedRoute.prototype, "root", {
  1976. /** The root of the router state */
  1977. get: function () { return this._routerState.root; },
  1978. enumerable: true,
  1979. configurable: true
  1980. });
  1981. Object.defineProperty(ActivatedRoute.prototype, "parent", {
  1982. /** The parent of this route in the router state tree */
  1983. get: function () { return this._routerState.parent(this); },
  1984. enumerable: true,
  1985. configurable: true
  1986. });
  1987. Object.defineProperty(ActivatedRoute.prototype, "firstChild", {
  1988. /** The first child of this route in the router state tree */
  1989. get: function () { return this._routerState.firstChild(this); },
  1990. enumerable: true,
  1991. configurable: true
  1992. });
  1993. Object.defineProperty(ActivatedRoute.prototype, "children", {
  1994. /** The children of this route in the router state tree */
  1995. get: function () { return this._routerState.children(this); },
  1996. enumerable: true,
  1997. configurable: true
  1998. });
  1999. Object.defineProperty(ActivatedRoute.prototype, "pathFromRoot", {
  2000. /** The path from the root of the router state tree to this route */
  2001. get: function () { return this._routerState.pathFromRoot(this); },
  2002. enumerable: true,
  2003. configurable: true
  2004. });
  2005. Object.defineProperty(ActivatedRoute.prototype, "paramMap", {
  2006. get: function () {
  2007. if (!this._paramMap) {
  2008. this._paramMap = this.params.pipe(operators.map(function (p) { return convertToParamMap(p); }));
  2009. }
  2010. return this._paramMap;
  2011. },
  2012. enumerable: true,
  2013. configurable: true
  2014. });
  2015. Object.defineProperty(ActivatedRoute.prototype, "queryParamMap", {
  2016. get: function () {
  2017. if (!this._queryParamMap) {
  2018. this._queryParamMap =
  2019. this.queryParams.pipe(operators.map(function (p) { return convertToParamMap(p); }));
  2020. }
  2021. return this._queryParamMap;
  2022. },
  2023. enumerable: true,
  2024. configurable: true
  2025. });
  2026. ActivatedRoute.prototype.toString = function () {
  2027. return this.snapshot ? this.snapshot.toString() : "Future(" + this._futureSnapshot + ")";
  2028. };
  2029. return ActivatedRoute;
  2030. }());
  2031. /**
  2032. * Returns the inherited params, data, and resolve for a given route.
  2033. * By default, this only inherits values up to the nearest path-less or component-less route.
  2034. * @internal
  2035. */
  2036. function inheritedParamsDataResolve(route, paramsInheritanceStrategy) {
  2037. if (paramsInheritanceStrategy === void 0) { paramsInheritanceStrategy = 'emptyOnly'; }
  2038. var pathFromRoot = route.pathFromRoot;
  2039. var inheritingStartingFrom = 0;
  2040. if (paramsInheritanceStrategy !== 'always') {
  2041. inheritingStartingFrom = pathFromRoot.length - 1;
  2042. while (inheritingStartingFrom >= 1) {
  2043. var current = pathFromRoot[inheritingStartingFrom];
  2044. var parent_1 = pathFromRoot[inheritingStartingFrom - 1];
  2045. // current route is an empty path => inherits its parent's params and data
  2046. if (current.routeConfig && current.routeConfig.path === '') {
  2047. inheritingStartingFrom--;
  2048. // parent is componentless => current route should inherit its params and data
  2049. }
  2050. else if (!parent_1.component) {
  2051. inheritingStartingFrom--;
  2052. }
  2053. else {
  2054. break;
  2055. }
  2056. }
  2057. }
  2058. return flattenInherited(pathFromRoot.slice(inheritingStartingFrom));
  2059. }
  2060. /** @internal */
  2061. function flattenInherited(pathFromRoot) {
  2062. return pathFromRoot.reduce(function (res, curr) {
  2063. var params = __assign({}, res.params, curr.params);
  2064. var data = __assign({}, res.data, curr.data);
  2065. var resolve = __assign({}, res.resolve, curr._resolvedData);
  2066. return { params: params, data: data, resolve: resolve };
  2067. }, { params: {}, data: {}, resolve: {} });
  2068. }
  2069. /**
  2070. * @description
  2071. *
  2072. * Contains the information about a route associated with a component loaded in an
  2073. * outlet at a particular moment in time. ActivatedRouteSnapshot can also be used to
  2074. * traverse the router state tree.
  2075. *
  2076. * ```
  2077. * @Component({templateUrl:'./my-component.html'})
  2078. * class MyComponent {
  2079. * constructor(route: ActivatedRoute) {
  2080. * const id: string = route.snapshot.params.id;
  2081. * const url: string = route.snapshot.url.join('');
  2082. * const user = route.snapshot.data.user;
  2083. * }
  2084. * }
  2085. * ```
  2086. *
  2087. *
  2088. */
  2089. var ActivatedRouteSnapshot = /** @class */ (function () {
  2090. /** @internal */
  2091. function ActivatedRouteSnapshot(
  2092. /** The URL segments matched by this route */
  2093. url,
  2094. /** The matrix parameters scoped to this route */
  2095. params,
  2096. /** The query parameters shared by all the routes */
  2097. queryParams,
  2098. /** The URL fragment shared by all the routes */
  2099. fragment,
  2100. /** The static and resolved data of this route */
  2101. data,
  2102. /** The outlet name of the route */
  2103. outlet,
  2104. /** The component of the route */
  2105. component, routeConfig, urlSegment, lastPathIndex, resolve) {
  2106. this.url = url;
  2107. this.params = params;
  2108. this.queryParams = queryParams;
  2109. this.fragment = fragment;
  2110. this.data = data;
  2111. this.outlet = outlet;
  2112. this.component = component;
  2113. this.routeConfig = routeConfig;
  2114. this._urlSegment = urlSegment;
  2115. this._lastPathIndex = lastPathIndex;
  2116. this._resolve = resolve;
  2117. }
  2118. Object.defineProperty(ActivatedRouteSnapshot.prototype, "root", {
  2119. /** The root of the router state */
  2120. get: function () { return this._routerState.root; },
  2121. enumerable: true,
  2122. configurable: true
  2123. });
  2124. Object.defineProperty(ActivatedRouteSnapshot.prototype, "parent", {
  2125. /** The parent of this route in the router state tree */
  2126. get: function () { return this._routerState.parent(this); },
  2127. enumerable: true,
  2128. configurable: true
  2129. });
  2130. Object.defineProperty(ActivatedRouteSnapshot.prototype, "firstChild", {
  2131. /** The first child of this route in the router state tree */
  2132. get: function () { return this._routerState.firstChild(this); },
  2133. enumerable: true,
  2134. configurable: true
  2135. });
  2136. Object.defineProperty(ActivatedRouteSnapshot.prototype, "children", {
  2137. /** The children of this route in the router state tree */
  2138. get: function () { return this._routerState.children(this); },
  2139. enumerable: true,
  2140. configurable: true
  2141. });
  2142. Object.defineProperty(ActivatedRouteSnapshot.prototype, "pathFromRoot", {
  2143. /** The path from the root of the router state tree to this route */
  2144. get: function () { return this._routerState.pathFromRoot(this); },
  2145. enumerable: true,
  2146. configurable: true
  2147. });
  2148. Object.defineProperty(ActivatedRouteSnapshot.prototype, "paramMap", {
  2149. get: function () {
  2150. if (!this._paramMap) {
  2151. this._paramMap = convertToParamMap(this.params);
  2152. }
  2153. return this._paramMap;
  2154. },
  2155. enumerable: true,
  2156. configurable: true
  2157. });
  2158. Object.defineProperty(ActivatedRouteSnapshot.prototype, "queryParamMap", {
  2159. get: function () {
  2160. if (!this._queryParamMap) {
  2161. this._queryParamMap = convertToParamMap(this.queryParams);
  2162. }
  2163. return this._queryParamMap;
  2164. },
  2165. enumerable: true,
  2166. configurable: true
  2167. });
  2168. ActivatedRouteSnapshot.prototype.toString = function () {
  2169. var url = this.url.map(function (segment) { return segment.toString(); }).join('/');
  2170. var matched = this.routeConfig ? this.routeConfig.path : '';
  2171. return "Route(url:'" + url + "', path:'" + matched + "')";
  2172. };
  2173. return ActivatedRouteSnapshot;
  2174. }());
  2175. /**
  2176. * @description
  2177. *
  2178. * Represents the state of the router at a moment in time.
  2179. *
  2180. * This is a tree of activated route snapshots. Every node in this tree knows about
  2181. * the "consumed" URL segments, the extracted parameters, and the resolved data.
  2182. *
  2183. * ### Example
  2184. *
  2185. * ```
  2186. * @Component({templateUrl:'template.html'})
  2187. * class MyComponent {
  2188. * constructor(router: Router) {
  2189. * const state: RouterState = router.routerState;
  2190. * const snapshot: RouterStateSnapshot = state.snapshot;
  2191. * const root: ActivatedRouteSnapshot = snapshot.root;
  2192. * const child = root.firstChild;
  2193. * const id: Observable<string> = child.params.map(p => p.id);
  2194. * //...
  2195. * }
  2196. * }
  2197. * ```
  2198. *
  2199. *
  2200. */
  2201. var RouterStateSnapshot = /** @class */ (function (_super) {
  2202. __extends(RouterStateSnapshot, _super);
  2203. /** @internal */
  2204. function RouterStateSnapshot(
  2205. /** The url from which this snapshot was created */
  2206. url, root) {
  2207. var _this = _super.call(this, root) || this;
  2208. _this.url = url;
  2209. setRouterState(_this, root);
  2210. return _this;
  2211. }
  2212. RouterStateSnapshot.prototype.toString = function () { return serializeNode(this._root); };
  2213. return RouterStateSnapshot;
  2214. }(Tree));
  2215. function setRouterState(state, node) {
  2216. node.value._routerState = state;
  2217. node.children.forEach(function (c) { return setRouterState(state, c); });
  2218. }
  2219. function serializeNode(node) {
  2220. var c = node.children.length > 0 ? " { " + node.children.map(serializeNode).join(', ') + " } " : '';
  2221. return "" + node.value + c;
  2222. }
  2223. /**
  2224. * The expectation is that the activate route is created with the right set of parameters.
  2225. * So we push new values into the observables only when they are not the initial values.
  2226. * And we detect that by checking if the snapshot field is set.
  2227. */
  2228. function advanceActivatedRoute(route) {
  2229. if (route.snapshot) {
  2230. var currentSnapshot = route.snapshot;
  2231. var nextSnapshot = route._futureSnapshot;
  2232. route.snapshot = nextSnapshot;
  2233. if (!shallowEqual(currentSnapshot.queryParams, nextSnapshot.queryParams)) {
  2234. route.queryParams.next(nextSnapshot.queryParams);
  2235. }
  2236. if (currentSnapshot.fragment !== nextSnapshot.fragment) {
  2237. route.fragment.next(nextSnapshot.fragment);
  2238. }
  2239. if (!shallowEqual(currentSnapshot.params, nextSnapshot.params)) {
  2240. route.params.next(nextSnapshot.params);
  2241. }
  2242. if (!shallowEqualArrays(currentSnapshot.url, nextSnapshot.url)) {
  2243. route.url.next(nextSnapshot.url);
  2244. }
  2245. if (!shallowEqual(currentSnapshot.data, nextSnapshot.data)) {
  2246. route.data.next(nextSnapshot.data);
  2247. }
  2248. }
  2249. else {
  2250. route.snapshot = route._futureSnapshot;
  2251. // this is for resolved data
  2252. route.data.next(route._futureSnapshot.data);
  2253. }
  2254. }
  2255. function equalParamsAndUrlSegments(a, b) {
  2256. var equalUrlParams = shallowEqual(a.params, b.params) && equalSegments(a.url, b.url);
  2257. var parentsMismatch = !a.parent !== !b.parent;
  2258. return equalUrlParams && !parentsMismatch &&
  2259. (!a.parent || equalParamsAndUrlSegments(a.parent, b.parent));
  2260. }
  2261. /**
  2262. * @license
  2263. * Copyright Google Inc. All Rights Reserved.
  2264. *
  2265. * Use of this source code is governed by an MIT-style license that can be
  2266. * found in the LICENSE file at https://angular.io/license
  2267. */
  2268. function createRouterState(routeReuseStrategy, curr, prevState) {
  2269. var root = createNode(routeReuseStrategy, curr._root, prevState ? prevState._root : undefined);
  2270. return new RouterState(root, curr);
  2271. }
  2272. function createNode(routeReuseStrategy, curr, prevState) {
  2273. // reuse an activated route that is currently displayed on the screen
  2274. if (prevState && routeReuseStrategy.shouldReuseRoute(curr.value, prevState.value.snapshot)) {
  2275. var value = prevState.value;
  2276. value._futureSnapshot = curr.value;
  2277. var children = createOrReuseChildren(routeReuseStrategy, curr, prevState);
  2278. return new TreeNode(value, children);
  2279. // retrieve an activated route that is used to be displayed, but is not currently displayed
  2280. }
  2281. else {
  2282. var detachedRouteHandle = routeReuseStrategy.retrieve(curr.value);
  2283. if (detachedRouteHandle) {
  2284. var tree = detachedRouteHandle.route;
  2285. setFutureSnapshotsOfActivatedRoutes(curr, tree);
  2286. return tree;
  2287. }
  2288. else {
  2289. var value = createActivatedRoute(curr.value);
  2290. var children = curr.children.map(function (c) { return createNode(routeReuseStrategy, c); });
  2291. return new TreeNode(value, children);
  2292. }
  2293. }
  2294. }
  2295. function setFutureSnapshotsOfActivatedRoutes(curr, result) {
  2296. if (curr.value.routeConfig !== result.value.routeConfig) {
  2297. throw new Error('Cannot reattach ActivatedRouteSnapshot created from a different route');
  2298. }
  2299. if (curr.children.length !== result.children.length) {
  2300. throw new Error('Cannot reattach ActivatedRouteSnapshot with a different number of children');
  2301. }
  2302. result.value._futureSnapshot = curr.value;
  2303. for (var i = 0; i < curr.children.length; ++i) {
  2304. setFutureSnapshotsOfActivatedRoutes(curr.children[i], result.children[i]);
  2305. }
  2306. }
  2307. function createOrReuseChildren(routeReuseStrategy, curr, prevState) {
  2308. return curr.children.map(function (child) {
  2309. try {
  2310. for (var _a = __values(prevState.children), _b = _a.next(); !_b.done; _b = _a.next()) {
  2311. var p = _b.value;
  2312. if (routeReuseStrategy.shouldReuseRoute(p.value.snapshot, child.value)) {
  2313. return createNode(routeReuseStrategy, child, p);
  2314. }
  2315. }
  2316. }
  2317. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  2318. finally {
  2319. try {
  2320. if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
  2321. }
  2322. finally { if (e_1) throw e_1.error; }
  2323. }
  2324. return createNode(routeReuseStrategy, child);
  2325. var e_1, _c;
  2326. });
  2327. }
  2328. function createActivatedRoute(c) {
  2329. return new ActivatedRoute(new rxjs.BehaviorSubject(c.url), new rxjs.BehaviorSubject(c.params), new rxjs.BehaviorSubject(c.queryParams), new rxjs.BehaviorSubject(c.fragment), new rxjs.BehaviorSubject(c.data), c.outlet, c.component, c);
  2330. }
  2331. /**
  2332. * @license
  2333. * Copyright Google Inc. All Rights Reserved.
  2334. *
  2335. * Use of this source code is governed by an MIT-style license that can be
  2336. * found in the LICENSE file at https://angular.io/license
  2337. */
  2338. function createUrlTree(route, urlTree, commands, queryParams, fragment) {
  2339. if (commands.length === 0) {
  2340. return tree(urlTree.root, urlTree.root, urlTree, queryParams, fragment);
  2341. }
  2342. var nav = computeNavigation(commands);
  2343. if (nav.toRoot()) {
  2344. return tree(urlTree.root, new UrlSegmentGroup([], {}), urlTree, queryParams, fragment);
  2345. }
  2346. var startingPosition = findStartingPosition(nav, urlTree, route);
  2347. var segmentGroup = startingPosition.processChildren ?
  2348. updateSegmentGroupChildren(startingPosition.segmentGroup, startingPosition.index, nav.commands) :
  2349. updateSegmentGroup(startingPosition.segmentGroup, startingPosition.index, nav.commands);
  2350. return tree(startingPosition.segmentGroup, segmentGroup, urlTree, queryParams, fragment);
  2351. }
  2352. function isMatrixParams(command) {
  2353. return typeof command === 'object' && command != null && !command.outlets && !command.segmentPath;
  2354. }
  2355. function tree(oldSegmentGroup, newSegmentGroup, urlTree, queryParams, fragment) {
  2356. var qp = {};
  2357. if (queryParams) {
  2358. forEach(queryParams, function (value, name) {
  2359. qp[name] = Array.isArray(value) ? value.map(function (v) { return "" + v; }) : "" + value;
  2360. });
  2361. }
  2362. if (urlTree.root === oldSegmentGroup) {
  2363. return new UrlTree(newSegmentGroup, qp, fragment);
  2364. }
  2365. return new UrlTree(replaceSegment(urlTree.root, oldSegmentGroup, newSegmentGroup), qp, fragment);
  2366. }
  2367. function replaceSegment(current, oldSegment, newSegment) {
  2368. var children = {};
  2369. forEach(current.children, function (c, outletName) {
  2370. if (c === oldSegment) {
  2371. children[outletName] = newSegment;
  2372. }
  2373. else {
  2374. children[outletName] = replaceSegment(c, oldSegment, newSegment);
  2375. }
  2376. });
  2377. return new UrlSegmentGroup(current.segments, children);
  2378. }
  2379. var Navigation = /** @class */ (function () {
  2380. function Navigation(isAbsolute, numberOfDoubleDots, commands) {
  2381. this.isAbsolute = isAbsolute;
  2382. this.numberOfDoubleDots = numberOfDoubleDots;
  2383. this.commands = commands;
  2384. if (isAbsolute && commands.length > 0 && isMatrixParams(commands[0])) {
  2385. throw new Error('Root segment cannot have matrix parameters');
  2386. }
  2387. var cmdWithOutlet = commands.find(function (c) { return typeof c === 'object' && c != null && c.outlets; });
  2388. if (cmdWithOutlet && cmdWithOutlet !== last(commands)) {
  2389. throw new Error('{outlets:{}} has to be the last command');
  2390. }
  2391. }
  2392. Navigation.prototype.toRoot = function () {
  2393. return this.isAbsolute && this.commands.length === 1 && this.commands[0] == '/';
  2394. };
  2395. return Navigation;
  2396. }());
  2397. /** Transforms commands to a normalized `Navigation` */
  2398. function computeNavigation(commands) {
  2399. if ((typeof commands[0] === 'string') && commands.length === 1 && commands[0] === '/') {
  2400. return new Navigation(true, 0, commands);
  2401. }
  2402. var numberOfDoubleDots = 0;
  2403. var isAbsolute = false;
  2404. var res = commands.reduce(function (res, cmd, cmdIdx) {
  2405. if (typeof cmd === 'object' && cmd != null) {
  2406. if (cmd.outlets) {
  2407. var outlets_1 = {};
  2408. forEach(cmd.outlets, function (commands, name) {
  2409. outlets_1[name] = typeof commands === 'string' ? commands.split('/') : commands;
  2410. });
  2411. return __spread(res, [{ outlets: outlets_1 }]);
  2412. }
  2413. if (cmd.segmentPath) {
  2414. return __spread(res, [cmd.segmentPath]);
  2415. }
  2416. }
  2417. if (!(typeof cmd === 'string')) {
  2418. return __spread(res, [cmd]);
  2419. }
  2420. if (cmdIdx === 0) {
  2421. cmd.split('/').forEach(function (urlPart, partIndex) {
  2422. if (partIndex == 0 && urlPart === '.') ;
  2423. else if (partIndex == 0 && urlPart === '') {
  2424. isAbsolute = true;
  2425. }
  2426. else if (urlPart === '..') {
  2427. numberOfDoubleDots++;
  2428. }
  2429. else if (urlPart != '') {
  2430. res.push(urlPart);
  2431. }
  2432. });
  2433. return res;
  2434. }
  2435. return __spread(res, [cmd]);
  2436. }, []);
  2437. return new Navigation(isAbsolute, numberOfDoubleDots, res);
  2438. }
  2439. var Position = /** @class */ (function () {
  2440. function Position(segmentGroup, processChildren, index) {
  2441. this.segmentGroup = segmentGroup;
  2442. this.processChildren = processChildren;
  2443. this.index = index;
  2444. }
  2445. return Position;
  2446. }());
  2447. function findStartingPosition(nav, tree, route) {
  2448. if (nav.isAbsolute) {
  2449. return new Position(tree.root, true, 0);
  2450. }
  2451. if (route.snapshot._lastPathIndex === -1) {
  2452. return new Position(route.snapshot._urlSegment, true, 0);
  2453. }
  2454. var modifier = isMatrixParams(nav.commands[0]) ? 0 : 1;
  2455. var index = route.snapshot._lastPathIndex + modifier;
  2456. return createPositionApplyingDoubleDots(route.snapshot._urlSegment, index, nav.numberOfDoubleDots);
  2457. }
  2458. function createPositionApplyingDoubleDots(group, index, numberOfDoubleDots) {
  2459. var g = group;
  2460. var ci = index;
  2461. var dd = numberOfDoubleDots;
  2462. while (dd > ci) {
  2463. dd -= ci;
  2464. g = g.parent;
  2465. if (!g) {
  2466. throw new Error('Invalid number of \'../\'');
  2467. }
  2468. ci = g.segments.length;
  2469. }
  2470. return new Position(g, false, ci - dd);
  2471. }
  2472. function getPath(command) {
  2473. if (typeof command === 'object' && command != null && command.outlets) {
  2474. return command.outlets[PRIMARY_OUTLET];
  2475. }
  2476. return "" + command;
  2477. }
  2478. function getOutlets(commands) {
  2479. if (!(typeof commands[0] === 'object'))
  2480. return _a = {}, _a[PRIMARY_OUTLET] = commands, _a;
  2481. if (commands[0].outlets === undefined)
  2482. return _b = {}, _b[PRIMARY_OUTLET] = commands, _b;
  2483. return commands[0].outlets;
  2484. var _a, _b;
  2485. }
  2486. function updateSegmentGroup(segmentGroup, startIndex, commands) {
  2487. if (!segmentGroup) {
  2488. segmentGroup = new UrlSegmentGroup([], {});
  2489. }
  2490. if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
  2491. return updateSegmentGroupChildren(segmentGroup, startIndex, commands);
  2492. }
  2493. var m = prefixedWith(segmentGroup, startIndex, commands);
  2494. var slicedCommands = commands.slice(m.commandIndex);
  2495. if (m.match && m.pathIndex < segmentGroup.segments.length) {
  2496. var g = new UrlSegmentGroup(segmentGroup.segments.slice(0, m.pathIndex), {});
  2497. g.children[PRIMARY_OUTLET] =
  2498. new UrlSegmentGroup(segmentGroup.segments.slice(m.pathIndex), segmentGroup.children);
  2499. return updateSegmentGroupChildren(g, 0, slicedCommands);
  2500. }
  2501. else if (m.match && slicedCommands.length === 0) {
  2502. return new UrlSegmentGroup(segmentGroup.segments, {});
  2503. }
  2504. else if (m.match && !segmentGroup.hasChildren()) {
  2505. return createNewSegmentGroup(segmentGroup, startIndex, commands);
  2506. }
  2507. else if (m.match) {
  2508. return updateSegmentGroupChildren(segmentGroup, 0, slicedCommands);
  2509. }
  2510. else {
  2511. return createNewSegmentGroup(segmentGroup, startIndex, commands);
  2512. }
  2513. }
  2514. function updateSegmentGroupChildren(segmentGroup, startIndex, commands) {
  2515. if (commands.length === 0) {
  2516. return new UrlSegmentGroup(segmentGroup.segments, {});
  2517. }
  2518. else {
  2519. var outlets_2 = getOutlets(commands);
  2520. var children_1 = {};
  2521. forEach(outlets_2, function (commands, outlet) {
  2522. if (commands !== null) {
  2523. children_1[outlet] = updateSegmentGroup(segmentGroup.children[outlet], startIndex, commands);
  2524. }
  2525. });
  2526. forEach(segmentGroup.children, function (child, childOutlet) {
  2527. if (outlets_2[childOutlet] === undefined) {
  2528. children_1[childOutlet] = child;
  2529. }
  2530. });
  2531. return new UrlSegmentGroup(segmentGroup.segments, children_1);
  2532. }
  2533. }
  2534. function prefixedWith(segmentGroup, startIndex, commands) {
  2535. var currentCommandIndex = 0;
  2536. var currentPathIndex = startIndex;
  2537. var noMatch = { match: false, pathIndex: 0, commandIndex: 0 };
  2538. while (currentPathIndex < segmentGroup.segments.length) {
  2539. if (currentCommandIndex >= commands.length)
  2540. return noMatch;
  2541. var path = segmentGroup.segments[currentPathIndex];
  2542. var curr = getPath(commands[currentCommandIndex]);
  2543. var next = currentCommandIndex < commands.length - 1 ? commands[currentCommandIndex + 1] : null;
  2544. if (currentPathIndex > 0 && curr === undefined)
  2545. break;
  2546. if (curr && next && (typeof next === 'object') && next.outlets === undefined) {
  2547. if (!compare(curr, next, path))
  2548. return noMatch;
  2549. currentCommandIndex += 2;
  2550. }
  2551. else {
  2552. if (!compare(curr, {}, path))
  2553. return noMatch;
  2554. currentCommandIndex++;
  2555. }
  2556. currentPathIndex++;
  2557. }
  2558. return { match: true, pathIndex: currentPathIndex, commandIndex: currentCommandIndex };
  2559. }
  2560. function createNewSegmentGroup(segmentGroup, startIndex, commands) {
  2561. var paths = segmentGroup.segments.slice(0, startIndex);
  2562. var i = 0;
  2563. while (i < commands.length) {
  2564. if (typeof commands[i] === 'object' && commands[i].outlets !== undefined) {
  2565. var children = createNewSegmentChildren(commands[i].outlets);
  2566. return new UrlSegmentGroup(paths, children);
  2567. }
  2568. // if we start with an object literal, we need to reuse the path part from the segment
  2569. if (i === 0 && isMatrixParams(commands[0])) {
  2570. var p = segmentGroup.segments[startIndex];
  2571. paths.push(new UrlSegment(p.path, commands[0]));
  2572. i++;
  2573. continue;
  2574. }
  2575. var curr = getPath(commands[i]);
  2576. var next = (i < commands.length - 1) ? commands[i + 1] : null;
  2577. if (curr && next && isMatrixParams(next)) {
  2578. paths.push(new UrlSegment(curr, stringify(next)));
  2579. i += 2;
  2580. }
  2581. else {
  2582. paths.push(new UrlSegment(curr, {}));
  2583. i++;
  2584. }
  2585. }
  2586. return new UrlSegmentGroup(paths, {});
  2587. }
  2588. function createNewSegmentChildren(outlets) {
  2589. var children = {};
  2590. forEach(outlets, function (commands, outlet) {
  2591. if (commands !== null) {
  2592. children[outlet] = createNewSegmentGroup(new UrlSegmentGroup([], {}), 0, commands);
  2593. }
  2594. });
  2595. return children;
  2596. }
  2597. function stringify(params) {
  2598. var res = {};
  2599. forEach(params, function (v, k) { return res[k] = "" + v; });
  2600. return res;
  2601. }
  2602. function compare(path, params, segment) {
  2603. return path == segment.path && shallowEqual(params, segment.parameters);
  2604. }
  2605. /**
  2606. * @license
  2607. * Copyright Google Inc. All Rights Reserved.
  2608. *
  2609. * Use of this source code is governed by an MIT-style license that can be
  2610. * found in the LICENSE file at https://angular.io/license
  2611. */
  2612. var CanActivate = /** @class */ (function () {
  2613. function CanActivate(path) {
  2614. this.path = path;
  2615. this.route = this.path[this.path.length - 1];
  2616. }
  2617. return CanActivate;
  2618. }());
  2619. var CanDeactivate = /** @class */ (function () {
  2620. function CanDeactivate(component, route) {
  2621. this.component = component;
  2622. this.route = route;
  2623. }
  2624. return CanDeactivate;
  2625. }());
  2626. /**
  2627. * This class bundles the actions involved in preactivation of a route.
  2628. */
  2629. var PreActivation = /** @class */ (function () {
  2630. function PreActivation(future, curr, moduleInjector, forwardEvent) {
  2631. this.future = future;
  2632. this.curr = curr;
  2633. this.moduleInjector = moduleInjector;
  2634. this.forwardEvent = forwardEvent;
  2635. this.canActivateChecks = [];
  2636. this.canDeactivateChecks = [];
  2637. }
  2638. PreActivation.prototype.initialize = function (parentContexts) {
  2639. var futureRoot = this.future._root;
  2640. var currRoot = this.curr ? this.curr._root : null;
  2641. this.setupChildRouteGuards(futureRoot, currRoot, parentContexts, [futureRoot.value]);
  2642. };
  2643. PreActivation.prototype.checkGuards = function () {
  2644. var _this = this;
  2645. if (!this.isDeactivating() && !this.isActivating()) {
  2646. return rxjs.of(true);
  2647. }
  2648. var canDeactivate$ = this.runCanDeactivateChecks();
  2649. return canDeactivate$.pipe(operators.mergeMap(function (canDeactivate) { return canDeactivate ? _this.runCanActivateChecks() : rxjs.of(false); }));
  2650. };
  2651. PreActivation.prototype.resolveData = function (paramsInheritanceStrategy) {
  2652. var _this = this;
  2653. if (!this.isActivating())
  2654. return rxjs.of(null);
  2655. return rxjs.from(this.canActivateChecks)
  2656. .pipe(operators.concatMap(function (check) { return _this.runResolve(check.route, paramsInheritanceStrategy); }), operators.reduce(function (_, __) { return _; }));
  2657. };
  2658. PreActivation.prototype.isDeactivating = function () { return this.canDeactivateChecks.length !== 0; };
  2659. PreActivation.prototype.isActivating = function () { return this.canActivateChecks.length !== 0; };
  2660. /**
  2661. * Iterates over child routes and calls recursive `setupRouteGuards` to get `this` instance in
  2662. * proper state to run `checkGuards()` method.
  2663. */
  2664. PreActivation.prototype.setupChildRouteGuards = function (futureNode, currNode, contexts, futurePath) {
  2665. var _this = this;
  2666. var prevChildren = nodeChildrenAsMap(currNode);
  2667. // Process the children of the future route
  2668. futureNode.children.forEach(function (c) {
  2669. _this.setupRouteGuards(c, prevChildren[c.value.outlet], contexts, futurePath.concat([c.value]));
  2670. delete prevChildren[c.value.outlet];
  2671. });
  2672. // Process any children left from the current route (not active for the future route)
  2673. forEach(prevChildren, function (v, k) {
  2674. return _this.deactivateRouteAndItsChildren(v, contexts.getContext(k));
  2675. });
  2676. };
  2677. /**
  2678. * Iterates over child routes and calls recursive `setupRouteGuards` to get `this` instance in
  2679. * proper state to run `checkGuards()` method.
  2680. */
  2681. PreActivation.prototype.setupRouteGuards = function (futureNode, currNode, parentContexts, futurePath) {
  2682. var future = futureNode.value;
  2683. var curr = currNode ? currNode.value : null;
  2684. var context = parentContexts ? parentContexts.getContext(futureNode.value.outlet) : null;
  2685. // reusing the node
  2686. if (curr && future.routeConfig === curr.routeConfig) {
  2687. var shouldRunGuardsAndResolvers = this.shouldRunGuardsAndResolvers(curr, future, future.routeConfig.runGuardsAndResolvers);
  2688. if (shouldRunGuardsAndResolvers) {
  2689. this.canActivateChecks.push(new CanActivate(futurePath));
  2690. }
  2691. else {
  2692. // we need to set the data
  2693. future.data = curr.data;
  2694. future._resolvedData = curr._resolvedData;
  2695. }
  2696. // If we have a component, we need to go through an outlet.
  2697. if (future.component) {
  2698. this.setupChildRouteGuards(futureNode, currNode, context ? context.children : null, futurePath);
  2699. // if we have a componentless route, we recurse but keep the same outlet map.
  2700. }
  2701. else {
  2702. this.setupChildRouteGuards(futureNode, currNode, parentContexts, futurePath);
  2703. }
  2704. if (shouldRunGuardsAndResolvers) {
  2705. var outlet = context.outlet;
  2706. this.canDeactivateChecks.push(new CanDeactivate(outlet.component, curr));
  2707. }
  2708. }
  2709. else {
  2710. if (curr) {
  2711. this.deactivateRouteAndItsChildren(currNode, context);
  2712. }
  2713. this.canActivateChecks.push(new CanActivate(futurePath));
  2714. // If we have a component, we need to go through an outlet.
  2715. if (future.component) {
  2716. this.setupChildRouteGuards(futureNode, null, context ? context.children : null, futurePath);
  2717. // if we have a componentless route, we recurse but keep the same outlet map.
  2718. }
  2719. else {
  2720. this.setupChildRouteGuards(futureNode, null, parentContexts, futurePath);
  2721. }
  2722. }
  2723. };
  2724. PreActivation.prototype.shouldRunGuardsAndResolvers = function (curr, future, mode) {
  2725. switch (mode) {
  2726. case 'always':
  2727. return true;
  2728. case 'paramsOrQueryParamsChange':
  2729. return !equalParamsAndUrlSegments(curr, future) ||
  2730. !shallowEqual(curr.queryParams, future.queryParams);
  2731. case 'paramsChange':
  2732. default:
  2733. return !equalParamsAndUrlSegments(curr, future);
  2734. }
  2735. };
  2736. PreActivation.prototype.deactivateRouteAndItsChildren = function (route, context) {
  2737. var _this = this;
  2738. var children = nodeChildrenAsMap(route);
  2739. var r = route.value;
  2740. forEach(children, function (node, childName) {
  2741. if (!r.component) {
  2742. _this.deactivateRouteAndItsChildren(node, context);
  2743. }
  2744. else if (context) {
  2745. _this.deactivateRouteAndItsChildren(node, context.children.getContext(childName));
  2746. }
  2747. else {
  2748. _this.deactivateRouteAndItsChildren(node, null);
  2749. }
  2750. });
  2751. if (!r.component) {
  2752. this.canDeactivateChecks.push(new CanDeactivate(null, r));
  2753. }
  2754. else if (context && context.outlet && context.outlet.isActivated) {
  2755. this.canDeactivateChecks.push(new CanDeactivate(context.outlet.component, r));
  2756. }
  2757. else {
  2758. this.canDeactivateChecks.push(new CanDeactivate(null, r));
  2759. }
  2760. };
  2761. PreActivation.prototype.runCanDeactivateChecks = function () {
  2762. var _this = this;
  2763. return rxjs.from(this.canDeactivateChecks)
  2764. .pipe(operators.mergeMap(function (check) { return _this.runCanDeactivate(check.component, check.route); }), operators.every(function (result) { return result === true; }));
  2765. };
  2766. PreActivation.prototype.runCanActivateChecks = function () {
  2767. var _this = this;
  2768. return rxjs.from(this.canActivateChecks)
  2769. .pipe(operators.concatMap(function (check) { return andObservables(rxjs.from([
  2770. _this.fireChildActivationStart(check.route.parent),
  2771. _this.fireActivationStart(check.route), _this.runCanActivateChild(check.path),
  2772. _this.runCanActivate(check.route)
  2773. ])); }), operators.every(function (result) { return result === true; }));
  2774. // this.fireChildActivationStart(check.path),
  2775. };
  2776. /**
  2777. * This should fire off `ActivationStart` events for each route being activated at this
  2778. * level.
  2779. * In other words, if you're activating `a` and `b` below, `path` will contain the
  2780. * `ActivatedRouteSnapshot`s for both and we will fire `ActivationStart` for both. Always
  2781. * return
  2782. * `true` so checks continue to run.
  2783. */
  2784. PreActivation.prototype.fireActivationStart = function (snapshot) {
  2785. if (snapshot !== null && this.forwardEvent) {
  2786. this.forwardEvent(new ActivationStart(snapshot));
  2787. }
  2788. return rxjs.of(true);
  2789. };
  2790. /**
  2791. * This should fire off `ChildActivationStart` events for each route being activated at this
  2792. * level.
  2793. * In other words, if you're activating `a` and `b` below, `path` will contain the
  2794. * `ActivatedRouteSnapshot`s for both and we will fire `ChildActivationStart` for both. Always
  2795. * return
  2796. * `true` so checks continue to run.
  2797. */
  2798. PreActivation.prototype.fireChildActivationStart = function (snapshot) {
  2799. if (snapshot !== null && this.forwardEvent) {
  2800. this.forwardEvent(new ChildActivationStart(snapshot));
  2801. }
  2802. return rxjs.of(true);
  2803. };
  2804. PreActivation.prototype.runCanActivate = function (future) {
  2805. var _this = this;
  2806. var canActivate = future.routeConfig ? future.routeConfig.canActivate : null;
  2807. if (!canActivate || canActivate.length === 0)
  2808. return rxjs.of(true);
  2809. var obs = rxjs.from(canActivate).pipe(operators.map(function (c) {
  2810. var guard = _this.getToken(c, future);
  2811. var observable;
  2812. if (guard.canActivate) {
  2813. observable = wrapIntoObservable(guard.canActivate(future, _this.future));
  2814. }
  2815. else {
  2816. observable = wrapIntoObservable(guard(future, _this.future));
  2817. }
  2818. return observable.pipe(operators.first());
  2819. }));
  2820. return andObservables(obs);
  2821. };
  2822. PreActivation.prototype.runCanActivateChild = function (path) {
  2823. var _this = this;
  2824. var future = path[path.length - 1];
  2825. var canActivateChildGuards = path.slice(0, path.length - 1)
  2826. .reverse()
  2827. .map(function (p) { return _this.extractCanActivateChild(p); })
  2828. .filter(function (_) { return _ !== null; });
  2829. return andObservables(rxjs.from(canActivateChildGuards).pipe(operators.map(function (d) {
  2830. var obs = rxjs.from(d.guards).pipe(operators.map(function (c) {
  2831. var guard = _this.getToken(c, d.node);
  2832. var observable;
  2833. if (guard.canActivateChild) {
  2834. observable = wrapIntoObservable(guard.canActivateChild(future, _this.future));
  2835. }
  2836. else {
  2837. observable = wrapIntoObservable(guard(future, _this.future));
  2838. }
  2839. return observable.pipe(operators.first());
  2840. }));
  2841. return andObservables(obs);
  2842. })));
  2843. };
  2844. PreActivation.prototype.extractCanActivateChild = function (p) {
  2845. var canActivateChild = p.routeConfig ? p.routeConfig.canActivateChild : null;
  2846. if (!canActivateChild || canActivateChild.length === 0)
  2847. return null;
  2848. return { node: p, guards: canActivateChild };
  2849. };
  2850. PreActivation.prototype.runCanDeactivate = function (component, curr) {
  2851. var _this = this;
  2852. var canDeactivate = curr && curr.routeConfig ? curr.routeConfig.canDeactivate : null;
  2853. if (!canDeactivate || canDeactivate.length === 0)
  2854. return rxjs.of(true);
  2855. var canDeactivate$ = rxjs.from(canDeactivate).pipe(operators.mergeMap(function (c) {
  2856. var guard = _this.getToken(c, curr);
  2857. var observable;
  2858. if (guard.canDeactivate) {
  2859. observable =
  2860. wrapIntoObservable(guard.canDeactivate(component, curr, _this.curr, _this.future));
  2861. }
  2862. else {
  2863. observable = wrapIntoObservable(guard(component, curr, _this.curr, _this.future));
  2864. }
  2865. return observable.pipe(operators.first());
  2866. }));
  2867. return canDeactivate$.pipe(operators.every(function (result) { return result === true; }));
  2868. };
  2869. PreActivation.prototype.runResolve = function (future, paramsInheritanceStrategy) {
  2870. var resolve = future._resolve;
  2871. return this.resolveNode(resolve, future).pipe(operators.map(function (resolvedData) {
  2872. future._resolvedData = resolvedData;
  2873. future.data = __assign({}, future.data, inheritedParamsDataResolve(future, paramsInheritanceStrategy).resolve);
  2874. return null;
  2875. }));
  2876. };
  2877. PreActivation.prototype.resolveNode = function (resolve, future) {
  2878. var _this = this;
  2879. var keys = Object.keys(resolve);
  2880. if (keys.length === 0) {
  2881. return rxjs.of({});
  2882. }
  2883. if (keys.length === 1) {
  2884. var key_1 = keys[0];
  2885. return this.getResolver(resolve[key_1], future).pipe(operators.map(function (value) {
  2886. return _a = {}, _a[key_1] = value, _a;
  2887. var _a;
  2888. }));
  2889. }
  2890. var data = {};
  2891. var runningResolvers$ = rxjs.from(keys).pipe(operators.mergeMap(function (key) {
  2892. return _this.getResolver(resolve[key], future).pipe(operators.map(function (value) {
  2893. data[key] = value;
  2894. return value;
  2895. }));
  2896. }));
  2897. return runningResolvers$.pipe(operators.last(), operators.map(function () { return data; }));
  2898. };
  2899. PreActivation.prototype.getResolver = function (injectionToken, future) {
  2900. var resolver = this.getToken(injectionToken, future);
  2901. return resolver.resolve ? wrapIntoObservable(resolver.resolve(future, this.future)) :
  2902. wrapIntoObservable(resolver(future, this.future));
  2903. };
  2904. PreActivation.prototype.getToken = function (token, snapshot) {
  2905. var config = closestLoadedConfig(snapshot);
  2906. var injector = config ? config.module.injector : this.moduleInjector;
  2907. return injector.get(token);
  2908. };
  2909. return PreActivation;
  2910. }());
  2911. function closestLoadedConfig(snapshot) {
  2912. if (!snapshot)
  2913. return null;
  2914. for (var s = snapshot.parent; s; s = s.parent) {
  2915. var route = s.routeConfig;
  2916. if (route && route._loadedConfig)
  2917. return route._loadedConfig;
  2918. }
  2919. return null;
  2920. }
  2921. /**
  2922. * @license
  2923. * Copyright Google Inc. All Rights Reserved.
  2924. *
  2925. * Use of this source code is governed by an MIT-style license that can be
  2926. * found in the LICENSE file at https://angular.io/license
  2927. */
  2928. var NoMatch$1 = /** @class */ (function () {
  2929. function NoMatch() {
  2930. }
  2931. return NoMatch;
  2932. }());
  2933. function recognize(rootComponentType, config, urlTree, url, paramsInheritanceStrategy) {
  2934. if (paramsInheritanceStrategy === void 0) { paramsInheritanceStrategy = 'emptyOnly'; }
  2935. return new Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy)
  2936. .recognize();
  2937. }
  2938. var Recognizer = /** @class */ (function () {
  2939. function Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy) {
  2940. this.rootComponentType = rootComponentType;
  2941. this.config = config;
  2942. this.urlTree = urlTree;
  2943. this.url = url;
  2944. this.paramsInheritanceStrategy = paramsInheritanceStrategy;
  2945. }
  2946. Recognizer.prototype.recognize = function () {
  2947. try {
  2948. var rootSegmentGroup = split$1(this.urlTree.root, [], [], this.config).segmentGroup;
  2949. var children = this.processSegmentGroup(this.config, rootSegmentGroup, PRIMARY_OUTLET);
  2950. var root = new ActivatedRouteSnapshot([], Object.freeze({}), Object.freeze(__assign({}, this.urlTree.queryParams)), this.urlTree.fragment, {}, PRIMARY_OUTLET, this.rootComponentType, null, this.urlTree.root, -1, {});
  2951. var rootNode = new TreeNode(root, children);
  2952. var routeState = new RouterStateSnapshot(this.url, rootNode);
  2953. this.inheritParamsAndData(routeState._root);
  2954. return rxjs.of(routeState);
  2955. }
  2956. catch (e) {
  2957. return new rxjs.Observable(function (obs) { return obs.error(e); });
  2958. }
  2959. };
  2960. Recognizer.prototype.inheritParamsAndData = function (routeNode) {
  2961. var _this = this;
  2962. var route = routeNode.value;
  2963. var i = inheritedParamsDataResolve(route, this.paramsInheritanceStrategy);
  2964. route.params = Object.freeze(i.params);
  2965. route.data = Object.freeze(i.data);
  2966. routeNode.children.forEach(function (n) { return _this.inheritParamsAndData(n); });
  2967. };
  2968. Recognizer.prototype.processSegmentGroup = function (config, segmentGroup, outlet) {
  2969. if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
  2970. return this.processChildren(config, segmentGroup);
  2971. }
  2972. return this.processSegment(config, segmentGroup, segmentGroup.segments, outlet);
  2973. };
  2974. Recognizer.prototype.processChildren = function (config, segmentGroup) {
  2975. var _this = this;
  2976. var children = mapChildrenIntoArray(segmentGroup, function (child, childOutlet) { return _this.processSegmentGroup(config, child, childOutlet); });
  2977. checkOutletNameUniqueness(children);
  2978. sortActivatedRouteSnapshots(children);
  2979. return children;
  2980. };
  2981. Recognizer.prototype.processSegment = function (config, segmentGroup, segments, outlet) {
  2982. try {
  2983. for (var config_1 = __values(config), config_1_1 = config_1.next(); !config_1_1.done; config_1_1 = config_1.next()) {
  2984. var r = config_1_1.value;
  2985. try {
  2986. return this.processSegmentAgainstRoute(r, segmentGroup, segments, outlet);
  2987. }
  2988. catch (e) {
  2989. if (!(e instanceof NoMatch$1))
  2990. throw e;
  2991. }
  2992. }
  2993. }
  2994. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  2995. finally {
  2996. try {
  2997. if (config_1_1 && !config_1_1.done && (_a = config_1.return)) _a.call(config_1);
  2998. }
  2999. finally { if (e_1) throw e_1.error; }
  3000. }
  3001. if (this.noLeftoversInUrl(segmentGroup, segments, outlet)) {
  3002. return [];
  3003. }
  3004. throw new NoMatch$1();
  3005. var e_1, _a;
  3006. };
  3007. Recognizer.prototype.noLeftoversInUrl = function (segmentGroup, segments, outlet) {
  3008. return segments.length === 0 && !segmentGroup.children[outlet];
  3009. };
  3010. Recognizer.prototype.processSegmentAgainstRoute = function (route, rawSegment, segments, outlet) {
  3011. if (route.redirectTo)
  3012. throw new NoMatch$1();
  3013. if ((route.outlet || PRIMARY_OUTLET) !== outlet)
  3014. throw new NoMatch$1();
  3015. var snapshot;
  3016. var consumedSegments = [];
  3017. var rawSlicedSegments = [];
  3018. if (route.path === '**') {
  3019. var params = segments.length > 0 ? last(segments).parameters : {};
  3020. snapshot = new ActivatedRouteSnapshot(segments, params, Object.freeze(__assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), outlet, route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + segments.length, getResolve(route));
  3021. }
  3022. else {
  3023. var result = match$1(rawSegment, route, segments);
  3024. consumedSegments = result.consumedSegments;
  3025. rawSlicedSegments = segments.slice(result.lastChild);
  3026. snapshot = new ActivatedRouteSnapshot(consumedSegments, result.parameters, Object.freeze(__assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), outlet, route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + consumedSegments.length, getResolve(route));
  3027. }
  3028. var childConfig = getChildConfig(route);
  3029. var _a = split$1(rawSegment, consumedSegments, rawSlicedSegments, childConfig), segmentGroup = _a.segmentGroup, slicedSegments = _a.slicedSegments;
  3030. if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
  3031. var children_1 = this.processChildren(childConfig, segmentGroup);
  3032. return [new TreeNode(snapshot, children_1)];
  3033. }
  3034. if (childConfig.length === 0 && slicedSegments.length === 0) {
  3035. return [new TreeNode(snapshot, [])];
  3036. }
  3037. var children = this.processSegment(childConfig, segmentGroup, slicedSegments, PRIMARY_OUTLET);
  3038. return [new TreeNode(snapshot, children)];
  3039. };
  3040. return Recognizer;
  3041. }());
  3042. function sortActivatedRouteSnapshots(nodes) {
  3043. nodes.sort(function (a, b) {
  3044. if (a.value.outlet === PRIMARY_OUTLET)
  3045. return -1;
  3046. if (b.value.outlet === PRIMARY_OUTLET)
  3047. return 1;
  3048. return a.value.outlet.localeCompare(b.value.outlet);
  3049. });
  3050. }
  3051. function getChildConfig(route) {
  3052. if (route.children) {
  3053. return route.children;
  3054. }
  3055. if (route.loadChildren) {
  3056. return route._loadedConfig.routes;
  3057. }
  3058. return [];
  3059. }
  3060. function match$1(segmentGroup, route, segments) {
  3061. if (route.path === '') {
  3062. if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || segments.length > 0)) {
  3063. throw new NoMatch$1();
  3064. }
  3065. return { consumedSegments: [], lastChild: 0, parameters: {} };
  3066. }
  3067. var matcher = route.matcher || defaultUrlMatcher;
  3068. var res = matcher(segments, segmentGroup, route);
  3069. if (!res)
  3070. throw new NoMatch$1();
  3071. var posParams = {};
  3072. forEach(res.posParams, function (v, k) { posParams[k] = v.path; });
  3073. var parameters = res.consumed.length > 0 ? __assign({}, posParams, res.consumed[res.consumed.length - 1].parameters) :
  3074. posParams;
  3075. return { consumedSegments: res.consumed, lastChild: res.consumed.length, parameters: parameters };
  3076. }
  3077. function checkOutletNameUniqueness(nodes) {
  3078. var names = {};
  3079. nodes.forEach(function (n) {
  3080. var routeWithSameOutletName = names[n.value.outlet];
  3081. if (routeWithSameOutletName) {
  3082. var p = routeWithSameOutletName.url.map(function (s) { return s.toString(); }).join('/');
  3083. var c = n.value.url.map(function (s) { return s.toString(); }).join('/');
  3084. throw new Error("Two segments cannot have the same outlet name: '" + p + "' and '" + c + "'.");
  3085. }
  3086. names[n.value.outlet] = n.value;
  3087. });
  3088. }
  3089. function getSourceSegmentGroup(segmentGroup) {
  3090. var s = segmentGroup;
  3091. while (s._sourceSegment) {
  3092. s = s._sourceSegment;
  3093. }
  3094. return s;
  3095. }
  3096. function getPathIndexShift(segmentGroup) {
  3097. var s = segmentGroup;
  3098. var res = (s._segmentIndexShift ? s._segmentIndexShift : 0);
  3099. while (s._sourceSegment) {
  3100. s = s._sourceSegment;
  3101. res += (s._segmentIndexShift ? s._segmentIndexShift : 0);
  3102. }
  3103. return res - 1;
  3104. }
  3105. function split$1(segmentGroup, consumedSegments, slicedSegments, config) {
  3106. if (slicedSegments.length > 0 &&
  3107. containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, config)) {
  3108. var s_1 = new UrlSegmentGroup(consumedSegments, createChildrenForEmptyPaths(segmentGroup, consumedSegments, config, new UrlSegmentGroup(slicedSegments, segmentGroup.children)));
  3109. s_1._sourceSegment = segmentGroup;
  3110. s_1._segmentIndexShift = consumedSegments.length;
  3111. return { segmentGroup: s_1, slicedSegments: [] };
  3112. }
  3113. if (slicedSegments.length === 0 &&
  3114. containsEmptyPathMatches(segmentGroup, slicedSegments, config)) {
  3115. var s_2 = new UrlSegmentGroup(segmentGroup.segments, addEmptyPathsToChildrenIfNeeded(segmentGroup, slicedSegments, config, segmentGroup.children));
  3116. s_2._sourceSegment = segmentGroup;
  3117. s_2._segmentIndexShift = consumedSegments.length;
  3118. return { segmentGroup: s_2, slicedSegments: slicedSegments };
  3119. }
  3120. var s = new UrlSegmentGroup(segmentGroup.segments, segmentGroup.children);
  3121. s._sourceSegment = segmentGroup;
  3122. s._segmentIndexShift = consumedSegments.length;
  3123. return { segmentGroup: s, slicedSegments: slicedSegments };
  3124. }
  3125. function addEmptyPathsToChildrenIfNeeded(segmentGroup, slicedSegments, routes, children) {
  3126. var res = {};
  3127. try {
  3128. for (var routes_1 = __values(routes), routes_1_1 = routes_1.next(); !routes_1_1.done; routes_1_1 = routes_1.next()) {
  3129. var r = routes_1_1.value;
  3130. if (emptyPathMatch(segmentGroup, slicedSegments, r) && !children[getOutlet$1(r)]) {
  3131. var s = new UrlSegmentGroup([], {});
  3132. s._sourceSegment = segmentGroup;
  3133. s._segmentIndexShift = segmentGroup.segments.length;
  3134. res[getOutlet$1(r)] = s;
  3135. }
  3136. }
  3137. }
  3138. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  3139. finally {
  3140. try {
  3141. if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
  3142. }
  3143. finally { if (e_2) throw e_2.error; }
  3144. }
  3145. return __assign({}, children, res);
  3146. var e_2, _a;
  3147. }
  3148. function createChildrenForEmptyPaths(segmentGroup, consumedSegments, routes, primarySegment) {
  3149. var res = {};
  3150. res[PRIMARY_OUTLET] = primarySegment;
  3151. primarySegment._sourceSegment = segmentGroup;
  3152. primarySegment._segmentIndexShift = consumedSegments.length;
  3153. try {
  3154. for (var routes_2 = __values(routes), routes_2_1 = routes_2.next(); !routes_2_1.done; routes_2_1 = routes_2.next()) {
  3155. var r = routes_2_1.value;
  3156. if (r.path === '' && getOutlet$1(r) !== PRIMARY_OUTLET) {
  3157. var s = new UrlSegmentGroup([], {});
  3158. s._sourceSegment = segmentGroup;
  3159. s._segmentIndexShift = consumedSegments.length;
  3160. res[getOutlet$1(r)] = s;
  3161. }
  3162. }
  3163. }
  3164. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  3165. finally {
  3166. try {
  3167. if (routes_2_1 && !routes_2_1.done && (_a = routes_2.return)) _a.call(routes_2);
  3168. }
  3169. finally { if (e_3) throw e_3.error; }
  3170. }
  3171. return res;
  3172. var e_3, _a;
  3173. }
  3174. function containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, routes) {
  3175. return routes.some(function (r) { return emptyPathMatch(segmentGroup, slicedSegments, r) && getOutlet$1(r) !== PRIMARY_OUTLET; });
  3176. }
  3177. function containsEmptyPathMatches(segmentGroup, slicedSegments, routes) {
  3178. return routes.some(function (r) { return emptyPathMatch(segmentGroup, slicedSegments, r); });
  3179. }
  3180. function emptyPathMatch(segmentGroup, slicedSegments, r) {
  3181. if ((segmentGroup.hasChildren() || slicedSegments.length > 0) && r.pathMatch === 'full') {
  3182. return false;
  3183. }
  3184. return r.path === '' && r.redirectTo === undefined;
  3185. }
  3186. function getOutlet$1(route) {
  3187. return route.outlet || PRIMARY_OUTLET;
  3188. }
  3189. function getData(route) {
  3190. return route.data || {};
  3191. }
  3192. function getResolve(route) {
  3193. return route.resolve || {};
  3194. }
  3195. /**
  3196. * @license
  3197. * Copyright Google Inc. All Rights Reserved.
  3198. *
  3199. * Use of this source code is governed by an MIT-style license that can be
  3200. * found in the LICENSE file at https://angular.io/license
  3201. */
  3202. /**
  3203. * @description
  3204. *
  3205. * Provides a way to customize when activated routes get reused.
  3206. *
  3207. * @experimental
  3208. */
  3209. var RouteReuseStrategy = /** @class */ (function () {
  3210. function RouteReuseStrategy() {
  3211. }
  3212. return RouteReuseStrategy;
  3213. }());
  3214. /**
  3215. * Does not detach any subtrees. Reuses routes as long as their route config is the same.
  3216. */
  3217. var DefaultRouteReuseStrategy = /** @class */ (function () {
  3218. function DefaultRouteReuseStrategy() {
  3219. }
  3220. DefaultRouteReuseStrategy.prototype.shouldDetach = function (route) { return false; };
  3221. DefaultRouteReuseStrategy.prototype.store = function (route, detachedTree) { };
  3222. DefaultRouteReuseStrategy.prototype.shouldAttach = function (route) { return false; };
  3223. DefaultRouteReuseStrategy.prototype.retrieve = function (route) { return null; };
  3224. DefaultRouteReuseStrategy.prototype.shouldReuseRoute = function (future, curr) {
  3225. return future.routeConfig === curr.routeConfig;
  3226. };
  3227. return DefaultRouteReuseStrategy;
  3228. }());
  3229. /**
  3230. * @license
  3231. * Copyright Google Inc. All Rights Reserved.
  3232. *
  3233. * Use of this source code is governed by an MIT-style license that can be
  3234. * found in the LICENSE file at https://angular.io/license
  3235. */
  3236. /**
  3237. * @docsNotRequired
  3238. * @experimental
  3239. */
  3240. var ROUTES = new core.InjectionToken('ROUTES');
  3241. var RouterConfigLoader = /** @class */ (function () {
  3242. function RouterConfigLoader(loader, compiler, onLoadStartListener, onLoadEndListener) {
  3243. this.loader = loader;
  3244. this.compiler = compiler;
  3245. this.onLoadStartListener = onLoadStartListener;
  3246. this.onLoadEndListener = onLoadEndListener;
  3247. }
  3248. RouterConfigLoader.prototype.load = function (parentInjector, route) {
  3249. var _this = this;
  3250. if (this.onLoadStartListener) {
  3251. this.onLoadStartListener(route);
  3252. }
  3253. var moduleFactory$ = this.loadModuleFactory(route.loadChildren);
  3254. return moduleFactory$.pipe(operators.map(function (factory) {
  3255. if (_this.onLoadEndListener) {
  3256. _this.onLoadEndListener(route);
  3257. }
  3258. var module = factory.create(parentInjector);
  3259. return new LoadedRouterConfig(flatten(module.injector.get(ROUTES)).map(standardizeConfig), module);
  3260. }));
  3261. };
  3262. RouterConfigLoader.prototype.loadModuleFactory = function (loadChildren) {
  3263. var _this = this;
  3264. if (typeof loadChildren === 'string') {
  3265. return rxjs.from(this.loader.load(loadChildren));
  3266. }
  3267. else {
  3268. return wrapIntoObservable(loadChildren()).pipe(operators.mergeMap(function (t) {
  3269. if (t instanceof core.NgModuleFactory) {
  3270. return rxjs.of(t);
  3271. }
  3272. else {
  3273. return rxjs.from(_this.compiler.compileModuleAsync(t));
  3274. }
  3275. }));
  3276. }
  3277. };
  3278. return RouterConfigLoader;
  3279. }());
  3280. /**
  3281. * @license
  3282. * Copyright Google Inc. All Rights Reserved.
  3283. *
  3284. * Use of this source code is governed by an MIT-style license that can be
  3285. * found in the LICENSE file at https://angular.io/license
  3286. */
  3287. /**
  3288. * @description
  3289. *
  3290. * Provides a way to migrate AngularJS applications to Angular.
  3291. *
  3292. * @experimental
  3293. */
  3294. var UrlHandlingStrategy = /** @class */ (function () {
  3295. function UrlHandlingStrategy() {
  3296. }
  3297. return UrlHandlingStrategy;
  3298. }());
  3299. /**
  3300. * @experimental
  3301. */
  3302. var DefaultUrlHandlingStrategy = /** @class */ (function () {
  3303. function DefaultUrlHandlingStrategy() {
  3304. }
  3305. DefaultUrlHandlingStrategy.prototype.shouldProcessUrl = function (url) { return true; };
  3306. DefaultUrlHandlingStrategy.prototype.extract = function (url) { return url; };
  3307. DefaultUrlHandlingStrategy.prototype.merge = function (newUrlPart, wholeUrl) { return newUrlPart; };
  3308. return DefaultUrlHandlingStrategy;
  3309. }());
  3310. /**
  3311. * @license
  3312. * Copyright Google Inc. All Rights Reserved.
  3313. *
  3314. * Use of this source code is governed by an MIT-style license that can be
  3315. * found in the LICENSE file at https://angular.io/license
  3316. */
  3317. function defaultErrorHandler(error) {
  3318. throw error;
  3319. }
  3320. function defaultMalformedUriErrorHandler(error, urlSerializer, url) {
  3321. return urlSerializer.parse('/');
  3322. }
  3323. /**
  3324. * @internal
  3325. */
  3326. function defaultRouterHook(snapshot) {
  3327. return rxjs.of(null);
  3328. }
  3329. /**
  3330. * @description
  3331. *
  3332. * Provides the navigation and url manipulation capabilities.
  3333. *
  3334. * See `Routes` for more details and examples.
  3335. *
  3336. * @ngModule RouterModule
  3337. *
  3338. *
  3339. */
  3340. var Router = /** @class */ (function () {
  3341. /**
  3342. * Creates the router service.
  3343. */
  3344. // TODO: vsavkin make internal after the final is out.
  3345. function Router(rootComponentType, urlSerializer, rootContexts, location, injector, loader, compiler, config) {
  3346. var _this = this;
  3347. this.rootComponentType = rootComponentType;
  3348. this.urlSerializer = urlSerializer;
  3349. this.rootContexts = rootContexts;
  3350. this.location = location;
  3351. this.config = config;
  3352. this.navigations = new rxjs.BehaviorSubject(null);
  3353. this.navigationId = 0;
  3354. this.events = new rxjs.Subject();
  3355. /**
  3356. * Error handler that is invoked when a navigation errors.
  3357. *
  3358. * See `ErrorHandler` for more information.
  3359. */
  3360. this.errorHandler = defaultErrorHandler;
  3361. /**
  3362. * Malformed uri error handler is invoked when `Router.parseUrl(url)` throws an
  3363. * error due to containing an invalid character. The most common case would be a `%` sign
  3364. * that's not encoded and is not part of a percent encoded sequence.
  3365. */
  3366. this.malformedUriErrorHandler = defaultMalformedUriErrorHandler;
  3367. /**
  3368. * Indicates if at least one navigation happened.
  3369. */
  3370. this.navigated = false;
  3371. this.lastSuccessfulId = -1;
  3372. /**
  3373. * Used by RouterModule. This allows us to
  3374. * pause the navigation either before preactivation or after it.
  3375. * @internal
  3376. */
  3377. this.hooks = {
  3378. beforePreactivation: defaultRouterHook,
  3379. afterPreactivation: defaultRouterHook
  3380. };
  3381. /**
  3382. * Extracts and merges URLs. Used for AngularJS to Angular migrations.
  3383. */
  3384. this.urlHandlingStrategy = new DefaultUrlHandlingStrategy();
  3385. this.routeReuseStrategy = new DefaultRouteReuseStrategy();
  3386. /**
  3387. * Define what the router should do if it receives a navigation request to the current URL.
  3388. * By default, the router will ignore this navigation. However, this prevents features such
  3389. * as a "refresh" button. Use this option to configure the behavior when navigating to the
  3390. * current URL. Default is 'ignore'.
  3391. */
  3392. this.onSameUrlNavigation = 'ignore';
  3393. /**
  3394. * Defines how the router merges params, data and resolved data from parent to child
  3395. * routes. Available options are:
  3396. *
  3397. * - `'emptyOnly'`, the default, only inherits parent params for path-less or component-less
  3398. * routes.
  3399. * - `'always'`, enables unconditional inheritance of parent params.
  3400. */
  3401. this.paramsInheritanceStrategy = 'emptyOnly';
  3402. var onLoadStart = function (r) { return _this.triggerEvent(new RouteConfigLoadStart(r)); };
  3403. var onLoadEnd = function (r) { return _this.triggerEvent(new RouteConfigLoadEnd(r)); };
  3404. this.ngModule = injector.get(core.NgModuleRef);
  3405. this.resetConfig(config);
  3406. this.currentUrlTree = createEmptyUrlTree();
  3407. this.rawUrlTree = this.currentUrlTree;
  3408. this.configLoader = new RouterConfigLoader(loader, compiler, onLoadStart, onLoadEnd);
  3409. this.routerState = createEmptyState(this.currentUrlTree, this.rootComponentType);
  3410. this.processNavigations();
  3411. }
  3412. /**
  3413. * @internal
  3414. * TODO: this should be removed once the constructor of the router made internal
  3415. */
  3416. Router.prototype.resetRootComponentType = function (rootComponentType) {
  3417. this.rootComponentType = rootComponentType;
  3418. // TODO: vsavkin router 4.0 should make the root component set to null
  3419. // this will simplify the lifecycle of the router.
  3420. this.routerState.root.component = this.rootComponentType;
  3421. };
  3422. /**
  3423. * Sets up the location change listener and performs the initial navigation.
  3424. */
  3425. Router.prototype.initialNavigation = function () {
  3426. this.setUpLocationChangeListener();
  3427. if (this.navigationId === 0) {
  3428. this.navigateByUrl(this.location.path(true), { replaceUrl: true });
  3429. }
  3430. };
  3431. /**
  3432. * Sets up the location change listener.
  3433. */
  3434. Router.prototype.setUpLocationChangeListener = function () {
  3435. var _this = this;
  3436. // Don't need to use Zone.wrap any more, because zone.js
  3437. // already patch onPopState, so location change callback will
  3438. // run into ngZone
  3439. if (!this.locationSubscription) {
  3440. this.locationSubscription = this.location.subscribe(function (change) {
  3441. var rawUrlTree = _this.parseUrl(change['url']);
  3442. var source = change['type'] === 'popstate' ? 'popstate' : 'hashchange';
  3443. var state = change.state && change.state.navigationId ?
  3444. { navigationId: change.state.navigationId } :
  3445. null;
  3446. setTimeout(function () { _this.scheduleNavigation(rawUrlTree, source, state, { replaceUrl: true }); }, 0);
  3447. });
  3448. }
  3449. };
  3450. Object.defineProperty(Router.prototype, "url", {
  3451. /** The current url */
  3452. get: function () { return this.serializeUrl(this.currentUrlTree); },
  3453. enumerable: true,
  3454. configurable: true
  3455. });
  3456. /** @internal */
  3457. Router.prototype.triggerEvent = function (e) { this.events.next(e); };
  3458. /**
  3459. * Resets the configuration used for navigation and generating links.
  3460. *
  3461. * ### Usage
  3462. *
  3463. * ```
  3464. * router.resetConfig([
  3465. * { path: 'team/:id', component: TeamCmp, children: [
  3466. * { path: 'simple', component: SimpleCmp },
  3467. * { path: 'user/:name', component: UserCmp }
  3468. * ]}
  3469. * ]);
  3470. * ```
  3471. */
  3472. Router.prototype.resetConfig = function (config) {
  3473. validateConfig(config);
  3474. this.config = config.map(standardizeConfig);
  3475. this.navigated = false;
  3476. this.lastSuccessfulId = -1;
  3477. };
  3478. /** @docsNotRequired */
  3479. Router.prototype.ngOnDestroy = function () { this.dispose(); };
  3480. /** Disposes of the router */
  3481. Router.prototype.dispose = function () {
  3482. if (this.locationSubscription) {
  3483. this.locationSubscription.unsubscribe();
  3484. this.locationSubscription = null;
  3485. }
  3486. };
  3487. /**
  3488. * Applies an array of commands to the current url tree and creates a new url tree.
  3489. *
  3490. * When given an activate route, applies the given commands starting from the route.
  3491. * When not given a route, applies the given command starting from the root.
  3492. *
  3493. * ### Usage
  3494. *
  3495. * ```
  3496. * // create /team/33/user/11
  3497. * router.createUrlTree(['/team', 33, 'user', 11]);
  3498. *
  3499. * // create /team/33;expand=true/user/11
  3500. * router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]);
  3501. *
  3502. * // you can collapse static segments like this (this works only with the first passed-in value):
  3503. * router.createUrlTree(['/team/33/user', userId]);
  3504. *
  3505. * // If the first segment can contain slashes, and you do not want the router to split it, you
  3506. * // can do the following:
  3507. *
  3508. * router.createUrlTree([{segmentPath: '/one/two'}]);
  3509. *
  3510. * // create /team/33/(user/11//right:chat)
  3511. * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: 'chat'}}]);
  3512. *
  3513. * // remove the right secondary node
  3514. * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: null}}]);
  3515. *
  3516. * // assuming the current url is `/team/33/user/11` and the route points to `user/11`
  3517. *
  3518. * // navigate to /team/33/user/11/details
  3519. * router.createUrlTree(['details'], {relativeTo: route});
  3520. *
  3521. * // navigate to /team/33/user/22
  3522. * router.createUrlTree(['../22'], {relativeTo: route});
  3523. *
  3524. * // navigate to /team/44/user/22
  3525. * router.createUrlTree(['../../team/44/user/22'], {relativeTo: route});
  3526. * ```
  3527. */
  3528. Router.prototype.createUrlTree = function (commands, navigationExtras) {
  3529. if (navigationExtras === void 0) { navigationExtras = {}; }
  3530. var relativeTo = navigationExtras.relativeTo, queryParams = navigationExtras.queryParams, fragment = navigationExtras.fragment, preserveQueryParams = navigationExtras.preserveQueryParams, queryParamsHandling = navigationExtras.queryParamsHandling, preserveFragment = navigationExtras.preserveFragment;
  3531. if (core.isDevMode() && preserveQueryParams && console && console.warn) {
  3532. console.warn('preserveQueryParams is deprecated, use queryParamsHandling instead.');
  3533. }
  3534. var a = relativeTo || this.routerState.root;
  3535. var f = preserveFragment ? this.currentUrlTree.fragment : fragment;
  3536. var q = null;
  3537. if (queryParamsHandling) {
  3538. switch (queryParamsHandling) {
  3539. case 'merge':
  3540. q = __assign({}, this.currentUrlTree.queryParams, queryParams);
  3541. break;
  3542. case 'preserve':
  3543. q = this.currentUrlTree.queryParams;
  3544. break;
  3545. default:
  3546. q = queryParams || null;
  3547. }
  3548. }
  3549. else {
  3550. q = preserveQueryParams ? this.currentUrlTree.queryParams : queryParams || null;
  3551. }
  3552. if (q !== null) {
  3553. q = this.removeEmptyProps(q);
  3554. }
  3555. return createUrlTree(a, this.currentUrlTree, commands, q, f);
  3556. };
  3557. /**
  3558. * Navigate based on the provided url. This navigation is always absolute.
  3559. *
  3560. * Returns a promise that:
  3561. * - resolves to 'true' when navigation succeeds,
  3562. * - resolves to 'false' when navigation fails,
  3563. * - is rejected when an error happens.
  3564. *
  3565. * ### Usage
  3566. *
  3567. * ```
  3568. * router.navigateByUrl("/team/33/user/11");
  3569. *
  3570. * // Navigate without updating the URL
  3571. * router.navigateByUrl("/team/33/user/11", { skipLocationChange: true });
  3572. * ```
  3573. *
  3574. * In opposite to `navigate`, `navigateByUrl` takes a whole URL
  3575. * and does not apply any delta to the current one.
  3576. */
  3577. Router.prototype.navigateByUrl = function (url, extras) {
  3578. if (extras === void 0) { extras = { skipLocationChange: false }; }
  3579. var urlTree = url instanceof UrlTree ? url : this.parseUrl(url);
  3580. var mergedTree = this.urlHandlingStrategy.merge(urlTree, this.rawUrlTree);
  3581. return this.scheduleNavigation(mergedTree, 'imperative', null, extras);
  3582. };
  3583. /**
  3584. * Navigate based on the provided array of commands and a starting point.
  3585. * If no starting route is provided, the navigation is absolute.
  3586. *
  3587. * Returns a promise that:
  3588. * - resolves to 'true' when navigation succeeds,
  3589. * - resolves to 'false' when navigation fails,
  3590. * - is rejected when an error happens.
  3591. *
  3592. * ### Usage
  3593. *
  3594. * ```
  3595. * router.navigate(['team', 33, 'user', 11], {relativeTo: route});
  3596. *
  3597. * // Navigate without updating the URL
  3598. * router.navigate(['team', 33, 'user', 11], {relativeTo: route, skipLocationChange: true});
  3599. * ```
  3600. *
  3601. * In opposite to `navigateByUrl`, `navigate` always takes a delta that is applied to the current
  3602. * URL.
  3603. */
  3604. Router.prototype.navigate = function (commands, extras) {
  3605. if (extras === void 0) { extras = { skipLocationChange: false }; }
  3606. validateCommands(commands);
  3607. return this.navigateByUrl(this.createUrlTree(commands, extras), extras);
  3608. };
  3609. /** Serializes a `UrlTree` into a string */
  3610. Router.prototype.serializeUrl = function (url) { return this.urlSerializer.serialize(url); };
  3611. /** Parses a string into a `UrlTree` */
  3612. Router.prototype.parseUrl = function (url) {
  3613. var urlTree;
  3614. try {
  3615. urlTree = this.urlSerializer.parse(url);
  3616. }
  3617. catch (e) {
  3618. urlTree = this.malformedUriErrorHandler(e, this.urlSerializer, url);
  3619. }
  3620. return urlTree;
  3621. };
  3622. /** Returns whether the url is activated */
  3623. Router.prototype.isActive = function (url, exact) {
  3624. if (url instanceof UrlTree) {
  3625. return containsTree(this.currentUrlTree, url, exact);
  3626. }
  3627. var urlTree = this.parseUrl(url);
  3628. return containsTree(this.currentUrlTree, urlTree, exact);
  3629. };
  3630. Router.prototype.removeEmptyProps = function (params) {
  3631. return Object.keys(params).reduce(function (result, key) {
  3632. var value = params[key];
  3633. if (value !== null && value !== undefined) {
  3634. result[key] = value;
  3635. }
  3636. return result;
  3637. }, {});
  3638. };
  3639. Router.prototype.processNavigations = function () {
  3640. var _this = this;
  3641. this.navigations
  3642. .pipe(operators.concatMap(function (nav) {
  3643. if (nav) {
  3644. _this.executeScheduledNavigation(nav);
  3645. // a failed navigation should not stop the router from processing
  3646. // further navigations => the catch
  3647. return nav.promise.catch(function () { });
  3648. }
  3649. else {
  3650. return rxjs.of(null);
  3651. }
  3652. }))
  3653. .subscribe(function () { });
  3654. };
  3655. Router.prototype.scheduleNavigation = function (rawUrl, source, state, extras) {
  3656. var lastNavigation = this.navigations.value;
  3657. // If the user triggers a navigation imperatively (e.g., by using navigateByUrl),
  3658. // and that navigation results in 'replaceState' that leads to the same URL,
  3659. // we should skip those.
  3660. if (lastNavigation && source !== 'imperative' && lastNavigation.source === 'imperative' &&
  3661. lastNavigation.rawUrl.toString() === rawUrl.toString()) {
  3662. return Promise.resolve(true); // return value is not used
  3663. }
  3664. // Because of a bug in IE and Edge, the location class fires two events (popstate and
  3665. // hashchange) every single time. The second one should be ignored. Otherwise, the URL will
  3666. // flicker. Handles the case when a popstate was emitted first.
  3667. if (lastNavigation && source == 'hashchange' && lastNavigation.source === 'popstate' &&
  3668. lastNavigation.rawUrl.toString() === rawUrl.toString()) {
  3669. return Promise.resolve(true); // return value is not used
  3670. }
  3671. // Because of a bug in IE and Edge, the location class fires two events (popstate and
  3672. // hashchange) every single time. The second one should be ignored. Otherwise, the URL will
  3673. // flicker. Handles the case when a hashchange was emitted first.
  3674. if (lastNavigation && source == 'popstate' && lastNavigation.source === 'hashchange' &&
  3675. lastNavigation.rawUrl.toString() === rawUrl.toString()) {
  3676. return Promise.resolve(true); // return value is not used
  3677. }
  3678. var resolve = null;
  3679. var reject = null;
  3680. var promise = new Promise(function (res, rej) {
  3681. resolve = res;
  3682. reject = rej;
  3683. });
  3684. var id = ++this.navigationId;
  3685. this.navigations.next({ id: id, source: source, state: state, rawUrl: rawUrl, extras: extras, resolve: resolve, reject: reject, promise: promise });
  3686. // Make sure that the error is propagated even though `processNavigations` catch
  3687. // handler does not rethrow
  3688. return promise.catch(function (e) { return Promise.reject(e); });
  3689. };
  3690. Router.prototype.executeScheduledNavigation = function (_a) {
  3691. var _this = this;
  3692. var id = _a.id, rawUrl = _a.rawUrl, extras = _a.extras, resolve = _a.resolve, reject = _a.reject, source = _a.source, state = _a.state;
  3693. var url = this.urlHandlingStrategy.extract(rawUrl);
  3694. var urlTransition = !this.navigated || url.toString() !== this.currentUrlTree.toString();
  3695. if ((this.onSameUrlNavigation === 'reload' ? true : urlTransition) &&
  3696. this.urlHandlingStrategy.shouldProcessUrl(rawUrl)) {
  3697. this.events
  3698. .next(new NavigationStart(id, this.serializeUrl(url), source, state));
  3699. Promise.resolve()
  3700. .then(function (_) { return _this.runNavigate(url, rawUrl, !!extras.skipLocationChange, !!extras.replaceUrl, id, null); })
  3701. .then(resolve, reject);
  3702. // we cannot process the current URL, but we could process the previous one =>
  3703. // we need to do some cleanup
  3704. }
  3705. else if (urlTransition && this.rawUrlTree &&
  3706. this.urlHandlingStrategy.shouldProcessUrl(this.rawUrlTree)) {
  3707. this.events
  3708. .next(new NavigationStart(id, this.serializeUrl(url), source, state));
  3709. Promise.resolve()
  3710. .then(function (_) { return _this.runNavigate(url, rawUrl, false, false, id, createEmptyState(url, _this.rootComponentType).snapshot); })
  3711. .then(resolve, reject);
  3712. }
  3713. else {
  3714. this.rawUrlTree = rawUrl;
  3715. resolve(null);
  3716. }
  3717. };
  3718. Router.prototype.runNavigate = function (url, rawUrl, skipLocationChange, replaceUrl, id, precreatedState) {
  3719. var _this = this;
  3720. if (id !== this.navigationId) {
  3721. this.events
  3722. .next(new NavigationCancel(id, this.serializeUrl(url), "Navigation ID " + id + " is not equal to the current navigation id " + this.navigationId));
  3723. return Promise.resolve(false);
  3724. }
  3725. return new Promise(function (resolvePromise, rejectPromise) {
  3726. // create an observable of the url and route state snapshot
  3727. // this operation do not result in any side effects
  3728. var urlAndSnapshot$;
  3729. if (!precreatedState) {
  3730. var moduleInjector = _this.ngModule.injector;
  3731. var redirectsApplied$ = applyRedirects(moduleInjector, _this.configLoader, _this.urlSerializer, url, _this.config);
  3732. urlAndSnapshot$ = redirectsApplied$.pipe(operators.mergeMap(function (appliedUrl) {
  3733. return recognize(_this.rootComponentType, _this.config, appliedUrl, _this.serializeUrl(appliedUrl), _this.paramsInheritanceStrategy)
  3734. .pipe(operators.map(function (snapshot) {
  3735. _this.events
  3736. .next(new RoutesRecognized(id, _this.serializeUrl(url), _this.serializeUrl(appliedUrl), snapshot));
  3737. return { appliedUrl: appliedUrl, snapshot: snapshot };
  3738. }));
  3739. }));
  3740. }
  3741. else {
  3742. urlAndSnapshot$ = rxjs.of({ appliedUrl: url, snapshot: precreatedState });
  3743. }
  3744. var beforePreactivationDone$ = urlAndSnapshot$.pipe(operators.mergeMap(function (p) {
  3745. if (typeof p === 'boolean')
  3746. return rxjs.of(p);
  3747. return _this.hooks.beforePreactivation(p.snapshot).pipe(operators.map(function () { return p; }));
  3748. }));
  3749. // run preactivation: guards and data resolvers
  3750. var preActivation;
  3751. var preactivationSetup$ = beforePreactivationDone$.pipe(operators.map(function (p) {
  3752. if (typeof p === 'boolean')
  3753. return p;
  3754. var appliedUrl = p.appliedUrl, snapshot = p.snapshot;
  3755. var moduleInjector = _this.ngModule.injector;
  3756. preActivation = new PreActivation(snapshot, _this.routerState.snapshot, moduleInjector, function (evt) { return _this.triggerEvent(evt); });
  3757. preActivation.initialize(_this.rootContexts);
  3758. return { appliedUrl: appliedUrl, snapshot: snapshot };
  3759. }));
  3760. var preactivationCheckGuards$ = preactivationSetup$.pipe(operators.mergeMap(function (p) {
  3761. if (typeof p === 'boolean' || _this.navigationId !== id)
  3762. return rxjs.of(false);
  3763. var appliedUrl = p.appliedUrl, snapshot = p.snapshot;
  3764. _this.triggerEvent(new GuardsCheckStart(id, _this.serializeUrl(url), _this.serializeUrl(appliedUrl), snapshot));
  3765. return preActivation.checkGuards().pipe(operators.map(function (shouldActivate) {
  3766. _this.triggerEvent(new GuardsCheckEnd(id, _this.serializeUrl(url), _this.serializeUrl(appliedUrl), snapshot, shouldActivate));
  3767. return { appliedUrl: appliedUrl, snapshot: snapshot, shouldActivate: shouldActivate };
  3768. }));
  3769. }));
  3770. var preactivationResolveData$ = preactivationCheckGuards$.pipe(operators.mergeMap(function (p) {
  3771. if (typeof p === 'boolean' || _this.navigationId !== id)
  3772. return rxjs.of(false);
  3773. if (p.shouldActivate && preActivation.isActivating()) {
  3774. _this.triggerEvent(new ResolveStart(id, _this.serializeUrl(url), _this.serializeUrl(p.appliedUrl), p.snapshot));
  3775. return preActivation.resolveData(_this.paramsInheritanceStrategy).pipe(operators.map(function () {
  3776. _this.triggerEvent(new ResolveEnd(id, _this.serializeUrl(url), _this.serializeUrl(p.appliedUrl), p.snapshot));
  3777. return p;
  3778. }));
  3779. }
  3780. else {
  3781. return rxjs.of(p);
  3782. }
  3783. }));
  3784. var preactivationDone$ = preactivationResolveData$.pipe(operators.mergeMap(function (p) {
  3785. if (typeof p === 'boolean' || _this.navigationId !== id)
  3786. return rxjs.of(false);
  3787. return _this.hooks.afterPreactivation(p.snapshot).pipe(operators.map(function () { return p; }));
  3788. }));
  3789. // create router state
  3790. // this operation has side effects => route state is being affected
  3791. var routerState$ = preactivationDone$.pipe(operators.map(function (p) {
  3792. if (typeof p === 'boolean' || _this.navigationId !== id)
  3793. return false;
  3794. var appliedUrl = p.appliedUrl, snapshot = p.snapshot, shouldActivate = p.shouldActivate;
  3795. if (shouldActivate) {
  3796. var state = createRouterState(_this.routeReuseStrategy, snapshot, _this.routerState);
  3797. return { appliedUrl: appliedUrl, state: state, shouldActivate: shouldActivate };
  3798. }
  3799. else {
  3800. return { appliedUrl: appliedUrl, state: null, shouldActivate: shouldActivate };
  3801. }
  3802. }));
  3803. _this.activateRoutes(routerState$, _this.routerState, _this.currentUrlTree, id, url, rawUrl, skipLocationChange, replaceUrl, resolvePromise, rejectPromise);
  3804. });
  3805. };
  3806. /**
  3807. * Performs the logic of activating routes. This is a synchronous process by default. While this
  3808. * is a private method, it could be overridden to make activation asynchronous.
  3809. */
  3810. Router.prototype.activateRoutes = function (state, storedState, storedUrl, id, url, rawUrl, skipLocationChange, replaceUrl, resolvePromise, rejectPromise) {
  3811. var _this = this;
  3812. // applied the new router state
  3813. // this operation has side effects
  3814. var navigationIsSuccessful;
  3815. state
  3816. .forEach(function (p) {
  3817. if (typeof p === 'boolean' || !p.shouldActivate || id !== _this.navigationId || !p.state) {
  3818. navigationIsSuccessful = false;
  3819. return;
  3820. }
  3821. var appliedUrl = p.appliedUrl, state = p.state;
  3822. _this.currentUrlTree = appliedUrl;
  3823. _this.rawUrlTree = _this.urlHandlingStrategy.merge(_this.currentUrlTree, rawUrl);
  3824. _this.routerState = state;
  3825. if (!skipLocationChange) {
  3826. var path = _this.urlSerializer.serialize(_this.rawUrlTree);
  3827. if (_this.location.isCurrentPathEqualTo(path) || replaceUrl) {
  3828. _this.location.replaceState(path, '', { navigationId: id });
  3829. }
  3830. else {
  3831. _this.location.go(path, '', { navigationId: id });
  3832. }
  3833. }
  3834. new ActivateRoutes(_this.routeReuseStrategy, state, storedState, function (evt) { return _this.triggerEvent(evt); })
  3835. .activate(_this.rootContexts);
  3836. navigationIsSuccessful = true;
  3837. })
  3838. .then(function () {
  3839. if (navigationIsSuccessful) {
  3840. _this.navigated = true;
  3841. _this.lastSuccessfulId = id;
  3842. _this.events
  3843. .next(new NavigationEnd(id, _this.serializeUrl(url), _this.serializeUrl(_this.currentUrlTree)));
  3844. resolvePromise(true);
  3845. }
  3846. else {
  3847. _this.resetUrlToCurrentUrlTree();
  3848. _this.events
  3849. .next(new NavigationCancel(id, _this.serializeUrl(url), ''));
  3850. resolvePromise(false);
  3851. }
  3852. }, function (e) {
  3853. if (isNavigationCancelingError(e)) {
  3854. _this.navigated = true;
  3855. _this.resetStateAndUrl(storedState, storedUrl, rawUrl);
  3856. _this.events
  3857. .next(new NavigationCancel(id, _this.serializeUrl(url), e.message));
  3858. resolvePromise(false);
  3859. }
  3860. else {
  3861. _this.resetStateAndUrl(storedState, storedUrl, rawUrl);
  3862. _this.events
  3863. .next(new NavigationError(id, _this.serializeUrl(url), e));
  3864. try {
  3865. resolvePromise(_this.errorHandler(e));
  3866. }
  3867. catch (ee) {
  3868. rejectPromise(ee);
  3869. }
  3870. }
  3871. });
  3872. };
  3873. Router.prototype.resetStateAndUrl = function (storedState, storedUrl, rawUrl) {
  3874. this.routerState = storedState;
  3875. this.currentUrlTree = storedUrl;
  3876. this.rawUrlTree = this.urlHandlingStrategy.merge(this.currentUrlTree, rawUrl);
  3877. this.resetUrlToCurrentUrlTree();
  3878. };
  3879. Router.prototype.resetUrlToCurrentUrlTree = function () {
  3880. this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree), '', { navigationId: this.lastSuccessfulId });
  3881. };
  3882. return Router;
  3883. }());
  3884. var ActivateRoutes = /** @class */ (function () {
  3885. function ActivateRoutes(routeReuseStrategy, futureState, currState, forwardEvent) {
  3886. this.routeReuseStrategy = routeReuseStrategy;
  3887. this.futureState = futureState;
  3888. this.currState = currState;
  3889. this.forwardEvent = forwardEvent;
  3890. }
  3891. ActivateRoutes.prototype.activate = function (parentContexts) {
  3892. var futureRoot = this.futureState._root;
  3893. var currRoot = this.currState ? this.currState._root : null;
  3894. this.deactivateChildRoutes(futureRoot, currRoot, parentContexts);
  3895. advanceActivatedRoute(this.futureState.root);
  3896. this.activateChildRoutes(futureRoot, currRoot, parentContexts);
  3897. };
  3898. // De-activate the child route that are not re-used for the future state
  3899. ActivateRoutes.prototype.deactivateChildRoutes = function (futureNode, currNode, contexts) {
  3900. var _this = this;
  3901. var children = nodeChildrenAsMap(currNode);
  3902. // Recurse on the routes active in the future state to de-activate deeper children
  3903. futureNode.children.forEach(function (futureChild) {
  3904. var childOutletName = futureChild.value.outlet;
  3905. _this.deactivateRoutes(futureChild, children[childOutletName], contexts);
  3906. delete children[childOutletName];
  3907. });
  3908. // De-activate the routes that will not be re-used
  3909. forEach(children, function (v, childName) {
  3910. _this.deactivateRouteAndItsChildren(v, contexts);
  3911. });
  3912. };
  3913. ActivateRoutes.prototype.deactivateRoutes = function (futureNode, currNode, parentContext) {
  3914. var future = futureNode.value;
  3915. var curr = currNode ? currNode.value : null;
  3916. if (future === curr) {
  3917. // Reusing the node, check to see if the children need to be de-activated
  3918. if (future.component) {
  3919. // If we have a normal route, we need to go through an outlet.
  3920. var context = parentContext.getContext(future.outlet);
  3921. if (context) {
  3922. this.deactivateChildRoutes(futureNode, currNode, context.children);
  3923. }
  3924. }
  3925. else {
  3926. // if we have a componentless route, we recurse but keep the same outlet map.
  3927. this.deactivateChildRoutes(futureNode, currNode, parentContext);
  3928. }
  3929. }
  3930. else {
  3931. if (curr) {
  3932. // Deactivate the current route which will not be re-used
  3933. this.deactivateRouteAndItsChildren(currNode, parentContext);
  3934. }
  3935. }
  3936. };
  3937. ActivateRoutes.prototype.deactivateRouteAndItsChildren = function (route, parentContexts) {
  3938. if (this.routeReuseStrategy.shouldDetach(route.value.snapshot)) {
  3939. this.detachAndStoreRouteSubtree(route, parentContexts);
  3940. }
  3941. else {
  3942. this.deactivateRouteAndOutlet(route, parentContexts);
  3943. }
  3944. };
  3945. ActivateRoutes.prototype.detachAndStoreRouteSubtree = function (route, parentContexts) {
  3946. var context = parentContexts.getContext(route.value.outlet);
  3947. if (context && context.outlet) {
  3948. var componentRef = context.outlet.detach();
  3949. var contexts = context.children.onOutletDeactivated();
  3950. this.routeReuseStrategy.store(route.value.snapshot, { componentRef: componentRef, route: route, contexts: contexts });
  3951. }
  3952. };
  3953. ActivateRoutes.prototype.deactivateRouteAndOutlet = function (route, parentContexts) {
  3954. var _this = this;
  3955. var context = parentContexts.getContext(route.value.outlet);
  3956. if (context) {
  3957. var children = nodeChildrenAsMap(route);
  3958. var contexts_1 = route.value.component ? context.children : parentContexts;
  3959. forEach(children, function (v, k) { return _this.deactivateRouteAndItsChildren(v, contexts_1); });
  3960. if (context.outlet) {
  3961. // Destroy the component
  3962. context.outlet.deactivate();
  3963. // Destroy the contexts for all the outlets that were in the component
  3964. context.children.onOutletDeactivated();
  3965. }
  3966. }
  3967. };
  3968. ActivateRoutes.prototype.activateChildRoutes = function (futureNode, currNode, contexts) {
  3969. var _this = this;
  3970. var children = nodeChildrenAsMap(currNode);
  3971. futureNode.children.forEach(function (c) {
  3972. _this.activateRoutes(c, children[c.value.outlet], contexts);
  3973. _this.forwardEvent(new ActivationEnd(c.value.snapshot));
  3974. });
  3975. if (futureNode.children.length) {
  3976. this.forwardEvent(new ChildActivationEnd(futureNode.value.snapshot));
  3977. }
  3978. };
  3979. ActivateRoutes.prototype.activateRoutes = function (futureNode, currNode, parentContexts) {
  3980. var future = futureNode.value;
  3981. var curr = currNode ? currNode.value : null;
  3982. advanceActivatedRoute(future);
  3983. // reusing the node
  3984. if (future === curr) {
  3985. if (future.component) {
  3986. // If we have a normal route, we need to go through an outlet.
  3987. var context = parentContexts.getOrCreateContext(future.outlet);
  3988. this.activateChildRoutes(futureNode, currNode, context.children);
  3989. }
  3990. else {
  3991. // if we have a componentless route, we recurse but keep the same outlet map.
  3992. this.activateChildRoutes(futureNode, currNode, parentContexts);
  3993. }
  3994. }
  3995. else {
  3996. if (future.component) {
  3997. // if we have a normal route, we need to place the component into the outlet and recurse.
  3998. var context = parentContexts.getOrCreateContext(future.outlet);
  3999. if (this.routeReuseStrategy.shouldAttach(future.snapshot)) {
  4000. var stored = this.routeReuseStrategy.retrieve(future.snapshot);
  4001. this.routeReuseStrategy.store(future.snapshot, null);
  4002. context.children.onOutletReAttached(stored.contexts);
  4003. context.attachRef = stored.componentRef;
  4004. context.route = stored.route.value;
  4005. if (context.outlet) {
  4006. // Attach right away when the outlet has already been instantiated
  4007. // Otherwise attach from `RouterOutlet.ngOnInit` when it is instantiated
  4008. context.outlet.attach(stored.componentRef, stored.route.value);
  4009. }
  4010. advanceActivatedRouteNodeAndItsChildren(stored.route);
  4011. }
  4012. else {
  4013. var config = parentLoadedConfig(future.snapshot);
  4014. var cmpFactoryResolver = config ? config.module.componentFactoryResolver : null;
  4015. context.route = future;
  4016. context.resolver = cmpFactoryResolver;
  4017. if (context.outlet) {
  4018. // Activate the outlet when it has already been instantiated
  4019. // Otherwise it will get activated from its `ngOnInit` when instantiated
  4020. context.outlet.activateWith(future, cmpFactoryResolver);
  4021. }
  4022. this.activateChildRoutes(futureNode, null, context.children);
  4023. }
  4024. }
  4025. else {
  4026. // if we have a componentless route, we recurse but keep the same outlet map.
  4027. this.activateChildRoutes(futureNode, null, parentContexts);
  4028. }
  4029. }
  4030. };
  4031. return ActivateRoutes;
  4032. }());
  4033. function advanceActivatedRouteNodeAndItsChildren(node) {
  4034. advanceActivatedRoute(node.value);
  4035. node.children.forEach(advanceActivatedRouteNodeAndItsChildren);
  4036. }
  4037. function parentLoadedConfig(snapshot) {
  4038. for (var s = snapshot.parent; s; s = s.parent) {
  4039. var route = s.routeConfig;
  4040. if (route && route._loadedConfig)
  4041. return route._loadedConfig;
  4042. if (route && route.component)
  4043. return null;
  4044. }
  4045. return null;
  4046. }
  4047. function validateCommands(commands) {
  4048. for (var i = 0; i < commands.length; i++) {
  4049. var cmd = commands[i];
  4050. if (cmd == null) {
  4051. throw new Error("The requested path contains " + cmd + " segment at index " + i);
  4052. }
  4053. }
  4054. }
  4055. /**
  4056. * @license
  4057. * Copyright Google Inc. All Rights Reserved.
  4058. *
  4059. * Use of this source code is governed by an MIT-style license that can be
  4060. * found in the LICENSE file at https://angular.io/license
  4061. */
  4062. /**
  4063. * @description
  4064. *
  4065. * Lets you link to specific routes in your app.
  4066. *
  4067. * Consider the following route configuration:
  4068. * `[{ path: 'user/:name', component: UserCmp }]`.
  4069. * When linking to this `user/:name` route, you use the `RouterLink` directive.
  4070. *
  4071. * If the link is static, you can use the directive as follows:
  4072. * `<a routerLink="/user/bob">link to user component</a>`
  4073. *
  4074. * If you use dynamic values to generate the link, you can pass an array of path
  4075. * segments, followed by the params for each segment.
  4076. *
  4077. * For instance `['/team', teamId, 'user', userName, {details: true}]`
  4078. * means that we want to generate a link to `/team/11/user/bob;details=true`.
  4079. *
  4080. * Multiple static segments can be merged into one
  4081. * (e.g., `['/team/11/user', userName, {details: true}]`).
  4082. *
  4083. * The first segment name can be prepended with `/`, `./`, or `../`:
  4084. * * If the first segment begins with `/`, the router will look up the route from the root of the
  4085. * app.
  4086. * * If the first segment begins with `./`, or doesn't begin with a slash, the router will
  4087. * instead look in the children of the current activated route.
  4088. * * And if the first segment begins with `../`, the router will go up one level.
  4089. *
  4090. * You can set query params and fragment as follows:
  4091. *
  4092. * ```
  4093. * <a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" fragment="education">
  4094. * link to user component
  4095. * </a>
  4096. * ```
  4097. * RouterLink will use these to generate this link: `/user/bob#education?debug=true`.
  4098. *
  4099. * (Deprecated in v4.0.0 use `queryParamsHandling` instead) You can also tell the
  4100. * directive to preserve the current query params and fragment:
  4101. *
  4102. * ```
  4103. * <a [routerLink]="['/user/bob']" preserveQueryParams preserveFragment>
  4104. * link to user component
  4105. * </a>
  4106. * ```
  4107. *
  4108. * You can tell the directive to how to handle queryParams, available options are:
  4109. * - `'merge'`: merge the queryParams into the current queryParams
  4110. * - `'preserve'`: preserve the current queryParams
  4111. * - default/`''`: use the queryParams only
  4112. *
  4113. * Same options for {@link NavigationExtras#queryParamsHandling
  4114. * NavigationExtras#queryParamsHandling}.
  4115. *
  4116. * ```
  4117. * <a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" queryParamsHandling="merge">
  4118. * link to user component
  4119. * </a>
  4120. * ```
  4121. *
  4122. * The router link directive always treats the provided input as a delta to the current url.
  4123. *
  4124. * For instance, if the current url is `/user/(box//aux:team)`.
  4125. *
  4126. * Then the following link `<a [routerLink]="['/user/jim']">Jim</a>` will generate the link
  4127. * `/user/(jim//aux:team)`.
  4128. *
  4129. * See {@link Router#createUrlTree createUrlTree} for more information.
  4130. *
  4131. * @ngModule RouterModule
  4132. *
  4133. *
  4134. */
  4135. var RouterLink = /** @class */ (function () {
  4136. function RouterLink(router, route, tabIndex, renderer, el) {
  4137. this.router = router;
  4138. this.route = route;
  4139. this.commands = [];
  4140. if (tabIndex == null) {
  4141. renderer.setAttribute(el.nativeElement, 'tabindex', '0');
  4142. }
  4143. }
  4144. Object.defineProperty(RouterLink.prototype, "routerLink", {
  4145. set: function (commands) {
  4146. if (commands != null) {
  4147. this.commands = Array.isArray(commands) ? commands : [commands];
  4148. }
  4149. else {
  4150. this.commands = [];
  4151. }
  4152. },
  4153. enumerable: true,
  4154. configurable: true
  4155. });
  4156. Object.defineProperty(RouterLink.prototype, "preserveQueryParams", {
  4157. /**
  4158. * @deprecated 4.0.0 use `queryParamsHandling` instead.
  4159. */
  4160. set: function (value) {
  4161. if (core.isDevMode() && console && console.warn) {
  4162. console.warn('preserveQueryParams is deprecated!, use queryParamsHandling instead.');
  4163. }
  4164. this.preserve = value;
  4165. },
  4166. enumerable: true,
  4167. configurable: true
  4168. });
  4169. RouterLink.prototype.onClick = function () {
  4170. var extras = {
  4171. skipLocationChange: attrBoolValue(this.skipLocationChange),
  4172. replaceUrl: attrBoolValue(this.replaceUrl),
  4173. };
  4174. this.router.navigateByUrl(this.urlTree, extras);
  4175. return true;
  4176. };
  4177. Object.defineProperty(RouterLink.prototype, "urlTree", {
  4178. get: function () {
  4179. return this.router.createUrlTree(this.commands, {
  4180. relativeTo: this.route,
  4181. queryParams: this.queryParams,
  4182. fragment: this.fragment,
  4183. preserveQueryParams: attrBoolValue(this.preserve),
  4184. queryParamsHandling: this.queryParamsHandling,
  4185. preserveFragment: attrBoolValue(this.preserveFragment),
  4186. });
  4187. },
  4188. enumerable: true,
  4189. configurable: true
  4190. });
  4191. RouterLink.decorators = [
  4192. { type: core.Directive, args: [{ selector: ':not(a)[routerLink]' },] }
  4193. ];
  4194. /** @nocollapse */
  4195. RouterLink.ctorParameters = function () { return [
  4196. { type: Router },
  4197. { type: ActivatedRoute },
  4198. { type: String, decorators: [{ type: core.Attribute, args: ['tabindex',] }] },
  4199. { type: core.Renderer2 },
  4200. { type: core.ElementRef }
  4201. ]; };
  4202. RouterLink.propDecorators = {
  4203. queryParams: [{ type: core.Input }],
  4204. fragment: [{ type: core.Input }],
  4205. queryParamsHandling: [{ type: core.Input }],
  4206. preserveFragment: [{ type: core.Input }],
  4207. skipLocationChange: [{ type: core.Input }],
  4208. replaceUrl: [{ type: core.Input }],
  4209. routerLink: [{ type: core.Input }],
  4210. preserveQueryParams: [{ type: core.Input }],
  4211. onClick: [{ type: core.HostListener, args: ['click',] }]
  4212. };
  4213. return RouterLink;
  4214. }());
  4215. /**
  4216. * @description
  4217. *
  4218. * Lets you link to specific routes in your app.
  4219. *
  4220. * See `RouterLink` for more information.
  4221. *
  4222. * @ngModule RouterModule
  4223. *
  4224. *
  4225. */
  4226. var RouterLinkWithHref = /** @class */ (function () {
  4227. function RouterLinkWithHref(router, route, locationStrategy) {
  4228. var _this = this;
  4229. this.router = router;
  4230. this.route = route;
  4231. this.locationStrategy = locationStrategy;
  4232. this.commands = [];
  4233. this.subscription = router.events.subscribe(function (s) {
  4234. if (s instanceof NavigationEnd) {
  4235. _this.updateTargetUrlAndHref();
  4236. }
  4237. });
  4238. }
  4239. Object.defineProperty(RouterLinkWithHref.prototype, "routerLink", {
  4240. set: function (commands) {
  4241. if (commands != null) {
  4242. this.commands = Array.isArray(commands) ? commands : [commands];
  4243. }
  4244. else {
  4245. this.commands = [];
  4246. }
  4247. },
  4248. enumerable: true,
  4249. configurable: true
  4250. });
  4251. Object.defineProperty(RouterLinkWithHref.prototype, "preserveQueryParams", {
  4252. set: function (value) {
  4253. if (core.isDevMode() && console && console.warn) {
  4254. console.warn('preserveQueryParams is deprecated, use queryParamsHandling instead.');
  4255. }
  4256. this.preserve = value;
  4257. },
  4258. enumerable: true,
  4259. configurable: true
  4260. });
  4261. RouterLinkWithHref.prototype.ngOnChanges = function (changes) { this.updateTargetUrlAndHref(); };
  4262. RouterLinkWithHref.prototype.ngOnDestroy = function () { this.subscription.unsubscribe(); };
  4263. RouterLinkWithHref.prototype.onClick = function (button, ctrlKey, metaKey, shiftKey) {
  4264. if (button !== 0 || ctrlKey || metaKey || shiftKey) {
  4265. return true;
  4266. }
  4267. if (typeof this.target === 'string' && this.target != '_self') {
  4268. return true;
  4269. }
  4270. var extras = {
  4271. skipLocationChange: attrBoolValue(this.skipLocationChange),
  4272. replaceUrl: attrBoolValue(this.replaceUrl),
  4273. };
  4274. this.router.navigateByUrl(this.urlTree, extras);
  4275. return false;
  4276. };
  4277. RouterLinkWithHref.prototype.updateTargetUrlAndHref = function () {
  4278. this.href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.urlTree));
  4279. };
  4280. Object.defineProperty(RouterLinkWithHref.prototype, "urlTree", {
  4281. get: function () {
  4282. return this.router.createUrlTree(this.commands, {
  4283. relativeTo: this.route,
  4284. queryParams: this.queryParams,
  4285. fragment: this.fragment,
  4286. preserveQueryParams: attrBoolValue(this.preserve),
  4287. queryParamsHandling: this.queryParamsHandling,
  4288. preserveFragment: attrBoolValue(this.preserveFragment),
  4289. });
  4290. },
  4291. enumerable: true,
  4292. configurable: true
  4293. });
  4294. RouterLinkWithHref.decorators = [
  4295. { type: core.Directive, args: [{ selector: 'a[routerLink]' },] }
  4296. ];
  4297. /** @nocollapse */
  4298. RouterLinkWithHref.ctorParameters = function () { return [
  4299. { type: Router },
  4300. { type: ActivatedRoute },
  4301. { type: common.LocationStrategy }
  4302. ]; };
  4303. RouterLinkWithHref.propDecorators = {
  4304. target: [{ type: core.HostBinding, args: ['attr.target',] }, { type: core.Input }],
  4305. queryParams: [{ type: core.Input }],
  4306. fragment: [{ type: core.Input }],
  4307. queryParamsHandling: [{ type: core.Input }],
  4308. preserveFragment: [{ type: core.Input }],
  4309. skipLocationChange: [{ type: core.Input }],
  4310. replaceUrl: [{ type: core.Input }],
  4311. href: [{ type: core.HostBinding }],
  4312. routerLink: [{ type: core.Input }],
  4313. preserveQueryParams: [{ type: core.Input }],
  4314. onClick: [{ type: core.HostListener, args: ['click', ['$event.button', '$event.ctrlKey', '$event.metaKey', '$event.shiftKey'],] }]
  4315. };
  4316. return RouterLinkWithHref;
  4317. }());
  4318. function attrBoolValue(s) {
  4319. return s === '' || !!s;
  4320. }
  4321. /**
  4322. * @license
  4323. * Copyright Google Inc. All Rights Reserved.
  4324. *
  4325. * Use of this source code is governed by an MIT-style license that can be
  4326. * found in the LICENSE file at https://angular.io/license
  4327. */
  4328. /**
  4329. *
  4330. * @description
  4331. *
  4332. * Lets you add a CSS class to an element when the link's route becomes active.
  4333. *
  4334. * This directive lets you add a CSS class to an element when the link's route
  4335. * becomes active.
  4336. *
  4337. * Consider the following example:
  4338. *
  4339. * ```
  4340. * <a routerLink="/user/bob" routerLinkActive="active-link">Bob</a>
  4341. * ```
  4342. *
  4343. * When the url is either '/user' or '/user/bob', the active-link class will
  4344. * be added to the `a` tag. If the url changes, the class will be removed.
  4345. *
  4346. * You can set more than one class, as follows:
  4347. *
  4348. * ```
  4349. * <a routerLink="/user/bob" routerLinkActive="class1 class2">Bob</a>
  4350. * <a routerLink="/user/bob" [routerLinkActive]="['class1', 'class2']">Bob</a>
  4351. * ```
  4352. *
  4353. * You can configure RouterLinkActive by passing `exact: true`. This will add the classes
  4354. * only when the url matches the link exactly.
  4355. *
  4356. * ```
  4357. * <a routerLink="/user/bob" routerLinkActive="active-link" [routerLinkActiveOptions]="{exact:
  4358. * true}">Bob</a>
  4359. * ```
  4360. *
  4361. * You can assign the RouterLinkActive instance to a template variable and directly check
  4362. * the `isActive` status.
  4363. * ```
  4364. * <a routerLink="/user/bob" routerLinkActive #rla="routerLinkActive">
  4365. * Bob {{ rla.isActive ? '(already open)' : ''}}
  4366. * </a>
  4367. * ```
  4368. *
  4369. * Finally, you can apply the RouterLinkActive directive to an ancestor of a RouterLink.
  4370. *
  4371. * ```
  4372. * <div routerLinkActive="active-link" [routerLinkActiveOptions]="{exact: true}">
  4373. * <a routerLink="/user/jim">Jim</a>
  4374. * <a routerLink="/user/bob">Bob</a>
  4375. * </div>
  4376. * ```
  4377. *
  4378. * This will set the active-link class on the div tag if the url is either '/user/jim' or
  4379. * '/user/bob'.
  4380. *
  4381. * @ngModule RouterModule
  4382. *
  4383. *
  4384. */
  4385. var RouterLinkActive = /** @class */ (function () {
  4386. function RouterLinkActive(router, element, renderer, cdr) {
  4387. var _this = this;
  4388. this.router = router;
  4389. this.element = element;
  4390. this.renderer = renderer;
  4391. this.cdr = cdr;
  4392. this.classes = [];
  4393. this.isActive = false;
  4394. this.routerLinkActiveOptions = { exact: false };
  4395. this.subscription = router.events.subscribe(function (s) {
  4396. if (s instanceof NavigationEnd) {
  4397. _this.update();
  4398. }
  4399. });
  4400. }
  4401. RouterLinkActive.prototype.ngAfterContentInit = function () {
  4402. var _this = this;
  4403. this.links.changes.subscribe(function (_) { return _this.update(); });
  4404. this.linksWithHrefs.changes.subscribe(function (_) { return _this.update(); });
  4405. this.update();
  4406. };
  4407. Object.defineProperty(RouterLinkActive.prototype, "routerLinkActive", {
  4408. set: function (data) {
  4409. var classes = Array.isArray(data) ? data : data.split(' ');
  4410. this.classes = classes.filter(function (c) { return !!c; });
  4411. },
  4412. enumerable: true,
  4413. configurable: true
  4414. });
  4415. RouterLinkActive.prototype.ngOnChanges = function (changes) { this.update(); };
  4416. RouterLinkActive.prototype.ngOnDestroy = function () { this.subscription.unsubscribe(); };
  4417. RouterLinkActive.prototype.update = function () {
  4418. var _this = this;
  4419. if (!this.links || !this.linksWithHrefs || !this.router.navigated)
  4420. return;
  4421. Promise.resolve().then(function () {
  4422. var hasActiveLinks = _this.hasActiveLinks();
  4423. if (_this.isActive !== hasActiveLinks) {
  4424. _this.isActive = hasActiveLinks;
  4425. _this.classes.forEach(function (c) {
  4426. if (hasActiveLinks) {
  4427. _this.renderer.addClass(_this.element.nativeElement, c);
  4428. }
  4429. else {
  4430. _this.renderer.removeClass(_this.element.nativeElement, c);
  4431. }
  4432. });
  4433. }
  4434. });
  4435. };
  4436. RouterLinkActive.prototype.isLinkActive = function (router) {
  4437. var _this = this;
  4438. return function (link) {
  4439. return router.isActive(link.urlTree, _this.routerLinkActiveOptions.exact);
  4440. };
  4441. };
  4442. RouterLinkActive.prototype.hasActiveLinks = function () {
  4443. return this.links.some(this.isLinkActive(this.router)) ||
  4444. this.linksWithHrefs.some(this.isLinkActive(this.router));
  4445. };
  4446. RouterLinkActive.decorators = [
  4447. { type: core.Directive, args: [{
  4448. selector: '[routerLinkActive]',
  4449. exportAs: 'routerLinkActive',
  4450. },] }
  4451. ];
  4452. /** @nocollapse */
  4453. RouterLinkActive.ctorParameters = function () { return [
  4454. { type: Router },
  4455. { type: core.ElementRef },
  4456. { type: core.Renderer2 },
  4457. { type: core.ChangeDetectorRef }
  4458. ]; };
  4459. RouterLinkActive.propDecorators = {
  4460. links: [{ type: core.ContentChildren, args: [RouterLink, { descendants: true },] }],
  4461. linksWithHrefs: [{ type: core.ContentChildren, args: [RouterLinkWithHref, { descendants: true },] }],
  4462. routerLinkActiveOptions: [{ type: core.Input }],
  4463. routerLinkActive: [{ type: core.Input }]
  4464. };
  4465. return RouterLinkActive;
  4466. }());
  4467. /**
  4468. * @license
  4469. * Copyright Google Inc. All Rights Reserved.
  4470. *
  4471. * Use of this source code is governed by an MIT-style license that can be
  4472. * found in the LICENSE file at https://angular.io/license
  4473. */
  4474. /**
  4475. * Store contextual information about a `RouterOutlet`
  4476. *
  4477. *
  4478. */
  4479. var OutletContext = /** @class */ (function () {
  4480. function OutletContext() {
  4481. this.outlet = null;
  4482. this.route = null;
  4483. this.resolver = null;
  4484. this.children = new ChildrenOutletContexts();
  4485. this.attachRef = null;
  4486. }
  4487. return OutletContext;
  4488. }());
  4489. /**
  4490. * Store contextual information about the children (= nested) `RouterOutlet`
  4491. *
  4492. *
  4493. */
  4494. var ChildrenOutletContexts = /** @class */ (function () {
  4495. function ChildrenOutletContexts() {
  4496. // contexts for child outlets, by name.
  4497. this.contexts = new Map();
  4498. }
  4499. /** Called when a `RouterOutlet` directive is instantiated */
  4500. ChildrenOutletContexts.prototype.onChildOutletCreated = function (childName, outlet) {
  4501. var context = this.getOrCreateContext(childName);
  4502. context.outlet = outlet;
  4503. this.contexts.set(childName, context);
  4504. };
  4505. /**
  4506. * Called when a `RouterOutlet` directive is destroyed.
  4507. * We need to keep the context as the outlet could be destroyed inside a NgIf and might be
  4508. * re-created later.
  4509. */
  4510. ChildrenOutletContexts.prototype.onChildOutletDestroyed = function (childName) {
  4511. var context = this.getContext(childName);
  4512. if (context) {
  4513. context.outlet = null;
  4514. }
  4515. };
  4516. /**
  4517. * Called when the corresponding route is deactivated during navigation.
  4518. * Because the component get destroyed, all children outlet are destroyed.
  4519. */
  4520. ChildrenOutletContexts.prototype.onOutletDeactivated = function () {
  4521. var contexts = this.contexts;
  4522. this.contexts = new Map();
  4523. return contexts;
  4524. };
  4525. ChildrenOutletContexts.prototype.onOutletReAttached = function (contexts) { this.contexts = contexts; };
  4526. ChildrenOutletContexts.prototype.getOrCreateContext = function (childName) {
  4527. var context = this.getContext(childName);
  4528. if (!context) {
  4529. context = new OutletContext();
  4530. this.contexts.set(childName, context);
  4531. }
  4532. return context;
  4533. };
  4534. ChildrenOutletContexts.prototype.getContext = function (childName) { return this.contexts.get(childName) || null; };
  4535. return ChildrenOutletContexts;
  4536. }());
  4537. /**
  4538. * @license
  4539. * Copyright Google Inc. All Rights Reserved.
  4540. *
  4541. * Use of this source code is governed by an MIT-style license that can be
  4542. * found in the LICENSE file at https://angular.io/license
  4543. */
  4544. /**
  4545. * @description
  4546. *
  4547. * Acts as a placeholder that Angular dynamically fills based on the current router state.
  4548. *
  4549. * ```
  4550. * <router-outlet></router-outlet>
  4551. * <router-outlet name='left'></router-outlet>
  4552. * <router-outlet name='right'></router-outlet>
  4553. * ```
  4554. *
  4555. * A router outlet will emit an activate event any time a new component is being instantiated,
  4556. * and a deactivate event when it is being destroyed.
  4557. *
  4558. * ```
  4559. * <router-outlet
  4560. * (activate)='onActivate($event)'
  4561. * (deactivate)='onDeactivate($event)'></router-outlet>
  4562. * ```
  4563. * @ngModule RouterModule
  4564. *
  4565. *
  4566. */
  4567. var RouterOutlet = /** @class */ (function () {
  4568. function RouterOutlet(parentContexts, location, resolver, name, changeDetector) {
  4569. this.parentContexts = parentContexts;
  4570. this.location = location;
  4571. this.resolver = resolver;
  4572. this.changeDetector = changeDetector;
  4573. this.activated = null;
  4574. this._activatedRoute = null;
  4575. this.activateEvents = new core.EventEmitter();
  4576. this.deactivateEvents = new core.EventEmitter();
  4577. this.name = name || PRIMARY_OUTLET;
  4578. parentContexts.onChildOutletCreated(this.name, this);
  4579. }
  4580. RouterOutlet.prototype.ngOnDestroy = function () { this.parentContexts.onChildOutletDestroyed(this.name); };
  4581. RouterOutlet.prototype.ngOnInit = function () {
  4582. if (!this.activated) {
  4583. // If the outlet was not instantiated at the time the route got activated we need to populate
  4584. // the outlet when it is initialized (ie inside a NgIf)
  4585. var context = this.parentContexts.getContext(this.name);
  4586. if (context && context.route) {
  4587. if (context.attachRef) {
  4588. // `attachRef` is populated when there is an existing component to mount
  4589. this.attach(context.attachRef, context.route);
  4590. }
  4591. else {
  4592. // otherwise the component defined in the configuration is created
  4593. this.activateWith(context.route, context.resolver || null);
  4594. }
  4595. }
  4596. }
  4597. };
  4598. Object.defineProperty(RouterOutlet.prototype, "isActivated", {
  4599. get: function () { return !!this.activated; },
  4600. enumerable: true,
  4601. configurable: true
  4602. });
  4603. Object.defineProperty(RouterOutlet.prototype, "component", {
  4604. get: function () {
  4605. if (!this.activated)
  4606. throw new Error('Outlet is not activated');
  4607. return this.activated.instance;
  4608. },
  4609. enumerable: true,
  4610. configurable: true
  4611. });
  4612. Object.defineProperty(RouterOutlet.prototype, "activatedRoute", {
  4613. get: function () {
  4614. if (!this.activated)
  4615. throw new Error('Outlet is not activated');
  4616. return this._activatedRoute;
  4617. },
  4618. enumerable: true,
  4619. configurable: true
  4620. });
  4621. Object.defineProperty(RouterOutlet.prototype, "activatedRouteData", {
  4622. get: function () {
  4623. if (this._activatedRoute) {
  4624. return this._activatedRoute.snapshot.data;
  4625. }
  4626. return {};
  4627. },
  4628. enumerable: true,
  4629. configurable: true
  4630. });
  4631. /**
  4632. * Called when the `RouteReuseStrategy` instructs to detach the subtree
  4633. */
  4634. RouterOutlet.prototype.detach = function () {
  4635. if (!this.activated)
  4636. throw new Error('Outlet is not activated');
  4637. this.location.detach();
  4638. var cmp = this.activated;
  4639. this.activated = null;
  4640. this._activatedRoute = null;
  4641. return cmp;
  4642. };
  4643. /**
  4644. * Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree
  4645. */
  4646. RouterOutlet.prototype.attach = function (ref, activatedRoute) {
  4647. this.activated = ref;
  4648. this._activatedRoute = activatedRoute;
  4649. this.location.insert(ref.hostView);
  4650. };
  4651. RouterOutlet.prototype.deactivate = function () {
  4652. if (this.activated) {
  4653. var c = this.component;
  4654. this.activated.destroy();
  4655. this.activated = null;
  4656. this._activatedRoute = null;
  4657. this.deactivateEvents.emit(c);
  4658. }
  4659. };
  4660. RouterOutlet.prototype.activateWith = function (activatedRoute, resolver) {
  4661. if (this.isActivated) {
  4662. throw new Error('Cannot activate an already activated outlet');
  4663. }
  4664. this._activatedRoute = activatedRoute;
  4665. var snapshot = activatedRoute._futureSnapshot;
  4666. var component = snapshot.routeConfig.component;
  4667. resolver = resolver || this.resolver;
  4668. var factory = resolver.resolveComponentFactory(component);
  4669. var childContexts = this.parentContexts.getOrCreateContext(this.name).children;
  4670. var injector = new OutletInjector(activatedRoute, childContexts, this.location.injector);
  4671. this.activated = this.location.createComponent(factory, this.location.length, injector);
  4672. // Calling `markForCheck` to make sure we will run the change detection when the
  4673. // `RouterOutlet` is inside a `ChangeDetectionStrategy.OnPush` component.
  4674. this.changeDetector.markForCheck();
  4675. this.activateEvents.emit(this.activated.instance);
  4676. };
  4677. RouterOutlet.decorators = [
  4678. { type: core.Directive, args: [{ selector: 'router-outlet', exportAs: 'outlet' },] }
  4679. ];
  4680. /** @nocollapse */
  4681. RouterOutlet.ctorParameters = function () { return [
  4682. { type: ChildrenOutletContexts },
  4683. { type: core.ViewContainerRef },
  4684. { type: core.ComponentFactoryResolver },
  4685. { type: String, decorators: [{ type: core.Attribute, args: ['name',] }] },
  4686. { type: core.ChangeDetectorRef }
  4687. ]; };
  4688. RouterOutlet.propDecorators = {
  4689. activateEvents: [{ type: core.Output, args: ['activate',] }],
  4690. deactivateEvents: [{ type: core.Output, args: ['deactivate',] }]
  4691. };
  4692. return RouterOutlet;
  4693. }());
  4694. var OutletInjector = /** @class */ (function () {
  4695. function OutletInjector(route, childContexts, parent) {
  4696. this.route = route;
  4697. this.childContexts = childContexts;
  4698. this.parent = parent;
  4699. }
  4700. OutletInjector.prototype.get = function (token, notFoundValue) {
  4701. if (token === ActivatedRoute) {
  4702. return this.route;
  4703. }
  4704. if (token === ChildrenOutletContexts) {
  4705. return this.childContexts;
  4706. }
  4707. return this.parent.get(token, notFoundValue);
  4708. };
  4709. return OutletInjector;
  4710. }());
  4711. /**
  4712. *@license
  4713. *Copyright Google Inc. All Rights Reserved.
  4714. *
  4715. *Use of this source code is governed by an MIT-style license that can be
  4716. *found in the LICENSE file at https://angular.io/license
  4717. */
  4718. /**
  4719. * @description
  4720. *
  4721. * Provides a preloading strategy.
  4722. *
  4723. * @experimental
  4724. */
  4725. var PreloadingStrategy = /** @class */ (function () {
  4726. function PreloadingStrategy() {
  4727. }
  4728. return PreloadingStrategy;
  4729. }());
  4730. /**
  4731. * @description
  4732. *
  4733. * Provides a preloading strategy that preloads all modules as quickly as possible.
  4734. *
  4735. * ```
  4736. * RouteModule.forRoot(ROUTES, {preloadingStrategy: PreloadAllModules})
  4737. * ```
  4738. *
  4739. * @experimental
  4740. */
  4741. var PreloadAllModules = /** @class */ (function () {
  4742. function PreloadAllModules() {
  4743. }
  4744. PreloadAllModules.prototype.preload = function (route, fn) {
  4745. return fn().pipe(operators.catchError(function () { return rxjs.of(null); }));
  4746. };
  4747. return PreloadAllModules;
  4748. }());
  4749. /**
  4750. * @description
  4751. *
  4752. * Provides a preloading strategy that does not preload any modules.
  4753. *
  4754. * This strategy is enabled by default.
  4755. *
  4756. * @experimental
  4757. */
  4758. var NoPreloading = /** @class */ (function () {
  4759. function NoPreloading() {
  4760. }
  4761. NoPreloading.prototype.preload = function (route, fn) { return rxjs.of(null); };
  4762. return NoPreloading;
  4763. }());
  4764. /**
  4765. * The preloader optimistically loads all router configurations to
  4766. * make navigations into lazily-loaded sections of the application faster.
  4767. *
  4768. * The preloader runs in the background. When the router bootstraps, the preloader
  4769. * starts listening to all navigation events. After every such event, the preloader
  4770. * will check if any configurations can be loaded lazily.
  4771. *
  4772. * If a route is protected by `canLoad` guards, the preloaded will not load it.
  4773. *
  4774. *
  4775. */
  4776. var RouterPreloader = /** @class */ (function () {
  4777. function RouterPreloader(router, moduleLoader, compiler, injector, preloadingStrategy) {
  4778. this.router = router;
  4779. this.injector = injector;
  4780. this.preloadingStrategy = preloadingStrategy;
  4781. var onStartLoad = function (r) { return router.triggerEvent(new RouteConfigLoadStart(r)); };
  4782. var onEndLoad = function (r) { return router.triggerEvent(new RouteConfigLoadEnd(r)); };
  4783. this.loader = new RouterConfigLoader(moduleLoader, compiler, onStartLoad, onEndLoad);
  4784. }
  4785. RouterPreloader.prototype.setUpPreloading = function () {
  4786. var _this = this;
  4787. this.subscription =
  4788. this.router.events
  4789. .pipe(operators.filter(function (e) { return e instanceof NavigationEnd; }), operators.concatMap(function () { return _this.preload(); }))
  4790. .subscribe(function () { });
  4791. };
  4792. RouterPreloader.prototype.preload = function () {
  4793. var ngModule = this.injector.get(core.NgModuleRef);
  4794. return this.processRoutes(ngModule, this.router.config);
  4795. };
  4796. // TODO(jasonaden): This class relies on code external to the class to call setUpPreloading. If
  4797. // this hasn't been done, ngOnDestroy will fail as this.subscription will be undefined. This
  4798. // should be refactored.
  4799. RouterPreloader.prototype.ngOnDestroy = function () { this.subscription.unsubscribe(); };
  4800. RouterPreloader.prototype.processRoutes = function (ngModule, routes) {
  4801. var res = [];
  4802. try {
  4803. for (var routes_1 = __values(routes), routes_1_1 = routes_1.next(); !routes_1_1.done; routes_1_1 = routes_1.next()) {
  4804. var route = routes_1_1.value;
  4805. // we already have the config loaded, just recurse
  4806. if (route.loadChildren && !route.canLoad && route._loadedConfig) {
  4807. var childConfig = route._loadedConfig;
  4808. res.push(this.processRoutes(childConfig.module, childConfig.routes));
  4809. // no config loaded, fetch the config
  4810. }
  4811. else if (route.loadChildren && !route.canLoad) {
  4812. res.push(this.preloadConfig(ngModule, route));
  4813. // recurse into children
  4814. }
  4815. else if (route.children) {
  4816. res.push(this.processRoutes(ngModule, route.children));
  4817. }
  4818. }
  4819. }
  4820. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  4821. finally {
  4822. try {
  4823. if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
  4824. }
  4825. finally { if (e_1) throw e_1.error; }
  4826. }
  4827. return rxjs.from(res).pipe(operators.mergeAll(), operators.map(function (_) { return void 0; }));
  4828. var e_1, _a;
  4829. };
  4830. RouterPreloader.prototype.preloadConfig = function (ngModule, route) {
  4831. var _this = this;
  4832. return this.preloadingStrategy.preload(route, function () {
  4833. var loaded$ = _this.loader.load(ngModule.injector, route);
  4834. return loaded$.pipe(operators.mergeMap(function (config) {
  4835. route._loadedConfig = config;
  4836. return _this.processRoutes(config.module, config.routes);
  4837. }));
  4838. });
  4839. };
  4840. RouterPreloader.decorators = [
  4841. { type: core.Injectable }
  4842. ];
  4843. /** @nocollapse */
  4844. RouterPreloader.ctorParameters = function () { return [
  4845. { type: Router },
  4846. { type: core.NgModuleFactoryLoader },
  4847. { type: core.Compiler },
  4848. { type: core.Injector },
  4849. { type: PreloadingStrategy }
  4850. ]; };
  4851. return RouterPreloader;
  4852. }());
  4853. /**
  4854. * @license
  4855. * Copyright Google Inc. All Rights Reserved.
  4856. *
  4857. * Use of this source code is governed by an MIT-style license that can be
  4858. * found in the LICENSE file at https://angular.io/license
  4859. */
  4860. /**
  4861. * @description
  4862. *
  4863. * Contains a list of directives
  4864. *
  4865. *
  4866. */
  4867. var ROUTER_DIRECTIVES = [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, EmptyOutletComponent];
  4868. /**
  4869. * @description
  4870. *
  4871. * Is used in DI to configure the router.
  4872. *
  4873. *
  4874. */
  4875. var ROUTER_CONFIGURATION = new core.InjectionToken('ROUTER_CONFIGURATION');
  4876. /**
  4877. * @docsNotRequired
  4878. */
  4879. var ROUTER_FORROOT_GUARD = new core.InjectionToken('ROUTER_FORROOT_GUARD');
  4880. var ROUTER_PROVIDERS = [
  4881. common.Location,
  4882. { provide: UrlSerializer, useClass: DefaultUrlSerializer },
  4883. {
  4884. provide: Router,
  4885. useFactory: setupRouter,
  4886. deps: [
  4887. core.ApplicationRef, UrlSerializer, ChildrenOutletContexts, common.Location, core.Injector,
  4888. core.NgModuleFactoryLoader, core.Compiler, ROUTES, ROUTER_CONFIGURATION,
  4889. [UrlHandlingStrategy, new core.Optional()], [RouteReuseStrategy, new core.Optional()]
  4890. ]
  4891. },
  4892. ChildrenOutletContexts,
  4893. { provide: ActivatedRoute, useFactory: rootRoute, deps: [Router] },
  4894. { provide: core.NgModuleFactoryLoader, useClass: core.SystemJsNgModuleLoader },
  4895. RouterPreloader,
  4896. NoPreloading,
  4897. PreloadAllModules,
  4898. { provide: ROUTER_CONFIGURATION, useValue: { enableTracing: false } },
  4899. ];
  4900. function routerNgProbeToken() {
  4901. return new core.NgProbeToken('Router', Router);
  4902. }
  4903. /**
  4904. * @usageNotes
  4905. *
  4906. * RouterModule can be imported multiple times: once per lazily-loaded bundle.
  4907. * Since the router deals with a global shared resource--location, we cannot have
  4908. * more than one router service active.
  4909. *
  4910. * That is why there are two ways to create the module: `RouterModule.forRoot` and
  4911. * `RouterModule.forChild`.
  4912. *
  4913. * * `forRoot` creates a module that contains all the directives, the given routes, and the router
  4914. * service itself.
  4915. * * `forChild` creates a module that contains all the directives and the given routes, but does not
  4916. * include the router service.
  4917. *
  4918. * When registered at the root, the module should be used as follows
  4919. *
  4920. * ```
  4921. * @NgModule({
  4922. * imports: [RouterModule.forRoot(ROUTES)]
  4923. * })
  4924. * class MyNgModule {}
  4925. * ```
  4926. *
  4927. * For submodules and lazy loaded submodules the module should be used as follows:
  4928. *
  4929. * ```
  4930. * @NgModule({
  4931. * imports: [RouterModule.forChild(ROUTES)]
  4932. * })
  4933. * class MyNgModule {}
  4934. * ```
  4935. *
  4936. * @description
  4937. *
  4938. * Adds router directives and providers.
  4939. *
  4940. * Managing state transitions is one of the hardest parts of building applications. This is
  4941. * especially true on the web, where you also need to ensure that the state is reflected in the URL.
  4942. * In addition, we often want to split applications into multiple bundles and load them on demand.
  4943. * Doing this transparently is not trivial.
  4944. *
  4945. * The Angular router solves these problems. Using the router, you can declaratively specify
  4946. * application states, manage state transitions while taking care of the URL, and load bundles on
  4947. * demand.
  4948. *
  4949. * [Read this developer guide](https://angular.io/docs/ts/latest/guide/router.html) to get an
  4950. * overview of how the router should be used.
  4951. *
  4952. *
  4953. */
  4954. var RouterModule = /** @class */ (function () {
  4955. // Note: We are injecting the Router so it gets created eagerly...
  4956. function RouterModule(guard, router) {
  4957. }
  4958. /**
  4959. * Creates a module with all the router providers and directives. It also optionally sets up an
  4960. * application listener to perform an initial navigation.
  4961. *
  4962. * Options (see `ExtraOptions`):
  4963. * * `enableTracing` makes the router log all its internal events to the console.
  4964. * * `useHash` enables the location strategy that uses the URL fragment instead of the history
  4965. * API.
  4966. * * `initialNavigation` disables the initial navigation.
  4967. * * `errorHandler` provides a custom error handler.
  4968. * * `preloadingStrategy` configures a preloading strategy (see `PreloadAllModules`).
  4969. * * `onSameUrlNavigation` configures how the router handles navigation to the current URL. See
  4970. * `ExtraOptions` for more details.
  4971. * * `paramsInheritanceStrategy` defines how the router merges params, data and resolved data
  4972. * from parent to child routes.
  4973. */
  4974. RouterModule.forRoot = function (routes, config) {
  4975. return {
  4976. ngModule: RouterModule,
  4977. providers: [
  4978. ROUTER_PROVIDERS,
  4979. provideRoutes(routes),
  4980. {
  4981. provide: ROUTER_FORROOT_GUARD,
  4982. useFactory: provideForRootGuard,
  4983. deps: [[Router, new core.Optional(), new core.SkipSelf()]]
  4984. },
  4985. { provide: ROUTER_CONFIGURATION, useValue: config ? config : {} },
  4986. {
  4987. provide: common.LocationStrategy,
  4988. useFactory: provideLocationStrategy,
  4989. deps: [
  4990. common.PlatformLocation, [new core.Inject(common.APP_BASE_HREF), new core.Optional()], ROUTER_CONFIGURATION
  4991. ]
  4992. },
  4993. {
  4994. provide: PreloadingStrategy,
  4995. useExisting: config && config.preloadingStrategy ? config.preloadingStrategy :
  4996. NoPreloading
  4997. },
  4998. { provide: core.NgProbeToken, multi: true, useFactory: routerNgProbeToken },
  4999. provideRouterInitializer(),
  5000. ],
  5001. };
  5002. };
  5003. /**
  5004. * Creates a module with all the router directives and a provider registering routes.
  5005. */
  5006. RouterModule.forChild = function (routes) {
  5007. return { ngModule: RouterModule, providers: [provideRoutes(routes)] };
  5008. };
  5009. RouterModule.decorators = [
  5010. { type: core.NgModule, args: [{
  5011. declarations: ROUTER_DIRECTIVES,
  5012. exports: ROUTER_DIRECTIVES,
  5013. entryComponents: [EmptyOutletComponent]
  5014. },] }
  5015. ];
  5016. /** @nocollapse */
  5017. RouterModule.ctorParameters = function () { return [
  5018. { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [ROUTER_FORROOT_GUARD,] }] },
  5019. { type: Router, decorators: [{ type: core.Optional }] }
  5020. ]; };
  5021. return RouterModule;
  5022. }());
  5023. function provideLocationStrategy(platformLocationStrategy, baseHref, options) {
  5024. if (options === void 0) { options = {}; }
  5025. return options.useHash ? new common.HashLocationStrategy(platformLocationStrategy, baseHref) :
  5026. new common.PathLocationStrategy(platformLocationStrategy, baseHref);
  5027. }
  5028. function provideForRootGuard(router) {
  5029. if (router) {
  5030. throw new Error("RouterModule.forRoot() called twice. Lazy loaded modules should use RouterModule.forChild() instead.");
  5031. }
  5032. return 'guarded';
  5033. }
  5034. /**
  5035. * @description
  5036. *
  5037. * Registers routes.
  5038. *
  5039. * ### Example
  5040. *
  5041. * ```
  5042. * @NgModule({
  5043. * imports: [RouterModule.forChild(ROUTES)],
  5044. * providers: [provideRoutes(EXTRA_ROUTES)]
  5045. * })
  5046. * class MyNgModule {}
  5047. * ```
  5048. *
  5049. *
  5050. */
  5051. function provideRoutes(routes) {
  5052. return [
  5053. { provide: core.ANALYZE_FOR_ENTRY_COMPONENTS, multi: true, useValue: routes },
  5054. { provide: ROUTES, multi: true, useValue: routes },
  5055. ];
  5056. }
  5057. function setupRouter(ref, urlSerializer, contexts, location, injector, loader, compiler, config, opts, urlHandlingStrategy, routeReuseStrategy) {
  5058. if (opts === void 0) { opts = {}; }
  5059. var router = new Router(null, urlSerializer, contexts, location, injector, loader, compiler, flatten(config));
  5060. if (urlHandlingStrategy) {
  5061. router.urlHandlingStrategy = urlHandlingStrategy;
  5062. }
  5063. if (routeReuseStrategy) {
  5064. router.routeReuseStrategy = routeReuseStrategy;
  5065. }
  5066. if (opts.errorHandler) {
  5067. router.errorHandler = opts.errorHandler;
  5068. }
  5069. if (opts.malformedUriErrorHandler) {
  5070. router.malformedUriErrorHandler = opts.malformedUriErrorHandler;
  5071. }
  5072. if (opts.enableTracing) {
  5073. var dom_1 = platformBrowser.ɵgetDOM();
  5074. router.events.subscribe(function (e) {
  5075. dom_1.logGroup("Router Event: " + e.constructor.name);
  5076. dom_1.log(e.toString());
  5077. dom_1.log(e);
  5078. dom_1.logGroupEnd();
  5079. });
  5080. }
  5081. if (opts.onSameUrlNavigation) {
  5082. router.onSameUrlNavigation = opts.onSameUrlNavigation;
  5083. }
  5084. if (opts.paramsInheritanceStrategy) {
  5085. router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;
  5086. }
  5087. return router;
  5088. }
  5089. function rootRoute(router) {
  5090. return router.routerState.root;
  5091. }
  5092. /**
  5093. * To initialize the router properly we need to do in two steps:
  5094. *
  5095. * We need to start the navigation in a APP_INITIALIZER to block the bootstrap if
  5096. * a resolver or a guards executes asynchronously. Second, we need to actually run
  5097. * activation in a BOOTSTRAP_LISTENER. We utilize the afterPreactivation
  5098. * hook provided by the router to do that.
  5099. *
  5100. * The router navigation starts, reaches the point when preactivation is done, and then
  5101. * pauses. It waits for the hook to be resolved. We then resolve it only in a bootstrap listener.
  5102. */
  5103. var RouterInitializer = /** @class */ (function () {
  5104. function RouterInitializer(injector) {
  5105. this.injector = injector;
  5106. this.initNavigation = false;
  5107. this.resultOfPreactivationDone = new rxjs.Subject();
  5108. }
  5109. RouterInitializer.prototype.appInitializer = function () {
  5110. var _this = this;
  5111. var p = this.injector.get(common.LOCATION_INITIALIZED, Promise.resolve(null));
  5112. return p.then(function () {
  5113. var resolve = null;
  5114. var res = new Promise(function (r) { return resolve = r; });
  5115. var router = _this.injector.get(Router);
  5116. var opts = _this.injector.get(ROUTER_CONFIGURATION);
  5117. if (_this.isLegacyDisabled(opts) || _this.isLegacyEnabled(opts)) {
  5118. resolve(true);
  5119. }
  5120. else if (opts.initialNavigation === 'disabled') {
  5121. router.setUpLocationChangeListener();
  5122. resolve(true);
  5123. }
  5124. else if (opts.initialNavigation === 'enabled') {
  5125. router.hooks.afterPreactivation = function () {
  5126. // only the initial navigation should be delayed
  5127. if (!_this.initNavigation) {
  5128. _this.initNavigation = true;
  5129. resolve(true);
  5130. return _this.resultOfPreactivationDone;
  5131. // subsequent navigations should not be delayed
  5132. }
  5133. else {
  5134. return rxjs.of(null);
  5135. }
  5136. };
  5137. router.initialNavigation();
  5138. }
  5139. else {
  5140. throw new Error("Invalid initialNavigation options: '" + opts.initialNavigation + "'");
  5141. }
  5142. return res;
  5143. });
  5144. };
  5145. RouterInitializer.prototype.bootstrapListener = function (bootstrappedComponentRef) {
  5146. var opts = this.injector.get(ROUTER_CONFIGURATION);
  5147. var preloader = this.injector.get(RouterPreloader);
  5148. var router = this.injector.get(Router);
  5149. var ref = this.injector.get(core.ApplicationRef);
  5150. if (bootstrappedComponentRef !== ref.components[0]) {
  5151. return;
  5152. }
  5153. if (this.isLegacyEnabled(opts)) {
  5154. router.initialNavigation();
  5155. }
  5156. else if (this.isLegacyDisabled(opts)) {
  5157. router.setUpLocationChangeListener();
  5158. }
  5159. preloader.setUpPreloading();
  5160. router.resetRootComponentType(ref.componentTypes[0]);
  5161. this.resultOfPreactivationDone.next(null);
  5162. this.resultOfPreactivationDone.complete();
  5163. };
  5164. RouterInitializer.prototype.isLegacyEnabled = function (opts) {
  5165. return opts.initialNavigation === 'legacy_enabled' || opts.initialNavigation === true ||
  5166. opts.initialNavigation === undefined;
  5167. };
  5168. RouterInitializer.prototype.isLegacyDisabled = function (opts) {
  5169. return opts.initialNavigation === 'legacy_disabled' || opts.initialNavigation === false;
  5170. };
  5171. RouterInitializer.decorators = [
  5172. { type: core.Injectable }
  5173. ];
  5174. /** @nocollapse */
  5175. RouterInitializer.ctorParameters = function () { return [
  5176. { type: core.Injector }
  5177. ]; };
  5178. return RouterInitializer;
  5179. }());
  5180. function getAppInitializer(r) {
  5181. return r.appInitializer.bind(r);
  5182. }
  5183. function getBootstrapListener(r) {
  5184. return r.bootstrapListener.bind(r);
  5185. }
  5186. /**
  5187. * A token for the router initializer that will be called after the app is bootstrapped.
  5188. *
  5189. * @experimental
  5190. */
  5191. var ROUTER_INITIALIZER = new core.InjectionToken('Router Initializer');
  5192. function provideRouterInitializer() {
  5193. return [
  5194. RouterInitializer,
  5195. {
  5196. provide: core.APP_INITIALIZER,
  5197. multi: true,
  5198. useFactory: getAppInitializer,
  5199. deps: [RouterInitializer]
  5200. },
  5201. { provide: ROUTER_INITIALIZER, useFactory: getBootstrapListener, deps: [RouterInitializer] },
  5202. { provide: core.APP_BOOTSTRAP_LISTENER, multi: true, useExisting: ROUTER_INITIALIZER },
  5203. ];
  5204. }
  5205. /**
  5206. * @license
  5207. * Copyright Google Inc. All Rights Reserved.
  5208. *
  5209. * Use of this source code is governed by an MIT-style license that can be
  5210. * found in the LICENSE file at https://angular.io/license
  5211. */
  5212. var VERSION = new core.Version('6.0.9');
  5213. /**
  5214. * @license
  5215. * Copyright Google Inc. All Rights Reserved.
  5216. *
  5217. * Use of this source code is governed by an MIT-style license that can be
  5218. * found in the LICENSE file at https://angular.io/license
  5219. */
  5220. /**
  5221. * @license
  5222. * Copyright Google Inc. All Rights Reserved.
  5223. *
  5224. * Use of this source code is governed by an MIT-style license that can be
  5225. * found in the LICENSE file at https://angular.io/license
  5226. */
  5227. /**
  5228. * @license
  5229. * Copyright Google Inc. All Rights Reserved.
  5230. *
  5231. * Use of this source code is governed by an MIT-style license that can be
  5232. * found in the LICENSE file at https://angular.io/license
  5233. */
  5234. // This file only reexports content of the `src` folder. Keep it that way.
  5235. /**
  5236. * @license
  5237. * Copyright Google Inc. All Rights Reserved.
  5238. *
  5239. * Use of this source code is governed by an MIT-style license that can be
  5240. * found in the LICENSE file at https://angular.io/license
  5241. */
  5242. /**
  5243. * Generated bundle index. Do not edit.
  5244. */
  5245. exports.ɵangular_packages_router_router_a = ROUTER_FORROOT_GUARD;
  5246. exports.ɵangular_packages_router_router_g = RouterInitializer;
  5247. exports.ɵangular_packages_router_router_h = getAppInitializer;
  5248. exports.ɵangular_packages_router_router_i = getBootstrapListener;
  5249. exports.ɵangular_packages_router_router_d = provideForRootGuard;
  5250. exports.ɵangular_packages_router_router_c = provideLocationStrategy;
  5251. exports.ɵangular_packages_router_router_j = provideRouterInitializer;
  5252. exports.ɵangular_packages_router_router_f = rootRoute;
  5253. exports.ɵangular_packages_router_router_b = routerNgProbeToken;
  5254. exports.ɵangular_packages_router_router_e = setupRouter;
  5255. exports.ɵangular_packages_router_router_k = Tree;
  5256. exports.ɵangular_packages_router_router_l = TreeNode;
  5257. exports.RouterLink = RouterLink;
  5258. exports.RouterLinkWithHref = RouterLinkWithHref;
  5259. exports.RouterLinkActive = RouterLinkActive;
  5260. exports.RouterOutlet = RouterOutlet;
  5261. exports.ActivationEnd = ActivationEnd;
  5262. exports.ActivationStart = ActivationStart;
  5263. exports.ChildActivationEnd = ChildActivationEnd;
  5264. exports.ChildActivationStart = ChildActivationStart;
  5265. exports.GuardsCheckEnd = GuardsCheckEnd;
  5266. exports.GuardsCheckStart = GuardsCheckStart;
  5267. exports.NavigationCancel = NavigationCancel;
  5268. exports.NavigationEnd = NavigationEnd;
  5269. exports.NavigationError = NavigationError;
  5270. exports.NavigationStart = NavigationStart;
  5271. exports.ResolveEnd = ResolveEnd;
  5272. exports.ResolveStart = ResolveStart;
  5273. exports.RouteConfigLoadEnd = RouteConfigLoadEnd;
  5274. exports.RouteConfigLoadStart = RouteConfigLoadStart;
  5275. exports.RouterEvent = RouterEvent;
  5276. exports.RoutesRecognized = RoutesRecognized;
  5277. exports.RouteReuseStrategy = RouteReuseStrategy;
  5278. exports.Router = Router;
  5279. exports.ROUTES = ROUTES;
  5280. exports.ROUTER_CONFIGURATION = ROUTER_CONFIGURATION;
  5281. exports.ROUTER_INITIALIZER = ROUTER_INITIALIZER;
  5282. exports.RouterModule = RouterModule;
  5283. exports.provideRoutes = provideRoutes;
  5284. exports.ChildrenOutletContexts = ChildrenOutletContexts;
  5285. exports.OutletContext = OutletContext;
  5286. exports.NoPreloading = NoPreloading;
  5287. exports.PreloadAllModules = PreloadAllModules;
  5288. exports.PreloadingStrategy = PreloadingStrategy;
  5289. exports.RouterPreloader = RouterPreloader;
  5290. exports.ActivatedRoute = ActivatedRoute;
  5291. exports.ActivatedRouteSnapshot = ActivatedRouteSnapshot;
  5292. exports.RouterState = RouterState;
  5293. exports.RouterStateSnapshot = RouterStateSnapshot;
  5294. exports.PRIMARY_OUTLET = PRIMARY_OUTLET;
  5295. exports.convertToParamMap = convertToParamMap;
  5296. exports.UrlHandlingStrategy = UrlHandlingStrategy;
  5297. exports.DefaultUrlSerializer = DefaultUrlSerializer;
  5298. exports.UrlSegment = UrlSegment;
  5299. exports.UrlSegmentGroup = UrlSegmentGroup;
  5300. exports.UrlSerializer = UrlSerializer;
  5301. exports.UrlTree = UrlTree;
  5302. exports.VERSION = VERSION;
  5303. exports.ɵEmptyOutletComponent = EmptyOutletComponent;
  5304. exports.ɵROUTER_PROVIDERS = ROUTER_PROVIDERS;
  5305. exports.ɵflatten = flatten;
  5306. Object.defineProperty(exports, '__esModule', { value: true });
  5307. })));
  5308. //# sourceMappingURL=router.umd.js.map