ember-source 4.4.0-alpha.4 → 4.4.0-alpha.7

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 (85) hide show
  1. package/CHANGELOG.md +3 -5
  2. package/blueprints/-addon-import.js +9 -0
  3. package/blueprints/-maybe-polyfill-typescript-blueprints.js +17 -0
  4. package/blueprints/acceptance-test/index.js +8 -0
  5. package/blueprints/acceptance-test/mocha-rfc-232-files/tests/acceptance/{__name__-test.js → __name__-test.ts} +0 -0
  6. package/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/{__name__-test.js → __name__-test.ts} +0 -0
  7. package/blueprints/component/files/__root__/__path__/{__name__.js → __name__.ts} +0 -0
  8. package/blueprints/component/index.js +6 -1
  9. package/blueprints/component-addon/files/__root__/__path__/{__name__.js → __name__.ts} +0 -0
  10. package/blueprints/component-addon/index.js +9 -0
  11. package/blueprints/component-class/files/__root__/__path__/{__name__.js → __name__.ts} +0 -0
  12. package/blueprints/component-class/index.js +5 -0
  13. package/blueprints/component-class-addon/files/__root__/__path__/{__name__.js → __name__.ts} +0 -0
  14. package/blueprints/component-class-addon/index.js +9 -0
  15. package/blueprints/component-test/index.js +8 -0
  16. package/blueprints/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/{__test__.js → __test__.ts} +0 -0
  17. package/blueprints/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/{__test__.js → __test__.ts} +1 -1
  18. package/blueprints/controller/files/__root__/__path__/{__name__.js → __name__.ts} +0 -0
  19. package/blueprints/controller/index.js +10 -0
  20. package/blueprints/controller-test/index.js +10 -0
  21. package/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/{__test__.js → __test__.ts} +0 -0
  22. package/blueprints/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/{__test__.js → __test__.ts} +0 -0
  23. package/blueprints/helper/files/__root__/__collection__/{__name__.js → __name__.ts} +0 -0
  24. package/blueprints/helper/index.js +9 -0
  25. package/blueprints/helper-addon/files/__root__/__path__/{__name__.js → __name__.ts} +0 -0
  26. package/blueprints/helper-test/index.js +9 -0
  27. package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/{__name__-test.js → __name__-test.ts} +0 -0
  28. package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/{__name__-test.js → __name__-test.ts} +0 -0
  29. package/blueprints/initializer/files/__root__/initializers/__name__.ts +6 -0
  30. package/blueprints/initializer/index.js +9 -0
  31. package/blueprints/initializer-addon/files/__root__/__path__/{__name__.js → __name__.ts} +0 -0
  32. package/blueprints/initializer-test/index.js +8 -0
  33. package/blueprints/initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/{__name__-test.js → __name__-test.ts} +3 -1
  34. package/blueprints/initializer-test/qunit-rfc-232-files/__root__/__testType__/__path__/__name__-test.ts +37 -0
  35. package/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.ts +6 -0
  36. package/blueprints/instance-initializer/index.js +9 -0
  37. package/blueprints/instance-initializer-addon/files/__root__/__path__/{__name__.js → __name__.ts} +0 -0
  38. package/blueprints/instance-initializer-test/index.js +8 -0
  39. package/blueprints/instance-initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/{__name__-test.js → __name__-test.ts} +5 -1
  40. package/blueprints/instance-initializer-test/qunit-rfc-232-files/__root__/__testType__/__path__/{__name__-test.js → __name__-test.ts} +6 -1
  41. package/blueprints/route/files/__root__/__path__/{__name__.js → __name__.ts} +2 -4
  42. package/blueprints/route/index.js +9 -0
  43. package/blueprints/route-addon/files/__root__/__path__/{__name__.js → __name__.ts} +0 -0
  44. package/blueprints/route-addon/index.js +9 -0
  45. package/blueprints/route-test/index.js +9 -0
  46. package/blueprints/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/{__test__.js → __test__.ts} +0 -0
  47. package/blueprints/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/{__test__.js → __test__.ts} +0 -0
  48. package/blueprints/service/files/__root__/__path__/{__name__.js → __name__.ts} +0 -0
  49. package/blueprints/service/index.js +10 -0
  50. package/blueprints/service-test/index.js +8 -0
  51. package/blueprints/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/{__test__.js → __test__.ts} +0 -0
  52. package/blueprints/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/{__test__.js → __test__.ts} +0 -0
  53. package/blueprints/util/files/__root__/utils/{__name__.js → __name__.ts} +0 -0
  54. package/blueprints/util/index.js +10 -0
  55. package/blueprints/util-test/index.js +8 -0
  56. package/blueprints/util-test/mocha-rfc-232-files/__root__/__testType__/{__name__-test.js → __name__-test.ts} +0 -0
  57. package/blueprints/util-test/qunit-rfc-232-files/__root__/__testType__/{__name__-test.js → __name__-test.ts} +0 -0
  58. package/build-metadata.json +3 -3
  59. package/dist/ember-template-compiler.js +10 -12
  60. package/dist/ember-template-compiler.map +1 -1
  61. package/dist/ember-testing.js +7 -3
  62. package/dist/ember-testing.map +1 -1
  63. package/dist/ember.debug.js +484 -785
  64. package/dist/ember.debug.map +1 -1
  65. package/dist/header/license.js +1 -1
  66. package/dist/packages/@ember/-internals/container/index.js +1 -10
  67. package/dist/packages/@ember/-internals/glimmer/index.js +107 -218
  68. package/dist/packages/@ember/-internals/meta/lib/meta.js +1 -1
  69. package/dist/packages/@ember/-internals/metal/index.js +22 -21
  70. package/dist/packages/@ember/-internals/routing/lib/services/router.js +140 -145
  71. package/dist/packages/@ember/-internals/routing/lib/system/route-info.js +4 -0
  72. package/dist/packages/@ember/-internals/routing/lib/system/router.js +2 -0
  73. package/dist/packages/@ember/-internals/routing/lib/system/transition.js +4 -0
  74. package/dist/packages/@ember/-internals/runtime/lib/system/core_object.js +118 -302
  75. package/dist/packages/@ember/-internals/runtime/lib/system/object.js +8 -23
  76. package/dist/packages/@ember/-internals/views/lib/views/core_view.js +47 -29
  77. package/dist/packages/@ember/canary-features/index.js +1 -5
  78. package/dist/packages/@ember/debug/lib/deprecate.js +6 -2
  79. package/dist/packages/ember/version.js +1 -1
  80. package/docs/data.json +448 -810
  81. package/package.json +20 -17
  82. package/blueprints/initializer/files/__root__/initializers/__name__.js +0 -5
  83. package/blueprints/initializer-test/qunit-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +0 -34
  84. package/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js +0 -5
  85. package/dist/packages/@ember/renderer/index.js +0 -21
@@ -26,151 +26,6 @@ function cleanURL(url, rootURL) {
26
26
  }
27
27
 
28
28
  class RouterService extends Service.extend(Evented) {
29
- constructor() {
30
- super(...arguments);
31
- /**
32
- You can register a listener for events emitted by this service with `.on()`:
33
- ```app/routes/contact-form.js
34
- import Route from '@ember/routing';
35
- import { service } from '@ember/service';
36
- export default class extends Route {
37
- @service router;
38
- activate() {
39
- this.router.on('routeWillChange', (transition) => {
40
- if (!transition.to.find(route => route.name === this.routeName)) {
41
- alert("Please save or cancel your changes.");
42
- transition.abort();
43
- }
44
- })
45
- }
46
- }
47
- ```
48
- @method on
49
- @param {String} eventName
50
- @param {Function} callback
51
- @public
52
- */
53
-
54
- /**
55
- You can unregister a listener for events emitted by this service with `.off()`:
56
- ```app/routes/contact-form.js
57
- import Route from '@ember/routing';
58
- import { service } from '@ember/service';
59
- export default class extends Route {
60
- @service router;
61
- callback = (transition) => {
62
- if (!transition.to.find(route => route.name === this.routeName)) {
63
- alert("Please save or cancel your changes.");
64
- transition.abort();
65
- }
66
- };
67
- activate() {
68
- this.router.on('routeWillChange', this.callback);
69
- }
70
- deactivate() {
71
- this.router.off('routeWillChange', this.callback);
72
- }
73
- ```
74
- @method off
75
- @param {String} eventName
76
- @param {Function} callback
77
- @public
78
- */
79
-
80
- /**
81
- The `routeWillChange` event is fired at the beginning of any
82
- attempted transition with a `Transition` object as the sole
83
- argument. This action can be used for aborting, redirecting,
84
- or decorating the transition from the currently active routes.
85
- A good example is preventing navigation when a form is
86
- half-filled out:
87
- ```app/routes/contact-form.js
88
- import Route from '@ember/routing';
89
- import { service } from '@ember/service';
90
- export default class extends Route {
91
- @service router;
92
- activate() {
93
- this.router.on('routeWillChange', (transition) => {
94
- if (!transition.to.find(route => route.name === this.routeName)) {
95
- alert("Please save or cancel your changes.");
96
- transition.abort();
97
- }
98
- })
99
- }
100
- }
101
- ```
102
- The `routeWillChange` event fires whenever a new route is chosen as the desired target of a transition. This includes `transitionTo`, `replaceWith`, all redirection for any reason including error handling, and abort. Aborting implies changing the desired target back to where you already were. Once a transition has completed, `routeDidChange` fires.
103
- @event routeWillChange
104
- @param {Transition} transition
105
- @public
106
- */
107
-
108
- /**
109
- The `routeDidChange` event only fires once a transition has settled.
110
- This includes aborts and error substates. Like the `routeWillChange` event
111
- it receives a Transition as the sole argument.
112
- A good example is sending some analytics when the route has transitioned:
113
- ```app/routes/contact-form.js
114
- import Route from '@ember/routing';
115
- import { service } from '@ember/service';
116
- export default class extends Route {
117
- @service router;
118
- activate() {
119
- this.router.on('routeDidChange', (transition) => {
120
- ga.send('pageView', {
121
- current: transition.to.name,
122
- from: transition.from.name
123
- });
124
- })
125
- }
126
- }
127
- ```
128
- `routeDidChange` will be called after any `Route`'s
129
- [didTransition](/ember/release/classes/Route/events/didTransition?anchor=didTransition)
130
- action has been fired.
131
- The updates of properties
132
- [currentURL](/ember/release/classes/RouterService/properties/currentURL?anchor=currentURL),
133
- [currentRouteName](/ember/release/classes/RouterService/properties/currentURL?anchor=currentRouteName)
134
- and
135
- [currentRoute](/ember/release/classes/RouterService/properties/currentURL?anchor=currentRoute)
136
- are completed at the time `routeDidChange` is called.
137
- @event routeDidChange
138
- @param {Transition} transition
139
- @public
140
- */
141
- // Canary features
142
-
143
- /**
144
- * Refreshes all currently active routes, doing a full transition.
145
- * If a route name is provided and refers to a currently active route,
146
- * it will refresh only that route and its descendents.
147
- * Returns a promise that will be resolved once the refresh is complete.
148
- * All resetController, beforeModel, model, afterModel, redirect, and setupController
149
- * hooks will be called again. You will get new data from the model hook.
150
- *
151
- * @method refresh
152
- * @param {String} [routeName] the route to refresh (along with all child routes)
153
- * @return Transition
154
- * @category EMBER_ROUTING_ROUTER_SERVICE_REFRESH
155
- * @public
156
- */
157
-
158
- this.refresh = true
159
- /* EMBER_ROUTING_ROUTER_SERVICE_REFRESH */
160
- ? function (pivotRouteName) {
161
- if (!pivotRouteName) {
162
- return this._router._routerMicrolib.refresh();
163
- }
164
-
165
- assert(`The route "${pivotRouteName}" was not found`, this._router.hasRoute(pivotRouteName));
166
- assert(`The route "${pivotRouteName}" is currently not active`, this.isActive(pivotRouteName));
167
- let owner = getOwner(this);
168
- assert('RouterService is unexpectedly missing an owner', owner);
169
- let pivotRoute = owner.lookup(`route:${pivotRouteName}`);
170
- return this._router._routerMicrolib.refresh(pivotRoute);
171
- } : undefined;
172
- }
173
-
174
29
  get _router() {
175
30
  let router = this[ROUTER];
176
31
 
@@ -494,6 +349,146 @@ class RouterService extends Service.extend(Evented) {
494
349
  let internalURL = cleanURL(url, this.rootURL);
495
350
  return this._router._routerMicrolib.recognizeAndLoad(internalURL);
496
351
  }
352
+ /**
353
+ You can register a listener for events emitted by this service with `.on()`:
354
+ ```app/routes/contact-form.js
355
+ import Route from '@ember/routing';
356
+ import { service } from '@ember/service';
357
+ export default class extends Route {
358
+ @service router;
359
+ activate() {
360
+ this.router.on('routeWillChange', (transition) => {
361
+ if (!transition.to.find(route => route.name === this.routeName)) {
362
+ alert("Please save or cancel your changes.");
363
+ transition.abort();
364
+ }
365
+ })
366
+ }
367
+ }
368
+ ```
369
+ @method on
370
+ @param {String} eventName
371
+ @param {Function} callback
372
+ @public
373
+ */
374
+
375
+ /**
376
+ You can unregister a listener for events emitted by this service with `.off()`:
377
+ ```app/routes/contact-form.js
378
+ import Route from '@ember/routing';
379
+ import { service } from '@ember/service';
380
+ export default class extends Route {
381
+ @service router;
382
+ callback = (transition) => {
383
+ if (!transition.to.find(route => route.name === this.routeName)) {
384
+ alert("Please save or cancel your changes.");
385
+ transition.abort();
386
+ }
387
+ };
388
+ activate() {
389
+ this.router.on('routeWillChange', this.callback);
390
+ }
391
+ deactivate() {
392
+ this.router.off('routeWillChange', this.callback);
393
+ }
394
+ ```
395
+ @method off
396
+ @param {String} eventName
397
+ @param {Function} callback
398
+ @public
399
+ */
400
+
401
+ /**
402
+ The `routeWillChange` event is fired at the beginning of any
403
+ attempted transition with a `Transition` object as the sole
404
+ argument. This action can be used for aborting, redirecting,
405
+ or decorating the transition from the currently active routes.
406
+ A good example is preventing navigation when a form is
407
+ half-filled out:
408
+ ```app/routes/contact-form.js
409
+ import Route from '@ember/routing';
410
+ import { service } from '@ember/service';
411
+ export default class extends Route {
412
+ @service router;
413
+ activate() {
414
+ this.router.on('routeWillChange', (transition) => {
415
+ if (!transition.to.find(route => route.name === this.routeName)) {
416
+ alert("Please save or cancel your changes.");
417
+ transition.abort();
418
+ }
419
+ })
420
+ }
421
+ }
422
+ ```
423
+ The `routeWillChange` event fires whenever a new route is chosen as the desired target of a transition. This includes `transitionTo`, `replaceWith`, all redirection for any reason including error handling, and abort. Aborting implies changing the desired target back to where you already were. Once a transition has completed, `routeDidChange` fires.
424
+ @event routeWillChange
425
+ @param {Transition} transition
426
+ @public
427
+ */
428
+
429
+ /**
430
+ The `routeDidChange` event only fires once a transition has settled.
431
+ This includes aborts and error substates. Like the `routeWillChange` event
432
+ it receives a Transition as the sole argument.
433
+ A good example is sending some analytics when the route has transitioned:
434
+ ```app/routes/contact-form.js
435
+ import Route from '@ember/routing';
436
+ import { service } from '@ember/service';
437
+ export default class extends Route {
438
+ @service router;
439
+ activate() {
440
+ this.router.on('routeDidChange', (transition) => {
441
+ ga.send('pageView', {
442
+ current: transition.to.name,
443
+ from: transition.from.name
444
+ });
445
+ })
446
+ }
447
+ }
448
+ ```
449
+ `routeDidChange` will be called after any `Route`'s
450
+ [didTransition](/ember/release/classes/Route/events/didTransition?anchor=didTransition)
451
+ action has been fired.
452
+ The updates of properties
453
+ [currentURL](/ember/release/classes/RouterService/properties/currentURL?anchor=currentURL),
454
+ [currentRouteName](/ember/release/classes/RouterService/properties/currentURL?anchor=currentRouteName)
455
+ and
456
+ [currentRoute](/ember/release/classes/RouterService/properties/currentURL?anchor=currentRoute)
457
+ are completed at the time `routeDidChange` is called.
458
+ @event routeDidChange
459
+ @param {Transition} transition
460
+ @public
461
+ */
462
+
463
+ /**
464
+ * Refreshes all currently active routes, doing a full transition.
465
+ * If a route name is provided and refers to a currently active route,
466
+ * it will refresh only that route and its descendents.
467
+ * Returns a promise that will be resolved once the refresh is complete.
468
+ * All resetController, beforeModel, model, afterModel, redirect, and setupController
469
+ * hooks will be called again. You will get new data from the model hook.
470
+ *
471
+ * @method refresh
472
+ * @param {String} [routeName] the route to refresh (along with all child routes)
473
+ * @return Transition
474
+ * @public
475
+ */
476
+
477
+
478
+ refresh(pivotRouteName) {
479
+ if (!pivotRouteName) {
480
+ return this._router._routerMicrolib.refresh();
481
+ }
482
+
483
+ assert(`The route "${pivotRouteName}" was not found`, this._router.hasRoute(pivotRouteName));
484
+ assert(`The route "${pivotRouteName}" is currently not active`, this.isActive(pivotRouteName));
485
+ let owner = getOwner(this);
486
+ assert('RouterService is unexpectedly missing an owner', owner);
487
+ let pivotRoute = owner.lookup(`route:${pivotRouteName}`); // R could be instantiated with a different sub-type
488
+ // @ts-ignore
489
+
490
+ return this._router._routerMicrolib.refresh(pivotRoute);
491
+ }
497
492
 
498
493
  }
499
494
 
@@ -1,4 +1,8 @@
1
1
  export {};
2
+ /**
3
+ @module @ember/routing
4
+ */
5
+
2
6
  /**
3
7
  A `RouteInfoWithAttributes` is an object that contains
4
8
  metadata, including the resolved value from the routes
@@ -225,6 +225,8 @@ class EmberRouter extends EmberObject.extend(Evented) {
225
225
  seen[name] = true;
226
226
 
227
227
  if (!route) {
228
+ // SAFETY: this is configured in `commonSetupRegistry` in the
229
+ // `@ember/application/lib` package.
228
230
  let DefaultRoute = routeOwner.factoryFor('route:basic').class;
229
231
  routeOwner.register(fullRouteName, DefaultRoute.extend());
230
232
  route = routeOwner.lookup(fullRouteName);
@@ -1,4 +1,8 @@
1
1
  "use strict";
2
+ /**
3
+ @module @ember/routing
4
+ */
5
+
2
6
  /**
3
7
  A Transition is a thennable (a promise-like object) that represents
4
8
  an attempt to transition to another route. It can be aborted, either