UNPKG

8.2 kBSource Map (JSON)View Raw
1{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../../../modules/@angular/router-deprecated/src/rules/rules.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAkB,sBAAsB,CAAC,CAAA;AACzC,2BAA4B,sBAAsB,CAAC,CAAA;AACnD,qBAAiC,gBAAgB,CAAC,CAAA;AAClD,wBAA6B,mBAAmB,CAAC,CAAA;AACjD,4BAAmC,gBAAgB,CAAC,CAAA;AACpD,2BAA2C,eAAe,CAAC,CAAA;AAO3D,6EAA6E;AAC7E;IAAA;IAAkC,CAAC;IAAD,iBAAC;AAAD,CAAC,AAAnC,IAAmC;AAAb,kBAAU,aAAG,CAAA;AAEnC;IAA+B,6BAAU;IACvC,mBACW,WAAiC,EAAS,SAAc,EAAS,YAAmB;QAC7F,iBAAO,CAAC;QADC,gBAAW,GAAX,WAAW,CAAsB;QAAS,cAAS,GAAT,SAAS,CAAK;QAAS,iBAAY,GAAZ,YAAY,CAAO;IAE/F,CAAC;IACH,gBAAC;AAAD,CAAC,AALD,CAA+B,UAAU,GAKxC;AALY,iBAAS,YAKrB,CAAA;AAED;IAAmC,iCAAU;IAC3C,uBAAmB,UAAiB,EAAS,WAAgB,CAAC,iBAAiB;QAAI,iBAAO,CAAC;QAAxE,eAAU,GAAV,UAAU,CAAO;QAAS,gBAAW,GAAX,WAAW,CAAK;IAA+B,CAAC;IAC/F,oBAAC;AAAD,CAAC,AAFD,CAAmC,UAAU,GAE5C;AAFY,qBAAa,gBAEzB,CAAA;AAUD;IAGE,sBAAoB,eAA0B,EAAS,UAAiB;QAApD,oBAAe,GAAf,eAAe,CAAW;QAAS,eAAU,GAAV,UAAU,CAAO;QACtE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;IACxC,CAAC;IAED,sBAAI,8BAAI;aAAR,cAAa,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;aAC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,IAAI,0BAAa,CAAC,sDAAsD,CAAC,CAAC;QAClF,CAAC;QACD,IAAI,OAAO,GAAG,OAAO,GAAG,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClD,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,WAAW,GAAG,IAAI,kCAAoB,CACtC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,EAChF,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAEtC,MAAM,CAAC,WAAW,CAAC;IACrB,CAAC;IACH,gBAAC;AAAD,CAAC,AA1DD,IA0DC;AA1DY,iBAAS,YA0DrB,CAAA","sourcesContent":["import {Map} from '../facade/collection';\nimport {BaseException} from '../facade/exceptions';\nimport {isBlank, isPresent} from '../facade/lang';\nimport {PromiseWrapper} from '../facade/promise';\nimport {ComponentInstruction} from '../instruction';\nimport {Url, convertUrlParamsToArray} from '../url_parser';\n\nimport {RouteHandler} from './route_handlers/route_handler';\nimport {GeneratedUrl, RoutePath} from './route_paths/route_path';\n\n\n\n// RouteMatch objects hold information about a match between a rule and a URL\nexport abstract class RouteMatch {}\n\nexport class PathMatch extends RouteMatch {\n constructor(\n public instruction: ComponentInstruction, public remaining: Url, public remainingAux: Url[]) {\n super();\n }\n}\n\nexport class RedirectMatch extends RouteMatch {\n constructor(public redirectTo: any[], public specificity: any /** TODO #9100 */) { super(); }\n}\n\n// Rules are responsible for recognizing URL segments and generating instructions\nexport interface AbstractRule {\n hash: string;\n path: string;\n recognize(beginningSegment: Url): Promise<RouteMatch>;\n generate(params: {[key: string]: any}): ComponentInstruction;\n}\n\nexport class RedirectRule implements AbstractRule {\n public hash: string;\n\n constructor(private _pathRecognizer: RoutePath, public redirectTo: any[]) {\n this.hash = this._pathRecognizer.hash;\n }\n\n get path() { return this._pathRecognizer.toString(); }\n set path(val) { throw new BaseException('you cannot set the path of a RedirectRule directly'); }\n\n /**\n * Returns `null` or a `ParsedUrl` representing the new path to match\n */\n recognize(beginningSegment: Url): Promise<RouteMatch> {\n var match: any /** TODO #9100 */ = null;\n if (isPresent(this._pathRecognizer.matchUrl(beginningSegment))) {\n match = new RedirectMatch(this.redirectTo, this._pathRecognizer.specificity);\n }\n return PromiseWrapper.resolve(match);\n }\n\n generate(params: {[key: string]: any}): ComponentInstruction {\n throw new BaseException(`Tried to generate a redirect.`);\n }\n}\n\n\n// represents something like '/foo/:bar'\nexport class RouteRule implements AbstractRule {\n specificity: string;\n terminal: boolean;\n hash: string;\n\n private _cache: Map<string, ComponentInstruction> = new Map<string, ComponentInstruction>();\n\n // TODO: cache component instruction instances by params and by ParsedUrl instance\n\n constructor(\n private _routePath: RoutePath, public handler: RouteHandler, private _routeName: string) {\n this.specificity = this._routePath.specificity;\n this.hash = this._routePath.hash;\n this.terminal = this._routePath.terminal;\n }\n\n get path() { return this._routePath.toString(); }\n set path(val) { throw new BaseException('you cannot set the path of a RouteRule directly'); }\n\n recognize(beginningSegment: Url): Promise<RouteMatch> {\n var res = this._routePath.matchUrl(beginningSegment);\n if (isBlank(res)) {\n return null;\n }\n\n return this.handler.resolveComponentType().then((_) => {\n var componentInstruction = this._getInstruction(res.urlPath, res.urlParams, res.allParams);\n return new PathMatch(componentInstruction, res.rest, res.auxiliary);\n });\n }\n\n generate(params: {[key: string]: any}): ComponentInstruction {\n var generated = this._routePath.generateUrl(params);\n var urlPath = generated.urlPath;\n var urlParams = generated.urlParams;\n return this._getInstruction(urlPath, convertUrlParamsToArray(urlParams), params);\n }\n\n generateComponentPathValues(params: {[key: string]: any}): GeneratedUrl {\n return this._routePath.generateUrl(params);\n }\n\n private _getInstruction(urlPath: string, urlParams: string[], params: {[key: string]: any}):\n ComponentInstruction {\n if (isBlank(this.handler.componentType)) {\n throw new BaseException(`Tried to get instruction before the type was loaded.`);\n }\n var hashKey = urlPath + '?' + urlParams.join('&');\n if (this._cache.has(hashKey)) {\n return this._cache.get(hashKey);\n }\n var instruction = new ComponentInstruction(\n urlPath, urlParams, this.handler.data, this.handler.componentType, this.terminal,\n this.specificity, params, this._routeName);\n this._cache.set(hashKey, instruction);\n\n return instruction;\n }\n}\n"]}
\No newline at end of file