|
| 1 | +### ui-router-core changes |
| 2 | +# [3.0.0](https://github.com/ui-router/core/compare/2.0.0...3.0.0) (2017-01-08) |
| 3 | + |
| 4 | + |
| 5 | +### Bug Fixes |
| 6 | + |
| 7 | +* **lazyLoad:** Use UrlService.match() to retry url sync after successful lazy load triggered by url ([8c2461d](https://github.com/ui-router/core/commit/8c2461d)), closes [#19](https://github.com/ui-router/core/issues/19) |
| 8 | +* **Params:** `params: { foo: { raw: true } }` overrides `ParamType.raw` ([aefeabf](https://github.com/ui-router/core/commit/aefeabf)) |
| 9 | +* **Params:** Mark all query parameters as optional ([7334d98](https://github.com/ui-router/core/commit/7334d98)) |
| 10 | +* **Params:** Check for null in `int` param type `is()` check ([aa551e4](https://github.com/ui-router/core/commit/aa551e4)), closes [#3197](https://github.com/ui-router/core/issues/3197) |
| 11 | +* **Transition:** Use { location: replace } when redirecting a transtition in response to a URL sync ([23e2b78](https://github.com/ui-router/core/commit/23e2b78)) |
| 12 | +* **UrlService:** Wire urlMatcherFactory and urlRouter functions ([a7b58d6](https://github.com/ui-router/core/commit/a7b58d6)) |
| 13 | +* **vanilla:** vanilla locations: do not parse "empty string" query key parameter ([f949480](https://github.com/ui-router/core/commit/f949480)) |
| 14 | + |
| 15 | + |
| 16 | +### Features |
| 17 | + |
| 18 | +* (CoreServices) Move `location` and `locationConfig` from `services` to `UIRouter.locationService` and `UIRouter.locationConfig`. ([029fb00](https://github.com/ui-router/core/commit/029fb00)) |
| 19 | +* Built-in `string` parameter type no longer encodes slashes as `~2F` nor tildes as `~~` ([72bb2d8](https://github.com/ui-router/core/commit/72bb2d8)) |
| 20 | +* Move `html5Mode` and `hashPrefix` from `LocationServices` to `LocationConfig` interface ([9d316a7](https://github.com/ui-router/core/commit/9d316a7)) |
| 21 | +* Order URL Matching Rules by priority, not registration order ([eb2f5d7](https://github.com/ui-router/core/commit/eb2f5d7)) |
| 22 | +* Path/Query parameters no longer default to `string` param type ([72bb2d8](https://github.com/ui-router/core/commit/72bb2d8)) |
| 23 | +* Remove `getResolveValue` and `getResolvable` methods from `Transition` in favor of `injector().get()` and `injector().getAsync()` ([111d259](https://github.com/ui-router/core/commit/111d259)) |
| 24 | +* Replace `LocationServices.setUrl` with `LocationServices.url` ([4c39dcb](https://github.com/ui-router/core/commit/4c39dcb)) |
| 25 | +* Replace UrlRouterProvider/UrlRouter with just UrlRouter ([fddd1e2](https://github.com/ui-router/core/commit/fddd1e2)) |
| 26 | +* **hash:** Change the hash parameter type (`'#'`) to `inherit: false` so it is cleared out when another transition occurs. ([849f84f](https://github.com/ui-router/core/commit/849f84f)), closes [#3245](https://github.com/ui-router/core/issues/3245) [#3218](https://github.com/ui-router/core/issues/3218) [#3017](https://github.com/ui-router/core/issues/3017) |
| 27 | +* **LocationServices:** Add a `parts()` method which returns the URL parts as an object ([32e64f0](https://github.com/ui-router/core/commit/32e64f0)) |
| 28 | +* **Params:** Add `path` and `query` param types ([72bb2d8](https://github.com/ui-router/core/commit/72bb2d8)) |
| 29 | +* **Params:** add option to use generic type for Transition.params ([#17](https://github.com/ui-router/core/issues/17)) ([eb12ec8](https://github.com/ui-router/core/commit/eb12ec8)), closes [#16](https://github.com/ui-router/core/issues/16) |
| 30 | +* **Params:** Allow `inherit: false` specified per parameter or type ([849f84f](https://github.com/ui-router/core/commit/849f84f)) |
| 31 | +* **Resolve:** implement NOWAIT policy: Do not wait for resolves before completing a transition. ([05d4c73](https://github.com/ui-router/core/commit/05d4c73)), closes [#3243](https://github.com/ui-router/core/issues/3243) [#2691](https://github.com/ui-router/core/issues/2691) |
| 32 | +* **Transition:** Add Transition.originalTransition() to return the initial transition in a chain of redirects ([4fe39e3](https://github.com/ui-router/core/commit/4fe39e3)) |
| 33 | +* **Transition:** Allow `injector()` to retrieve resolves for the exiting states/path ([df502e8](https://github.com/ui-router/core/commit/df502e8)) |
| 34 | +* **Transition:** Allow a plain object `ResolvableLiteral` in `Transition.addResolvable` ([ad9ae81](https://github.com/ui-router/core/commit/ad9ae81)) |
| 35 | +* **Transition:** Make Transition.params() immutable to avoid confusion about mutability ([0162212](https://github.com/ui-router/core/commit/0162212)) |
| 36 | +* **UrlMatcher:** Add comparison function by UrlMatcher specificity ([eb2f5d7](https://github.com/ui-router/core/commit/eb2f5d7)) |
| 37 | +* **UrlRouter:** sort url rules by specificity, not by registration order. ([eb2f5d7](https://github.com/ui-router/core/commit/eb2f5d7)) |
| 38 | +* **UrlService:** allow eager or lazy binding of location objects during construction ([7e0a8af](https://github.com/ui-router/core/commit/7e0a8af)) |
| 39 | +* **UrlService:** Add `match()`: given a URL, return the best matching Url Rule ([32e64f0](https://github.com/ui-router/core/commit/32e64f0)) |
| 40 | + |
| 41 | + |
| 42 | +### BREAKING CHANGES |
| 43 | + |
| 44 | +* BREAKING CHANGE: Remove `getResolveValue` and `getResolvable` methods from `Transition` in favor of `injector().get()` and `injector().getAsync()` |
| 45 | + |
| 46 | +In beta.3, the Transition APIs: `injector()`, `getResolvable`, and `getResolveValue` duplicated functionality. |
| 47 | + |
| 48 | +Instead of: |
| 49 | +```js |
| 50 | +trans.getResolveValue('myResolve'); |
| 51 | +``` |
| 52 | +use: |
| 53 | +```js |
| 54 | +trans.injector().get('myResolve') |
| 55 | +``` |
| 56 | +* BREAKING CHANGE: Order URL Matching Rules by priority, not registration order |
| 57 | + |
| 58 | +URL Rules can come from registered states' `.url`s, calling `.when()`, or calling `.rule()`. |
| 59 | +It's possible that two or more URL Rules could match the URL. |
| 60 | + |
| 61 | +### Previously |
| 62 | + |
| 63 | +Previously, url rules were matched in the order in which they were registered. |
| 64 | +The rule which was registered first would handle the URL change. |
| 65 | + |
| 66 | +### Now |
| 67 | + |
| 68 | +Now, the URL rules are sorted according to a sort function. |
| 69 | +More specific rules are preferred over less specific rules |
| 70 | + |
| 71 | +### Why |
| 72 | + |
| 73 | +It's possible to have multiple url rules that match a given URL. |
| 74 | +Consider the following states: |
| 75 | + |
| 76 | + - `{ name: 'books', url: '/books/index' }''` |
| 77 | + - `{ name: 'book', url: '/books/:bookId' }''` |
| 78 | + |
| 79 | +Both states match when the url is `/books/index`. |
| 80 | +Additionally, you might have some custom url rewrite rules such as: |
| 81 | + |
| 82 | + `.when('/books/list', '/books/index')`. |
| 83 | + |
| 84 | +The `book` state also matches when the rewrite rule is matched. |
| 85 | + |
| 86 | +Previously, we simply used the first rule that matched. However, now that lazy loading is officially supported, it can be difficult for developers to ensure the rules are registered in the right order. |
| 87 | + |
| 88 | +Instead, we now prioritize url rules by how specific they are. More specific rules are matched earlier than less specific rules. |
| 89 | +We split the path on `/`. A static segment (such as `index` in the example) is more specific than a parameter (such as`:bookId`). |
| 90 | + |
| 91 | +### More Details |
| 92 | + |
| 93 | +The built-in rule sorting function (see `UrlRouter.defaultRuleSortFn`) sorts rules in this order: |
| 94 | + |
| 95 | +- Explicit priority: `.when('/foo', '/bar', { priority: 1 })` (default priority is 0) |
| 96 | +- Rule Type: |
| 97 | + - UrlMatchers first (registered states and `.when(string, ...)`) |
| 98 | + - then regular Expressions (`.when(regexp, ...)`) |
| 99 | + - finally, everything else (`.rule()`) |
| 100 | +- UrlMatcher specificity: static path segments are more specific than variables (see `UrlMatcher.compare`) |
| 101 | +- Registration order (except for UrlMatcher based rules) |
| 102 | + |
| 103 | +For complete control, a custom sort function can be registered with `UrlService.rules.sort(sortFn)` |
| 104 | + |
| 105 | +### Query params |
| 106 | + |
| 107 | +Because query parameters are optional, they are not considered during sorting. |
| 108 | +For example, both these rules will match when the url is `'/foo/bar'`: |
| 109 | + |
| 110 | +``` |
| 111 | +.when('/foo/bar', doSomething); |
| 112 | +.when('/foo/bar?queryparam', doSomethingElse); |
| 113 | +``` |
| 114 | + |
| 115 | +To choose the most specific rule, we match both rules, then choose the rule with the "best ratio" of matched optional parameters (see `UrlRuleFactory.fromUrlMatcher`) |
| 116 | + |
| 117 | +This allows child states to be defined with only query params for a URL. |
| 118 | +The state only activates when the query parameter is present. |
| 119 | + |
| 120 | +``` |
| 121 | +.state('parent', { url: '/parent' }); |
| 122 | +.state('parent.child', { url: '?queryParam' }); |
| 123 | +``` |
| 124 | + |
| 125 | +## Restoring the previous behavior |
| 126 | + |
| 127 | +For backwards compatibility, register a sort function which sorts by the registration order: |
| 128 | + |
| 129 | +```js |
| 130 | +myApp.config(function ($urlServiceProvider) { |
| 131 | + |
| 132 | + function sortByRegistrationOrder(a, b) { |
| 133 | + return a.$id - b.$id; |
| 134 | + } |
| 135 | + |
| 136 | + $urlServiceProvider.rules.sort(sortByRegistrationOrder); |
| 137 | + |
| 138 | +}); |
| 139 | +``` |
| 140 | +* BREAKING CHANGE: Replace `LocationServices.setUrl` with `LocationServices.url` |
| 141 | + |
| 142 | +This makes `url()` a getter/setter. It also adds the optional `state` parameter to pass through to the browser history when using pushstate. |
| 143 | +End users should not notice this change, but plugin authors may. |
| 144 | +* BREAKING CHANGE: Replace UrlRouterProvider/UrlRouter with just UrlRouter |
| 145 | + |
| 146 | +The configuration functions from the provider object have been integrated into the normal UrlRouter object. |
| 147 | +The `UIRouter` object no longer has a `uriRouterProvider`, but the equivalent functions can be found on `uiRouter` |
| 148 | + |
| 149 | +One difference between the old functions on `urlRouterProvider` and the new ones on `uriRouter` is that new functions do not accept injectable functions. |
| 150 | +* BREAKING CHANGE: Built-in `string` parameter type no longer encodes slashes as `~2F` nor tildes as `~~` |
| 151 | + |
| 152 | +Previously, the `string` parameter type pre-encoded tilde chars (`~`) as two tilde chars (`~~`) and slashes (`/`) as `~2F`. |
| 153 | + |
| 154 | +Now, the `string` parameter type does not pre-encode slashes nor tildes. |
| 155 | +If you rely on the previous encoding, create a custom parameter type that implements the behavior: |
| 156 | + |
| 157 | +```js |
| 158 | +urlMatcherFactory.type('tildes', { |
| 159 | + encode: (val: any) => |
| 160 | + val != null ? val.toString().replace(/(~|\/)/g, m => ({ '~': '~~', '/': '~2F' }[m])) : val; |
| 161 | + decode: (val: string) => |
| 162 | + val != null ? val.toString().replace(/(~~|~2F)/g, m => ({ '~~': '~', '~2F': '/' }[m])) : val; |
| 163 | + pattern: /[^/]*/ |
| 164 | +}); |
| 165 | +``` |
| 166 | +* BREAKING CHANGE: Path/Query parameters no longer default to `string` param type |
| 167 | + |
| 168 | +Previously, if a url parameter's type was not specified (in either the path or query), it defaulted to the `string` type. |
| 169 | + |
| 170 | +Now, path parameters default to the new `path` type and query parameters default to the new `query` type. |
| 171 | + |
| 172 | +**In Angular 1 only**, the new `path` parameter type retains the old behavior of pre-encoding `~` to `~~` and `/` to `~2F` |
| 173 | +* BREAKING CHANGE: (CoreServices) Move `location` and `locationConfig` from `services` to `UIRouter.locationService` and `UIRouter.locationConfig`. |
| 174 | + |
| 175 | +The core `services` object is a mutable object which each framework was monkey patching. |
| 176 | +This change removes the requirement to monkey patch a global mutable object. |
| 177 | +Instead, framework implementors should pass the `LocationServices` and `LocationConfig` implementations into the `UIRouter` constructor. |
| 178 | + |
| 179 | +### End Users |
| 180 | + |
| 181 | +End users who were accessing `services.location` or `services.locationConfig` should access these off the `UIRouter` instance instead. |
| 182 | +* BREAKING CHANGE: Move `html5Mode` and `hashPrefix` from `LocationServices` to `LocationConfig` interface |
| 183 | + |
| 184 | +### End users should not notice |
| 185 | + |
| 186 | + |
| 187 | + |
1 | 188 | ### ui-router-core changes
|
2 | 189 | # [2.0.0](https://github.com/ui-router/core/compare/1.0.1...2.0.0) (2016-12-09)
|
3 | 190 |
|
|
0 commit comments