@angular-wave/angular.ts 0.8.4 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/@types/core/scope/scope.d.ts +1 -4
  2. package/@types/interface.d.ts +17 -3
  3. package/@types/shared/interface.d.ts +17 -0
  4. package/@types/shared/utils.d.ts +4 -19
  5. package/dist/angular-ts.esm.js +42 -160
  6. package/dist/angular-ts.umd.js +42 -160
  7. package/dist/angular-ts.umd.min.js +1 -1
  8. package/docs/layouts/shortcodes/version.html +1 -1
  9. package/docs/static/typedoc/assets/hierarchy.js +1 -1
  10. package/docs/static/typedoc/assets/main.js +2 -2
  11. package/docs/static/typedoc/assets/navigation.js +1 -1
  12. package/docs/static/typedoc/assets/search.js +1 -1
  13. package/docs/static/typedoc/assets/style.css +2 -9
  14. package/docs/static/typedoc/classes/Location.html +20 -20
  15. package/docs/static/typedoc/classes/LocationProvider.html +5 -5
  16. package/docs/static/typedoc/classes/LogProvider.html +3 -3
  17. package/docs/static/typedoc/classes/PubSub.html +21 -21
  18. package/docs/static/typedoc/classes/PubSubProvider.html +1 -1
  19. package/docs/static/typedoc/classes/TemplateCacheProvider.html +2 -2
  20. package/docs/static/typedoc/hierarchy.html +1 -1
  21. package/docs/static/typedoc/index.html +1 -1
  22. package/docs/static/typedoc/interfaces/ChangesObject.html +3 -3
  23. package/docs/static/typedoc/interfaces/ComponentOptions.html +8 -8
  24. package/docs/static/typedoc/interfaces/Controller.html +6 -6
  25. package/docs/static/typedoc/interfaces/DefaultPorts.html +1 -1
  26. package/docs/static/typedoc/interfaces/Directive.html +18 -18
  27. package/docs/static/typedoc/interfaces/DirectivePrePost.html +1 -1
  28. package/docs/static/typedoc/interfaces/Html5Mode.html +1 -1
  29. package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +7 -7
  30. package/docs/static/typedoc/interfaces/HttpService.html +21 -21
  31. package/docs/static/typedoc/interfaces/LogService.html +6 -6
  32. package/docs/static/typedoc/interfaces/NgModelController.html +15 -15
  33. package/docs/static/typedoc/interfaces/NgModelOptions.html +8 -8
  34. package/docs/static/typedoc/interfaces/Provider.html +17 -17
  35. package/docs/static/typedoc/interfaces/RequestConfig.html +15 -15
  36. package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +11 -11
  37. package/docs/static/typedoc/interfaces/ServiceProvider.html +1 -1
  38. package/docs/static/typedoc/interfaces/TemplateCache.html +1 -1
  39. package/docs/static/typedoc/interfaces/TranscludeFunctionObject.html +4 -4
  40. package/docs/static/typedoc/interfaces/UrlParts.html +4 -4
  41. package/docs/static/typedoc/types/AnnotatedFactory.html +1 -1
  42. package/docs/static/typedoc/types/CloneAttachFunction.html +1 -1
  43. package/docs/static/typedoc/types/ControllerConstructor.html +1 -1
  44. package/docs/static/typedoc/types/DirectiveCompileFn.html +1 -1
  45. package/docs/static/typedoc/types/DirectiveController.html +1 -1
  46. package/docs/static/typedoc/types/DirectiveFactoryFn.html +1 -1
  47. package/docs/static/typedoc/types/DirectiveLinkFn.html +1 -1
  48. package/docs/static/typedoc/types/Expression.html +1 -1
  49. package/docs/static/typedoc/types/FilterFactory.html +1 -1
  50. package/docs/static/typedoc/types/FilterFn.html +1 -1
  51. package/docs/static/typedoc/types/Injectable.html +1 -1
  52. package/docs/static/typedoc/types/InjectableFactory.html +1 -1
  53. package/docs/static/typedoc/types/LogCall.html +1 -1
  54. package/docs/static/typedoc/types/LogServiceFactory.html +1 -1
  55. package/docs/static/typedoc/types/OnChangesObject.html +1 -1
  56. package/docs/static/typedoc/types/SwapModeType.html +1 -1
  57. package/docs/static/typedoc/types/TController.html +1 -1
  58. package/docs/static/typedoc/types/UrlChangeListener.html +4 -4
  59. package/docs/static/typedoc/variables/SwapMode.html +10 -10
  60. package/legacy.d.ts +0 -82
  61. package/package.json +2 -2
  62. package/src/animations/animate-js.js +2 -1
  63. package/src/animations/animate-queue.js +7 -6
  64. package/src/core/parse/interpreter.js +11 -6
  65. package/src/core/parse/parse.spec.js +6 -8
  66. package/src/core/scope/scope.js +10 -12
  67. package/src/core/scope/scope.spec.js +4 -4
  68. package/src/directive/http/form-router-test.html +44 -0
  69. package/src/directive/options/options-example.html +7 -3
  70. package/src/directive/options/options.js +1 -0
  71. package/src/directive/options/options.spec.js +117 -170
  72. package/src/interface.ts +20 -3
  73. package/src/router/directives/view-directive.js +0 -1
  74. package/src/router/directives/view-directive.spec.js +10 -9
  75. package/src/router/resolve/resolve-context.js +0 -19
  76. package/src/router/state/state-registry.js +3 -10
  77. package/src/router/state/state-service.js +5 -5
  78. package/src/router/transition/transition.js +1 -86
  79. package/src/router/view-hook.spec.js +1 -1
  80. package/src/shared/interface.ts +19 -0
  81. package/src/shared/utils.js +3 -12
  82. package/tsconfig.types.json +2 -2
  83. package/@types/angular.d.ts +0 -150
  84. package/@types/animations/animate-cache.d.ts +0 -50
  85. package/@types/animations/animate-children-directive.d.ts +0 -10
  86. package/@types/animations/animate-css-driver.d.ts +0 -18
  87. package/@types/animations/animate-css.d.ts +0 -18
  88. package/@types/animations/animate-js-driver.d.ts +0 -14
  89. package/@types/animations/animate-js.d.ts +0 -23
  90. package/@types/animations/animate-queue.d.ts +0 -28
  91. package/@types/animations/animate-runner.d.ts +0 -31
  92. package/@types/animations/animate-swap.d.ts +0 -9
  93. package/@types/animations/animate.d.ts +0 -450
  94. package/@types/animations/animation.d.ts +0 -14
  95. package/@types/animations/interface.d.ts +0 -17
  96. package/@types/animations/raf-scheduler.d.ts +0 -37
  97. package/@types/animations/shared.d.ts +0 -74
  98. package/@types/core/compile/compile.d.ts +0 -201
  99. package/@types/core/controller/controller.d.ts +0 -54
  100. package/@types/core/di/injector.d.ts +0 -22
  101. package/@types/core/filter/filter.d.ts +0 -23
  102. package/@types/core/interpolate/interpolate.d.ts +0 -38
  103. package/@types/core/parse/ast/ast-node.d.ts +0 -56
  104. package/@types/core/parse/ast/ast.d.ts +0 -164
  105. package/@types/core/parse/lexer/lexer.d.ts +0 -119
  106. package/@types/core/parse/lexer/token.d.ts +0 -17
  107. package/@types/core/parse/parse.d.ts +0 -33
  108. package/@types/core/parse/parser/parser.d.ts +0 -41
  109. package/@types/core/sanitize/interface.d.ts +0 -10
  110. package/@types/core/sanitize/sanitize-uri.d.ts +0 -40
  111. package/@types/directive/aria/aria.d.ts +0 -104
  112. package/@types/directive/attrs/attrs.d.ts +0 -8
  113. package/@types/directive/bind/bind.d.ts +0 -18
  114. package/@types/directive/channel/channel.d.ts +0 -10
  115. package/@types/directive/class/class.d.ts +0 -3
  116. package/@types/directive/cloak/cloak.d.ts +0 -4
  117. package/@types/directive/controller/controller.d.ts +0 -4
  118. package/@types/directive/events/events.d.ts +0 -21
  119. package/@types/directive/form/form.d.ts +0 -264
  120. package/@types/directive/http/http.d.ts +0 -46
  121. package/@types/directive/if/if.d.ts +0 -10
  122. package/@types/directive/include/include.d.ts +0 -28
  123. package/@types/directive/init/init.d.ts +0 -4
  124. package/@types/directive/input/input.d.ts +0 -70
  125. package/@types/directive/messages/messages.d.ts +0 -63
  126. package/@types/directive/model/model.d.ts +0 -515
  127. package/@types/directive/model-options/model-options.d.ts +0 -56
  128. package/@types/directive/non-bindable/non-bindable.d.ts +0 -4
  129. package/@types/directive/observe/observe.d.ts +0 -9
  130. package/@types/directive/options/options.d.ts +0 -13
  131. package/@types/directive/ref/ref.d.ts +0 -11
  132. package/@types/directive/repeat/repeat.d.ts +0 -11
  133. package/@types/directive/script/script.d.ts +0 -10
  134. package/@types/directive/select/select.d.ts +0 -15
  135. package/@types/directive/setter/setter.d.ts +0 -12
  136. package/@types/directive/show-hide/show-hide.d.ts +0 -19
  137. package/@types/directive/style/style.d.ts +0 -4
  138. package/@types/directive/switch/switch.d.ts +0 -18
  139. package/@types/directive/transclude/transclude.d.ts +0 -10
  140. package/@types/directive/validators/validators.d.ts +0 -149
  141. package/@types/filters/filter.d.ts +0 -4
  142. package/@types/filters/filters.d.ts +0 -38
  143. package/@types/filters/limit-to.d.ts +0 -4
  144. package/@types/filters/order-by.d.ts +0 -7
  145. package/@types/index.d.ts +0 -2
  146. package/@types/ng.d.ts +0 -8
  147. package/@types/router/common/trace.d.ts +0 -66
  148. package/@types/router/directives/state-directives.d.ts +0 -46
  149. package/@types/router/directives/view-directive.d.ts +0 -138
  150. package/@types/router/glob/glob.d.ts +0 -81
  151. package/@types/router/hooks/core-resolvables.d.ts +0 -2
  152. package/@types/router/hooks/ignored-transition.d.ts +0 -1
  153. package/@types/router/hooks/invalid-transition.d.ts +0 -1
  154. package/@types/router/hooks/lazy-load.d.ts +0 -42
  155. package/@types/router/hooks/on-enter-exit-retain.d.ts +0 -3
  156. package/@types/router/hooks/redirect-to.d.ts +0 -4
  157. package/@types/router/hooks/resolve.d.ts +0 -4
  158. package/@types/router/hooks/update-globals.d.ts +0 -1
  159. package/@types/router/hooks/url.d.ts +0 -5
  160. package/@types/router/hooks/views.d.ts +0 -5
  161. package/@types/router/params/interface.d.ts +0 -606
  162. package/@types/router/params/param-factory.d.ts +0 -16
  163. package/@types/router/params/param-type.d.ts +0 -59
  164. package/@types/router/params/param-types.d.ts +0 -36
  165. package/@types/router/params/param.d.ts +0 -71
  166. package/@types/router/params/state-params.d.ts +0 -12
  167. package/@types/router/path/path-node.d.ts +0 -38
  168. package/@types/router/path/path-utils.d.ts +0 -88
  169. package/@types/router/resolve/interface.d.ts +0 -200
  170. package/@types/router/resolve/resolvable.d.ts +0 -50
  171. package/@types/router/resolve/resolve-context.d.ts +0 -102
  172. package/@types/router/router.d.ts +0 -47
  173. package/@types/router/state/interface.d.ts +0 -983
  174. package/@types/router/state/state-builder.d.ts +0 -95
  175. package/@types/router/state/state-matcher.d.ts +0 -7
  176. package/@types/router/state/state-object.d.ts +0 -83
  177. package/@types/router/state/state-queue-manager.d.ts +0 -29
  178. package/@types/router/state/state-registry.d.ts +0 -134
  179. package/@types/router/state/state-service.d.ts +0 -419
  180. package/@types/router/state/target-state.d.ts +0 -102
  181. package/@types/router/state/views.d.ts +0 -58
  182. package/@types/router/state-filters.d.ts +0 -39
  183. package/@types/router/template-factory.d.ts +0 -117
  184. package/@types/router/transition/hook-builder.d.ts +0 -45
  185. package/@types/router/transition/hook-registry.d.ts +0 -102
  186. package/@types/router/transition/interface.d.ts +0 -880
  187. package/@types/router/transition/reject-factory.d.ts +0 -43
  188. package/@types/router/transition/transition-event-type.d.ts +0 -24
  189. package/@types/router/transition/transition-hook.d.ts +0 -86
  190. package/@types/router/transition/transition-service.d.ts +0 -116
  191. package/@types/router/transition/transition.d.ts +0 -396
  192. package/@types/router/url/url-config.d.ts +0 -99
  193. package/@types/router/url/url-matcher.d.ts +0 -174
  194. package/@types/router/url/url-rule.d.ts +0 -161
  195. package/@types/router/url/url-rules.d.ts +0 -249
  196. package/@types/router/url/url-service.d.ts +0 -254
  197. package/@types/router/view/interface.d.ts +0 -44
  198. package/@types/router/view/view.d.ts +0 -149
  199. package/@types/router/view-scroll.d.ts +0 -10
  200. package/@types/services/anchor-scroll.d.ts +0 -25
  201. package/@types/services/cookie-reader.d.ts +0 -4
  202. package/@types/services/http/http.d.ts +0 -134
  203. package/@types/services/http-backend/http-backend.d.ts +0 -58
  204. package/@types/services/sce/sce.d.ts +0 -238
  205. package/@types/services/template-request.d.ts +0 -55
  206. package/@types/shared/common.d.ts +0 -197
  207. package/@types/shared/hof.d.ts +0 -108
  208. package/@types/shared/predicates.d.ts +0 -17
  209. package/@types/shared/queue.d.ts +0 -64
  210. package/@types/shared/strings.d.ts +0 -58
  211. package/@types/shared/test-utils.d.ts +0 -18
  212. package/docs/static/typedoc/classes/NgModule.html +0 -32
  213. package/src/router/params/README.md +0 -8
@@ -1,99 +0,0 @@
1
- /**
2
- * An API to customize the URL behavior and retrieve URL configuration
3
- *
4
- * This API is used to customize the behavior of the URL.
5
- * This includes optional trailing slashes ([[strictMode]]), case sensitivity ([[caseInsensitive]]),
6
- * and custom parameter encoding (custom [[type]]).
7
- *
8
- * It also has information about the location (url) configuration such as [[port]] and [[baseHref]].
9
- * This information can be used to build absolute URLs, such as
10
- * `https://example.com:443/basepath/state/substate?param1=a#hashvalue`;
11
- *
12
- * This API is found at `router.urlService.config` (see: [[UIRouter.urlService]], [[URLService.config]])
13
- */
14
- export class UrlConfigProvider {
15
- /** @type {ParamTypes} */
16
- paramTypes: ParamTypes;
17
- /** @type {boolean} */
18
- _isCaseInsensitive: boolean;
19
- /** @type {boolean} */
20
- _isStrictMode: boolean;
21
- /** @type {boolean} */
22
- _defaultSquashPolicy: boolean;
23
- $get: (() => any)[];
24
- /**
25
- * Defines whether URL matching should be case sensitive (the default behavior), or not.
26
- *
27
- * #### Example:
28
- * ```js
29
- * // Allow case insensitive url matches
30
- * urlService.config.caseInsensitive(true);
31
- * ```
32
- *
33
- * @param value `false` to match URL in a case sensitive manner; otherwise `true`;
34
- * @returns the current value of caseInsensitive
35
- */
36
- caseInsensitive(value: any): any;
37
- /**
38
- * Sets the default behavior when generating or matching URLs with default parameter values.
39
- *
40
- * #### Example:
41
- * ```js
42
- * // Remove default parameter values from the url
43
- * urlService.config.defaultSquashPolicy(true);
44
- * ```
45
- *
46
- * @param value A string that defines the default parameter URL squashing behavior.
47
- * - `nosquash`: When generating an href with a default parameter value, do not squash the parameter value from the URL
48
- * - `slash`: When generating an href with a default parameter value, squash (remove) the parameter value, and, if the
49
- * parameter is surrounded by slashes, squash (remove) one slash from the URL
50
- * - any other string, e.g. "~": When generating an href with a default parameter value, squash (remove)
51
- * the parameter value from the URL and replace it with this string.
52
- * @returns the current value of defaultSquashPolicy
53
- */
54
- defaultSquashPolicy(value: any): any;
55
- /**
56
- * Defines whether URLs should match trailing slashes, or not (the default behavior).
57
- *
58
- * #### Example:
59
- * ```js
60
- * // Allow optional trailing slashes
61
- * urlService.config.strictMode(false);
62
- * ```
63
- *
64
- * @param value `false` to match trailing slashes in URLs, otherwise `true`.
65
- * @returns the current value of strictMode
66
- */
67
- strictMode(value: any): any;
68
- /**
69
- * Creates and registers a custom [[ParamType]] object
70
- *
71
- * A custom parameter type can be used to generate URLs with typed parameters or custom encoding/decoding.
72
- *
73
- * #### Note: Register custom types *before using them* in a state definition.
74
- *
75
- * #### Example:
76
- * ```js
77
- * // Encode object parameter as JSON string
78
- * urlService.config.type('myjson', {
79
- * encode: (obj) => JSON.stringify(obj),
80
- * decode: (str) => JSON.parse(str),
81
- * is: (val) => typeof(val) === 'object',
82
- * pattern: /[^/]+/,
83
- * equals: (a, b) => _.isEqual(a, b),
84
- * });
85
- * ```
86
- *
87
- * See [[ParamTypeDefinition]] for more examples
88
- *
89
- * @param name The type name.
90
- * @param definition The type definition. See [[ParamTypeDefinition]] for information on the values accepted.
91
- * @param definitionFn A function that is injected before the app runtime starts.
92
- * The result of this function should be a [[ParamTypeDefinition]].
93
- * The result is merged into the existing `definition`.
94
- * See [[ParamType]] for information on the values accepted.
95
- *
96
- * @returns if only the `name` parameter was specified: the currently registered [[ParamType]] object, or undefined
97
- */
98
- type(name: any, definition: any, definitionFn: any): any;
99
- }
@@ -1,174 +0,0 @@
1
- /**
2
- * Matches URLs against patterns.
3
- *
4
- * Matches URLs against patterns and extracts named parameters from the path or the search
5
- * part of the URL.
6
- *
7
- * A URL pattern consists of a path pattern, optionally followed by '?' and a list of search (query)
8
- * parameters. Multiple search parameter names are separated by '&'. Search parameters
9
- * do not influence whether or not a URL is matched, but their values are passed through into
10
- * the matched parameters returned by [[UrlMatcher.exec]].
11
- *
12
- * - *Path parameters* are defined using curly brace placeholders (`/somepath/{param}`)
13
- * or colon placeholders (`/somePath/:param`).
14
- *
15
- * - *A parameter RegExp* may be defined for a param after a colon
16
- * (`/somePath/{param:[a-zA-Z0-9]+}`) in a curly brace placeholder.
17
- * The regexp must match for the url to be matched.
18
- * Should the regexp itself contain curly braces, they must be in matched pairs or escaped with a backslash.
19
- *
20
- * Note: a RegExp parameter will encode its value using either [[ParamTypes.path]] or [[ParamTypes.query]].
21
- *
22
- * - *Custom parameter types* may also be specified after a colon (`/somePath/{param:int}`) in curly brace parameters.
23
- * See [[UrlMatcherFactory.type]] for more information.
24
- *
25
- * - *Catch-all parameters* are defined using an asterisk placeholder (`/somepath/*catchallparam`).
26
- * A catch-all * parameter value will contain the remainder of the URL.
27
- *
28
- * ---
29
- *
30
- * Parameter names may contain only word characters (latin letters, digits, and underscore) and
31
- * must be unique within the pattern (across both path and search parameters).
32
- * A path parameter matches any number of characters other than '/'. For catch-all
33
- * placeholders the path parameter matches any number of characters.
34
- *
35
- * Examples:
36
- *
37
- * * `'/hello/'` - Matches only if the path is exactly '/hello/'. There is no special treatment for
38
- * trailing slashes, and patterns have to match the entire path, not just a prefix.
39
- * * `'/user/:id'` - Matches '/user/bob' or '/user/1234!!!' or even '/user/' but not '/user' or
40
- * '/user/bob/details'. The second path segment will be captured as the parameter 'id'.
41
- * * `'/user/{id}'` - Same as the previous example, but using curly brace syntax.
42
- * * `'/user/{id:[^/]*}'` - Same as the previous example.
43
- * * `'/user/{id:[0-9a-fA-F]{1,8}}'` - Similar to the previous example, but only matches if the id
44
- * parameter consists of 1 to 8 hex digits.
45
- * * `'/files/{path:.*}'` - Matches any URL starting with '/files/' and captures the rest of the
46
- * path into the parameter 'path'.
47
- * * `'/files/*path'` - ditto.
48
- * * `'/calendar/{start:date}'` - Matches "/calendar/2014-11-12" (because the pattern defined
49
- * in the built-in `date` ParamType matches `2014-11-12`) and provides a Date object in $stateParams.start
50
- *
51
- */
52
- export class UrlMatcher {
53
- /** @internal Given a matcher, return an array with the matcher's path segments and path params, in order */
54
- static pathSegmentsAndParams(matcher: any): any;
55
- /** @internal Given a matcher, return an array with the matcher's query params */
56
- static queryParams(matcher: any): any;
57
- /**
58
- * Compare two UrlMatchers
59
- *
60
- * This comparison function converts a UrlMatcher into static and dynamic path segments.
61
- * Each static path segment is a static string between a path separator (slash character).
62
- * Each dynamic segment is a path parameter.
63
- *
64
- * The comparison function sorts static segments before dynamic ones.
65
- */
66
- static compare(a: any, b: any): number;
67
- /**
68
- * @param pattern The pattern to compile into a matcher.
69
- * @param paramTypes The [[ParamTypes]] registry
70
- * @param paramFactory A [[ParamFactory]] object
71
- * @param config A [[UrlMatcherCompileConfig]] configuration object
72
- */
73
- constructor(pattern: any, paramTypes: any, paramFactory: any, config: any);
74
- _cache: {
75
- path: UrlMatcher[];
76
- };
77
- _children: any[];
78
- _params: any[];
79
- _segments: any[];
80
- _compiled: any[];
81
- config: any;
82
- pattern: any;
83
- /**
84
- * Creates a new concatenated UrlMatcher
85
- *
86
- * Builds a new UrlMatcher by appending another UrlMatcher to this one.
87
- *
88
- * @param url A `UrlMatcher` instance to append as a child of the current `UrlMatcher`.
89
- */
90
- append(url: any): any;
91
- isRoot(): boolean;
92
- /** Returns the input pattern string */
93
- toString(): any;
94
- _getDecodedParamValue(value: any, param: any): any;
95
- /**
96
- * Tests the specified url/path against this matcher.
97
- *
98
- * Tests if the given url matches this matcher's pattern, and returns an object containing the captured
99
- * parameter values. Returns null if the path does not match.
100
- *
101
- * The returned object contains the values
102
- * of any search parameters that are mentioned in the pattern, but their value may be null if
103
- * they are not present in `search`. This means that search parameters are always treated
104
- * as optional.
105
- *
106
- * #### Example:
107
- * ```js
108
- * new UrlMatcher('/user/{id}?q&r').exec('/user/bob', {
109
- * x: '1', q: 'hello'
110
- * });
111
- * // returns { id: 'bob', q: 'hello', r: null }
112
- * ```
113
- *
114
- * @param path The URL path to match, e.g. `$location.getPath()`.
115
- * @param search URL search parameters, e.g. `$location.getSearch()`.
116
- * @param hash URL hash e.g. `$location.getHash()`.
117
- *
118
- * @returns The captured parameter values.
119
- */
120
- exec(
121
- path: any,
122
- search: {},
123
- hash: any,
124
- ): {
125
- "#": any;
126
- };
127
- /**
128
- * @internal
129
- * Returns all the [[Param]] objects of all path and search parameters of this pattern in order of appearance.
130
- *
131
- * @returns {Array.<Param>} An array of [[Param]] objects. Must be treated as read-only. If the
132
- * pattern has no parameters, an empty array is returned.
133
- */
134
- parameters(opts?: {}): Array<Param>;
135
- /**
136
- * @internal
137
- * Returns a single parameter from this UrlMatcher by id
138
- *
139
- * @param id
140
- * @param opts
141
- * @returns {Param|any|boolean|UrlMatcher|null}
142
- */
143
- parameter(id: any, opts?: {}): Param | any | boolean | UrlMatcher | null;
144
- /**
145
- * Validates the input parameter values against this UrlMatcher
146
- *
147
- * Checks an object hash of parameters to validate their correctness according to the parameter
148
- * types of this `UrlMatcher`.
149
- *
150
- * @param params The object hash of parameters to validate.
151
- * @returns Returns `true` if `params` validates, otherwise `false`.
152
- */
153
- validates(params: any): any;
154
- /**
155
- * Given a set of parameter values, creates a URL from this UrlMatcher.
156
- *
157
- * Creates a URL that matches this pattern by substituting the specified values
158
- * for the path and search parameters.
159
- *
160
- * #### Example:
161
- * ```js
162
- * new UrlMatcher('/user/{id}?q').format({ id:'bob', q:'yes' });
163
- * // returns '/user/bob?q=yes'
164
- * ```
165
- *
166
- * @param values the values to substitute for the parameters in this pattern.
167
- * @returns the formatted URL (path and optionally search part).
168
- */
169
- format(values?: {}): string;
170
- }
171
- export namespace UrlMatcher {
172
- let nameValidator: RegExp;
173
- }
174
- import { Param } from "../params/param.js";
@@ -1,161 +0,0 @@
1
- /**
2
- * Creates a [[UrlRule]]
3
- *
4
- * Creates a [[UrlRule]] from a:
5
- *
6
- * - `string`
7
- * - [[UrlMatcher]]
8
- * - `RegExp`
9
- * - [[StateObject]]
10
- */
11
- export class UrlRuleFactory {
12
- /**
13
- * @param {import('../url/url-service.js').UrlService} urlService
14
- * @param {import('../state/state-service.js').StateProvider} stateService
15
- * @param {import('../router.js').Router} routerGlobals
16
- */
17
- constructor(
18
- urlService: import("../url/url-service.js").UrlService,
19
- stateService: import("../state/state-service.js").StateProvider,
20
- routerGlobals: import("../router.js").Router,
21
- );
22
- urlService: import("../url/url-service.js").UrlService;
23
- stateService: import("../state/state-service.js").StateProvider;
24
- routerGlobals: import("../router.js").Router;
25
- /**
26
- *
27
- * @param {*} what
28
- * @param {*} handler
29
- * @returns {BaseUrlRule}
30
- */
31
- create(what: any, handler: any): BaseUrlRule;
32
- /**
33
- * A UrlRule which matches based on a UrlMatcher
34
- *
35
- * The `handler` may be either a `string`, a [[UrlRuleHandlerFn]] or another [[UrlMatcher]]
36
- *
37
- * ## Handler as a function
38
- *
39
- * If `handler` is a function, the function is invoked with:
40
- *
41
- * - matched parameter values ([[RawParams]] from [[UrlMatcher.exec]])
42
- * - url: the current Url ([[UrlParts]])
43
- * - router: the router object ([[UIRouter]])
44
- *
45
- * #### Example:
46
- * ```js
47
- * var urlMatcher = $umf.compile("/foo/:fooId/:barId");
48
- * var rule = factory.fromUrlMatcher(urlMatcher, match => "/home/" + match.fooId + "/" + match.barId);
49
- * var match = rule.match('/foo/123/456'); // results in { fooId: '123', barId: '456' }
50
- * var result = rule.handler(match); // '/home/123/456'
51
- * ```
52
- *
53
- * ## Handler as UrlMatcher
54
- *
55
- * If `handler` is a UrlMatcher, the handler matcher is used to create the new url.
56
- * The `handler` UrlMatcher is formatted using the matched param from the first matcher.
57
- * The url is replaced with the result.
58
- *
59
- * #### Example:
60
- * ```js
61
- * var urlMatcher = $umf.compile("/foo/:fooId/:barId");
62
- * var handler = $umf.compile("/home/:fooId/:barId");
63
- * var rule = factory.fromUrlMatcher(urlMatcher, handler);
64
- * var match = rule.match('/foo/123/456'); // results in { fooId: '123', barId: '456' }
65
- * var result = rule.handler(match); // '/home/123/456'
66
- * ```
67
- */
68
- fromUrlMatcher(
69
- urlMatcher: any,
70
- handler: any,
71
- ): BaseUrlRule & {
72
- urlMatcher: any;
73
- matchPriority: (params: any) => number;
74
- type: string;
75
- };
76
- /**
77
- * A UrlRule which matches a state by its url
78
- *
79
- * #### Example:
80
- * ```js
81
- * var rule = factory.fromState($state.get('foo'), router);
82
- * var match = rule.match('/foo/123/456'); // results in { fooId: '123', barId: '456' }
83
- * var result = rule.handler(match);
84
- * // Starts a transition to 'foo' with params: { fooId: '123', barId: '456' }
85
- * ```
86
- */
87
- fromState(
88
- stateOrDecl: any,
89
- stateService: any,
90
- globals: any,
91
- ): BaseUrlRule & {
92
- urlMatcher: any;
93
- matchPriority: (params: any) => number;
94
- type: string;
95
- } & {
96
- state: any;
97
- type: string;
98
- };
99
- /**
100
- * A UrlRule which matches based on a regular expression
101
- *
102
- * The `handler` may be either a [[UrlRuleHandlerFn]] or a string.
103
- *
104
- * ## Handler as a function
105
- *
106
- * If `handler` is a function, the function is invoked with:
107
- *
108
- * - regexp match array (from `regexp`)
109
- * - url: the current Url ([[UrlParts]])
110
- * - router: the router object ([[UIRouter]])
111
- *
112
- * #### Example:
113
- * ```js
114
- * var rule = factory.fromRegExp(/^\/foo\/(bar|baz)$/, match => "/home/" + match[1])
115
- * var match = rule.match('/foo/bar'); // results in [ '/foo/bar', 'bar' ]
116
- * var result = rule.handler(match); // '/home/bar'
117
- * ```
118
- *
119
- * ## Handler as string
120
- *
121
- * If `handler` is a string, the url is *replaced by the string* when the Rule is invoked.
122
- * The string is first interpolated using `string.replace()` style pattern.
123
- *
124
- * #### Example:
125
- * ```js
126
- * var rule = factory.fromRegExp(/^\/foo\/(bar|baz)$/, "/home/$1")
127
- * var match = rule.match('/foo/bar'); // results in [ '/foo/bar', 'bar' ]
128
- * var result = rule.handler(match); // '/home/bar'
129
- * ```
130
- */
131
- fromRegExp(
132
- regexp: any,
133
- handler: any,
134
- ): BaseUrlRule & {
135
- regexp: any;
136
- type: string;
137
- };
138
- }
139
- export namespace UrlRuleFactory {
140
- function isUrlRule(obj: any): boolean;
141
- }
142
- /**
143
- * A base rule which calls `match`
144
- *
145
- * The value from the `match` function is passed through to the `handler`.
146
- */
147
- export class BaseUrlRule {
148
- constructor(match: any, handler: any);
149
- match: any;
150
- type: string;
151
- $id: number;
152
- _group: any;
153
- handler: any;
154
- priority: any;
155
- /**
156
- * This function should be overridden
157
- * @param {*} [params]
158
- * @returns {number}
159
- */
160
- matchPriority(params?: any): number;
161
- }
@@ -1,249 +0,0 @@
1
- /**
2
- * API for managing URL rules
3
- *
4
- * This API is used to create and manage URL rules.
5
- * URL rules are a mechanism to respond to specific URL patterns.
6
- *
7
- * The most commonly used methods are [[otherwise]] and [[when]].
8
- *
9
- * This API is found at `$url.rules` (see: [[UIRouter.urlService]], [[URLService.rules]])
10
- */
11
- export class UrlRules {
12
- /** @param {UrlRuleFactory} urlRuleFactory */
13
- constructor(urlRuleFactory: UrlRuleFactory);
14
- _sortFn: typeof defaultRuleSortFn;
15
- _rules: any[];
16
- _id: number;
17
- urlRuleFactory: UrlRuleFactory;
18
- /**
19
- * Defines the initial state, path, or behavior to use when the app starts.
20
- *
21
- * This rule defines the initial/starting state for the application.
22
- *
23
- * This rule is triggered the first time the URL is checked (when the app initially loads).
24
- * The rule is triggered only when the url matches either `""` or `"/"`.
25
- *
26
- * Note: The rule is intended to be used when the root of the application is directly linked to.
27
- * When the URL is *not* `""` or `"/"` and doesn't match other rules, the [[otherwise]] rule is triggered.
28
- * This allows 404-like behavior when an unknown URL is deep-linked.
29
- *
30
- * #### Example:
31
- * Start app at `home` state.
32
- * ```js
33
- * .initial({ state: 'home' });
34
- * ```
35
- *
36
- * #### Example:
37
- * Start app at `/home` (by url)
38
- * ```js
39
- * .initial('/home');
40
- * ```
41
- *
42
- * #### Example:
43
- * When no other url rule matches, go to `home` state
44
- * ```js
45
- * .initial((matchValue, url, router) => {
46
- * console.log('initial state');
47
- * return { state: 'home' };
48
- * })
49
- * ```
50
- *
51
- * @param handler The initial state or url path, or a function which returns the state or url path (or performs custom logic).
52
- */
53
- initial(handler: any): void;
54
- /**
55
- * Defines the state, url, or behavior to use when no other rule matches the URL.
56
- *
57
- * This rule is matched when *no other rule* matches.
58
- * It is generally used to handle unknown URLs (similar to "404" behavior, but on the client side).
59
- *
60
- * - If `handler` a string, it is treated as a url redirect
61
- *
62
- * #### Example:
63
- * When no other url rule matches, redirect to `/index`
64
- * ```js
65
- * .otherwise('/index');
66
- * ```
67
- *
68
- * - If `handler` is an object with a `state` property, the state is activated.
69
- *
70
- * #### Example:
71
- * When no other url rule matches, redirect to `home` and provide a `dashboard` parameter value.
72
- * ```js
73
- * .otherwise({ state: 'home', params: { dashboard: 'default' } });
74
- * ```
75
- *
76
- * - If `handler` is a function, the function receives the current url ([[UrlParts]]) and the [[UIRouter]] object.
77
- * The function can perform actions, and/or return a value.
78
- *
79
- * #### Example:
80
- * When no other url rule matches, manually trigger a transition to the `home` state
81
- * ```js
82
- * .otherwise((matchValue, urlParts, router) => {
83
- * router.stateService.go('home');
84
- * });
85
- * ```
86
- *
87
- * #### Example:
88
- * When no other url rule matches, go to `home` state
89
- * ```js
90
- * .otherwise((matchValue, urlParts, router) => {
91
- * return { state: 'home' };
92
- * });
93
- * ```
94
- *
95
- * @param handler The url path to redirect to, or a function which returns the url path (or performs custom logic).
96
- */
97
- otherwise(handler: any): void;
98
- _otherwiseFn: import("./url-rule.js").BaseUrlRule;
99
- _sorted: boolean;
100
- /**
101
- * Remove a rule previously registered
102
- *
103
- * @param rule the matcher rule that was previously registered using [[rule]]
104
- */
105
- removeRule(rule: any): void;
106
- /**
107
- * Manually adds a URL Rule.
108
- *
109
- * Usually, a url rule is added using [[StateDeclaration.url]] or [[when]].
110
- * This api can be used directly for more control (to register a [[BaseUrlRule]], for example).
111
- * Rules can be created using [[urlRuleFactory]], or created manually as simple objects.
112
- *
113
- * A rule should have a `match` function which returns truthy if the rule matched.
114
- * It should also have a `handler` function which is invoked if the rule is the best match.
115
- *
116
- * @return a function that deregisters the rule
117
- */
118
- rule(rule: any): () => void;
119
- /**
120
- * Gets all registered rules
121
- *
122
- * @returns an array of all the registered rules
123
- */
124
- rules(): any[];
125
- /**
126
- * Defines URL Rule priorities
127
- *
128
- * More than one rule ([[UrlRule]]) might match a given URL.
129
- * This `compareFn` is used to sort the rules by priority.
130
- * Higher priority rules should sort earlier.
131
- *
132
- * The [[defaultRuleSortFn]] is used by default.
133
- *
134
- * You only need to call this function once.
135
- * The `compareFn` will be used to sort the rules as each is registered.
136
- *
137
- * If called without any parameter, it will re-sort the rules.
138
- *
139
- * ---
140
- *
141
- * Url rules may come from multiple sources: states's urls ([[StateDeclaration.url]]), [[when]], and [[rule]].
142
- * Each rule has a (user-provided) [[UrlRule.priority]], a [[UrlRule.type]], and a [[UrlRule.$id]]
143
- * The `$id` is is the order in which the rule was registered.
144
- *
145
- * The sort function should use these data, or data found on a specific type
146
- * of [[UrlRule]] (such as [[StateRule.state]]), to order the rules as desired.
147
- *
148
- * #### Example:
149
- * This compare function prioritizes rules by the order in which the rules were registered.
150
- * A rule registered earlier has higher priority.
151
- *
152
- * ```js
153
- * function compareFn(a, b) {
154
- * return a.$id - b.$id;
155
- * }
156
- * ```
157
- *
158
- * @param compareFn a function that compares to [[UrlRule]] objects.
159
- * The `compareFn` should abide by the `Array.sort` compare function rules.
160
- * Given two rules, `a` and `b`, return a negative number if `a` should be higher priority.
161
- * Return a positive number if `b` should be higher priority.
162
- * Return `0` if the rules are identical.
163
- *
164
- * See the [mozilla reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Description)
165
- * for details.
166
- */
167
- sort(compareFn: any): void;
168
- ensureSorted(): void;
169
- stableSort(arr: any, compareFn: any): any;
170
- /**
171
- * Registers a `matcher` and `handler` for custom URLs handling.
172
- *
173
- * The `matcher` can be:
174
- *
175
- * - a [[UrlMatcher]]: See: [[UrlMatcherFactory.compile]]
176
- * - a `string`: The string is compiled to a [[UrlMatcher]]
177
- * - a `RegExp`: The regexp is used to match the url.
178
- *
179
- * The `handler` can be:
180
- *
181
- * - a string: The url is redirected to the value of the string.
182
- * - a function: The url is redirected to the return value of the function.
183
- *
184
- * ---
185
- *
186
- * When the `handler` is a `string` and the `matcher` is a `UrlMatcher` (or string), the redirect
187
- * string is interpolated with parameter values.
188
- *
189
- * #### Example:
190
- * When the URL is `/foo/123` the rule will redirect to `/bar/123`.
191
- * ```js
192
- * .when("/foo/:param1", "/bar/:param1")
193
- * ```
194
- *
195
- * ---
196
- *
197
- * When the `handler` is a string and the `matcher` is a `RegExp`, the redirect string is
198
- * interpolated with capture groups from the RegExp.
199
- *
200
- * #### Example:
201
- * When the URL is `/foo/123` the rule will redirect to `/bar/123`.
202
- * ```js
203
- * .when(new RegExp("^/foo/(.*)$"), "/bar/$1");
204
- * ```
205
- *
206
- * ---
207
- *
208
- * When the handler is a function, it receives the matched value, the current URL, and the `UIRouter` object (See [[UrlRuleHandlerFn]]).
209
- * The "matched value" differs based on the `matcher`.
210
- * For [[UrlMatcher]]s, it will be the matched state params.
211
- * For `RegExp`, it will be the match array from `regexp.exec()`.
212
- *
213
- * If the handler returns a string, the URL is redirected to the string.
214
- *
215
- * #### Example:
216
- * When the URL is `/foo/123` the rule will redirect to `/bar/123`.
217
- * ```js
218
- * .when(new RegExp("^/foo/(.*)$"), match => "/bar/" + match[1]);
219
- * ```
220
- *
221
- * Note: the `handler` may also invoke arbitrary code, such as `$state.go()`
222
- *
223
- * @param matcher A pattern `string` to match, compiled as a [[UrlMatcher]], or a `RegExp`.
224
- * @param handler The path to redirect to, or a function that returns the path.
225
- * @param options `{ priority: number }`
226
- *
227
- * @return the registered [[UrlRule]]
228
- */
229
- when(
230
- matcher: any,
231
- handler: any,
232
- options: any,
233
- ): import("./url-rule.js").BaseUrlRule;
234
- }
235
- /**
236
- * Default rule priority sorting function.
237
- *
238
- * Sorts rules by:
239
- *
240
- * - Explicit priority (set rule priority using [[UrlRules.when]])
241
- * - Rule type (STATE: 4, URLMATCHER: 4, REGEXP: 3, RAW: 2, OTHER: 1)
242
- * - `UrlMatcher` specificity ([[UrlMatcher.compare]]): works for STATE and URLMATCHER types to pick the most specific rule.
243
- * - Rule registration order (for rule types other than STATE and URLMATCHER)
244
- * - Equally sorted State and UrlMatcher rules will each match the URL.
245
- * Then, the *best* match is chosen based on how many parameter values were matched.
246
- */
247
- declare function defaultRuleSortFn(a: any, b: any): number;
248
- import { UrlRuleFactory } from "./url-rule.js";
249
- export {};