ember-source 4.9.0-beta.3 → 4.9.0-beta.4
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 +5 -0
- package/build-metadata.json +3 -3
- package/dist/ember-template-compiler.js +2 -2
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +1 -1
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +2 -2
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +256 -50
- package/package.json +2 -2
- package/types/preview/@ember/application/index.d.ts +16 -2
- package/types/preview/@ember/array/-private/native-array.d.ts +162 -4
- package/types/preview/@ember/array/index.d.ts +14 -6
- package/types/preview/@ember/array/mutable.d.ts +4 -4
- package/types/preview/ember/-private/type-utils.d.ts +16 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-source",
|
|
3
|
-
"version": "4.9.0-beta.
|
|
3
|
+
"version": "4.9.0-beta.4",
|
|
4
4
|
"description": "A JavaScript framework for creating ambitious web applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
]
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
|
-
"_originalVersion": "4.9.0-beta.
|
|
182
|
+
"_originalVersion": "4.9.0-beta.4",
|
|
183
183
|
"_versionPreviouslyCalculated": true,
|
|
184
184
|
"publishConfig": {
|
|
185
185
|
"tag": "beta"
|
|
@@ -123,7 +123,13 @@ declare module '@ember/application' {
|
|
|
123
123
|
// whenever we add new base classes to the framework. For example, if we
|
|
124
124
|
// introduce a standalone `Service` or `Route` base class which *does not*
|
|
125
125
|
// extend from `EmberObject`, it will need to be added here.
|
|
126
|
-
|
|
126
|
+
//
|
|
127
|
+
// NOTE: we use `any` here because we need to make sure *not* to fix the
|
|
128
|
+
// actual GlimmerComponent type; using `unknown` or `{}` or `never` (the
|
|
129
|
+
// obvious alternatives here) results in a version which is too narrow, such
|
|
130
|
+
// that any subclass which applies a signature does not get resolved by the
|
|
131
|
+
// definition of `getOwner()` below.
|
|
132
|
+
type KnownFrameworkObject = EmberObject | GlimmerComponent<any>;
|
|
127
133
|
|
|
128
134
|
/**
|
|
129
135
|
* Framework objects in an Ember application (components, services, routes, etc.)
|
|
@@ -131,7 +137,15 @@ declare module '@ember/application' {
|
|
|
131
137
|
* objects is the responsibility of an "owner", which handled its
|
|
132
138
|
* instantiation and manages its lifetime.
|
|
133
139
|
*/
|
|
134
|
-
|
|
140
|
+
// SAFETY: this first overload is, strictly speaking, *unsafe*. It is possible
|
|
141
|
+
// to do `let x = EmberObject.create(); getOwner(x);` and the result will *not*
|
|
142
|
+
// be `Owner` but instead `undefined`. However, that's quite unusual at this
|
|
143
|
+
// point, and more to the point we cannot actually distinguish a `Service`
|
|
144
|
+
// subclass from `EmberObject` at this point: `Service` subclasses `EmberObject`
|
|
145
|
+
// and adds nothing to it. Accordingly, if we want to catch `Service`s with this
|
|
146
|
+
// (and `getOwner(this)` for some service will definitely be defined!), it has
|
|
147
|
+
// to be this way. :sigh:
|
|
148
|
+
export function getOwner(object: KnownFrameworkObject): Owner;
|
|
135
149
|
export function getOwner(object: unknown): Owner | undefined;
|
|
136
150
|
/**
|
|
137
151
|
* `setOwner` forces a new owner on a given object instance. This is primarily
|
|
@@ -1,11 +1,172 @@
|
|
|
1
1
|
declare module '@ember/array/-private/native-array' {
|
|
2
2
|
import Observable from '@ember/object/observable';
|
|
3
|
+
import EmberArray from '@ember/array';
|
|
3
4
|
import MutableArray from '@ember/array/mutable';
|
|
4
5
|
import Mixin from '@ember/object/mixin';
|
|
5
6
|
|
|
6
7
|
// Get an alias to the global Array type to use in inner scope below.
|
|
7
8
|
type Array<T> = T[];
|
|
8
9
|
|
|
10
|
+
type AnyArray<T> = EmberArray<T> | Array<T>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The final definition of NativeArray removes all native methods. This is the list of removed methods
|
|
14
|
+
* when run in Chrome 106.
|
|
15
|
+
*/
|
|
16
|
+
type IGNORED_MUTABLE_ARRAY_METHODS =
|
|
17
|
+
| 'length'
|
|
18
|
+
| 'slice'
|
|
19
|
+
| 'indexOf'
|
|
20
|
+
| 'lastIndexOf'
|
|
21
|
+
| 'forEach'
|
|
22
|
+
| 'map'
|
|
23
|
+
| 'filter'
|
|
24
|
+
| 'find'
|
|
25
|
+
| 'every'
|
|
26
|
+
| 'reduce'
|
|
27
|
+
| 'includes';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* These additional items must be redefined since `Omit` causes methods that return `this` to return the
|
|
31
|
+
* type at the time of the Omit.
|
|
32
|
+
*/
|
|
33
|
+
type RETURN_SELF_ARRAY_METHODS =
|
|
34
|
+
| '[]'
|
|
35
|
+
| 'clear'
|
|
36
|
+
| 'insertAt'
|
|
37
|
+
| 'removeAt'
|
|
38
|
+
| 'pushObjects'
|
|
39
|
+
| 'unshiftObjects'
|
|
40
|
+
| 'reverseObjects'
|
|
41
|
+
| 'setObjects'
|
|
42
|
+
| 'removeObject'
|
|
43
|
+
| 'removeObjects'
|
|
44
|
+
| 'addObject'
|
|
45
|
+
| 'addObjects'
|
|
46
|
+
| 'setEach';
|
|
47
|
+
|
|
48
|
+
// This is the same as MutableArray, but removes the actual native methods that exist on Array.prototype.
|
|
49
|
+
interface MutableArrayWithoutNative<T>
|
|
50
|
+
extends Omit<MutableArray<T>, IGNORED_MUTABLE_ARRAY_METHODS | RETURN_SELF_ARRAY_METHODS> {
|
|
51
|
+
/**
|
|
52
|
+
* Remove all elements from the array. This is useful if you
|
|
53
|
+
* want to reuse an existing array without having to recreate it.
|
|
54
|
+
*/
|
|
55
|
+
clear(): this;
|
|
56
|
+
/**
|
|
57
|
+
* This will use the primitive `replace()` method to insert an object at the
|
|
58
|
+
* specified index.
|
|
59
|
+
*/
|
|
60
|
+
insertAt(idx: number, object: T): this;
|
|
61
|
+
/**
|
|
62
|
+
* Remove an object at the specified index using the `replace()` primitive
|
|
63
|
+
* method. You can pass either a single index, or a start and a length.
|
|
64
|
+
*/
|
|
65
|
+
removeAt(start: number, len?: number): this;
|
|
66
|
+
/**
|
|
67
|
+
* Add the objects in the passed numerable to the end of the array. Defers
|
|
68
|
+
* notifying observers of the change until all objects are added.
|
|
69
|
+
*/
|
|
70
|
+
pushObjects(objects: AnyArray<T>): this;
|
|
71
|
+
/**
|
|
72
|
+
* Adds the named objects to the beginning of the array. Defers notifying
|
|
73
|
+
* observers until all objects have been added.
|
|
74
|
+
*/
|
|
75
|
+
unshiftObjects(objects: AnyArray<T>): this;
|
|
76
|
+
/**
|
|
77
|
+
* Reverse objects in the array. Works just like `reverse()` but it is
|
|
78
|
+
* KVO-compliant.
|
|
79
|
+
*/
|
|
80
|
+
reverseObjects(): this;
|
|
81
|
+
/**
|
|
82
|
+
* Replace all the receiver's content with content of the argument.
|
|
83
|
+
* If argument is an empty array receiver will be cleared.
|
|
84
|
+
*/
|
|
85
|
+
setObjects(objects: AnyArray<T>): this;
|
|
86
|
+
/**
|
|
87
|
+
Remove all occurrences of an object in the array.
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
let cities = ['Chicago', 'Berlin', 'Lima', 'Chicago'];
|
|
91
|
+
|
|
92
|
+
cities.removeObject('Chicago'); // ['Berlin', 'Lima']
|
|
93
|
+
cities.removeObject('Lima'); // ['Berlin']
|
|
94
|
+
cities.removeObject('Tokyo') // ['Berlin']
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
@method removeObject
|
|
98
|
+
@param {*} obj object to remove
|
|
99
|
+
@return {EmberArray} receiver
|
|
100
|
+
@public
|
|
101
|
+
*/
|
|
102
|
+
removeObject(object: T): this;
|
|
103
|
+
/**
|
|
104
|
+
* Removes each object in the passed array from the receiver.
|
|
105
|
+
*/
|
|
106
|
+
removeObjects(objects: AnyArray<T>): this;
|
|
107
|
+
/**
|
|
108
|
+
Push the object onto the end of the array if it is not already
|
|
109
|
+
present in the array.
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
let cities = ['Chicago', 'Berlin'];
|
|
113
|
+
|
|
114
|
+
cities.addObject('Lima'); // ['Chicago', 'Berlin', 'Lima']
|
|
115
|
+
cities.addObject('Berlin'); // ['Chicago', 'Berlin', 'Lima']
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
@method addObject
|
|
119
|
+
@param {*} obj object to add, if not already present
|
|
120
|
+
@return {EmberArray} receiver
|
|
121
|
+
@public
|
|
122
|
+
*/
|
|
123
|
+
addObject(obj: T): this;
|
|
124
|
+
/**
|
|
125
|
+
* Adds each object in the passed enumerable to the receiver.
|
|
126
|
+
*/
|
|
127
|
+
addObjects(objects: AnyArray<T>): this;
|
|
128
|
+
/**
|
|
129
|
+
Sets the value on the named property for each member. This is more
|
|
130
|
+
ergonomic than using other methods defined on this helper. If the object
|
|
131
|
+
implements Observable, the value will be changed to `set(),` otherwise
|
|
132
|
+
it will be set directly. `null` objects are skipped.
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
let people = [{name: 'Joe'}, {name: 'Matt'}];
|
|
136
|
+
|
|
137
|
+
people.setEach('zipCode', '10011');
|
|
138
|
+
// [{name: 'Joe', zipCode: '10011'}, {name: 'Matt', zipCode: '10011'}];
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
@method setEach
|
|
142
|
+
@param {String} key The key to set
|
|
143
|
+
@param {Object} value The object to set
|
|
144
|
+
@return {Object} receiver
|
|
145
|
+
@public
|
|
146
|
+
*/
|
|
147
|
+
setEach<K extends keyof T>(key: K, value: T[K]): this;
|
|
148
|
+
/**
|
|
149
|
+
This is the handler for the special array content property. If you get
|
|
150
|
+
this property, it will return this. If you set this property to a new
|
|
151
|
+
array, it will replace the current content.
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
let peopleToMoon = ['Armstrong', 'Aldrin'];
|
|
155
|
+
|
|
156
|
+
peopleToMoon.get('[]'); // ['Armstrong', 'Aldrin']
|
|
157
|
+
|
|
158
|
+
peopleToMoon.set('[]', ['Collins']); // ['Collins']
|
|
159
|
+
peopleToMoon.get('[]'); // ['Collins']
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
@property []
|
|
163
|
+
@return this
|
|
164
|
+
@public
|
|
165
|
+
*/
|
|
166
|
+
get '[]'(): this;
|
|
167
|
+
set '[]'(newValue: T[] | this);
|
|
168
|
+
}
|
|
169
|
+
|
|
9
170
|
/**
|
|
10
171
|
* The NativeArray mixin contains the properties needed to make the native
|
|
11
172
|
* Array support Ember.MutableArray and all of its dependent APIs. Unless you
|
|
@@ -13,10 +174,7 @@ declare module '@ember/array/-private/native-array' {
|
|
|
13
174
|
* false, this will be applied automatically. Otherwise you can apply the mixin
|
|
14
175
|
* at anytime by calling `Ember.NativeArray.apply(Array.prototype)`.
|
|
15
176
|
*/
|
|
16
|
-
interface NativeArray<T>
|
|
17
|
-
extends Omit<Array<T>, 'every' | 'filter' | 'find' | 'forEach' | 'map' | 'reduce' | 'slice'>,
|
|
18
|
-
Observable,
|
|
19
|
-
MutableArray<T> {}
|
|
177
|
+
interface NativeArray<T> extends Array<T>, Observable, MutableArrayWithoutNative<T> {}
|
|
20
178
|
|
|
21
179
|
const NativeArray: Mixin;
|
|
22
180
|
export default NativeArray;
|
|
@@ -73,7 +73,7 @@ declare module '@ember/array' {
|
|
|
73
73
|
* implements Ember.Observable, the value will be changed to `set(),` otherwise
|
|
74
74
|
* it will be set directly. `null` objects are skipped.
|
|
75
75
|
*/
|
|
76
|
-
setEach<K extends keyof T>(key: K, value: T[K]):
|
|
76
|
+
setEach<K extends keyof T>(key: K, value: T[K]): this;
|
|
77
77
|
/**
|
|
78
78
|
* Maps all of the items in the enumeration to another value, returning
|
|
79
79
|
* a new array. This method corresponds to `map()` defined in JavaScript 1.6.
|
|
@@ -111,12 +111,14 @@ declare module '@ember/array' {
|
|
|
111
111
|
* this will match any property that evaluates to `true`.
|
|
112
112
|
*/
|
|
113
113
|
filterBy<K extends keyof T>(key: K, value?: T[K]): NativeArray<T>;
|
|
114
|
+
filterBy(key: string, value?: unknown): NativeArray<T>;
|
|
114
115
|
/**
|
|
115
116
|
* Returns an array with the items that do not have truthy values for
|
|
116
117
|
* key. You can pass an optional second argument with the target value. Otherwise
|
|
117
118
|
* this will match any property that evaluates to false.
|
|
118
119
|
*/
|
|
119
120
|
rejectBy<K extends keyof T>(key: K, value?: T[K]): NativeArray<T>;
|
|
121
|
+
rejectBy(key: string, value?: unknown): NativeArray<T>;
|
|
120
122
|
/**
|
|
121
123
|
* Returns the first item in the array for which the callback returns true.
|
|
122
124
|
* This method works similar to the `filter()` method defined in JavaScript 1.6
|
|
@@ -136,6 +138,7 @@ declare module '@ember/array' {
|
|
|
136
138
|
* this will match any property that evaluates to `true`.
|
|
137
139
|
*/
|
|
138
140
|
findBy<K extends keyof T>(key: K, value?: T[K]): T | undefined;
|
|
141
|
+
findBy(key: string, value?: unknown): T | undefined;
|
|
139
142
|
/**
|
|
140
143
|
* Returns `true` if the passed function returns true for every item in the
|
|
141
144
|
* enumeration. This corresponds with the `every()` method in JavaScript 1.6.
|
|
@@ -150,6 +153,7 @@ declare module '@ember/array' {
|
|
|
150
153
|
* than using a callback.
|
|
151
154
|
*/
|
|
152
155
|
isEvery<K extends keyof T>(key: K, value?: T[K]): boolean;
|
|
156
|
+
isEvery(key: string, value?: unknown): boolean;
|
|
153
157
|
/**
|
|
154
158
|
* Returns `true` if the passed function returns true for any item in the
|
|
155
159
|
* enumeration.
|
|
@@ -164,12 +168,16 @@ declare module '@ember/array' {
|
|
|
164
168
|
* than using a callback.
|
|
165
169
|
*/
|
|
166
170
|
isAny<K extends keyof T>(key: K, value?: T[K]): boolean;
|
|
171
|
+
isAny(key: string, value?: unknown): boolean;
|
|
167
172
|
/**
|
|
168
173
|
* This will combine the values of the enumerator into a single value. It
|
|
169
174
|
* is a useful way to collect a summary value from an enumeration. This
|
|
170
175
|
* corresponds to the `reduce()` method defined in JavaScript 1.8.
|
|
171
176
|
*/
|
|
172
|
-
reduce
|
|
177
|
+
reduce<V>(
|
|
178
|
+
callback: (summation: V, current: T, index: number, arr: this) => V,
|
|
179
|
+
initialValue?: V
|
|
180
|
+
): V;
|
|
173
181
|
/**
|
|
174
182
|
* Invokes the named method on every object in the receiver that
|
|
175
183
|
* implements it. This method corresponds to the implementation in
|
|
@@ -178,7 +186,7 @@ declare module '@ember/array' {
|
|
|
178
186
|
invoke<M extends MethodNamesOf<T>>(
|
|
179
187
|
methodName: M,
|
|
180
188
|
...args: MethodParams<T, M>
|
|
181
|
-
):
|
|
189
|
+
): NativeArray<MethodReturns<T, M>>;
|
|
182
190
|
/**
|
|
183
191
|
* Simply converts the enumerable into a genuine array. The order is not
|
|
184
192
|
* guaranteed. Corresponds to the method implemented by Prototype.
|
|
@@ -196,7 +204,7 @@ declare module '@ember/array' {
|
|
|
196
204
|
* Converts the enumerable into an array and sorts by the keys
|
|
197
205
|
* specified in the argument.
|
|
198
206
|
*/
|
|
199
|
-
sortBy(...properties: string[]):
|
|
207
|
+
sortBy(...properties: string[]): T[];
|
|
200
208
|
/**
|
|
201
209
|
* Returns a new enumerable that excludes the passed value. The default
|
|
202
210
|
* implementation returns an array regardless of the receiver type.
|
|
@@ -219,8 +227,8 @@ declare module '@ember/array' {
|
|
|
219
227
|
* this property, it will return this. If you set this property to a new
|
|
220
228
|
* array, it will replace the current content.
|
|
221
229
|
*/
|
|
222
|
-
get '[]'():
|
|
223
|
-
set '[]'(newValue:
|
|
230
|
+
get '[]'(): this;
|
|
231
|
+
set '[]'(newValue: T[] | Array<T>);
|
|
224
232
|
}
|
|
225
233
|
// Ember.Array rather than Array because the `array-type` lint rule doesn't realize the global is shadowed
|
|
226
234
|
const Array: Mixin;
|
|
@@ -15,7 +15,7 @@ declare module '@ember/array/mutable' {
|
|
|
15
15
|
/**
|
|
16
16
|
* __Required.__ You must implement this method to apply this mixin.
|
|
17
17
|
*/
|
|
18
|
-
replace(idx: number, amt: number, objects: T[]):
|
|
18
|
+
replace(idx: number, amt: number, objects: T[]): void;
|
|
19
19
|
/**
|
|
20
20
|
* Remove all elements from the array. This is useful if you
|
|
21
21
|
* want to reuse an existing array without having to recreate it.
|
|
@@ -45,12 +45,12 @@ declare module '@ember/array/mutable' {
|
|
|
45
45
|
* Pop object from array or nil if none are left. Works just like `pop()` but
|
|
46
46
|
* it is KVO-compliant.
|
|
47
47
|
*/
|
|
48
|
-
popObject(): T;
|
|
48
|
+
popObject(): T | null | undefined;
|
|
49
49
|
/**
|
|
50
50
|
* Shift an object from start of array or nil if none are left. Works just
|
|
51
51
|
* like `shift()` but it is KVO-compliant.
|
|
52
52
|
*/
|
|
53
|
-
shiftObject(): T;
|
|
53
|
+
shiftObject(): T | null | undefined;
|
|
54
54
|
/**
|
|
55
55
|
* Unshift an object to start of array. Works just like `unshift()` but it is
|
|
56
56
|
* KVO-compliant.
|
|
@@ -82,7 +82,7 @@ declare module '@ember/array/mutable' {
|
|
|
82
82
|
/**
|
|
83
83
|
* __Required.__ You must implement this method to apply this mixin.
|
|
84
84
|
*/
|
|
85
|
-
addObject(object: T):
|
|
85
|
+
addObject(object: T): this;
|
|
86
86
|
/**
|
|
87
87
|
* Adds each object in the passed enumerable to the receiver.
|
|
88
88
|
*/
|
|
@@ -7,15 +7,19 @@ declare module 'ember/-private/type-utils' {
|
|
|
7
7
|
|
|
8
8
|
export type AnyMethod<Target> = (this: Target, ...args: any[]) => unknown;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// The formatting here is designed to help make this type actually be
|
|
11
|
+
// comprehensible to mortals, including the mortals who came up with it.
|
|
12
|
+
// prettier-ignore
|
|
13
|
+
export type MethodsOf<T> = {
|
|
14
|
+
// This `keyof` check is the thing which gives us *only* these keys, and no
|
|
15
|
+
// `foo: never` appears in the final type.
|
|
16
|
+
[K in keyof T as T[K] extends AnyFn ? K : never]:
|
|
17
|
+
// While this makes sure the resolved type only has `AnyFn` in it, so that
|
|
18
|
+
// the resulting type is known to be only function types.
|
|
19
|
+
T[K] extends AnyFn ? T[K] : never;
|
|
12
20
|
};
|
|
13
21
|
|
|
14
|
-
|
|
15
|
-
// `never` fields.
|
|
16
|
-
export type MethodNamesOf<O> = {
|
|
17
|
-
[K in keyof O]: O[K] extends AnyFn ? K : never;
|
|
18
|
-
}[keyof O];
|
|
22
|
+
export type MethodNamesOf<T> = keyof MethodsOf<T>;
|
|
19
23
|
|
|
20
24
|
export type MethodParams<T, M extends MethodNamesOf<T>> = Parameters<MethodsOf<T>[M]>;
|
|
21
25
|
|
|
@@ -24,16 +28,15 @@ declare module 'ember/-private/type-utils' {
|
|
|
24
28
|
// prettier-ignore
|
|
25
29
|
/** Get the return value of a method string name or a function. */
|
|
26
30
|
export type EmberMethodParams<T, M extends EmberMethod<T>> =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
// For a basic method, we can just use the direct accessor.
|
|
32
|
+
M extends AnyMethod<T> ? Parameters<M> :
|
|
33
|
+
M extends MethodNamesOf<T> ? Parameters<MethodsOf<T>[M]> : never;
|
|
30
34
|
|
|
31
35
|
// prettier-ignore
|
|
32
36
|
/** Get the return value of a method string name or a function. */
|
|
33
37
|
export type EmberMethodReturn<T, M extends EmberMethod<T>> =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
never;
|
|
38
|
+
M extends AnyMethod<T> ? ReturnType<M> :
|
|
39
|
+
M extends MethodNamesOf<T> ? ReturnType<MethodsOf<T>[M]> : never;
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* A type utility for Ember's common name-of-object-on-target-or-function
|