ember-source 4.3.0-alpha.2 → 4.4.0-alpha.1
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.
- package/CHANGELOG.md +6 -2
- package/build-metadata.json +3 -3
- package/dist/dependencies/router_js.js +66 -31
- package/dist/ember-template-compiler.js +1169 -779
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +74 -43
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +3290 -2760
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/container/index.js +15 -11
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +3 -3
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +52 -52
- package/dist/packages/@ember/-internals/glimmer/index.js +139 -103
- package/dist/packages/@ember/-internals/meta/lib/meta.js +8 -9
- package/dist/packages/@ember/-internals/metal/index.js +44 -45
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +10 -8
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +155 -190
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/system/route-info.js +2 -2
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +110 -378
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +74 -36
- package/dist/packages/@ember/-internals/routing/lib/utils.js +33 -21
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -0
- package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +4 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +29 -29
- package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +16 -16
- package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +48 -48
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +8 -8
- package/dist/packages/@ember/-internals/runtime/lib/system/namespace.js +1 -2
- package/dist/packages/@ember/-internals/runtime/lib/type-of.js +1 -1
- package/dist/packages/@ember/-internals/utils/index.js +10 -8
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +2 -0
- package/dist/packages/@ember/array/index.js +1 -1
- package/dist/packages/@ember/controller/index.js +3 -54
- package/dist/packages/@ember/instrumentation/index.js +9 -13
- package/dist/packages/@ember/object/compat.js +16 -7
- package/dist/packages/@ember/routing/router-service.js +1 -0
- package/dist/packages/@ember/service/index.js +6 -73
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +571 -521
- package/package.json +13 -13
package/dist/header/license.js
CHANGED
|
@@ -18,6 +18,7 @@ if (DEBUG) {
|
|
|
18
18
|
containers = new WeakSet();
|
|
19
19
|
return {
|
|
20
20
|
hasContainers() {
|
|
21
|
+
// @ts-expect-error We just checked if it is definied
|
|
21
22
|
gc();
|
|
22
23
|
return GetWeakSetValues(containers).length > 0;
|
|
23
24
|
},
|
|
@@ -123,7 +124,7 @@ class Container {
|
|
|
123
124
|
|
|
124
125
|
lookup(fullName, options) {
|
|
125
126
|
if (this.isDestroyed) {
|
|
126
|
-
throw new Error(`
|
|
127
|
+
throw new Error(`Cannot call \`.lookup\` after the owner has been destroyed`);
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
assert('fullName must be a proper full name', this.registry.isValidFullName(fullName));
|
|
@@ -194,7 +195,7 @@ class Container {
|
|
|
194
195
|
|
|
195
196
|
factoryFor(fullName) {
|
|
196
197
|
if (this.isDestroyed) {
|
|
197
|
-
throw new Error(`
|
|
198
|
+
throw new Error(`Cannot call \`.factoryFor\` after the owner has been destroyed`);
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
let normalizedName = this.registry.normalize(fullName);
|
|
@@ -351,9 +352,9 @@ function destroyDestroyables(container) {
|
|
|
351
352
|
let cache = container.cache;
|
|
352
353
|
let keys = Object.keys(cache);
|
|
353
354
|
|
|
354
|
-
for (let
|
|
355
|
-
let key = keys[i];
|
|
355
|
+
for (let key of keys) {
|
|
356
356
|
let value = cache[key];
|
|
357
|
+
assert('has cached value', value);
|
|
357
358
|
|
|
358
359
|
if (value.destroy) {
|
|
359
360
|
value.destroy();
|
|
@@ -386,7 +387,6 @@ function getFactoryFor(obj) {
|
|
|
386
387
|
function setFactoryFor(obj, factory) {
|
|
387
388
|
obj[INIT_FACTORY] = factory;
|
|
388
389
|
}
|
|
389
|
-
|
|
390
390
|
class FactoryManager {
|
|
391
391
|
constructor(container, factory, fullName, normalizedName) {
|
|
392
392
|
this.container = container;
|
|
@@ -417,7 +417,7 @@ class FactoryManager {
|
|
|
417
417
|
} = this;
|
|
418
418
|
|
|
419
419
|
if (container.isDestroyed) {
|
|
420
|
-
throw new Error(`
|
|
420
|
+
throw new Error(`Cannot create new instances after the owner has been destroyed (you attempted to create ${this.fullName})`);
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
let props = {};
|
|
@@ -781,6 +781,8 @@ class Registry {
|
|
|
781
781
|
}
|
|
782
782
|
|
|
783
783
|
let type = fullName.split(':')[0];
|
|
784
|
+
assert('has type', type); // split always will have at least one value
|
|
785
|
+
|
|
784
786
|
options = this._typeOptions[type];
|
|
785
787
|
|
|
786
788
|
if (options && options[optionName] !== undefined) {
|
|
@@ -827,8 +829,7 @@ class Registry {
|
|
|
827
829
|
let localKnown = dictionary(null);
|
|
828
830
|
let registeredNames = Object.keys(this.registrations);
|
|
829
831
|
|
|
830
|
-
for (let
|
|
831
|
-
let fullName = registeredNames[index];
|
|
832
|
+
for (let fullName of registeredNames) {
|
|
832
833
|
let itemType = fullName.split(':')[0];
|
|
833
834
|
|
|
834
835
|
if (itemType === type) {
|
|
@@ -863,9 +864,11 @@ if (DEBUG) {
|
|
|
863
864
|
|
|
864
865
|
for (let key in hash) {
|
|
865
866
|
if (Object.prototype.hasOwnProperty.call(hash, key)) {
|
|
867
|
+
let value = hash[key];
|
|
868
|
+
assert('has value', value);
|
|
866
869
|
let {
|
|
867
870
|
specifier
|
|
868
|
-
} =
|
|
871
|
+
} = value;
|
|
869
872
|
assert(`Expected a proper full name, given '${specifier}'`, this.isValidFullName(specifier));
|
|
870
873
|
injections.push({
|
|
871
874
|
property: key,
|
|
@@ -882,10 +885,10 @@ if (DEBUG) {
|
|
|
882
885
|
return;
|
|
883
886
|
}
|
|
884
887
|
|
|
885
|
-
for (let
|
|
888
|
+
for (let injection of injections) {
|
|
886
889
|
let {
|
|
887
890
|
specifier
|
|
888
|
-
} =
|
|
891
|
+
} = injection;
|
|
889
892
|
assert(`Attempting to inject an unknown injection: '${specifier}'`, this.has(specifier));
|
|
890
893
|
}
|
|
891
894
|
};
|
|
@@ -929,6 +932,7 @@ function has(registry, fullName) {
|
|
|
929
932
|
const privateNames = dictionary(null);
|
|
930
933
|
const privateSuffix = `${Math.random()}${Date.now()}`.replace('.', '');
|
|
931
934
|
function privatize([fullName]) {
|
|
935
|
+
assert('has a single string argument', arguments.length === 1 && fullName);
|
|
932
936
|
let name = privateNames[fullName];
|
|
933
937
|
|
|
934
938
|
if (name) {
|
|
@@ -51,7 +51,7 @@ export default EmberObject.extend({
|
|
|
51
51
|
The resolver instance of the application
|
|
52
52
|
being debugged. This property will be injected
|
|
53
53
|
on creation.
|
|
54
|
-
|
|
54
|
+
@property resolver
|
|
55
55
|
@default null
|
|
56
56
|
@public
|
|
57
57
|
*/
|
|
@@ -60,7 +60,7 @@ export default EmberObject.extend({
|
|
|
60
60
|
/**
|
|
61
61
|
Returns true if it is possible to catalog a list of available
|
|
62
62
|
classes in the resolver for a given type.
|
|
63
|
-
|
|
63
|
+
@method canCatalogEntriesByType
|
|
64
64
|
@param {String} type The type. e.g. "model", "controller", "route".
|
|
65
65
|
@return {boolean} whether a list is available for this type.
|
|
66
66
|
@public
|
|
@@ -75,7 +75,7 @@ export default EmberObject.extend({
|
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
Returns the available classes a given type.
|
|
78
|
-
|
|
78
|
+
@method catalogEntriesByType
|
|
79
79
|
@param {String} type The type. e.g. "model", "controller", "route".
|
|
80
80
|
@return {Array} An array of strings.
|
|
81
81
|
@public
|
|
@@ -16,25 +16,6 @@ function iterate(arr, fn) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
class RecordsWatcher {
|
|
19
|
-
getCacheForItem(record) {
|
|
20
|
-
let recordCache = this.recordCaches.get(record);
|
|
21
|
-
|
|
22
|
-
if (!recordCache) {
|
|
23
|
-
let hasBeenAdded = false;
|
|
24
|
-
recordCache = createCache(() => {
|
|
25
|
-
if (!hasBeenAdded) {
|
|
26
|
-
this.added.push(this.wrapRecord(record));
|
|
27
|
-
hasBeenAdded = true;
|
|
28
|
-
} else {
|
|
29
|
-
this.updated.push(this.wrapRecord(record));
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
this.recordCaches.set(record, recordCache);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return recordCache;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
19
|
constructor(records, recordsAdded, recordsUpdated, recordsRemoved, wrapRecord, release) {
|
|
39
20
|
this.recordCaches = new Map();
|
|
40
21
|
this.added = [];
|
|
@@ -78,6 +59,25 @@ class RecordsWatcher {
|
|
|
78
59
|
});
|
|
79
60
|
}
|
|
80
61
|
|
|
62
|
+
getCacheForItem(record) {
|
|
63
|
+
let recordCache = this.recordCaches.get(record);
|
|
64
|
+
|
|
65
|
+
if (!recordCache) {
|
|
66
|
+
let hasBeenAdded = false;
|
|
67
|
+
recordCache = createCache(() => {
|
|
68
|
+
if (!hasBeenAdded) {
|
|
69
|
+
this.added.push(this.wrapRecord(record));
|
|
70
|
+
hasBeenAdded = true;
|
|
71
|
+
} else {
|
|
72
|
+
this.updated.push(this.wrapRecord(record));
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
this.recordCaches.set(record, recordCache);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return recordCache;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
81
|
revalidate() {
|
|
82
82
|
getValue(this.recordArrayCache);
|
|
83
83
|
}
|
|
@@ -168,7 +168,7 @@ export default EmberObject.extend({
|
|
|
168
168
|
/**
|
|
169
169
|
The container-debug-adapter which is used
|
|
170
170
|
to list all models.
|
|
171
|
-
|
|
171
|
+
@property containerDebugAdapter
|
|
172
172
|
@default undefined
|
|
173
173
|
@since 1.5.0
|
|
174
174
|
@public
|
|
@@ -178,7 +178,7 @@ export default EmberObject.extend({
|
|
|
178
178
|
The number of attributes to send
|
|
179
179
|
as columns. (Enough to make the record
|
|
180
180
|
identifiable).
|
|
181
|
-
|
|
181
|
+
@private
|
|
182
182
|
@property attributeLimit
|
|
183
183
|
@default 3
|
|
184
184
|
@since 1.3.0
|
|
@@ -189,24 +189,24 @@ export default EmberObject.extend({
|
|
|
189
189
|
Ember Data > v1.0.0-beta.18
|
|
190
190
|
requires string model names to be passed
|
|
191
191
|
around instead of the actual factories.
|
|
192
|
-
|
|
192
|
+
This is a stamp for the Ember Inspector
|
|
193
193
|
to differentiate between the versions
|
|
194
194
|
to be able to support older versions too.
|
|
195
|
-
|
|
195
|
+
@public
|
|
196
196
|
@property acceptsModelName
|
|
197
197
|
*/
|
|
198
198
|
acceptsModelName: true,
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
201
|
Map from records arrays to RecordsWatcher instances
|
|
202
|
-
|
|
202
|
+
@private
|
|
203
203
|
@property recordsWatchers
|
|
204
204
|
@since 3.26.0
|
|
205
205
|
*/
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
208
|
Map from records arrays to TypeWatcher instances
|
|
209
|
-
|
|
209
|
+
@private
|
|
210
210
|
@property typeWatchers
|
|
211
211
|
@since 3.26.0
|
|
212
212
|
*/
|
|
@@ -214,15 +214,15 @@ export default EmberObject.extend({
|
|
|
214
214
|
/**
|
|
215
215
|
Callback that is currently scheduled on backburner end to flush and check
|
|
216
216
|
all active watchers.
|
|
217
|
-
|
|
217
|
+
@private
|
|
218
218
|
@property flushWatchers
|
|
219
219
|
@since 3.26.0
|
|
220
|
-
|
|
220
|
+
*/
|
|
221
221
|
|
|
222
222
|
/**
|
|
223
223
|
Stores all methods that clear observers.
|
|
224
224
|
These methods will be called on destruction.
|
|
225
|
-
|
|
225
|
+
@private
|
|
226
226
|
@property releaseMethods
|
|
227
227
|
@since 1.3.0
|
|
228
228
|
*/
|
|
@@ -231,7 +231,7 @@ export default EmberObject.extend({
|
|
|
231
231
|
Specifies how records can be filtered.
|
|
232
232
|
Records returned will need to have a `filterValues`
|
|
233
233
|
property with a key for every name in the returned array.
|
|
234
|
-
|
|
234
|
+
@public
|
|
235
235
|
@method getFilters
|
|
236
236
|
@return {Array} List of objects defining filters.
|
|
237
237
|
The object should have a `name` and `desc` property.
|
|
@@ -242,13 +242,13 @@ export default EmberObject.extend({
|
|
|
242
242
|
|
|
243
243
|
/**
|
|
244
244
|
Fetch the model types and observe them for changes.
|
|
245
|
-
|
|
245
|
+
@public
|
|
246
246
|
@method watchModelTypes
|
|
247
|
-
|
|
247
|
+
@param {Function} typesAdded Callback to call to add types.
|
|
248
248
|
Takes an array of objects containing wrapped types (returned from `wrapModelType`).
|
|
249
|
-
|
|
249
|
+
@param {Function} typesUpdated Callback to call when a type has changed.
|
|
250
250
|
Takes an array of objects containing wrapped types.
|
|
251
|
-
|
|
251
|
+
@return {Function} Method to call to remove all observers
|
|
252
252
|
*/
|
|
253
253
|
watchModelTypes(typesAdded, typesUpdated) {
|
|
254
254
|
let modelTypes = this.getModelTypes();
|
|
@@ -283,19 +283,19 @@ export default EmberObject.extend({
|
|
|
283
283
|
|
|
284
284
|
/**
|
|
285
285
|
Fetch the records of a given type and observe them for changes.
|
|
286
|
-
|
|
286
|
+
@public
|
|
287
287
|
@method watchRecords
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
@param {String} modelName The model name.
|
|
289
|
+
@param {Function} recordsAdded Callback to call to add records.
|
|
290
290
|
Takes an array of objects containing wrapped records.
|
|
291
291
|
The object should have the following properties:
|
|
292
292
|
columnValues: {Object} The key and value of a table cell.
|
|
293
293
|
object: {Object} The actual record object.
|
|
294
|
-
|
|
294
|
+
@param {Function} recordsUpdated Callback to call when a record has changed.
|
|
295
295
|
Takes an array of objects containing wrapped records.
|
|
296
|
-
|
|
296
|
+
@param {Function} recordsRemoved Callback to call when a record has removed.
|
|
297
297
|
Takes an array of objects containing wrapped records.
|
|
298
|
-
|
|
298
|
+
@return {Function} Method to call to remove all observers.
|
|
299
299
|
*/
|
|
300
300
|
watchRecords(modelName, recordsAdded, recordsUpdated, recordsRemoved) {
|
|
301
301
|
let klass = this._nameToClass(modelName);
|
|
@@ -355,9 +355,9 @@ export default EmberObject.extend({
|
|
|
355
355
|
|
|
356
356
|
/**
|
|
357
357
|
Detect whether a class is a model.
|
|
358
|
-
|
|
358
|
+
Test that against the model class
|
|
359
359
|
of your persistence library.
|
|
360
|
-
|
|
360
|
+
@public
|
|
361
361
|
@method detect
|
|
362
362
|
@return boolean Whether the class is a model class or not.
|
|
363
363
|
*/
|
|
@@ -367,7 +367,7 @@ export default EmberObject.extend({
|
|
|
367
367
|
|
|
368
368
|
/**
|
|
369
369
|
Get the columns for a given model type.
|
|
370
|
-
|
|
370
|
+
@public
|
|
371
371
|
@method columnsForType
|
|
372
372
|
@return {Array} An array of columns of the following format:
|
|
373
373
|
name: {String} The name of the column.
|
|
@@ -379,7 +379,7 @@ export default EmberObject.extend({
|
|
|
379
379
|
|
|
380
380
|
/**
|
|
381
381
|
Adds observers to a model type class.
|
|
382
|
-
|
|
382
|
+
@private
|
|
383
383
|
@method observeModelType
|
|
384
384
|
@param {String} modelName The model type name.
|
|
385
385
|
@param {Function} typesUpdated Called when a type is modified.
|
|
@@ -414,7 +414,7 @@ export default EmberObject.extend({
|
|
|
414
414
|
|
|
415
415
|
/**
|
|
416
416
|
Wraps a given model type and observes changes to it.
|
|
417
|
-
|
|
417
|
+
@private
|
|
418
418
|
@method wrapModelType
|
|
419
419
|
@param {Class} klass A model class.
|
|
420
420
|
@param {String} modelName Name of the class.
|
|
@@ -442,7 +442,7 @@ export default EmberObject.extend({
|
|
|
442
442
|
|
|
443
443
|
/**
|
|
444
444
|
Fetches all models defined in the application.
|
|
445
|
-
|
|
445
|
+
@private
|
|
446
446
|
@method getModelTypes
|
|
447
447
|
@return {Array} Array of model types.
|
|
448
448
|
*/
|
|
@@ -470,7 +470,7 @@ export default EmberObject.extend({
|
|
|
470
470
|
/**
|
|
471
471
|
Loops over all namespaces and all objects
|
|
472
472
|
attached to them.
|
|
473
|
-
|
|
473
|
+
@private
|
|
474
474
|
@method _getObjectsOnNamespaces
|
|
475
475
|
@return {Array} Array of model type strings.
|
|
476
476
|
*/
|
|
@@ -498,7 +498,7 @@ export default EmberObject.extend({
|
|
|
498
498
|
|
|
499
499
|
/**
|
|
500
500
|
Fetches all loaded records for a given type.
|
|
501
|
-
|
|
501
|
+
@public
|
|
502
502
|
@method getRecords
|
|
503
503
|
@return {Array} An array of records.
|
|
504
504
|
This array will be observed for changes,
|
|
@@ -510,7 +510,7 @@ export default EmberObject.extend({
|
|
|
510
510
|
|
|
511
511
|
/**
|
|
512
512
|
Wraps a record and observers changes to it.
|
|
513
|
-
|
|
513
|
+
@private
|
|
514
514
|
@method wrapRecord
|
|
515
515
|
@param {Object} record The record instance.
|
|
516
516
|
@return {Object} The wrapped record. Format:
|
|
@@ -530,7 +530,7 @@ export default EmberObject.extend({
|
|
|
530
530
|
|
|
531
531
|
/**
|
|
532
532
|
Gets the values for each column.
|
|
533
|
-
|
|
533
|
+
@public
|
|
534
534
|
@method getRecordColumnValues
|
|
535
535
|
@return {Object} Keys should match column names defined
|
|
536
536
|
by the model type.
|
|
@@ -541,7 +541,7 @@ export default EmberObject.extend({
|
|
|
541
541
|
|
|
542
542
|
/**
|
|
543
543
|
Returns keywords to match when searching records.
|
|
544
|
-
|
|
544
|
+
@public
|
|
545
545
|
@method getRecordKeywords
|
|
546
546
|
@return {Array} Relevant keywords for search.
|
|
547
547
|
*/
|
|
@@ -551,7 +551,7 @@ export default EmberObject.extend({
|
|
|
551
551
|
|
|
552
552
|
/**
|
|
553
553
|
Returns the values of filters defined by `getFilters`.
|
|
554
|
-
|
|
554
|
+
@public
|
|
555
555
|
@method getRecordFilterValues
|
|
556
556
|
@param {Object} record The record instance.
|
|
557
557
|
@return {Object} The filter values.
|
|
@@ -562,7 +562,7 @@ export default EmberObject.extend({
|
|
|
562
562
|
|
|
563
563
|
/**
|
|
564
564
|
Each record can have a color that represents its state.
|
|
565
|
-
|
|
565
|
+
@public
|
|
566
566
|
@method getRecordColor
|
|
567
567
|
@param {Object} record The record instance
|
|
568
568
|
@return {String} The records color.
|