ember-source 4.8.0-alpha.5 → 4.8.0-beta.2

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 (244) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/blueprints/helper/files/__root__/{__collection__ → helpers}/__name__.ts +0 -0
  3. package/blueprints/helper/index.js +0 -15
  4. package/blueprints/helper-test/index.js +0 -3
  5. package/blueprints/helper-test/mocha-0.12-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
  6. package/blueprints/helper-test/mocha-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
  7. package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.ts +0 -0
  8. package/blueprints/helper-test/qunit-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
  9. package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.ts +0 -0
  10. package/blueprints-js/helper/files/__root__/{__collection__ → helpers}/__name__.js +0 -0
  11. package/blueprints-js/helper-test/mocha-0.12-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
  12. package/blueprints-js/helper-test/mocha-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
  13. package/blueprints-js/helper-test/mocha-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
  14. package/blueprints-js/helper-test/qunit-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
  15. package/blueprints-js/helper-test/qunit-rfc-232-files/__root__/__testType__/{__collection__ → helpers}/__name__-test.js +0 -0
  16. package/build-metadata.json +3 -3
  17. package/dist/dependencies/router_js.js +1 -1
  18. package/dist/ember-template-compiler.js +675 -18
  19. package/dist/ember-template-compiler.map +1 -1
  20. package/dist/ember-testing.js +11 -11
  21. package/dist/ember-testing.map +1 -1
  22. package/dist/ember.debug.js +19576 -20510
  23. package/dist/ember.debug.map +1 -1
  24. package/dist/header/license.js +1 -1
  25. package/dist/packages/@ember/-internals/glimmer/index.js +4 -2
  26. package/dist/packages/@ember/-internals/metal/index.js +214 -1094
  27. package/dist/packages/@ember/-internals/routing/index.js +1 -17
  28. package/dist/packages/@ember/-internals/runtime/index.js +3 -16
  29. package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +2 -1
  30. package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +4 -3
  31. package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +1 -1
  32. package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +1 -1
  33. package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +1 -8
  34. package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +2 -1
  35. package/dist/packages/@ember/-internals/utils/index.js +3 -3
  36. package/dist/packages/@ember/-internals/views/lib/component_lookup.js +1 -1
  37. package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +2 -1
  38. package/dist/packages/@ember/-internals/views/lib/mixins/child_views_support.js +2 -1
  39. package/dist/packages/@ember/-internals/views/lib/mixins/class_names_support.js +2 -1
  40. package/dist/packages/@ember/-internals/views/lib/mixins/view_state_support.js +1 -1
  41. package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +2 -1
  42. package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +1 -1
  43. package/dist/packages/@ember/-internals/views/lib/views/core_view.js +3 -1
  44. package/dist/packages/@ember/application/index.js +876 -2
  45. package/dist/packages/@ember/application/instance.js +2 -2
  46. package/dist/packages/@ember/application/namespace.js +70 -1
  47. package/dist/packages/@ember/array/index.js +1503 -2
  48. package/dist/packages/@ember/array/mutable.js +1 -1
  49. package/dist/packages/@ember/array/proxy.js +307 -1
  50. package/dist/packages/@ember/canary-features/index.js +2 -2
  51. package/dist/packages/@ember/controller/index.js +260 -3
  52. package/dist/packages/@ember/debug/container-debug-adapter.js +99 -1
  53. package/dist/packages/@ember/debug/data-adapter.js +574 -1
  54. package/dist/packages/@ember/engine/index.js +5 -5
  55. package/dist/packages/@ember/engine/instance.js +4 -4
  56. package/dist/packages/@ember/enumerable/index.js +3 -1
  57. package/dist/packages/@ember/enumerable/mutable.js +4 -0
  58. package/dist/packages/@ember/{-internals/runtime/lib/system/object.js → object/-internals.js} +4 -17
  59. package/dist/packages/@ember/object/core.js +731 -1
  60. package/dist/packages/@ember/object/evented.js +93 -2
  61. package/dist/packages/@ember/object/index.js +76 -4
  62. package/dist/packages/@ember/object/internals.js +3 -2
  63. package/dist/packages/@ember/object/lib/computed/computed_macros.js +3 -1
  64. package/dist/packages/@ember/object/lib/computed/reduce_computed_macros.js +4 -3
  65. package/dist/packages/@ember/object/mixin.js +659 -1
  66. package/dist/packages/@ember/object/observable.js +341 -1
  67. package/dist/packages/@ember/object/promise-proxy-mixin.js +150 -1
  68. package/dist/packages/@ember/object/proxy.js +10 -1
  69. package/dist/packages/@ember/routing/-internals.js +7 -0
  70. package/dist/packages/@ember/routing/auto-location.js +249 -1
  71. package/dist/packages/@ember/routing/hash-location.js +169 -1
  72. package/dist/packages/@ember/routing/history-location.js +289 -1
  73. package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/cache.js +0 -0
  74. package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/controller_for.js +0 -0
  75. package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/dsl.js +0 -0
  76. package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/engines.js +0 -0
  77. package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/generate_controller.js +0 -0
  78. package/dist/packages/@ember/{-internals/routing/lib/location/util.js → routing/lib/location-utils.js} +0 -0
  79. package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/query_params.js +0 -0
  80. package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/route-info.js +0 -0
  81. package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/router_state.js +1 -1
  82. package/dist/packages/@ember/{-internals/routing/lib/services/routing.js → routing/lib/routing-service.js} +2 -2
  83. package/dist/packages/@ember/{-internals/routing/lib/system → routing/lib}/transition.js +0 -0
  84. package/dist/packages/@ember/{-internals/routing → routing}/lib/utils.js +0 -0
  85. package/dist/packages/@ember/routing/location.js +104 -1
  86. package/dist/packages/@ember/routing/none-location.js +123 -1
  87. package/dist/packages/@ember/routing/route.js +1700 -1
  88. package/dist/packages/@ember/routing/router-service.js +510 -1
  89. package/dist/packages/@ember/routing/router.js +1666 -1
  90. package/dist/packages/@ember/service/index.js +1 -1
  91. package/dist/packages/@ember/utils/index.js +7 -2
  92. package/dist/packages/@ember/{-internals/runtime → utils}/lib/compare.js +2 -2
  93. package/dist/packages/@ember/{-internals/runtime → utils}/lib/is-equal.js +0 -0
  94. package/dist/packages/@ember/utils/lib/is_blank.js +35 -0
  95. package/dist/packages/@ember/utils/lib/is_empty.js +68 -0
  96. package/dist/packages/@ember/utils/lib/is_none.js +27 -0
  97. package/dist/packages/@ember/utils/lib/is_present.js +38 -0
  98. package/dist/packages/@ember/{-internals/runtime → utils}/lib/type-of.js +2 -2
  99. package/dist/packages/ember/index.js +47 -28
  100. package/dist/packages/ember/version.js +1 -1
  101. package/dist/packages/ember-testing/lib/adapters/adapter.js +1 -1
  102. package/dist/packages/ember-testing/lib/helpers/current_path.js +2 -2
  103. package/dist/packages/ember-testing/lib/helpers/current_route_name.js +2 -2
  104. package/dist/packages/ember-testing/lib/helpers/current_url.js +1 -1
  105. package/docs/data.json +9428 -9189
  106. package/package.json +23 -8
  107. package/types/preview/@ember/-internals/resolver.d.ts +35 -0
  108. package/types/preview/@ember/application/-private/event-dispatcher.d.ts +18 -0
  109. package/types/preview/@ember/application/-private/registry.d.ts +15 -0
  110. package/types/preview/@ember/application/deprecations.d.ts +24 -0
  111. package/types/preview/@ember/application/index.d.ts +153 -0
  112. package/types/preview/@ember/application/instance.d.ts +9 -0
  113. package/types/preview/@ember/application/tsconfig.json +3 -0
  114. package/types/preview/@ember/application/types.d.ts +29 -0
  115. package/types/preview/@ember/array/-private/enumerable.d.ts +13 -0
  116. package/types/preview/@ember/array/-private/mutable-enumerable.d.ts +13 -0
  117. package/types/preview/@ember/array/-private/native-array.d.ts +23 -0
  118. package/types/preview/@ember/array/index.d.ts +243 -0
  119. package/types/preview/@ember/array/mutable.d.ts +94 -0
  120. package/types/preview/@ember/array/proxy.d.ts +29 -0
  121. package/types/preview/@ember/array/tsconfig.json +3 -0
  122. package/types/preview/@ember/component/-private/class-names-support.d.ts +27 -0
  123. package/types/preview/@ember/component/-private/core-view.d.ts +14 -0
  124. package/types/preview/@ember/component/-private/glimmer-interfaces.d.ts +45 -0
  125. package/types/preview/@ember/component/-private/signature-utils.d.ts +107 -0
  126. package/types/preview/@ember/component/-private/view-mixin.d.ts +59 -0
  127. package/types/preview/@ember/component/helper.d.ts +122 -0
  128. package/types/preview/@ember/component/index.d.ts +132 -0
  129. package/types/preview/@ember/component/template-only.d.ts +47 -0
  130. package/types/preview/@ember/component/tsconfig.json +3 -0
  131. package/types/preview/@ember/controller/index.d.ts +48 -0
  132. package/types/preview/@ember/controller/tsconfig.json +3 -0
  133. package/types/preview/@ember/debug/container-debug-adapter.d.ts +13 -0
  134. package/types/preview/@ember/debug/data-adapter.d.ts +64 -0
  135. package/types/preview/@ember/debug/index.d.ts +98 -0
  136. package/types/preview/@ember/debug/tsconfig.json +3 -0
  137. package/types/preview/@ember/destroyable/index.d.ts +23 -0
  138. package/types/preview/@ember/destroyable/tsconfig.json +3 -0
  139. package/types/preview/@ember/engine/-private/container-proxy-mixin.d.ts +17 -0
  140. package/types/preview/@ember/engine/-private/registry-proxy-mixin.d.ts +54 -0
  141. package/types/preview/@ember/engine/-private/types/initializer.d.ts +8 -0
  142. package/types/preview/@ember/engine/index.d.ts +45 -0
  143. package/types/preview/@ember/engine/instance.d.ts +24 -0
  144. package/types/preview/@ember/engine/tsconfig.json +3 -0
  145. package/types/preview/@ember/error/index.d.ts +6 -0
  146. package/types/preview/@ember/error/tsconfig.json +3 -0
  147. package/types/preview/@ember/helper/index.d.ts +49 -0
  148. package/types/preview/@ember/helper/tsconfig.json +3 -0
  149. package/types/preview/@ember/modifier/index.d.ts +33 -0
  150. package/types/preview/@ember/modifier/tsconfig.json +3 -0
  151. package/types/preview/@ember/object/-private/action-handler.d.ts +31 -0
  152. package/types/preview/@ember/object/-private/types.d.ts +63 -0
  153. package/types/preview/@ember/object/compat.d.ts +9 -0
  154. package/types/preview/@ember/object/computed.d.ts +263 -0
  155. package/types/preview/@ember/object/core.d.ts +89 -0
  156. package/types/preview/@ember/object/evented.d.ts +45 -0
  157. package/types/preview/@ember/object/events.d.ts +47 -0
  158. package/types/preview/@ember/object/index.d.ts +126 -0
  159. package/types/preview/@ember/object/internals.d.ts +17 -0
  160. package/types/preview/@ember/object/mixin.d.ts +19 -0
  161. package/types/preview/@ember/object/observable.d.ts +89 -0
  162. package/types/preview/@ember/object/observers.d.ts +34 -0
  163. package/types/preview/@ember/object/promise-proxy-mixin.d.ts +37 -0
  164. package/types/preview/@ember/object/proxy.d.ts +27 -0
  165. package/types/preview/@ember/object/tsconfig.json +3 -0
  166. package/types/preview/@ember/owner/index.d.ts +102 -0
  167. package/types/preview/@ember/owner/tsconfig.json +3 -0
  168. package/types/preview/@ember/polyfills/index.d.ts +23 -0
  169. package/types/preview/@ember/polyfills/tsconfig.json +3 -0
  170. package/types/preview/@ember/polyfills/types.d.ts +6 -0
  171. package/types/preview/@ember/routing/-private/router-dsl.d.ts +20 -0
  172. package/types/preview/@ember/routing/auto-location.d.ts +8 -0
  173. package/types/preview/@ember/routing/hash-location.d.ts +10 -0
  174. package/types/preview/@ember/routing/history-location.d.ts +9 -0
  175. package/types/preview/@ember/routing/index.d.ts +20 -0
  176. package/types/preview/@ember/routing/none-location.d.ts +11 -0
  177. package/types/preview/@ember/routing/route-info.d.ts +74 -0
  178. package/types/preview/@ember/routing/route.d.ts +533 -0
  179. package/types/preview/@ember/routing/router-service.d.ts +351 -0
  180. package/types/preview/@ember/routing/router.d.ts +49 -0
  181. package/types/preview/@ember/routing/transition.d.ts +126 -0
  182. package/types/preview/@ember/routing/tsconfig.json +3 -0
  183. package/types/preview/@ember/routing/types.d.ts +15 -0
  184. package/types/preview/@ember/runloop/-private/backburner.d.ts +43 -0
  185. package/types/preview/@ember/runloop/-private/types.d.ts +9 -0
  186. package/types/preview/@ember/runloop/index.d.ts +175 -0
  187. package/types/preview/@ember/runloop/tsconfig.json +3 -0
  188. package/types/preview/@ember/runloop/types.d.ts +5 -0
  189. package/types/preview/@ember/service/index.d.ts +25 -0
  190. package/types/preview/@ember/service/tsconfig.json +3 -0
  191. package/types/preview/@ember/string/index.d.ts +9 -0
  192. package/types/preview/@ember/string/tsconfig.json +3 -0
  193. package/types/preview/@ember/template/-private/handlebars.d.ts +7 -0
  194. package/types/preview/@ember/template/index.d.ts +5 -0
  195. package/types/preview/@ember/template/tsconfig.json +3 -0
  196. package/types/preview/@ember/test/adapter.d.ts +22 -0
  197. package/types/preview/@ember/test/index.d.ts +49 -0
  198. package/types/preview/@ember/test/tsconfig.json +3 -0
  199. package/types/preview/@ember/utils/-private/types.d.ts +39 -0
  200. package/types/preview/@ember/utils/index.d.ts +42 -0
  201. package/types/preview/@ember/utils/tsconfig.json +3 -0
  202. package/types/preview/ember/-private/type-utils.d.ts +54 -0
  203. package/types/preview/ember/index.d.ts +381 -0
  204. package/types/preview/ember/tsconfig.json +3 -0
  205. package/types/preview/index.d.ts +120 -0
  206. package/types/preview/tsconfig.json +6 -0
  207. package/blueprints/helper/mu-files/__root__/__collection__/__name__.js +0 -7
  208. package/blueprints-js/helper/mu-files/__root__/__collection__/__name__.js +0 -7
  209. package/dist/packages/@ember/-internals/extension-support/index.js +0 -2
  210. package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +0 -96
  211. package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +0 -576
  212. package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +0 -224
  213. package/dist/packages/@ember/-internals/routing/lib/location/api.js +0 -104
  214. package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +0 -250
  215. package/dist/packages/@ember/-internals/routing/lib/location/hash_location.js +0 -170
  216. package/dist/packages/@ember/-internals/routing/lib/location/history_location.js +0 -290
  217. package/dist/packages/@ember/-internals/routing/lib/location/none_location.js +0 -124
  218. package/dist/packages/@ember/-internals/routing/lib/services/router.js +0 -506
  219. package/dist/packages/@ember/-internals/routing/lib/system/route.js +0 -1696
  220. package/dist/packages/@ember/-internals/routing/lib/system/router.js +0 -1662
  221. package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +0 -1501
  222. package/dist/packages/@ember/-internals/runtime/lib/mixins/enumerable.js +0 -3
  223. package/dist/packages/@ember/-internals/runtime/lib/mixins/evented.js +0 -91
  224. package/dist/packages/@ember/-internals/runtime/lib/mixins/mutable_enumerable.js +0 -4
  225. package/dist/packages/@ember/-internals/runtime/lib/mixins/observable.js +0 -339
  226. package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +0 -149
  227. package/dist/packages/@ember/-internals/runtime/lib/system/array_proxy.js +0 -305
  228. package/dist/packages/@ember/-internals/runtime/lib/system/core_object.js +0 -730
  229. package/dist/packages/@ember/-internals/runtime/lib/system/namespace.js +0 -69
  230. package/dist/packages/@ember/-internals/runtime/lib/system/object_proxy.js +0 -7
  231. package/dist/packages/@ember/application/lib/application.js +0 -870
  232. package/dist/packages/@ember/controller/lib/controller_mixin.js +0 -42
  233. package/dist/packages/@ember/runloop/type-tests.ts/begin-end.test.js +0 -5
  234. package/dist/packages/@ember/runloop/type-tests.ts/bind.test.js +0 -59
  235. package/dist/packages/@ember/runloop/type-tests.ts/cancel.test.js +0 -5
  236. package/dist/packages/@ember/runloop/type-tests.ts/debounce.test.js +0 -77
  237. package/dist/packages/@ember/runloop/type-tests.ts/join.test.js +0 -38
  238. package/dist/packages/@ember/runloop/type-tests.ts/later.test.js +0 -38
  239. package/dist/packages/@ember/runloop/type-tests.ts/next.test.js +0 -38
  240. package/dist/packages/@ember/runloop/type-tests.ts/once.test.js +0 -38
  241. package/dist/packages/@ember/runloop/type-tests.ts/run.test.js +0 -38
  242. package/dist/packages/@ember/runloop/type-tests.ts/schedule-once.test.js +0 -39
  243. package/dist/packages/@ember/runloop/type-tests.ts/schedule.test.js +0 -39
  244. package/dist/packages/@ember/runloop/type-tests.ts/throttle.test.js +0 -77
@@ -1,224 +0,0 @@
1
- import { get } from '@ember/-internals/metal';
2
- import { getOwner } from '@ember/-internals/owner';
3
- import ControllerMixin from '@ember/controller/lib/controller_mixin';
4
- import { deprecateTransitionMethods, prefixRouteNameArg } from '../utils';
5
- /**
6
- @module ember
7
- */
8
-
9
- ControllerMixin.reopen({
10
- concatenatedProperties: ['queryParams'],
11
-
12
- init() {
13
- this._super(...arguments);
14
-
15
- let owner = getOwner(this);
16
-
17
- if (owner) {
18
- this.namespace = owner.lookup('application:main');
19
- this.target = owner.lookup('router:main');
20
- }
21
- },
22
-
23
- /**
24
- Defines which query parameters the controller accepts.
25
- If you give the names `['category','page']` it will bind
26
- the values of these query parameters to the variables
27
- `this.category` and `this.page`.
28
- By default, query parameters are parsed as strings. This
29
- may cause unexpected behavior if a query parameter is used with `toggleProperty`,
30
- because the initial value set for `param=false` will be the string `"false"`, which is truthy.
31
- To avoid this, you may specify that the query parameter should be parsed as a boolean
32
- by using the following verbose form with a `type` property:
33
- ```javascript
34
- queryParams: [{
35
- category: {
36
- type: 'boolean'
37
- }
38
- }]
39
- ```
40
- Available values for the `type` parameter are `'boolean'`, `'number'`, `'array'`, and `'string'`.
41
- If query param type is not specified, it will default to `'string'`.
42
- @for Ember.ControllerMixin
43
- @property queryParams
44
- @public
45
- */
46
- queryParams: null,
47
-
48
- /**
49
- This property is updated to various different callback functions depending on
50
- the current "state" of the backing route. It is used by
51
- `Controller.prototype._qpChanged`.
52
- The methods backing each state can be found in the `Route.prototype._qp` computed
53
- property return value (the `.states` property). The current values are listed here for
54
- the sanity of future travelers:
55
- * `inactive` - This state is used when this controller instance is not part of the active
56
- route hierarchy. Set in `Route.prototype._reset` (a `router.js` microlib hook) and
57
- `Route.prototype.actions.finalizeQueryParamChange`.
58
- * `active` - This state is used when this controller instance is part of the active
59
- route hierarchy. Set in `Route.prototype.actions.finalizeQueryParamChange`.
60
- * `allowOverrides` - This state is used in `Route.prototype.setup` (`route.js` microlib hook).
61
- @method _qpDelegate
62
- @private
63
- */
64
- _qpDelegate: null,
65
-
66
- /**
67
- During `Route#setup` observers are created to invoke this method
68
- when any of the query params declared in `Controller#queryParams` property
69
- are changed.
70
- When invoked this method uses the currently active query param update delegate
71
- (see `Controller.prototype._qpDelegate` for details) and invokes it with
72
- the QP key/value being changed.
73
- @method _qpChanged
74
- @private
75
- */
76
- _qpChanged(controller, _prop) {
77
- let dotIndex = _prop.indexOf('.[]');
78
-
79
- let prop = dotIndex === -1 ? _prop : _prop.slice(0, dotIndex);
80
- let delegate = controller._qpDelegate;
81
- let value = get(controller, prop);
82
- delegate(prop, value);
83
- },
84
-
85
- /**
86
- Transition the application into another route. The route may
87
- be either a single route or route path:
88
- ```javascript
89
- aController.transitionToRoute('blogPosts');
90
- aController.transitionToRoute('blogPosts.recentEntries');
91
- ```
92
- Optionally supply a model for the route in question. The model
93
- will be serialized into the URL using the `serialize` hook of
94
- the route:
95
- ```javascript
96
- aController.transitionToRoute('blogPost', aPost);
97
- ```
98
- If a literal is passed (such as a number or a string), it will
99
- be treated as an identifier instead. In this case, the `model`
100
- hook of the route will be triggered:
101
- ```javascript
102
- aController.transitionToRoute('blogPost', 1);
103
- ```
104
- Multiple models will be applied last to first recursively up the
105
- route tree.
106
- ```app/router.js
107
- Router.map(function() {
108
- this.route('blogPost', { path: ':blogPostId' }, function() {
109
- this.route('blogComment', { path: ':blogCommentId', resetNamespace: true });
110
- });
111
- });
112
- ```
113
- ```javascript
114
- aController.transitionToRoute('blogComment', aPost, aComment);
115
- aController.transitionToRoute('blogComment', 1, 13);
116
- ```
117
- It is also possible to pass a URL (a string that starts with a
118
- `/`).
119
- ```javascript
120
- aController.transitionToRoute('/');
121
- aController.transitionToRoute('/blog/post/1/comment/13');
122
- aController.transitionToRoute('/blog/posts?sort=title');
123
- ```
124
- An options hash with a `queryParams` property may be provided as
125
- the final argument to add query parameters to the destination URL.
126
- ```javascript
127
- aController.transitionToRoute('blogPost', 1, {
128
- queryParams: { showComments: 'true' }
129
- });
130
- // if you just want to transition the query parameters without changing the route
131
- aController.transitionToRoute({ queryParams: { sort: 'date' } });
132
- ```
133
- See also [replaceRoute](/ember/release/classes/Ember.ControllerMixin/methods/replaceRoute?anchor=replaceRoute).
134
- @for Ember.ControllerMixin
135
- @method transitionToRoute
136
- @deprecated Use transitionTo from the Router service instead.
137
- @param {String} [name] the name of the route or a URL
138
- @param {...Object} models the model(s) or identifier(s) to be used
139
- while transitioning to the route.
140
- @param {Object} [options] optional hash with a queryParams property
141
- containing a mapping of query parameters
142
- @return {Transition} the transition object associated with this
143
- attempted transition
144
- @public
145
- */
146
- transitionToRoute(...args) {
147
- var _a;
148
-
149
- deprecateTransitionMethods('controller', 'transitionToRoute'); // target may be either another controller or a router
150
-
151
- let target = get(this, 'target'); // SAFETY: We can't actually assert that this is a full Controller or Router since some tests
152
- // mock out an object that only has the single method. Since this is deprecated, I think it's
153
- // ok to be a little less than proper here.
154
-
155
- let method = (_a = target.transitionToRoute) !== null && _a !== void 0 ? _a : target.transitionTo;
156
- return method.apply(target, prefixRouteNameArg(this, args));
157
- },
158
-
159
- /**
160
- Transition into another route while replacing the current URL, if possible.
161
- This will replace the current history entry instead of adding a new one.
162
- Beside that, it is identical to `transitionToRoute` in all other respects.
163
- ```javascript
164
- aController.replaceRoute('blogPosts');
165
- aController.replaceRoute('blogPosts.recentEntries');
166
- ```
167
- Optionally supply a model for the route in question. The model
168
- will be serialized into the URL using the `serialize` hook of
169
- the route:
170
- ```javascript
171
- aController.replaceRoute('blogPost', aPost);
172
- ```
173
- If a literal is passed (such as a number or a string), it will
174
- be treated as an identifier instead. In this case, the `model`
175
- hook of the route will be triggered:
176
- ```javascript
177
- aController.replaceRoute('blogPost', 1);
178
- ```
179
- Multiple models will be applied last to first recursively up the
180
- route tree.
181
- ```app/router.js
182
- Router.map(function() {
183
- this.route('blogPost', { path: ':blogPostId' }, function() {
184
- this.route('blogComment', { path: ':blogCommentId', resetNamespace: true });
185
- });
186
- });
187
- ```
188
- ```
189
- aController.replaceRoute('blogComment', aPost, aComment);
190
- aController.replaceRoute('blogComment', 1, 13);
191
- ```
192
- It is also possible to pass a URL (a string that starts with a
193
- `/`).
194
- ```javascript
195
- aController.replaceRoute('/');
196
- aController.replaceRoute('/blog/post/1/comment/13');
197
- ```
198
- @for Ember.ControllerMixin
199
- @method replaceRoute
200
- @deprecated Use replaceWith from the Router service instead.
201
- @param {String} [name] the name of the route or a URL
202
- @param {...Object} models the model(s) or identifier(s) to be used
203
- while transitioning to the route.
204
- @param {Object} [options] optional hash with a queryParams property
205
- containing a mapping of query parameters
206
- @return {Transition} the transition object associated with this
207
- attempted transition
208
- @public
209
- */
210
- replaceRoute(...args) {
211
- var _a;
212
-
213
- deprecateTransitionMethods('controller', 'replaceRoute'); // target may be either another controller or a router
214
-
215
- let target = get(this, 'target'); // SAFETY: We can't actually assert that this is a full Controller or Router since some tests
216
- // mock out an object that only has the single method. Since this is deprecated, I think it's
217
- // ok to be a little less than proper here.
218
-
219
- let method = (_a = target.replaceRoute) !== null && _a !== void 0 ? _a : target.replaceWith;
220
- return method.apply(target, prefixRouteNameArg(this, args));
221
- }
222
-
223
- });
224
- export default ControllerMixin;
@@ -1,104 +0,0 @@
1
- import { assert, deprecate } from '@ember/debug';
2
- /**
3
- @module @ember/routing
4
- */
5
-
6
- /**
7
- Location returns an instance of the correct implementation of
8
- the `location` API.
9
-
10
- ## Implementations
11
-
12
- You can pass an implementation name (`hash`, `history`, `none`, `auto`) to force a
13
- particular implementation to be used in your application.
14
-
15
- See [HashLocation](/ember/release/classes/HashLocation).
16
- See [HistoryLocation](/ember/release/classes/HistoryLocation).
17
- See [NoneLocation](/ember/release/classes/NoneLocation).
18
- See [AutoLocation](/ember/release/classes/AutoLocation).
19
-
20
- ## Location API
21
-
22
- Each location implementation must provide the following methods:
23
-
24
- * implementation: returns the string name used to reference the implementation.
25
- * getURL: returns the current URL.
26
- * setURL(path): sets the current URL.
27
- * replaceURL(path): replace the current URL (optional).
28
- * onUpdateURL(callback): triggers the callback when the URL changes.
29
- * formatURL(url): formats `url` to be placed into `href` attribute.
30
- * detect() (optional): instructs the location to do any feature detection
31
- necessary. If the location needs to redirect to a different URL, it
32
- can cancel routing by setting the `cancelRouterSetup` property on itself
33
- to `false`.
34
-
35
- Calling setURL or replaceURL will not trigger onUpdateURL callbacks.
36
-
37
- ## Custom implementation
38
-
39
- Ember scans `app/locations/*` for extending the Location API.
40
-
41
- Example:
42
-
43
- ```javascript
44
- import HistoryLocation from '@ember/routing/history-location';
45
-
46
- export default class MyHistory {
47
- implementation = 'my-custom-history';
48
-
49
- constructor() {
50
- this._history = HistoryLocation.create(...arguments);
51
- }
52
-
53
- create() {
54
- return new this(...arguments);
55
- }
56
-
57
- pushState(path) {
58
- this._history.pushState(path);
59
- }
60
- }
61
- ```
62
-
63
- @class Location
64
- @private
65
- */
66
-
67
- export default {
68
- /**
69
- This is deprecated in favor of using the container to lookup the location
70
- implementation as desired.
71
- For example:
72
- ```javascript
73
- // Given a location registered as follows:
74
- container.register('location:history-test', HistoryTestLocation);
75
- // You could create a new instance via:
76
- container.lookup('location:history-test');
77
- ```
78
- @method create
79
- @param {Object} options
80
- @return {Object} an instance of an implementation of the `location` API
81
- @deprecated Use the container to lookup the location implementation that you
82
- need.
83
- @private
84
- */
85
- create(options) {
86
- let implementation = options === null || options === void 0 ? void 0 : options.implementation;
87
- assert("Location.create: you must specify a 'implementation' option", implementation);
88
- let implementationClass = this.implementations[implementation];
89
- assert(`Location.create: ${implementation} is not a valid implementation`, implementationClass);
90
- deprecate("Calling `create` on Location class is deprecated. Instead, use `container.lookup('location:my-location')` to lookup the location you need.", false, {
91
- id: 'deprecate-auto-location',
92
- until: '5.0.0',
93
- url: 'https://emberjs.com/deprecations/v4.x#toc_deprecate-auto-location',
94
- for: 'ember-source',
95
- since: {
96
- available: '4.1.0',
97
- enabled: '4.1.0'
98
- }
99
- });
100
- return implementationClass.create(...arguments);
101
- },
102
-
103
- implementations: {}
104
- };
@@ -1,250 +0,0 @@
1
- import { history, location, userAgent, window } from '@ember/-internals/browser-environment';
2
- import { set } from '@ember/-internals/metal';
3
- import { getOwner } from '@ember/-internals/owner';
4
- import { Object as EmberObject } from '@ember/-internals/runtime';
5
- import { assert } from '@ember/debug';
6
- import { getFullPath, getHash, getPath, getQuery, replacePath, supportsHashChange, supportsHistory } from './util';
7
- /**
8
- @module @ember/routing
9
- */
10
-
11
- /**
12
- AutoLocation will select the best location option based off browser
13
- support with the priority order: history, hash, none.
14
-
15
- Clean pushState paths accessed by hashchange-only browsers will be redirected
16
- to the hash-equivalent and vice versa so future transitions are consistent.
17
-
18
- Keep in mind that since some of your users will use `HistoryLocation`, your
19
- server must serve the Ember app at all the routes you define.
20
-
21
- Browsers that support the `history` API will use `HistoryLocation`, those that
22
- do not, but still support the `hashchange` event will use `HashLocation`, and
23
- in the rare case neither is supported will use `NoneLocation`.
24
-
25
- Example:
26
-
27
- ```app/router.js
28
- Router.map(function() {
29
- this.route('posts', function() {
30
- this.route('new');
31
- });
32
- });
33
-
34
- Router.reopen({
35
- location: 'auto'
36
- });
37
- ```
38
-
39
- This will result in a posts.new url of `/posts/new` for modern browsers that
40
- support the `history` api or `/#/posts/new` for older ones, like Internet
41
- Explorer 9 and below.
42
-
43
- When a user visits a link to your application, they will be automatically
44
- upgraded or downgraded to the appropriate `Location` class, with the URL
45
- transformed accordingly, if needed.
46
-
47
- Keep in mind that since some of your users will use `HistoryLocation`, your
48
- server must serve the Ember app at all the routes you define.
49
-
50
- @class AutoLocation
51
- @static
52
- @protected
53
- */
54
-
55
- export default class AutoLocation extends EmberObject {
56
- constructor() {
57
- super(...arguments);
58
- this.implementation = 'auto';
59
- }
60
- /**
61
- Called by the router to instruct the location to do any feature detection
62
- necessary. In the case of AutoLocation, we detect whether to use history
63
- or hash concrete implementations.
64
- @private
65
- */
66
-
67
-
68
- detect() {
69
- let rootURL = this.rootURL;
70
- assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/');
71
- let implementation = detectImplementation({
72
- location: this.location,
73
- history: this.history,
74
- userAgent: this.userAgent,
75
- rootURL,
76
- documentMode: this.documentMode,
77
- global: this.global
78
- });
79
-
80
- if (implementation === false) {
81
- set(this, 'cancelRouterSetup', true);
82
- implementation = 'none';
83
- }
84
-
85
- let owner = getOwner(this);
86
- assert('AutoLocation is unexpectedly missing an owner', owner);
87
- let concrete = owner.lookup(`location:${implementation}`);
88
- assert(`Could not find location '${implementation}'.`, concrete !== undefined);
89
- set(concrete, 'rootURL', rootURL);
90
- set(this, 'concreteImplementation', concrete);
91
- }
92
-
93
- willDestroy() {
94
- let {
95
- concreteImplementation
96
- } = this;
97
-
98
- if (concreteImplementation) {
99
- concreteImplementation.destroy();
100
- }
101
- }
102
-
103
- }
104
- AutoLocation.reopen({
105
- rootURL: '/',
106
- initState: delegateToConcreteImplementation('initState'),
107
- getURL: delegateToConcreteImplementation('getURL'),
108
- setURL: delegateToConcreteImplementation('setURL'),
109
- replaceURL: delegateToConcreteImplementation('replaceURL'),
110
- onUpdateURL: delegateToConcreteImplementation('onUpdateURL'),
111
- formatURL: delegateToConcreteImplementation('formatURL'),
112
- location: location,
113
- history: history,
114
- global: window,
115
- userAgent: userAgent,
116
- cancelRouterSetup: false
117
- });
118
-
119
- function delegateToConcreteImplementation(methodName) {
120
- return function (...args) {
121
- var _a;
122
-
123
- let {
124
- concreteImplementation
125
- } = this;
126
- assert("AutoLocation's detect() method should be called before calling any other hooks.", concreteImplementation); // We need this cast because `Parameters` is deferred so that it is not
127
- // possible for TS to see it will always produce the right type. However,
128
- // since `AnyFn` has a rest type, it is allowed. See discussion on [this
129
- // issue](https://github.com/microsoft/TypeScript/issues/47615).
130
-
131
- return (_a = concreteImplementation[methodName]) === null || _a === void 0 ? void 0 : _a.call(concreteImplementation, ...args);
132
- };
133
- }
134
-
135
- function detectImplementation(options) {
136
- let {
137
- location,
138
- userAgent,
139
- history,
140
- documentMode,
141
- global,
142
- rootURL
143
- } = options;
144
- let implementation = 'none';
145
- let cancelRouterSetup = false;
146
- let currentPath = getFullPath(location);
147
-
148
- if (supportsHistory(userAgent, history)) {
149
- let historyPath = getHistoryPath(rootURL, location); // If the browser supports history and we have a history path, we can use
150
- // the history location with no redirects.
151
-
152
- if (currentPath === historyPath) {
153
- implementation = 'history';
154
- } else if (currentPath.substring(0, 2) === '/#') {
155
- history.replaceState({
156
- path: historyPath
157
- }, '', historyPath);
158
- implementation = 'history';
159
- } else {
160
- cancelRouterSetup = true;
161
- replacePath(location, historyPath);
162
- }
163
- } else if (supportsHashChange(documentMode, global)) {
164
- let hashPath = getHashPath(rootURL, location); // Be sure we're using a hashed path, otherwise let's switch over it to so
165
- // we start off clean and consistent. We'll count an index path with no
166
- // hash as "good enough" as well.
167
-
168
- if (currentPath === hashPath || currentPath === '/' && hashPath === '/#/') {
169
- implementation = 'hash';
170
- } else {
171
- // Our URL isn't in the expected hash-supported format, so we want to
172
- // cancel the router setup and replace the URL to start off clean
173
- cancelRouterSetup = true;
174
- replacePath(location, hashPath);
175
- }
176
- }
177
-
178
- if (cancelRouterSetup) {
179
- return false;
180
- }
181
-
182
- return implementation;
183
- }
184
- /**
185
- @private
186
-
187
- Returns the current path as it should appear for HistoryLocation supported
188
- browsers. This may very well differ from the real current path (e.g. if it
189
- starts off as a hashed URL)
190
- */
191
-
192
-
193
- export function getHistoryPath(rootURL, location) {
194
- let path = getPath(location);
195
- let hash = getHash(location);
196
- let query = getQuery(location);
197
- let rootURLIndex = path.indexOf(rootURL);
198
- let routeHash;
199
- let hashParts;
200
- assert(`Path ${path} does not start with the provided rootURL ${rootURL}`, rootURLIndex === 0); // By convention, Ember.js routes using HashLocation are required to start
201
- // with `#/`. Anything else should NOT be considered a route and should
202
- // be passed straight through, without transformation.
203
-
204
- if (hash.substring(0, 2) === '#/') {
205
- // There could be extra hash segments after the route
206
- hashParts = hash.substring(1).split('#'); // The first one is always the route url
207
-
208
- routeHash = hashParts.shift(); // If the path already has a trailing slash, remove the one
209
- // from the hashed route so we don't double up.
210
-
211
- if (path.charAt(path.length - 1) === '/') {
212
- routeHash = routeHash.substring(1);
213
- } // This is the "expected" final order
214
-
215
-
216
- path += routeHash + query;
217
-
218
- if (hashParts.length) {
219
- path += `#${hashParts.join('#')}`;
220
- }
221
- } else {
222
- path += query + hash;
223
- }
224
-
225
- return path;
226
- }
227
- /**
228
- @private
229
-
230
- Returns the current path as it should appear for HashLocation supported
231
- browsers. This may very well differ from the real current path.
232
-
233
- @method _getHashPath
234
- */
235
-
236
- export function getHashPath(rootURL, location) {
237
- let path = rootURL;
238
- let historyPath = getHistoryPath(rootURL, location);
239
- let routePath = historyPath.substring(rootURL.length);
240
-
241
- if (routePath !== '') {
242
- if (routePath[0] !== '/') {
243
- routePath = `/${routePath}`;
244
- }
245
-
246
- path += `#${routePath}`;
247
- }
248
-
249
- return path;
250
- }