ember-source 4.0.0-beta.6 → 4.1.0-alpha.5

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.
@@ -5,5 +5,5 @@
5
5
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6
6
  * @license Licensed under MIT license
7
7
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
8
- * @version 4.0.0-beta.6
8
+ * @version 4.1.0-alpha.5
9
9
  */
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable no-var */
2
2
  /* globals global globalThis self */
3
+ /* eslint-disable-next-line no-unused-vars */
3
4
  var define, require;
4
5
 
5
6
  (function () {
@@ -19,7 +19,7 @@ export { DOMChanges, DOMTreeConstruction, isSerializationFirstNode } from '@glim
19
19
  import { CoreObject, TargetActionSupport, FrameworkObject, _contentFor, isArray } from '@ember/-internals/runtime';
20
20
  import { hasDOM } from '@ember/-internals/browser-environment';
21
21
  import { getEngineParent } from '@ember/engine';
22
- import { inject } from '@ember/service';
22
+ import { service } from '@ember/service';
23
23
  import { action } from '@ember/object';
24
24
  import { ENV } from '@ember/-internals/environment';
25
25
  import { getFactoryFor, privatize } from '@ember/-internals/container';
@@ -452,7 +452,7 @@ const ACTIONS = new _WeakSet();
452
452
 
453
453
  ```app/controllers/application.js
454
454
  import Controller from '@ember/controller';
455
- import { inject as service } from '@ember/service';
455
+ import { service } from '@ember/service';
456
456
 
457
457
  export default class extends Controller {
458
458
  @service someService;
@@ -3009,7 +3009,7 @@ const LinkComponent = Component.extend({
3009
3009
  this.on(eventName, this, this._invoke);
3010
3010
  },
3011
3011
 
3012
- _routing: inject('-routing'),
3012
+ _routing: service('-routing'),
3013
3013
  _currentRoute: alias('_routing.currentRouteName'),
3014
3014
  _currentRouterState: alias('_routing.currentState'),
3015
3015
  _targetRouterState: alias('_routing.targetState'),
@@ -4711,7 +4711,7 @@ let Helper = FrameworkObject.extend({
4711
4711
  session service changes:
4712
4712
  ```app/helpers/current-user-email.js
4713
4713
  import Helper from '@ember/component/helper'
4714
- import { inject as service } from '@ember/service'
4714
+ import { service } from '@ember/service'
4715
4715
  import { observer } from '@ember/object'
4716
4716
  export default Helper.extend({
4717
4717
  session: service(),
@@ -7827,7 +7827,7 @@ class LinkTo extends InternalComponent {
7827
7827
 
7828
7828
  }
7829
7829
 
7830
- __decorate$3([inject('-routing')], LinkTo.prototype, "routing", void 0);
7830
+ __decorate$3([service('-routing')], LinkTo.prototype, "routing", void 0);
7831
7831
 
7832
7832
  __decorate$3([action], LinkTo.prototype, "click", null); // Deprecated features
7833
7833
 
@@ -2241,7 +2241,7 @@ function isEmpty(obj) {
2241
2241
  return none;
2242
2242
  }
2243
2243
 
2244
- if (typeof obj.size === 'number') {
2244
+ if (typeof obj.unknownProperty !== 'function' && typeof obj.size === 'number') {
2245
2245
  return !obj.size;
2246
2246
  }
2247
2247
 
@@ -3478,6 +3478,69 @@ class TrackedDescriptor {
3478
3478
 
3479
3479
  }
3480
3480
 
3481
+ // NOTE: copied from: https://github.com/glimmerjs/glimmer.js/pull/358
3482
+ /**
3483
+ * @decorator
3484
+ *
3485
+ * The `@cached` decorator can be used on getters in order to cache the return
3486
+ * value of the getter. This is useful when a getter is expensive and used very
3487
+ * often.
3488
+ *
3489
+ *
3490
+ * @example
3491
+ *
3492
+ * in this guest list class, we have the `sortedGuests`
3493
+ * getter that sorts the guests alphabetically:
3494
+ *
3495
+ * ```js
3496
+ * import { tracked } from '@glimmer/tracking';
3497
+ *
3498
+ * class GuestList {
3499
+ * @tracked guests = ['Zoey', 'Tomster'];
3500
+ *
3501
+ * get sortedGuests() {
3502
+ * return this.guests.slice().sort()
3503
+ * }
3504
+ * }
3505
+ * ```
3506
+ *
3507
+ * Every time `sortedGuests` is accessed, a new array will be created and sorted,
3508
+ * because JavaScript getters do not cache by default. When the guest list is
3509
+ * small, like the one in the example, this is not a problem. However, if the guest
3510
+ * list were to grow very large, it would mean that we would be doing a large
3511
+ * amount of work each time we accessed `sortedGetters`. With `@cached`, we can
3512
+ * cache the value instead:
3513
+ *
3514
+ * ```js
3515
+ * import { tracked, cached } from '@glimmer/tracking';
3516
+ *
3517
+ * class GuestList {
3518
+ * @tracked guests = ['Zoey', 'Tomster'];
3519
+ *
3520
+ * @cached
3521
+ * get sortedGuests() {
3522
+ * return this.guests.slice().sort()
3523
+ * }
3524
+ * }
3525
+ * ```
3526
+ *
3527
+ * Now the `sortedGuests` getter will be cached based on _autotracking_. It will
3528
+ * only rerun and create a new sorted array when the `guests` tracked property is
3529
+ * updated.
3530
+ *
3531
+ * In general, you should avoid using `@cached` unless you have confirmed that the
3532
+ * getter you are decorating is computationally expensive. `@cached` adds a small
3533
+ * amount of overhead to the getter, making it more expensive. While this overhead
3534
+ * is small, if `@cached` is overused it can add up to a large impact overall in
3535
+ * your app. Many getters and tracked properties are only accessed once, rendered,
3536
+ * and then never rerendered, so adding `@cached` when it is unnecessary can
3537
+ * negatively impact performance.
3538
+ */
3539
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3540
+
3541
+ const cached = (...args) => {
3542
+ };
3543
+
3481
3544
  /**
3482
3545
  Ember uses caching based on trackable values to avoid updating large portions
3483
3546
  of the application. This caching is exposed via a cache primitive that can be
@@ -3600,4 +3663,4 @@ class TrackedDescriptor {
3600
3663
  @public
3601
3664
  */
3602
3665
 
3603
- export { computed, autoComputed, isComputed, ComputedProperty, getCachedValueFor, alias, deprecateProperty, PROXY_CONTENT, _getPath, get, _getProp, set, _setProp, trySet, objectAt, replace, replaceInNativeArray, addArrayObserver, removeArrayObserver, arrayContentWillChange, arrayContentDidChange, eachProxyArrayWillChange, eachProxyArrayDidChange, addListener, hasListeners, on, removeListener, sendEvent, isNone, isEmpty, isBlank, isPresent, beginPropertyChanges, changeProperties, endPropertyChanges, notifyPropertyChange, PROPERTY_DID_CHANGE, defineProperty, isElementDescriptor, nativeDescDecorator, descriptorForDecorator, descriptorForProperty, isClassicDecorator, setClassicDecorator, LIBRARIES as libraries, Libraries, getProperties, setProperties, expandProperties, ASYNC_OBSERVERS, SYNC_OBSERVERS, addObserver, activateObserver, removeObserver, flushAsyncObservers, Mixin, mixin, observer, applyMixin, inject, DEBUG_INJECTION_FUNCTIONS, tagForProperty, tagForObject, markObjectAsDirty, tracked, TrackedDescriptor, NAMESPACES, NAMESPACES_BY_ID, addNamespace, findNamespace, findNamespaces, processNamespace, processAllNamespaces, removeNamespace, isSearchDisabled as isNamespaceSearchDisabled, setSearchDisabled as setNamespaceSearchDisabled };
3666
+ export { computed, autoComputed, isComputed, ComputedProperty, getCachedValueFor, alias, deprecateProperty, PROXY_CONTENT, _getPath, get, _getProp, set, _setProp, trySet, objectAt, replace, replaceInNativeArray, addArrayObserver, removeArrayObserver, arrayContentWillChange, arrayContentDidChange, eachProxyArrayWillChange, eachProxyArrayDidChange, addListener, hasListeners, on, removeListener, sendEvent, isNone, isEmpty, isBlank, isPresent, beginPropertyChanges, changeProperties, endPropertyChanges, notifyPropertyChange, PROPERTY_DID_CHANGE, defineProperty, isElementDescriptor, nativeDescDecorator, descriptorForDecorator, descriptorForProperty, isClassicDecorator, setClassicDecorator, LIBRARIES as libraries, Libraries, getProperties, setProperties, expandProperties, ASYNC_OBSERVERS, SYNC_OBSERVERS, addObserver, activateObserver, removeObserver, flushAsyncObservers, Mixin, mixin, observer, applyMixin, inject, DEBUG_INJECTION_FUNCTIONS, tagForProperty, tagForObject, markObjectAsDirty, tracked, TrackedDescriptor, cached, NAMESPACES, NAMESPACES_BY_ID, addNamespace, findNamespace, findNamespaces, processNamespace, processAllNamespaces, removeNamespace, isSearchDisabled as isNamespaceSearchDisabled, setSearchDisabled as setNamespaceSearchDisabled };
@@ -28,7 +28,7 @@ function cleanURL(url, rootURL) {
28
28
  ```app/components/example.js
29
29
  import Component from '@glimmer/component';
30
30
  import { action } from '@ember/object';
31
- import { inject as service } from '@ember/service';
31
+ import { service } from '@ember/service';
32
32
 
33
33
  export default class ExampleComponent extends Component {
34
34
  @service router;
@@ -78,7 +78,7 @@ export default class RouterService extends Service {
78
78
  ```app/components/example.js
79
79
  import Component from '@glimmer/component';
80
80
  import { action } from '@ember/object';
81
- import { inject as service } from '@ember/service';
81
+ import { service } from '@ember/service';
82
82
  export default class extends Component {
83
83
  @service router;
84
84
  @action
@@ -172,7 +172,7 @@ export default class RouterService extends Service {
172
172
  ```
173
173
  ```app/components/copy-link.js
174
174
  import Component from '@glimmer/component';
175
- import { inject as service } from '@ember/service';
175
+ import { service } from '@ember/service';
176
176
  import { action } from '@ember/object';
177
177
  export default class CopyLinkComponent extends Component {
178
178
  @service router;
@@ -194,7 +194,7 @@ export default class RouterService extends Service {
194
194
  ```
195
195
  ```app/components/copy-link.js
196
196
  import Component from '@glimmer/component';
197
- import { inject as service } from '@ember/service';
197
+ import { service } from '@ember/service';
198
198
  import { action } from '@ember/object';
199
199
  export default class CopyLinkComponent extends Component {
200
200
  @service router;
@@ -234,7 +234,7 @@ export default class RouterService extends Service {
234
234
  In the following example, `isActive` will return `true` if the current route is `/posts`.
235
235
  ```app/components/posts.js
236
236
  import Component from '@glimmer/component';
237
- import { inject as service } from '@ember/service';
237
+ import { service } from '@ember/service';
238
238
  export default class extends Component {
239
239
  @service router;
240
240
  displayComments() {
@@ -246,7 +246,7 @@ export default class RouterService extends Service {
246
246
  assuming the post has an id of 1:
247
247
  ```app/components/posts.js
248
248
  import Component from '@glimmer/component';
249
- import { inject as service } from '@ember/service';
249
+ import { service } from '@ember/service';
250
250
  export default class extends Component {
251
251
  @service router;
252
252
  displayComments(post) {
@@ -325,7 +325,7 @@ export default class RouterService extends Service {
325
325
  application before transitioning to it.
326
326
  ```
327
327
  import Component from '@ember/component';
328
- import { inject as service } from '@ember/service';
328
+ import { service } from '@ember/service';
329
329
  export default class extends Component {
330
330
  @service router;
331
331
  path = '/';
@@ -520,7 +520,7 @@ RouterService.reopen(Evented, {
520
520
  Usage example:
521
521
  ```app/components/header.js
522
522
  import Component from '@glimmer/component';
523
- import { inject as service } from '@ember/service';
523
+ import { service } from '@ember/service';
524
524
  import { notEmpty } from '@ember/object/computed';
525
525
  export default class extends Component {
526
526
  @service router;
@@ -1286,7 +1286,7 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
1286
1286
  ```
1287
1287
  ```app/routes/application.js
1288
1288
  import Route from '@ember/routing/route';
1289
- import { inject as service } from '@ember/service';
1289
+ import { service } from '@ember/service';
1290
1290
  export default class ApplicationRoute extends Route {
1291
1291
  @service router
1292
1292
  constructor() {
@@ -862,7 +862,7 @@ const Application = Engine.extend({
862
862
  ```
863
863
  ```app/routes/post.js
864
864
  import Route from '@ember/routing/route';
865
- import { inject as service } from '@ember/service';
865
+ import { service } from '@ember/service';
866
866
  // An example of how the (hypothetical) service is used in routes.
867
867
  export default class IndexRoute extends Route {
868
868
  @service network;
@@ -11,15 +11,16 @@ import { ENV } from '@ember/-internals/environment';
11
11
  */
12
12
 
13
13
  export const DEFAULT_FEATURES = {
14
- EMBER_LIBRARIES_ISREGISTERED: false,
15
- EMBER_IMPROVED_INSTRUMENTATION: false,
14
+ EMBER_LIBRARIES_ISREGISTERED: null,
15
+ EMBER_IMPROVED_INSTRUMENTATION: null,
16
16
  EMBER_NAMED_BLOCKS: true,
17
17
  EMBER_GLIMMER_HELPER_MANAGER: true,
18
18
  EMBER_GLIMMER_INVOKE_HELPER: true,
19
19
  EMBER_MODERNIZED_BUILT_IN_COMPONENTS: true,
20
20
  EMBER_STRICT_MODE: true,
21
21
  EMBER_DYNAMIC_HELPERS_AND_MODIFIERS: true,
22
- EMBER_ROUTING_ROUTER_SERVICE_REFRESH: false
22
+ EMBER_ROUTING_ROUTER_SERVICE_REFRESH: null,
23
+ EMBER_CACHED: null
23
24
  };
24
25
  /**
25
26
  The hash of enabled Canary features. Add to this, any canary features
@@ -76,4 +77,5 @@ export const EMBER_GLIMMER_INVOKE_HELPER = featureValue(FEATURES.EMBER_GLIMMER_I
76
77
  export const EMBER_MODERNIZED_BUILT_IN_COMPONENTS = featureValue(FEATURES.EMBER_MODERNIZED_BUILT_IN_COMPONENTS);
77
78
  export const EMBER_STRICT_MODE = featureValue(FEATURES.EMBER_STRICT_MODE);
78
79
  export const EMBER_DYNAMIC_HELPERS_AND_MODIFIERS = featureValue(FEATURES.EMBER_DYNAMIC_HELPERS_AND_MODIFIERS);
79
- export const EMBER_ROUTING_ROUTER_SERVICE_REFRESH = featureValue(FEATURES.EMBER_ROUTING_ROUTER_SERVICE_REFRESH);
80
+ export const EMBER_ROUTING_ROUTER_SERVICE_REFRESH = featureValue(FEATURES.EMBER_ROUTING_ROUTER_SERVICE_REFRESH);
81
+ export const EMBER_CACHED = featureValue(FEATURES.EMBER_CACHED);
@@ -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 @@
1
- export { tracked } from '@ember/-internals/metal';
1
+ export { tracked, cached } from '@ember/-internals/metal';
@@ -12,7 +12,7 @@ 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
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';
@@ -227,7 +227,7 @@ Ember.inject = function inject() {
227
227
  assert(`Injected properties must be created through helpers, see '${Object.keys(inject).map(k => `'inject.${k}'`).join(' or ')}'`);
228
228
  };
229
229
 
230
- Ember.inject.service = injectService;
230
+ Ember.inject.service = service;
231
231
  Ember.inject.controller = injectController;
232
232
  Ember.Array = EmberArray;
233
233
  Ember.Comparable = Comparable;
@@ -1 +1 @@
1
- export default "4.0.0-beta.6";
1
+ export default "4.1.0-alpha.5";
@@ -23,6 +23,7 @@ export default Adapter.extend({
23
23
  asyncStart() {
24
24
  if (typeof QUnit.stop === 'function') {
25
25
  // very old QUnit version
26
+ // eslint-disable-next-line qunit/no-qunit-stop
26
27
  QUnit.stop();
27
28
  } else {
28
29
  this.doneCallbacks.push(QUnit.config.current ? QUnit.config.current.assert.async() : null);