ember-source 4.1.0-alpha.3 → 4.1.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 (56) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js +1 -1
  3. package/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +1 -1
  4. package/blueprints/component-test/qunit-files/__root__/__testType__/__path__/__test__.js +3 -3
  5. package/blueprints/helper-test/index.js +4 -22
  6. package/blueprints/helper-test/mocha-0.12-files/__root__/__testType__/__collection__/__name__-test.js +1 -13
  7. package/blueprints/helper-test/mocha-files/__root__/__testType__/__collection__/__name__-test.js +0 -13
  8. package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -12
  9. package/blueprints/helper-test/qunit-files/__root__/__testType__/__collection__/__name__-test.js +2 -13
  10. package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -14
  11. package/build-metadata.json +3 -3
  12. package/dist/dependencies/@glimmer/manager.js +19 -98
  13. package/dist/dependencies/@glimmer/opcode-compiler.js +9 -146
  14. package/dist/dependencies/@glimmer/validator.js +19 -51
  15. package/dist/ember-template-compiler.js +379 -696
  16. package/dist/ember-template-compiler.map +1 -1
  17. package/dist/ember-testing.js +3 -1
  18. package/dist/ember-testing.map +1 -1
  19. package/dist/ember.debug.js +3069 -5913
  20. package/dist/ember.debug.map +1 -1
  21. package/dist/header/license.js +1 -1
  22. package/dist/header/loader.js +1 -0
  23. package/dist/packages/@ember/-internals/container/index.js +1 -1
  24. package/dist/packages/@ember/-internals/environment/index.js +0 -15
  25. package/dist/packages/@ember/-internals/glimmer/index.js +4825 -6770
  26. package/dist/packages/@ember/-internals/metal/index.js +41 -73
  27. package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +1 -0
  28. package/dist/packages/@ember/-internals/routing/lib/location/api.js +10 -1
  29. package/dist/packages/@ember/-internals/routing/lib/location/none_location.js +7 -2
  30. package/dist/packages/@ember/-internals/routing/lib/services/router.js +8 -8
  31. package/dist/packages/@ember/-internals/routing/lib/services/routing.js +1 -1
  32. package/dist/packages/@ember/-internals/routing/lib/system/route.js +3 -42
  33. package/dist/packages/@ember/-internals/routing/lib/system/router.js +36 -46
  34. package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +3 -43
  35. package/dist/packages/@ember/-internals/utils/index.js +0 -3
  36. package/dist/packages/@ember/-internals/views/index.js +0 -1
  37. package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +4 -4
  38. package/dist/packages/@ember/application/lib/application.js +8 -9
  39. package/dist/packages/@ember/canary-features/index.js +1 -3
  40. package/dist/packages/@ember/component/index.js +1 -1
  41. package/dist/packages/@ember/deprecated-features/index.js +0 -1
  42. package/dist/packages/@ember/engine/index.js +1 -2
  43. package/dist/packages/@ember/routing/index.js +1 -1
  44. package/dist/packages/@ember/service/index.js +19 -5
  45. package/dist/packages/@glimmer/tracking/index.js +203 -1
  46. package/dist/packages/ember/index.js +11 -63
  47. package/dist/packages/ember/version.js +1 -1
  48. package/docs/data.json +355 -1147
  49. package/lib/index.js +11 -48
  50. package/package.json +20 -21
  51. package/dist/packages/@ember/-internals/views/lib/mixins/text_support.js +0 -345
  52. package/dist/packages/@ember/component/checkbox.js +0 -17
  53. package/dist/packages/@ember/component/text-area.js +0 -17
  54. package/dist/packages/@ember/component/text-field.js +0 -17
  55. package/dist/packages/@ember/routing/link-component.js +0 -17
  56. package/dist/packages/jquery/index.js +0 -2
@@ -16,11 +16,10 @@ export const DEFAULT_FEATURES = {
16
16
  EMBER_NAMED_BLOCKS: true,
17
17
  EMBER_GLIMMER_HELPER_MANAGER: true,
18
18
  EMBER_GLIMMER_INVOKE_HELPER: true,
19
- EMBER_MODERNIZED_BUILT_IN_COMPONENTS: true,
20
19
  EMBER_STRICT_MODE: true,
21
20
  EMBER_DYNAMIC_HELPERS_AND_MODIFIERS: true,
22
21
  EMBER_ROUTING_ROUTER_SERVICE_REFRESH: null,
23
- EMBER_CACHED: null
22
+ EMBER_CACHED: true
24
23
  };
25
24
  /**
26
25
  The hash of enabled Canary features. Add to this, any canary features
@@ -74,7 +73,6 @@ export const EMBER_IMPROVED_INSTRUMENTATION = featureValue(FEATURES.EMBER_IMPROV
74
73
  export const EMBER_NAMED_BLOCKS = featureValue(FEATURES.EMBER_NAMED_BLOCKS);
75
74
  export const EMBER_GLIMMER_HELPER_MANAGER = featureValue(FEATURES.EMBER_GLIMMER_HELPER_MANAGER);
76
75
  export const EMBER_GLIMMER_INVOKE_HELPER = featureValue(FEATURES.EMBER_GLIMMER_INVOKE_HELPER);
77
- export const EMBER_MODERNIZED_BUILT_IN_COMPONENTS = featureValue(FEATURES.EMBER_MODERNIZED_BUILT_IN_COMPONENTS);
78
76
  export const EMBER_STRICT_MODE = featureValue(FEATURES.EMBER_STRICT_MODE);
79
77
  export const EMBER_DYNAMIC_HELPERS_AND_MODIFIERS = featureValue(FEATURES.EMBER_DYNAMIC_HELPERS_AND_MODIFIERS);
80
78
  export const EMBER_ROUTING_ROUTER_SERVICE_REFRESH = featureValue(FEATURES.EMBER_ROUTING_ROUTER_SERVICE_REFRESH);
@@ -1,3 +1,3 @@
1
1
  export { setComponentTemplate, getComponentTemplate } from '@glimmer/manager';
2
- export { Component as default, Input } from '@ember/-internals/glimmer';
2
+ export { Component as default, Input, Textarea } from '@ember/-internals/glimmer';
3
3
  export { componentCapabilities as capabilities, setComponentManager } from '@ember/-internals/glimmer';
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable no-implicit-coercion */
2
2
  // These versions should be the version that the deprecation was _introduced_,
3
3
  // not the version that the feature will be removed.
4
- export const ROUTER_EVENTS = !!'4.0.0';
5
4
  export const ASSIGN = !!'4.0.0-beta.1';
@@ -292,7 +292,6 @@ Engine.reopenClass({
292
292
  and after.
293
293
  Example instanceInitializer to preload data into the store.
294
294
  ```app/initializer/preload-data.js
295
- import $ from 'jquery';
296
295
  export function initialize(application) {
297
296
  var userConfig, userConfigEncoded, store;
298
297
  // We have a HTML escaped JSON representation of the user's basic
@@ -303,7 +302,7 @@ Engine.reopenClass({
303
302
  // like all local models and data can be manipulated by the user, so it
304
303
  // should not be relied upon for security or authorization.
305
304
  // Grab the encoded data from the meta tag
306
- userConfigEncoded = $('head meta[name=app-user-config]').attr('content');
305
+ userConfigEncoded = document.querySelector('head meta[name=app-user-config]').attr('content');
307
306
  // Unescape the text, then parse the resulting JSON into a real object
308
307
  userConfig = JSON.parse(unescape(userConfigEncoded));
309
308
  // Lookup the store
@@ -1 +1 @@
1
- export { LinkComponent as LinkTo } from '@ember/-internals/glimmer';
1
+ export { LinkTo } from '@ember/-internals/glimmer';
@@ -5,6 +5,20 @@ import { inject as metalInject } from '@ember/-internals/metal';
5
5
  @public
6
6
  */
7
7
 
8
+ /**
9
+ @method inject
10
+ @static
11
+ @since 1.10.0
12
+ @for @ember/service
13
+ @param {String} name (optional) name of the service to inject, defaults to
14
+ the property's name
15
+ @return {ComputedDecorator} injection decorator instance
16
+ @public
17
+ */
18
+
19
+ export function inject() {
20
+ return metalInject('service', ...arguments);
21
+ }
8
22
  /**
9
23
  Creates a property that lazily looks up a service in the container. There are
10
24
  no restrictions as to what objects a service can be injected into.
@@ -13,7 +27,7 @@ import { inject as metalInject } from '@ember/-internals/metal';
13
27
 
14
28
  ```app/routes/application.js
15
29
  import Route from '@ember/routing/route';
16
- import { inject as service } from '@ember/service';
30
+ import { service } from '@ember/service';
17
31
 
18
32
  export default class ApplicationRoute extends Route {
19
33
  @service('auth') authManager;
@@ -28,7 +42,7 @@ import { inject as metalInject } from '@ember/-internals/metal';
28
42
 
29
43
  ```app/routes/application.js
30
44
  import Route from '@ember/routing/route';
31
- import { inject as service } from '@ember/service';
45
+ import { service } from '@ember/service';
32
46
 
33
47
  export default Route.extend({
34
48
  authManager: service('auth'),
@@ -43,9 +57,9 @@ import { inject as metalInject } from '@ember/-internals/metal';
43
57
  that looks up the `auth` service in the container, making it easily accessible
44
58
  in the `model` hook.
45
59
 
46
- @method inject
60
+ @method service
47
61
  @static
48
- @since 1.10.0
62
+ @since 4.1.0
49
63
  @for @ember/service
50
64
  @param {String} name (optional) name of the service to inject, defaults to
51
65
  the property's name
@@ -53,7 +67,7 @@ import { inject as metalInject } from '@ember/-internals/metal';
53
67
  @public
54
68
  */
55
69
 
56
- export function inject() {
70
+ export function service() {
57
71
  return metalInject('service', ...arguments);
58
72
  }
59
73
  /**
@@ -1 +1,203 @@
1
- export { tracked, cached } from '@ember/-internals/metal';
1
+ export { tracked, cached } from '@ember/-internals/metal';
2
+ /**
3
+ In order to tell Ember a value might change, we need to mark it as trackable.
4
+ Trackable values are values that:
5
+
6
+ - Can change over their component’s lifetime and
7
+ - Should cause Ember to rerender if and when they change
8
+
9
+ We can do this by marking the field with the `@tracked` decorator.
10
+
11
+ @module @glimmer/tracking
12
+ @public
13
+ */
14
+
15
+ /**
16
+ Marks a property as tracked. By default, values that are rendered in Ember app
17
+ templates are _static_, meaning that updates to them won't cause the
18
+ application to rerender. Marking a property as tracked means that when that
19
+ property changes, any templates that used that property, directly or
20
+ indirectly, will rerender. For instance, consider this component:
21
+
22
+ ```handlebars
23
+ <div>Count: {{this.count}}</div>
24
+ <div>Times Ten: {{this.timesTen}}</div>
25
+ <div>
26
+ <button {{on "click" this.plusOne}}>
27
+ Plus One
28
+ </button>
29
+ </div>
30
+ ```
31
+
32
+ ```javascript
33
+ import Component from '@glimmer/component';
34
+ import { tracked } from '@glimmer/tracking';
35
+ import { action } from '@ember/object';
36
+
37
+ export default class CounterComponent extends Component {
38
+ @tracked count = 0;
39
+
40
+ get timesTen() {
41
+ return this.count * 10;
42
+ }
43
+
44
+ @action
45
+ plusOne() {
46
+ this.count += 1;
47
+ }
48
+ }
49
+ ```
50
+
51
+ Both the `{{this.count}}` and the `{{this.timesTen}}` properties in the
52
+ template will update whenever the button is clicked. Any tracked properties
53
+ that are used in any way to calculate a value that is used in the template
54
+ will cause a rerender when updated - this includes through method calls and
55
+ other means:
56
+
57
+ ```javascript
58
+ import Component from '@glimmer/component';
59
+ import { tracked } from '@glimmer/tracking';
60
+
61
+ class Entry {
62
+ @tracked name;
63
+ @tracked phoneNumber;
64
+
65
+ constructor(name, phoneNumber) {
66
+ this.name = name;
67
+ this.phoneNumber = phoneNumber;
68
+ }
69
+ }
70
+
71
+ export default class PhoneBookComponent extends Component {
72
+ entries = [
73
+ new Entry('Pizza Palace', 5551234),
74
+ new Entry('1st Street Cleaners', 5554321),
75
+ new Entry('Plants R Us', 5552468),
76
+ ];
77
+
78
+ // Any usage of this property will update whenever any of the names in the
79
+ // entries arrays are updated
80
+ get names() {
81
+ return this.entries.map(e => e.name);
82
+ }
83
+
84
+ // Any usage of this property will update whenever any of the numbers in the
85
+ // entries arrays are updated
86
+ get numbers() {
87
+ return this.getFormattedNumbers();
88
+ }
89
+
90
+ getFormattedNumbers() {
91
+ return this.entries
92
+ .map(e => e.phoneNumber)
93
+ .map(number => {
94
+ let numberString = '' + number;
95
+
96
+ return numberString.slice(0, 3) + '-' + numberString.slice(3);
97
+ });
98
+ }
99
+ }
100
+ ```
101
+
102
+ It's important to note that setting tracked properties will always trigger an
103
+ update, even if the property is set to the same value as it was before.
104
+
105
+ ```js
106
+ let entry = new Entry('Pizza Palace', 5551234);
107
+ // if entry was used when rendering, this would cause a rerender, even though
108
+ // the name is being set to the same value as it was before
109
+ entry.name = entry.name;
110
+ ```
111
+
112
+ `tracked` can also be used with the classic Ember object model in a similar
113
+ manner to classic computed properties:
114
+
115
+ ```javascript
116
+ import EmberObject from '@ember/object';
117
+ import { tracked } from '@glimmer/tracking';
118
+
119
+ const Entry = EmberObject.extend({
120
+ name: tracked(),
121
+ phoneNumber: tracked()
122
+ });
123
+ ```
124
+
125
+ Often this is unnecessary, but to ensure robust auto-tracking behavior it is
126
+ advisable to mark tracked state appropriately wherever possible.
127
+ This form of `tracked` also accepts an optional configuration object
128
+ containing either an initial `value` or an `initializer` function (but not
129
+ both).
130
+
131
+ ```javascript
132
+ import EmberObject from '@ember/object';
133
+ import { tracked } from '@glimmer/tracking';
134
+
135
+ const Entry = EmberObject.extend({
136
+ name: tracked({ value: 'Zoey' }),
137
+ favoriteSongs: tracked({
138
+ initializer: () => ['Raspberry Beret', 'Time After Time']
139
+ })
140
+ });
141
+ ```
142
+
143
+ @method tracked
144
+ @static
145
+ @for @glimmer/tracking
146
+ @public
147
+ */
148
+
149
+ /**
150
+ The `@cached` decorator can be used on getters in order to cache the return
151
+ value of the getter. This is useful when a getter is expensive and used very
152
+ often. For instance, in this guest list class, we have the `sortedGuests`
153
+ getter that sorts the guests alphabetically:
154
+
155
+ ```js
156
+ import { tracked } from '@glimmer/tracking';
157
+
158
+ class GuestList {
159
+ @tracked guests = ['Zoey', 'Tomster'];
160
+
161
+ get sortedGuests() {
162
+ return this.guests.slice().sort()
163
+ }
164
+ }
165
+ ```
166
+
167
+ Every time `sortedGuests` is accessed, a new array will be created and sorted,
168
+ because JavaScript getters do not cache by default. When the guest list is
169
+ small, like the one in the example, this is not a problem. However, if the guest
170
+ list were to grow very large, it would mean that we would be doing a large
171
+ amount of work each time we accessed `sortedGetters`. With `@cached`, we can
172
+ cache the value instead:
173
+
174
+ ```js
175
+ import { tracked, cached } from '@glimmer/tracking';
176
+
177
+ class GuestList {
178
+ @tracked guests = ['Zoey', 'Tomster'];
179
+
180
+ @cached
181
+ get sortedGuests() {
182
+ return this.guests.slice().sort()
183
+ }
184
+ }
185
+ ```
186
+
187
+ Now the `sortedGuests` getter will be cached based on _autotracking_. It will
188
+ only rerun and create a new sorted array when the `guests` tracked property is
189
+ updated.
190
+
191
+ In general, you should avoid using `@cached` unless you have confirmed that the
192
+ getter you are decorating is computationally expensive. `@cached` adds a small
193
+ amount of overhead to the getter, making it more expensive. While this overhead
194
+ is small, if `@cached` is overused it can add up to a large impact overall in
195
+ your app. Many getters and tracked properties are only accessed once, rendered,
196
+ and then never rerendered, so adding `@cached` when it is unnecessary can
197
+ negatively impact performance.
198
+
199
+ @method cached
200
+ @static
201
+ @for @glimmer/tracking
202
+ @public
203
+ */
@@ -12,11 +12,11 @@ import Backburner from 'backburner';
12
12
  import Controller, { inject as injectController } from '@ember/controller';
13
13
  import ControllerMixin from '@ember/controller/lib/controller_mixin';
14
14
  import { _getStrings, _setStrings, dasherize, camelize, capitalize, classify, decamelize, loc, underscore, w } from '@ember/string';
15
- import Service, { inject as injectService } from '@ember/service';
15
+ import Service, { service } from '@ember/service';
16
16
  import { action, computed } from '@ember/object';
17
17
  import { dependentKeyCompat } from '@ember/object/compat';
18
- import { Object as EmberObject, RegistryProxyMixin, ContainerProxyMixin, compare, isEqual, Array as EmberArray, MutableEnumerable, MutableArray, TargetActionSupport, Evented, PromiseProxyMixin, Observable, typeOf, isArray, _ProxyMixin, RSVP, Comparable, Namespace, Enumerable, ArrayProxy, ObjectProxy, ActionHandler, CoreObject, NativeArray, A } from '@ember/-internals/runtime';
19
- import { Checkbox, Component, componentCapabilities, modifierCapabilities, setComponentManager, escapeExpression, getTemplates, Helper, helper, htmlSafe, isHTMLSafe, LinkComponent, setTemplates, template, TextField, TextArea, Input, isSerializationFirstNode } from '@ember/-internals/glimmer'; // eslint-disable-next-line import/no-unresolved
18
+ import { Object as EmberObject, RegistryProxyMixin, ContainerProxyMixin, compare, isEqual, Array as EmberArray, MutableEnumerable, MutableArray, Evented, PromiseProxyMixin, Observable, typeOf, isArray, _ProxyMixin, RSVP, Comparable, Namespace, Enumerable, ArrayProxy, ObjectProxy, ActionHandler, CoreObject, NativeArray, A } from '@ember/-internals/runtime';
19
+ import { Component, componentCapabilities, modifierCapabilities, setComponentManager, escapeExpression, getTemplates, Helper, helper, htmlSafe, isHTMLSafe, setTemplates, template, Input, isSerializationFirstNode } from '@ember/-internals/glimmer'; // eslint-disable-next-line import/no-unresolved
20
20
 
21
21
  import VERSION from './version';
22
22
  import * as views from '@ember/-internals/views';
@@ -164,12 +164,16 @@ Ember._isDestroyed = isDestroyed;
164
164
  and reporting code.
165
165
 
166
166
  ```javascript
167
- import $ from 'jquery';
168
167
 
169
168
  Ember.onerror = function(error) {
170
- $.ajax('/report-error', 'POST', {
169
+ const payload = {
171
170
  stack: error.stack,
172
171
  otherInformation: 'whatever app state you want to provide'
172
+ };
173
+
174
+ fetch('/report-error', {
175
+ method: 'POST',
176
+ body: JSON.stringify(payload)
173
177
  });
174
178
  };
175
179
  ```
@@ -227,7 +231,7 @@ Ember.inject = function inject() {
227
231
  assert(`Injected properties must be created through helpers, see '${Object.keys(inject).map(k => `'inject.${k}'`).join(' or ')}'`);
228
232
  };
229
233
 
230
- Ember.inject.service = injectService;
234
+ Ember.inject.service = service;
231
235
  Ember.inject.controller = injectController;
232
236
  Ember.Array = EmberArray;
233
237
  Ember.Comparable = Comparable;
@@ -296,52 +300,6 @@ Object.defineProperty(Ember, 'BOOTED', {
296
300
  Ember.Component = Component;
297
301
  Helper.helper = helper;
298
302
  Ember.Helper = Helper;
299
-
300
- if (true
301
- /* EMBER_MODERNIZED_BUILT_IN_COMPONENTS */
302
- ) {
303
- [['Checkbox', '@ember/component/checkbox', Checkbox, true], ['TextField', '@ember/component/text-field', TextField, true], ['TextArea', '@ember/component/text-area', TextArea, true], ['LinkComponent', '@ember/routing/link-component', LinkComponent, true], ['TextSupport', null, views.TextSupport, false], ['TargetActionSupport', null, TargetActionSupport, false]].forEach(([name, path, value, availableInLegacyAddon]) => {
304
- Object.defineProperty(Ember, name, {
305
- get() {
306
- let message = `Using Ember.${name}`;
307
-
308
- if (path !== null) {
309
- message += ` or importing from '${path}'`;
310
- }
311
-
312
- message += ` is deprecated.`;
313
-
314
- if (availableInLegacyAddon) {
315
- message += ` Install the \`@ember/legacy-built-in-components\` addon and use ` + `\`import { ${name} } from '@ember/legacy-built-in-components';\` instead.`;
316
- }
317
-
318
- deprecate(message, false, {
319
- id: 'ember.built-in-components.import',
320
- until: '4.0.0',
321
- for: 'ember-source',
322
- since: {
323
- enabled: '3.27.0'
324
- },
325
- url: 'https://deprecations.emberjs.com/v3.x#toc_ember-built-in-components-import'
326
- });
327
- return value;
328
- },
329
-
330
- configurable: true,
331
- enumerable: true
332
- }); // Expose a non-deprecated version for tests and the @ember/legacy-built-in-components addon
333
-
334
- Ember[`_Legacy${name}`] = value;
335
- });
336
- } else {
337
- Ember.Checkbox = Checkbox;
338
- Ember.TextField = TextField;
339
- Ember.TextArea = TextArea;
340
- Ember.LinkComponent = LinkComponent;
341
- Ember.TextSupport = views.TextSupport;
342
- Ember.TargetActionSupport = TargetActionSupport;
343
- }
344
-
345
303
  Ember._setComponentManager = setComponentManager;
346
304
  Ember._componentManagerCapabilities = componentCapabilities;
347
305
  Ember._setModifierManager = setModifierManager;
@@ -553,14 +511,4 @@ Ember.__loader = {
553
511
  // eslint-disable-next-line no-undef
554
512
  registry: typeof requirejs !== 'undefined' ? requirejs.entries : require.entries
555
513
  };
556
- export default Ember;
557
- /**
558
- @module jquery
559
- @public
560
- */
561
-
562
- /**
563
- @class jquery
564
- @public
565
- @static
566
- */
514
+ export default Ember;
@@ -1 +1 @@
1
- export default "4.1.0-alpha.3";
1
+ export default "4.1.0-alpha.7";