UNPKG

5.61 kBSource Map (JSON)View Raw
1{
2 "version": 3,
3 "file": "interface.js",
4 "sourceRoot": "",
5 "sources": [
6 "@uirouter/core/url/interface.ts"
7 ],
8 "names": [],
9 "mappings": "",
10 "sourcesContent": [
11 "/**\n * # URL subsystem\n *\n * Contains code related to managing the URL\n *\n * The primary API is found in [[UrlService]], [[UrlService.config]], and [[UrlService.rules]].\n *\n * @packageDocumentation\n * @preferred\n */\nimport { LocationConfig } from '../common';\nimport { UIRouter } from '../router';\nimport { StateDeclaration, StateObject, TargetState, TargetStateDef } from '../state';\nimport { UrlMatcher } from './urlMatcher';\nimport { UrlConfig } from './urlConfig';\nimport { UrlRules } from './urlRules';\nimport { UrlService } from './urlService';\n\nexport interface UrlMatcherCompileConfig {\n // If state is provided, use the configuration in the `params` block\n state?: StateDeclaration;\n strict?: boolean;\n caseInsensitive?: boolean;\n // If params are pre-decoded, set to false to avoid double decoding\n decodeParams?: boolean;\n}\n\n/** @deprecated use [[UrlConfig]] */\nexport interface UrlConfigApi extends LocationConfig, UrlMatcherConfig {}\n\n/** @deprecated use [[UrlConfig]] */\nexport interface UrlMatcherConfig {\n /** See: [[UrlConfig.caseInsensitive]] */ caseInsensitive: UrlConfig['caseInsensitive'];\n /** See: [[UrlConfig.strictMode]] */ strictMode: UrlConfig['strictMode'];\n /** See: [[UrlConfig.defaultSquashPolicy]] */ defaultSquashPolicy: UrlConfig['defaultSquashPolicy'];\n /** See: [[UrlConfig.type]] */ type: UrlConfig['type'];\n}\n\n/** @deprecated use [[UrlService]] */\nexport interface UrlSyncApi {\n /** See: [[UrlService.sync]] */ sync: UrlService['sync'];\n /** See: [[UrlService.listen]] */ listen: UrlService['listen'];\n /** See: [[UrlService.deferIntercept]] */ deferIntercept: UrlService['deferIntercept'];\n}\n\n/** @deprecated use [[UrlRules]] */\nexport interface UrlRulesApi {\n /** See: [[UrlRules.sort]] */ sort: UrlRules['sort'];\n /** See: [[UrlRules.when]] */ when: UrlRules['when'];\n /** See: [[UrlRules.otherwise]] */ otherwise: UrlRules['otherwise'];\n /** See: [[UrlRules.initial]] */ initial: UrlRules['initial'];\n /** See: [[UrlRules.rules]] */ rules: UrlRules['rules'];\n /** See: [[UrlRules.rule]] */ rule: UrlRules['rule'];\n /** See: [[UrlRules.removeRule]] */ removeRule: UrlRules['removeRule'];\n}\n\n/**\n * An object containing the three parts of a URL\n */\nexport interface UrlParts {\n path: string;\n search?: { [key: string]: any };\n hash?: string;\n}\n\n/**\n * A UrlRule match result\n *\n * The result of UrlRouter.match()\n */\nexport interface MatchResult {\n /** The matched value from a [[UrlRule]] */\n match: any;\n /** The rule that matched */\n rule: UrlRule;\n /** The match result weight */\n weight: number;\n}\n\n/**\n * A function that matches the URL for a [[UrlRule]]\n *\n * Implementations should match against the provided [[UrlParts]] and return the matched value (truthy) if the rule matches.\n * If this rule is selected, the matched value is passed to the [[UrlRuleHandlerFn]].\n *\n * @return the matched value, either truthy or falsey\n */\nexport interface UrlRuleMatchFn {\n (url?: UrlParts, router?: UIRouter): any;\n}\n\n/**\n * Handler invoked when a rule is matched\n *\n * The matched value from the rule's [[UrlRuleMatchFn]] is passed as the first argument\n * The handler should return a string (to redirect), a [[TargetState]]/[[TargetStateDef]], or void\n *\n * If the handler returns a string, the url is replaced with the string.\n * If the handler returns a [[TargetState]], the target state is activated.\n */\nexport interface UrlRuleHandlerFn {\n (matchValue?: any, url?: UrlParts, router?: UIRouter): string | TargetState | TargetStateDef | void;\n}\n\n/** @internal */\nexport type UrlRuleType = 'STATE' | 'URLMATCHER' | 'REGEXP' | 'RAW' | 'OTHER';\n\n/**\n * The interface for a URL Rule\n *\n * If you are creating a rule for use with [[UrlRules.rule]], it should implement this interface.\n */\nexport interface UrlRule {\n /**\n * The rule's ID.\n *\n * IDs are auto-assigned when the rule is registered, in increasing order.\n */\n $id: number;\n\n /**\n * The rule's priority (defaults to 0).\n *\n * This can be used to explicitly modify the rule's priority.\n * Higher numbers are higher priority.\n */\n priority: number;\n\n /** @internal */\n _group: number;\n\n /** The type of the rule */\n type: UrlRuleType;\n\n /**\n * This function should match the url and return the match details\n *\n * See [[UrlRuleMatchFn]] for details\n */\n match: UrlRuleMatchFn;\n\n /**\n * This function is called if the rule matched, and was selected as the \"best match\".\n * This function handles the rule match event.\n *\n * See [[UrlRuleHandlerFn]] for details\n */\n handler: UrlRuleHandlerFn;\n\n /**\n * The priority of a given match.\n *\n * Sometimes more than one UrlRule might have matched.\n * This method is used to choose the best match.\n *\n * If multiple rules matched, each rule's `matchPriority` is called with the value from [[match]].\n * The rule with the highest `matchPriority` has its [[handler]] called.\n */\n matchPriority(match: any): number;\n}\n\nexport interface MatcherUrlRule extends UrlRule {\n type: 'URLMATCHER' | 'STATE';\n urlMatcher: UrlMatcher;\n}\n\nexport interface StateRule extends MatcherUrlRule {\n type: 'STATE';\n state: StateObject;\n}\n\nexport interface RegExpRule extends UrlRule {\n type: 'REGEXP';\n regexp: RegExp;\n}\n"
12 ]
13}
\No newline at end of file