ember-source 4.4.0-alpha.7 → 4.5.0-alpha.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.
@@ -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.4.0-alpha.7
8
+ * @version 4.5.0-alpha.2
9
9
  */
@@ -116,8 +116,7 @@ class Container {
116
116
  @private
117
117
  @method lookup
118
118
  @param {String} fullName
119
- @param {Object} [options]
120
- @param {String} [options.source] The fullname of the request source (used for local lookup)
119
+ @param {TypeOptions} [options]
121
120
  @return {any}
122
121
  */
123
122
 
@@ -197,9 +196,7 @@ class Container {
197
196
  }
198
197
 
199
198
  let normalizedName = this.registry.normalize(fullName);
200
- assert('fullName must be a proper full name', this.registry.isValidFullName(normalizedName)); // TODO: This needs to return a Factory to be compatible with Owner.
201
- // We should correctly the types so that this cast is not necessary.
202
-
199
+ assert('fullName must be a proper full name', this.registry.isValidFullName(normalizedName));
203
200
  return factoryFor(this, normalizedName, fullName);
204
201
  }
205
202
 
@@ -458,7 +455,6 @@ class Registry {
458
455
  this.fallback = options.fallback || null;
459
456
  this.resolver = options.resolver || null;
460
457
  this.registrations = dictionary(options.registrations || null);
461
- this._localLookupCache = Object.create(null);
462
458
  this._normalizeCache = dictionary(null);
463
459
  this._resolveCache = dictionary(null);
464
460
  this._failSet = new Set();
@@ -551,7 +547,6 @@ class Registry {
551
547
  unregister(fullName) {
552
548
  assert('fullName must be a proper full name', this.isValidFullName(fullName));
553
549
  let normalizedName = this.normalize(fullName);
554
- this._localLookupCache = Object.create(null);
555
550
  delete this.registrations[normalizedName];
556
551
  delete this._resolveCache[normalizedName];
557
552
  delete this._options[normalizedName];
@@ -582,8 +577,6 @@ class Registry {
582
577
  @private
583
578
  @method resolve
584
579
  @param {String} fullName
585
- @param {Object} [options]
586
- @param {String} [options.source] the fullname of the request source (used for local lookups)
587
580
  @return {Function} fullName's factory
588
581
  */
589
582
 
@@ -592,7 +585,7 @@ class Registry {
592
585
  let factory = resolve(this, this.normalize(fullName));
593
586
 
594
587
  if (factory === undefined && this.fallback !== null) {
595
- factory = this.fallback.resolve(...arguments);
588
+ factory = this.fallback.resolve(fullName);
596
589
  }
597
590
 
598
591
  return factory;
@@ -1,6 +1,6 @@
1
1
  import { templateFactory, programCompilationContext } from '@glimmer/opcode-compiler';
2
2
  export { templateFactory as template, templateCacheCounters } from '@glimmer/opcode-compiler';
3
- import { setOwner, getOwner } from '@ember/-internals/owner';
3
+ import { setOwner, getOwner, isFactory } from '@ember/-internals/owner';
4
4
  import { guidFor, symbol, enumerableSymbol, getDebugName, isProxy, isEmberArray, isObject, uuid } from '@ember/-internals/utils';
5
5
  import { assert, warn, debugFreeze, inspect, deprecate } from '@ember/debug';
6
6
  import { setComponentTemplate, setInternalComponentManager, setInternalHelperManager, getInternalHelperManager, helperCapabilities, setHelperManager, capabilityFlagsFrom, setInternalModifierManager, getComponentTemplate, getInternalComponentManager, componentCapabilities, modifierCapabilities, setComponentManager } from '@glimmer/manager';
@@ -2733,6 +2733,7 @@ class Helper extends FrameworkObject {
2733
2733
  init(properties) {
2734
2734
  super.init(properties);
2735
2735
  this[RECOMPUTE_TAG] = createTag();
2736
+ assert('expected compute to be defined', this.compute);
2736
2737
  }
2737
2738
  /**
2738
2739
  On a class-based helper, it may be useful to force a recomputation of that
@@ -2785,6 +2786,14 @@ class ClassicHelperManager {
2785
2786
 
2786
2787
  createHelper(definition, args) {
2787
2788
  let instance = isFactoryManager(definition) ? definition.create() : definition.create(this.ownerInjection);
2789
+ assert('expected HelperInstance', function (instance) {
2790
+ if (instance !== null && typeof instance === 'object') {
2791
+ let cast = instance;
2792
+ return typeof cast.compute === 'function' && typeof cast.destroy === 'function';
2793
+ }
2794
+
2795
+ return false;
2796
+ }(instance));
2788
2797
  return {
2789
2798
  instance,
2790
2799
  args
@@ -3042,9 +3051,12 @@ class OutletComponentManager {
3042
3051
  assert('Expected currentOwner to be an EngineInstance', currentOwner instanceof EngineInstance);
3043
3052
  let mountPoint = currentOwner.mountPoint;
3044
3053
  state.engine = currentOwner;
3045
- state.engineBucket = {
3046
- mountPoint
3047
- };
3054
+
3055
+ if (mountPoint) {
3056
+ state.engineBucket = {
3057
+ mountPoint
3058
+ };
3059
+ }
3048
3060
  }
3049
3061
  }
3050
3062
 
@@ -4814,7 +4826,7 @@ function layoutFor(name, owner, options) {
4814
4826
  function lookupComponentPair(owner, name, options) {
4815
4827
  let component = componentFor(name, owner);
4816
4828
 
4817
- if (component !== null && component.class !== undefined) {
4829
+ if (isFactory(component) && component.class) {
4818
4830
  let layout = getComponentTemplate(component.class);
4819
4831
 
4820
4832
  if (layout !== undefined) {
@@ -4896,13 +4908,13 @@ class ResolverImpl {
4896
4908
 
4897
4909
  lookupHelper(name, owner) {
4898
4910
  assert(`You attempted to overwrite the built-in helper "${name}" which is not allowed. Please rename the helper.`, !(BUILTIN_HELPERS[name] && owner.hasRegistration(`helper:${name}`)));
4899
- const helper$$1 = BUILTIN_HELPERS[name];
4911
+ let helper$$1 = BUILTIN_HELPERS[name];
4900
4912
 
4901
4913
  if (helper$$1 !== undefined) {
4902
4914
  return helper$$1;
4903
4915
  }
4904
4916
 
4905
- const factory = owner.factoryFor(`helper:${name}`);
4917
+ let factory = owner.factoryFor(`helper:${name}`);
4906
4918
 
4907
4919
  if (factory === undefined) {
4908
4920
  return null;
@@ -1,4 +1,7 @@
1
1
  import { getOwner as glimmerGetOwner, setOwner as glimmerSetOwner } from '@glimmer/owner';
2
+ export function isFactory(obj) {
3
+ return obj != null && typeof obj.create === 'function';
4
+ }
2
5
  /**
3
6
  Framework objects in an Ember application (components, services, routes, etc.)
4
7
  are created via a factory and dependency injection system. Each of these
@@ -78,6 +78,8 @@ const {
78
78
  */
79
79
 
80
80
  class EmberRouter extends EmberObject.extend(Evented) {
81
+ // Note that owner is actually required in this scenario, but since it is strictly
82
+ // optional in other contexts trying to make it required here confuses TS.
81
83
  constructor(owner) {
82
84
  super(owner);
83
85
  this._didSetupRouter = false;
@@ -97,6 +99,7 @@ class EmberRouter extends EmberObject.extend(Evented) {
97
99
  this._slowTransitionTimer = null;
98
100
  this.currentState = null;
99
101
  this.targetState = null;
102
+ assert('BUG: Missing owner', owner);
100
103
 
101
104
  this._resetQueuedQueryParameterChanges();
102
105
 
@@ -4,6 +4,7 @@
4
4
  import { NAMESPACES, NAMESPACES_BY_ID, addNamespace, findNamespace, findNamespaces, get, processNamespace, processAllNamespaces, removeNamespace } from '@ember/-internals/metal'; // Preloaded into namespaces
5
5
 
6
6
  import { getName, guidFor, setName } from '@ember/-internals/utils';
7
+ import { assert } from '@ember/debug';
7
8
  import EmberObject from './object';
8
9
  /**
9
10
  A Namespace is an object usually used to contain other objects or methods
@@ -23,20 +24,22 @@ import EmberObject from './object';
23
24
  @public
24
25
  */
25
26
 
26
- export default class Namespace extends EmberObject {
27
- init() {
27
+ class Namespace extends EmberObject {
28
+ init(properties) {
29
+ super.init(properties);
28
30
  addNamespace(this);
29
31
  }
30
32
 
31
33
  toString() {
32
- let name = get(this, 'name') || get(this, 'modulePrefix');
34
+ let existing_name = get(this, 'name') || get(this, 'modulePrefix');
33
35
 
34
- if (name) {
35
- return name;
36
+ if (existing_name) {
37
+ assert("name wasn't a string", typeof existing_name === 'string');
38
+ return existing_name;
36
39
  }
37
40
 
38
41
  findNamespaces();
39
- name = getName(this);
42
+ let name = getName(this);
40
43
 
41
44
  if (name === undefined) {
42
45
  name = guidFor(this);
@@ -52,12 +55,15 @@ export default class Namespace extends EmberObject {
52
55
 
53
56
  destroy() {
54
57
  removeNamespace(this);
55
- super.destroy();
58
+ return super.destroy();
56
59
  }
57
60
 
58
61
  }
59
- Namespace.prototype.isNamespace = true;
62
+
60
63
  Namespace.NAMESPACES = NAMESPACES;
61
64
  Namespace.NAMESPACES_BY_ID = NAMESPACES_BY_ID;
62
65
  Namespace.processAll = processAllNamespaces;
63
- Namespace.byName = findNamespace;
66
+ Namespace.byName = findNamespace; // Declare on the prototype to have a single shared value.
67
+
68
+ Namespace.prototype.isNamespace = true;
69
+ export default Namespace;
@@ -10,11 +10,7 @@ import { inject } from '@ember/-internals/metal';
10
10
  import { ActionHandler, Evented, FrameworkObject } from '@ember/-internals/runtime';
11
11
  import states from './states';
12
12
 
13
- class CoreView extends FrameworkObject.extend(Evented, ActionHandler, {
14
- // Continue to declare `_states` here so that we have a single reference on the prototype
15
- // instead of one on each instance.
16
- _states: states
17
- }) {
13
+ class CoreView extends FrameworkObject.extend(Evented, ActionHandler) {
18
14
  constructor() {
19
15
  super(...arguments);
20
16
  this.isView = true;
@@ -72,6 +68,8 @@ class CoreView extends FrameworkObject.extend(Evented, ActionHandler, {
72
68
 
73
69
  CoreView.isViewFactory = true;
74
70
 
75
- __decorate([inject('renderer', '-dom')], CoreView.prototype, "renderer", void 0);
71
+ __decorate([inject('renderer', '-dom')], CoreView.prototype, "renderer", void 0); // Declare on the prototype to have a single shared value.
76
72
 
73
+
74
+ CoreView.prototype._states = states;
77
75
  export default CoreView;