ember-source 5.11.0 → 5.11.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.
Files changed (147) hide show
  1. package/build-metadata.json +3 -3
  2. package/dist/ember-template-compiler.js +48 -42
  3. package/dist/ember-testing.js +1 -1
  4. package/dist/ember.debug.js +23102 -23100
  5. package/dist/ember.prod.js +31562 -31563
  6. package/dist/packages/@ember/-internals/container/index.js +1 -1
  7. package/dist/packages/@ember/-internals/deprecations/index.js +2 -1
  8. package/dist/packages/@ember/-internals/glimmer/index.js +2 -1
  9. package/dist/packages/@ember/-internals/meta/lib/meta.js +4 -3
  10. package/dist/packages/@ember/-internals/metal/index.js +9 -8
  11. package/dist/packages/@ember/-internals/routing/index.js +6 -5
  12. package/dist/packages/@ember/-internals/runtime/lib/ext/rsvp.js +3 -2
  13. package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +6 -5
  14. package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +4 -3
  15. package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +1 -1
  16. package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +2 -1
  17. package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +4 -3
  18. package/dist/packages/@ember/-internals/string/index.js +1 -1
  19. package/dist/packages/@ember/-internals/utils/index.js +4 -4
  20. package/dist/packages/@ember/-internals/views/index.js +1 -1
  21. package/dist/packages/@ember/-internals/views/lib/compat/fallback-view-registry.js +1 -1
  22. package/dist/packages/@ember/-internals/views/lib/component_lookup.js +1 -1
  23. package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +5 -3
  24. package/dist/packages/@ember/-internals/views/lib/mixins/child_views_support.js +3 -3
  25. package/dist/packages/@ember/-internals/views/lib/mixins/class_names_support.js +4 -3
  26. package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +4 -3
  27. package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +6 -12
  28. package/dist/packages/@ember/-internals/views/lib/system/utils.js +3 -2
  29. package/dist/packages/@ember/-internals/views/lib/views/core_view.js +76 -8
  30. package/dist/packages/@ember/-internals/views/lib/views/states.js +4 -3
  31. package/dist/packages/@ember/application/index.js +16 -7
  32. package/dist/packages/@ember/application/instance.js +13 -9
  33. package/dist/packages/@ember/application/namespace.js +7 -6
  34. package/dist/packages/@ember/array/index.js +617 -11
  35. package/dist/packages/@ember/array/make.js +1 -0
  36. package/dist/packages/@ember/array/mutable.js +1 -1
  37. package/dist/packages/@ember/array/proxy.js +8 -5
  38. package/dist/packages/@ember/component/helper.js +4 -4
  39. package/dist/packages/@ember/component/index.js +4 -4
  40. package/dist/packages/@ember/controller/index.js +6 -6
  41. package/dist/packages/@ember/debug/container-debug-adapter.js +5 -4
  42. package/dist/packages/@ember/debug/data-adapter.js +7 -4
  43. package/dist/packages/@ember/debug/index.js +213 -4
  44. package/dist/packages/@ember/debug/lib/assert.js +47 -0
  45. package/dist/packages/@ember/debug/lib/deprecate.js +194 -4
  46. package/dist/packages/@ember/debug/lib/inspect.js +120 -2
  47. package/dist/packages/@ember/debug/lib/warn.js +94 -3
  48. package/dist/packages/@ember/engine/index.js +440 -17
  49. package/dist/packages/@ember/engine/instance.js +175 -11
  50. package/dist/packages/@ember/engine/parent.js +1 -0
  51. package/dist/packages/@ember/helper/index.js +4 -4
  52. package/dist/packages/@ember/instrumentation/index.js +2 -1
  53. package/dist/packages/@ember/modifier/index.js +13 -5
  54. package/dist/packages/@ember/modifier/on.js +15 -0
  55. package/dist/packages/@ember/object/-internals.js +6 -5
  56. package/dist/packages/@ember/object/compat.js +4 -3
  57. package/dist/packages/@ember/object/computed.js +4 -4
  58. package/dist/packages/@ember/object/core.js +861 -14
  59. package/dist/packages/@ember/object/evented.js +4 -4
  60. package/dist/packages/@ember/object/events.js +3 -3
  61. package/dist/packages/@ember/object/index.js +260 -9
  62. package/dist/packages/@ember/object/internals.js +1 -1
  63. package/dist/packages/@ember/object/lib/computed/computed_macros.js +8 -6
  64. package/dist/packages/@ember/object/lib/computed/reduce_computed_macros.js +8 -4
  65. package/dist/packages/@ember/object/mixin.js +6 -5
  66. package/dist/packages/@ember/object/observable.js +103 -9
  67. package/dist/packages/@ember/object/observers.js +3 -3
  68. package/dist/packages/@ember/object/promise-proxy-mixin.js +5 -5
  69. package/dist/packages/@ember/renderer/index.js +4 -4
  70. package/dist/packages/@ember/routing/-internals.js +3 -1
  71. package/dist/packages/@ember/routing/hash-location.js +2 -2
  72. package/dist/packages/@ember/routing/history-location.js +3 -2
  73. package/dist/packages/@ember/routing/index.js +4 -4
  74. package/dist/packages/@ember/routing/lib/dsl.js +2 -1
  75. package/dist/packages/@ember/routing/lib/generate_controller.js +4 -3
  76. package/dist/packages/@ember/routing/lib/router_state.js +26 -1
  77. package/dist/packages/@ember/routing/lib/routing-service.js +107 -9
  78. package/dist/packages/@ember/routing/lib/utils.js +238 -7
  79. package/dist/packages/@ember/routing/none-location.js +3 -2
  80. package/dist/packages/@ember/routing/route.js +1618 -22
  81. package/dist/packages/@ember/routing/router-service.js +638 -12
  82. package/dist/packages/@ember/routing/router.js +1449 -14
  83. package/dist/packages/@ember/runloop/index.js +760 -6
  84. package/dist/packages/@ember/service/index.js +3 -3
  85. package/dist/packages/@ember/template/index.js +4 -4
  86. package/dist/packages/@ember/utils/index.js +2 -1
  87. package/dist/packages/@ember/utils/lib/compare.js +159 -4
  88. package/dist/packages/@ember/utils/lib/is_empty.js +4 -4
  89. package/dist/packages/@ember/utils/lib/type-of.js +110 -1
  90. package/dist/packages/@glimmer/tracking/index.js +3 -3
  91. package/dist/packages/@glimmer/tracking/primitives/cache.js +3 -3
  92. package/dist/packages/ember/barrel.js +28 -13
  93. package/dist/packages/ember/version.js +1 -1
  94. package/dist/packages/ember-testing/lib/adapters/adapter.js +1 -1
  95. package/dist/packages/ember-testing/lib/adapters/qunit.js +2 -1
  96. package/dist/packages/ember-testing/lib/ext/application.js +2 -1
  97. package/dist/packages/ember-testing/lib/ext/rsvp.js +1 -1
  98. package/dist/packages/ember-testing/lib/helpers/and_then.js +2 -1
  99. package/dist/packages/ember-testing/lib/helpers/current_path.js +8 -6
  100. package/dist/packages/ember-testing/lib/helpers/current_route_name.js +8 -6
  101. package/dist/packages/ember-testing/lib/helpers/current_url.js +6 -5
  102. package/dist/packages/ember-testing/lib/helpers/pause_test.js +2 -1
  103. package/dist/packages/ember-testing/lib/helpers/visit.js +4 -3
  104. package/dist/packages/ember-testing/lib/helpers/wait.js +4 -3
  105. package/dist/packages/ember-testing/lib/initializers.js +15 -8
  106. package/dist/packages/ember-testing/lib/setup_for_testing.js +1 -1
  107. package/dist/packages/ember-testing/lib/test/run.js +1 -1
  108. package/dist/packages/router_js/index.js +2 -1
  109. package/dist/packages/shared-chunks/{alias-By_2yu5c.js → alias-Dri0koi2.js} +5 -3
  110. package/dist/packages/shared-chunks/array-3xbmc_4J.js +119 -0
  111. package/dist/packages/shared-chunks/{cache-gDE3bkXq.js → cache-BESCGvbE.js} +667 -1529
  112. package/dist/packages/shared-chunks/{core_view-Cxne2_wu.js → chunk-3SQBS3Y5-Cj4eryg1.js} +1 -88
  113. package/dist/packages/shared-chunks/{index-BXPoca1S.js → index-Llq6dmgX.js} +40 -4660
  114. package/dist/packages/shared-chunks/{is_proxy-Dmis-70B.js → is_proxy-DjvCKvd5.js} +1 -1
  115. package/dist/packages/shared-chunks/{mandatory-setter-1UQhiJOb.js → mandatory-setter-BiXq-dpN.js} +2 -1
  116. package/dist/packages/shared-chunks/{name-z9D9Yibn.js → name-Dx2bGFVv.js} +1 -1
  117. package/dist/packages/shared-chunks/{namespace_search-CBgHTkDh.js → namespace_search-btMaPM-_.js} +2 -2
  118. package/dist/packages/shared-chunks/{property_set-CW4q-uo4.js → property_set-BapAkp3X.js} +5 -4
  119. package/dist/packages/shared-chunks/{registry-DzfcDwii.js → registry-B8WARvkP.js} +3 -2
  120. package/dist/packages/shared-chunks/{router-B-Q1aYBn.js → router-DrLZsJeE.js} +2 -482
  121. package/dist/packages/shared-chunks/{set_properties-DvalyQdu.js → set_properties-BScfxzvI.js} +2 -2
  122. package/dist/packages/shared-chunks/setup-registry-du4pSGZi.js +48 -0
  123. package/dist/packages/shared-chunks/{to-string-D8i3mjEU.js → to-string-B1BmwUkt.js} +1 -1
  124. package/dist/packages/shared-chunks/unrecognized-url-error-zpz-JEoG.js +484 -0
  125. package/docs/data.json +152 -142
  126. package/package.json +2 -2
  127. package/types/stable/@ember/-internals/metal/lib/array.d.ts +1 -2
  128. package/types/stable/@ember/-internals/metal/lib/object-at.d.ts +4 -0
  129. package/types/stable/@ember/-internals/metal/lib/observer.d.ts +2 -1
  130. package/types/stable/@ember/array/index.d.ts +1 -1
  131. package/types/stable/@ember/array/make.d.ts +3 -0
  132. package/types/stable/@ember/debug/index.d.ts +3 -7
  133. package/types/stable/@ember/debug/lib/assert.d.ts +8 -0
  134. package/types/stable/@ember/engine/index.d.ts +1 -1
  135. package/types/stable/@ember/engine/instance.d.ts +2 -2
  136. package/types/stable/@ember/engine/parent.d.ts +3 -0
  137. package/types/stable/@ember/modifier/index.d.ts +1 -3
  138. package/types/stable/@ember/modifier/on.d.ts +5 -0
  139. package/types/stable/@ember/routing/lib/routing-service.d.ts +1 -1
  140. package/types/stable/@ember/routing/route.d.ts +2 -3
  141. package/types/stable/@ember/routing/router-service.d.ts +1 -1
  142. package/types/stable/@ember/routing/router.d.ts +4 -4
  143. package/types/stable/ember/barrel.d.ts +1 -1
  144. package/types/stable/ember/index.d.ts +1 -1
  145. package/types/stable/index.d.ts +5 -0
  146. package/dist/packages/shared-chunks/index-DTxy4Zgx.js +0 -641
  147. package/dist/packages/shared-chunks/index-PYiGj1jp.js +0 -2071
@@ -1,14 +1,15 @@
1
1
  import '../-internals/meta/lib/meta.js';
2
- import { g as guidFor } from '../../shared-chunks/mandatory-setter-1UQhiJOb.js';
2
+ import { g as guidFor } from '../../shared-chunks/mandatory-setter-BiXq-dpN.js';
3
3
  import { isDevelopingApp } from '@embroider/macros';
4
- import { g as getName, s as setName } from '../../shared-chunks/name-z9D9Yibn.js';
5
- import { a as assert } from '../../shared-chunks/index-DTxy4Zgx.js';
4
+ import { g as getName, s as setName } from '../../shared-chunks/name-Dx2bGFVv.js';
5
+ import '../debug/index.js';
6
6
  import '../../@glimmer/destroyable/index.js';
7
7
  import '../../@glimmer/validator/index.js';
8
- import { g as get } from '../../shared-chunks/cache-gDE3bkXq.js';
9
8
  import '../../@glimmer/manager/index.js';
10
- import { N as NAMESPACES, a as NAMESPACES_BY_ID, p as processAllNamespaces, f as findNamespace, b as addNamespace, c as findNamespaces, d as processNamespace, r as removeNamespace } from '../../shared-chunks/namespace_search-CBgHTkDh.js';
11
- import { E as EmberObject } from '../../shared-chunks/index-PYiGj1jp.js';
9
+ import { g as get } from '../../shared-chunks/cache-BESCGvbE.js';
10
+ import { N as NAMESPACES, a as NAMESPACES_BY_ID, p as processAllNamespaces, f as findNamespace, b as addNamespace, c as findNamespaces, d as processNamespace, r as removeNamespace } from '../../shared-chunks/namespace_search-btMaPM-_.js';
11
+ import EmberObject from '../object/index.js';
12
+ import { assert } from '../debug/lib/assert.js';
12
13
 
13
14
  /**
14
15
  @module @ember/application/namespace
@@ -1,16 +1,622 @@
1
- import '../../shared-chunks/cache-gDE3bkXq.js';
1
+ import { o as objectAt, g as get, l as endPropertyChanges, P as PROXY_CONTENT, c as computed, m as beginPropertyChanges } from '../../shared-chunks/cache-BESCGvbE.js';
2
2
  import '../-internals/meta/lib/meta.js';
3
- import '../../shared-chunks/index-DTxy4Zgx.js';
3
+ import '../debug/index.js';
4
4
  import '../../@glimmer/validator/index.js';
5
- import '../../shared-chunks/mandatory-setter-1UQhiJOb.js';
6
- import '@embroider/macros';
5
+ import '../../shared-chunks/mandatory-setter-BiXq-dpN.js';
6
+ import { isDevelopingApp } from '@embroider/macros';
7
7
  import '../../@glimmer/destroyable/index.js';
8
8
  import '../../@glimmer/manager/index.js';
9
- import '../../shared-chunks/property_set-CW4q-uo4.js';
10
- import '../../shared-chunks/env-BJLX2Arx.js';
11
- export { A, M as MutableArray, N as NativeArray, a as default, i as isArray, r as removeAt, u as uniqBy } from '../../shared-chunks/index-PYiGj1jp.js';
12
- import '../object/mixin.js';
13
- import '../enumerable/index.js';
14
- import '../enumerable/mutable.js';
15
- import './-internals.js';
9
+ import { s as set } from '../../shared-chunks/property_set-BapAkp3X.js';
10
+ import { r as replaceInNativeArray, a as replace } from '../../shared-chunks/array-3xbmc_4J.js';
11
+ import { E as ENV } from '../../shared-chunks/env-BJLX2Arx.js';
12
+ import '../object/index.js';
13
+ import Mixin from '../object/mixin.js';
14
+ import Enumerable from '../enumerable/index.js';
15
+ import MutableEnumerable from '../enumerable/mutable.js';
16
+ import typeOf from '../utils/lib/type-of.js';
17
+ import compare from '../utils/lib/compare.js';
18
+ import Observable from '../object/observable.js';
19
+ import { setEmberArray, isEmberArray } from './-internals.js';
16
20
  export { default as makeArray } from './lib/make-array.js';
21
+ import { assert } from '../debug/lib/assert.js';
22
+
23
+ /**
24
+ @module @ember/array
25
+ */
26
+
27
+ const EMPTY_ARRAY = Object.freeze([]);
28
+ const identityFunction = item => item;
29
+ function uniqBy(array, keyOrFunc = identityFunction) {
30
+ (isDevelopingApp() && !(isArray(array)) && assert(`first argument passed to \`uniqBy\` should be array`, isArray(array)));
31
+ let ret = A();
32
+ let seen = new Set();
33
+ let getter = typeof keyOrFunc === 'function' ? keyOrFunc : item => get(item, keyOrFunc);
34
+ array.forEach(item => {
35
+ let val = getter(item);
36
+ if (!seen.has(val)) {
37
+ seen.add(val);
38
+ ret.push(item);
39
+ }
40
+ });
41
+ return ret;
42
+ }
43
+ function iter(...args) {
44
+ let valueProvided = args.length === 2;
45
+ let [key, value] = args;
46
+ return valueProvided ? item => value === get(item, key) : item => Boolean(get(item, key));
47
+ }
48
+ function findIndex(array, predicate, startAt) {
49
+ let len = array.length;
50
+ for (let index = startAt; index < len; index++) {
51
+ // SAFETY: Because we're checking the index this value should always be set.
52
+ let item = objectAt(array, index);
53
+ if (predicate(item, index, array)) {
54
+ return index;
55
+ }
56
+ }
57
+ return -1;
58
+ }
59
+ function find(array, callback, target = null) {
60
+ let predicate = callback.bind(target);
61
+ let index = findIndex(array, predicate, 0);
62
+ return index === -1 ? undefined : objectAt(array, index);
63
+ }
64
+ function any(array, callback, target = null) {
65
+ let predicate = callback.bind(target);
66
+ return findIndex(array, predicate, 0) !== -1;
67
+ }
68
+ function every(array, callback, target = null) {
69
+ let cb = callback.bind(target);
70
+ let predicate = (item, index, array) => !cb(item, index, array);
71
+ return findIndex(array, predicate, 0) === -1;
72
+ }
73
+ function indexOf(array, val, startAt = 0, withNaNCheck) {
74
+ let len = array.length;
75
+ if (startAt < 0) {
76
+ startAt += len;
77
+ }
78
+
79
+ // SameValueZero comparison (NaN !== NaN)
80
+ let predicate = withNaNCheck && val !== val ? item => item !== item : item => item === val;
81
+ return findIndex(array, predicate, startAt);
82
+ }
83
+ function removeAt(array, index, len) {
84
+ (isDevelopingApp() && !(index > -1 && index < array.length) && assert(`\`removeAt\` index provided is out of range`, index > -1 && index < array.length));
85
+ replace(array, index, len ?? 1, EMPTY_ARRAY);
86
+ return array;
87
+ }
88
+ function insertAt(array, index, item) {
89
+ (isDevelopingApp() && !(index > -1 && index <= array.length) && assert(`\`insertAt\` index provided is out of range`, index > -1 && index <= array.length));
90
+ replace(array, index, 0, [item]);
91
+ return item;
92
+ }
93
+
94
+ /**
95
+ Returns true if the passed object is an array or Array-like.
96
+
97
+ Objects are considered Array-like if any of the following are true:
98
+
99
+ - the object is a native Array
100
+ - the object has an objectAt property
101
+ - the object is an Object, and has a length property
102
+
103
+ Unlike `typeOf` this method returns true even if the passed object is
104
+ not formally an array but appears to be array-like (i.e. implements `Array`)
105
+
106
+ ```javascript
107
+ import { isArray } from '@ember/array';
108
+ import ArrayProxy from '@ember/array/proxy';
109
+
110
+ isArray(); // false
111
+ isArray([]); // true
112
+ isArray(ArrayProxy.create({ content: [] })); // true
113
+ ```
114
+
115
+ @method isArray
116
+ @static
117
+ @for @ember/array
118
+ @param {Object} obj The object to test
119
+ @return {Boolean} true if the passed object is an array or Array-like
120
+ @public
121
+ */
122
+ function isArray(obj) {
123
+ if (isDevelopingApp() && typeof obj === 'object' && obj !== null) {
124
+ // SAFETY: Property read checks are safe if it's an object
125
+ let possibleProxyContent = obj[PROXY_CONTENT];
126
+ if (possibleProxyContent !== undefined) {
127
+ obj = possibleProxyContent;
128
+ }
129
+ }
130
+
131
+ // SAFETY: Property read checks are safe if it's an object
132
+ if (!obj || obj.setInterval) {
133
+ return false;
134
+ }
135
+ if (Array.isArray(obj) || EmberArray.detect(obj)) {
136
+ return true;
137
+ }
138
+ let type = typeOf(obj);
139
+ if ('array' === type) {
140
+ return true;
141
+ }
142
+
143
+ // SAFETY: Property read checks are safe if it's an object
144
+ let length = obj.length;
145
+ if (typeof length === 'number' && length === length && 'object' === type) {
146
+ return true;
147
+ }
148
+ return false;
149
+ }
150
+
151
+ /*
152
+ This allows us to define computed properties that are not enumerable.
153
+ The primary reason this is important is that when `NativeArray` is
154
+ applied to `Array.prototype` we need to ensure that we do not add _any_
155
+ new enumerable properties.
156
+ */
157
+ function nonEnumerableComputed(callback) {
158
+ let property = computed(callback);
159
+ property.enumerable = false;
160
+ return property;
161
+ }
162
+ function mapBy(key) {
163
+ return this.map(next => get(next, key));
164
+ }
165
+
166
+ // ..........................................................
167
+ // ARRAY
168
+ //
169
+ /**
170
+ This mixin implements Observer-friendly Array-like behavior. It is not a
171
+ concrete implementation, but it can be used up by other classes that want
172
+ to appear like arrays.
173
+
174
+ For example, ArrayProxy is a concrete class that can be instantiated to
175
+ implement array-like behavior. This class uses the Array Mixin by way of
176
+ the MutableArray mixin, which allows observable changes to be made to the
177
+ underlying array.
178
+
179
+ This mixin defines methods specifically for collections that provide
180
+ index-ordered access to their contents. When you are designing code that
181
+ needs to accept any kind of Array-like object, you should use these methods
182
+ instead of Array primitives because these will properly notify observers of
183
+ changes to the array.
184
+
185
+ Although these methods are efficient, they do add a layer of indirection to
186
+ your application so it is a good idea to use them only when you need the
187
+ flexibility of using both true JavaScript arrays and "virtual" arrays such
188
+ as controllers and collections.
189
+
190
+ You can use the methods defined in this module to access and modify array
191
+ contents in an observable-friendly way. You can also be notified whenever
192
+ the membership of an array changes by using `.observes('myArray.[]')`.
193
+
194
+ To support `EmberArray` in your own class, you must override two
195
+ primitives to use it: `length()` and `objectAt()`.
196
+
197
+ @class EmberArray
198
+ @uses Enumerable
199
+ @since Ember 0.9.0
200
+ @public
201
+ */
202
+
203
+ const EmberArray = Mixin.create(Enumerable, {
204
+ init() {
205
+ this._super(...arguments);
206
+ setEmberArray(this);
207
+ },
208
+ objectsAt(indexes) {
209
+ return indexes.map(idx => objectAt(this, idx));
210
+ },
211
+ '[]': nonEnumerableComputed({
212
+ get() {
213
+ return this;
214
+ },
215
+ set(_key, value) {
216
+ this.replace(0, this.length, value);
217
+ return this;
218
+ }
219
+ }),
220
+ firstObject: nonEnumerableComputed(function () {
221
+ return objectAt(this, 0);
222
+ }).readOnly(),
223
+ lastObject: nonEnumerableComputed(function () {
224
+ return objectAt(this, this.length - 1);
225
+ }).readOnly(),
226
+ // Add any extra methods to EmberArray that are native to the built-in Array.
227
+ slice(beginIndex = 0, endIndex) {
228
+ let ret = A();
229
+ let length = this.length;
230
+ if (beginIndex < 0) {
231
+ beginIndex = length + beginIndex;
232
+ }
233
+ let validatedEndIndex;
234
+ if (endIndex === undefined || endIndex > length) {
235
+ validatedEndIndex = length;
236
+ } else if (endIndex < 0) {
237
+ validatedEndIndex = length + endIndex;
238
+ } else {
239
+ validatedEndIndex = endIndex;
240
+ }
241
+ while (beginIndex < validatedEndIndex) {
242
+ ret[ret.length] = objectAt(this, beginIndex++);
243
+ }
244
+ return ret;
245
+ },
246
+ indexOf(object, startAt) {
247
+ return indexOf(this, object, startAt, false);
248
+ },
249
+ lastIndexOf(object, startAt) {
250
+ let len = this.length;
251
+ if (startAt === undefined || startAt >= len) {
252
+ startAt = len - 1;
253
+ }
254
+ if (startAt < 0) {
255
+ startAt += len;
256
+ }
257
+ for (let idx = startAt; idx >= 0; idx--) {
258
+ if (objectAt(this, idx) === object) {
259
+ return idx;
260
+ }
261
+ }
262
+ return -1;
263
+ },
264
+ forEach(callback, target = null) {
265
+ (isDevelopingApp() && !(typeof callback === 'function') && assert('`forEach` expects a function as first argument.', typeof callback === 'function'));
266
+ let length = this.length;
267
+ for (let index = 0; index < length; index++) {
268
+ let item = this.objectAt(index);
269
+ callback.call(target, item, index, this);
270
+ }
271
+ return this;
272
+ },
273
+ getEach: mapBy,
274
+ setEach(key, value) {
275
+ return this.forEach(item => set(item, key, value));
276
+ },
277
+ map(callback, target = null) {
278
+ (isDevelopingApp() && !(typeof callback === 'function') && assert('`map` expects a function as first argument.', typeof callback === 'function'));
279
+ let ret = A();
280
+ this.forEach((x, idx, i) => ret[idx] = callback.call(target, x, idx, i));
281
+ return ret;
282
+ },
283
+ mapBy,
284
+ filter(callback, target = null) {
285
+ (isDevelopingApp() && !(typeof callback === 'function') && assert('`filter` expects a function as first argument.', typeof callback === 'function'));
286
+ let ret = A();
287
+ this.forEach((x, idx, i) => {
288
+ if (callback.call(target, x, idx, i)) {
289
+ ret.push(x);
290
+ }
291
+ });
292
+ return ret;
293
+ },
294
+ reject(callback, target = null) {
295
+ (isDevelopingApp() && !(typeof callback === 'function') && assert('`reject` expects a function as first argument.', typeof callback === 'function'));
296
+ return this.filter(function () {
297
+ // @ts-expect-error TS doesn't like us using arguments like this
298
+ return !callback.apply(target, arguments);
299
+ });
300
+ },
301
+ filterBy() {
302
+ // @ts-expect-error TS doesn't like the ...arguments spread here.
303
+ return this.filter(iter(...arguments));
304
+ },
305
+ rejectBy() {
306
+ // @ts-expect-error TS doesn't like the ...arguments spread here.
307
+ return this.reject(iter(...arguments));
308
+ },
309
+ find(callback, target = null) {
310
+ (isDevelopingApp() && !(typeof callback === 'function') && assert('`find` expects a function as first argument.', typeof callback === 'function'));
311
+ return find(this, callback, target);
312
+ },
313
+ findBy() {
314
+ // @ts-expect-error TS doesn't like the ...arguments spread here.
315
+ let callback = iter(...arguments);
316
+ return find(this, callback);
317
+ },
318
+ every(callback, target = null) {
319
+ (isDevelopingApp() && !(typeof callback === 'function') && assert('`every` expects a function as first argument.', typeof callback === 'function'));
320
+ return every(this, callback, target);
321
+ },
322
+ isEvery() {
323
+ // @ts-expect-error TS doesn't like the ...arguments spread here.
324
+ let callback = iter(...arguments);
325
+ return every(this, callback);
326
+ },
327
+ any(callback, target = null) {
328
+ (isDevelopingApp() && !(typeof callback === 'function') && assert('`any` expects a function as first argument.', typeof callback === 'function'));
329
+ return any(this, callback, target);
330
+ },
331
+ isAny() {
332
+ // @ts-expect-error TS doesn't like us using arguments like this
333
+ let callback = iter(...arguments);
334
+ return any(this, callback);
335
+ },
336
+ // FIXME: When called without initialValue, behavior does not match native behavior
337
+ reduce(callback, initialValue) {
338
+ (isDevelopingApp() && !(typeof callback === 'function') && assert('`reduce` expects a function as first argument.', typeof callback === 'function'));
339
+ let ret = initialValue;
340
+ this.forEach(function (item, i) {
341
+ ret = callback(ret, item, i, this);
342
+ }, this);
343
+ return ret;
344
+ },
345
+ invoke(methodName, ...args) {
346
+ let ret = A();
347
+
348
+ // SAFETY: This is not entirely safe and the code will not work with Ember proxies
349
+ this.forEach(item => ret.push(item[methodName]?.(...args)));
350
+ return ret;
351
+ },
352
+ toArray() {
353
+ return this.map(item => item);
354
+ },
355
+ compact() {
356
+ return this.filter(value => value != null);
357
+ },
358
+ includes(object, startAt) {
359
+ return indexOf(this, object, startAt, true) !== -1;
360
+ },
361
+ sortBy() {
362
+ let sortKeys = arguments;
363
+ return this.toArray().sort((a, b) => {
364
+ for (let i = 0; i < sortKeys.length; i++) {
365
+ let key = sortKeys[i];
366
+ let propA = get(a, key);
367
+ let propB = get(b, key);
368
+ // return 1 or -1 else continue to the next sortKey
369
+ let compareValue = compare(propA, propB);
370
+ if (compareValue) {
371
+ return compareValue;
372
+ }
373
+ }
374
+ return 0;
375
+ });
376
+ },
377
+ uniq() {
378
+ return uniqBy(this);
379
+ },
380
+ uniqBy(key) {
381
+ return uniqBy(this, key);
382
+ },
383
+ without(value) {
384
+ if (!this.includes(value)) {
385
+ return this; // nothing to do
386
+ }
387
+
388
+ // SameValueZero comparison (NaN !== NaN)
389
+ let predicate = value === value ? item => item !== value : item => item === item;
390
+ return this.filter(predicate);
391
+ }
392
+ });
393
+
394
+ /**
395
+ This mixin defines the API for modifying array-like objects. These methods
396
+ can be applied only to a collection that keeps its items in an ordered set.
397
+ It builds upon the Array mixin and adds methods to modify the array.
398
+ One concrete implementations of this class include ArrayProxy.
399
+
400
+ It is important to use the methods in this class to modify arrays so that
401
+ changes are observable. This allows the binding system in Ember to function
402
+ correctly.
403
+
404
+
405
+ Note that an Array can change even if it does not implement this mixin.
406
+ For example, one might implement a SparseArray that cannot be directly
407
+ modified, but if its underlying enumerable changes, it will change also.
408
+
409
+ @class MutableArray
410
+ @uses EmberArray
411
+ @uses MutableEnumerable
412
+ @public
413
+ */
414
+
415
+ const MutableArray = Mixin.create(EmberArray, MutableEnumerable, {
416
+ clear() {
417
+ let len = this.length;
418
+ if (len === 0) {
419
+ return this;
420
+ }
421
+ this.replace(0, len, EMPTY_ARRAY);
422
+ return this;
423
+ },
424
+ insertAt(idx, object) {
425
+ insertAt(this, idx, object);
426
+ return this;
427
+ },
428
+ removeAt(start, len) {
429
+ return removeAt(this, start, len);
430
+ },
431
+ pushObject(obj) {
432
+ return insertAt(this, this.length, obj);
433
+ },
434
+ pushObjects(objects) {
435
+ this.replace(this.length, 0, objects);
436
+ return this;
437
+ },
438
+ popObject() {
439
+ let len = this.length;
440
+ if (len === 0) {
441
+ return null;
442
+ }
443
+ let ret = objectAt(this, len - 1);
444
+ this.removeAt(len - 1, 1);
445
+ return ret;
446
+ },
447
+ shiftObject() {
448
+ if (this.length === 0) {
449
+ return null;
450
+ }
451
+ let ret = objectAt(this, 0);
452
+ this.removeAt(0);
453
+ return ret;
454
+ },
455
+ unshiftObject(obj) {
456
+ return insertAt(this, 0, obj);
457
+ },
458
+ unshiftObjects(objects) {
459
+ this.replace(0, 0, objects);
460
+ return this;
461
+ },
462
+ reverseObjects() {
463
+ let len = this.length;
464
+ if (len === 0) {
465
+ return this;
466
+ }
467
+ let objects = this.toArray().reverse();
468
+ this.replace(0, len, objects);
469
+ return this;
470
+ },
471
+ setObjects(objects) {
472
+ if (objects.length === 0) {
473
+ return this.clear();
474
+ }
475
+ let len = this.length;
476
+ this.replace(0, len, objects);
477
+ return this;
478
+ },
479
+ removeObject(obj) {
480
+ let loc = this.length || 0;
481
+ while (--loc >= 0) {
482
+ let curObject = objectAt(this, loc);
483
+ if (curObject === obj) {
484
+ this.removeAt(loc);
485
+ }
486
+ }
487
+ return this;
488
+ },
489
+ removeObjects(objects) {
490
+ beginPropertyChanges();
491
+ for (let i = objects.length - 1; i >= 0; i--) {
492
+ // SAFETY: Due to the loop structure we know this will always exist.
493
+ this.removeObject(objects[i]);
494
+ }
495
+ endPropertyChanges();
496
+ return this;
497
+ },
498
+ addObject(obj) {
499
+ let included = this.includes(obj);
500
+ if (!included) {
501
+ this.pushObject(obj);
502
+ }
503
+ return this;
504
+ },
505
+ addObjects(objects) {
506
+ beginPropertyChanges();
507
+ objects.forEach(obj => this.addObject(obj));
508
+ endPropertyChanges();
509
+ return this;
510
+ }
511
+ });
512
+
513
+ /**
514
+ Creates an `Ember.NativeArray` from an Array-like object.
515
+ Does not modify the original object's contents. `A()` is not needed if
516
+ `EmberENV.EXTEND_PROTOTYPES` is `true` (the default value). However,
517
+ it is recommended that you use `A()` when creating addons for
518
+ ember or when you can not guarantee that `EmberENV.EXTEND_PROTOTYPES`
519
+ will be `true`.
520
+
521
+ Example
522
+
523
+ ```app/components/my-component.js
524
+ import Component from '@ember/component';
525
+ import { A } from '@ember/array';
526
+
527
+ export default Component.extend({
528
+ tagName: 'ul',
529
+ classNames: ['pagination'],
530
+
531
+ init() {
532
+ this._super(...arguments);
533
+
534
+ if (!this.get('content')) {
535
+ this.set('content', A());
536
+ this.set('otherContent', A([1,2,3]));
537
+ }
538
+ }
539
+ });
540
+ ```
541
+
542
+ @method A
543
+ @static
544
+ @for @ember/array
545
+ @return {Ember.NativeArray}
546
+ @public
547
+ */
548
+
549
+ // Add Ember.Array to Array.prototype. Remove methods with native
550
+ // implementations and supply some more optimized versions of generic methods
551
+ // because they are so common.
552
+ /**
553
+ @module ember
554
+ */
555
+
556
+ /**
557
+ * The final definition of NativeArray removes all native methods. This is the list of removed methods
558
+ * when run in Chrome 106.
559
+ */
560
+
561
+ /**
562
+ * These additional items must be redefined since `Omit` causes methods that return `this` to return the
563
+ * type at the time of the Omit.
564
+ */
565
+
566
+ // This is the same as MutableArray, but removes the actual native methods that exist on Array.prototype.
567
+
568
+ /**
569
+ The NativeArray mixin contains the properties needed to make the native
570
+ Array support MutableArray and all of its dependent APIs. Unless you
571
+ have `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Array` set to
572
+ false, this will be applied automatically. Otherwise you can apply the mixin
573
+ at anytime by calling `Ember.NativeArray.apply(Array.prototype)`.
574
+
575
+ @class Ember.NativeArray
576
+ @uses MutableArray
577
+ @uses Observable
578
+ @public
579
+ */
580
+
581
+ let NativeArray = Mixin.create(MutableArray, Observable, {
582
+ objectAt(idx) {
583
+ return this[idx];
584
+ },
585
+ // primitive for array support.
586
+ replace(start, deleteCount, items = EMPTY_ARRAY) {
587
+ (isDevelopingApp() && !(Array.isArray(items)) && assert('The third argument to replace needs to be an array.', Array.isArray(items)));
588
+ replaceInNativeArray(this, start, deleteCount, items);
589
+ return this;
590
+ }
591
+ });
592
+
593
+ // Remove any methods implemented natively so we don't override them
594
+ const ignore = ['length'];
595
+ NativeArray.keys().forEach(methodName => {
596
+ // SAFETY: It's safe to read unknown properties from an object
597
+ if (Array.prototype[methodName]) {
598
+ ignore.push(methodName);
599
+ }
600
+ });
601
+ NativeArray = NativeArray.without(...ignore);
602
+ let A;
603
+ if (ENV.EXTEND_PROTOTYPES.Array) {
604
+ NativeArray.apply(Array.prototype, true);
605
+ A = function (arr) {
606
+ (isDevelopingApp() && !(!(this instanceof A)) && assert('You cannot create an Ember Array with `new A()`, please update to calling A as a function: `A()`', !(this instanceof A))); // SAFTEY: Since we are extending prototypes all true native arrays are Ember NativeArrays
607
+ return arr || [];
608
+ };
609
+ } else {
610
+ A = function (arr) {
611
+ (isDevelopingApp() && !(!(this instanceof A)) && assert('You cannot create an Ember Array with `new A()`, please update to calling A as a function: `A()`', !(this instanceof A)));
612
+ if (isEmberArray(arr)) {
613
+ // SAFETY: If it's a true native array and it is also an EmberArray then it should be an Ember NativeArray
614
+ return arr;
615
+ } else {
616
+ // SAFETY: This will return an NativeArray but TS can't infer that.
617
+ return NativeArray.apply(arr ?? []);
618
+ }
619
+ };
620
+ }
621
+
622
+ export { A, MutableArray, NativeArray, EmberArray as default, isArray, removeAt, uniqBy };
@@ -0,0 +1 @@
1
+ export { default } from './lib/make-array.js';
@@ -1 +1 @@
1
- export { M as default } from '../../shared-chunks/index-PYiGj1jp.js';
1
+ export { MutableArray as default } from './index.js';
@@ -1,14 +1,17 @@
1
1
  import '../-internals/meta/lib/meta.js';
2
- import { e as isObject } from '../../shared-chunks/mandatory-setter-1UQhiJOb.js';
2
+ import { e as isObject } from '../../shared-chunks/mandatory-setter-BiXq-dpN.js';
3
3
  import { isDevelopingApp } from '@embroider/macros';
4
- import { a as assert } from '../../shared-chunks/index-DTxy4Zgx.js';
4
+ import '../debug/index.js';
5
5
  import '../../@glimmer/destroyable/index.js';
6
6
  import { consumeTag, validateTag, tagFor, valueForTag, combine } from '../../@glimmer/validator/index.js';
7
- import { Q as PROPERTY_DID_CHANGE, g as get, R as objectAt, S as replace, T as arrayContentWillChange, U as arrayContentDidChange, V as addArrayObserver, W as removeArrayObserver, a as tagForProperty } from '../../shared-chunks/cache-gDE3bkXq.js';
8
- import { a as alias } from '../../shared-chunks/alias-By_2yu5c.js';
7
+ import { Q as PROPERTY_DID_CHANGE, g as get, o as objectAt, a as tagForProperty } from '../../shared-chunks/cache-BESCGvbE.js';
8
+ import { a as alias } from '../../shared-chunks/alias-Dri0koi2.js';
9
+ import { a as replace, b as arrayContentWillChange, c as arrayContentDidChange, d as addArrayObserver, e as removeArrayObserver } from '../../shared-chunks/array-3xbmc_4J.js';
9
10
  import '../../shared-chunks/env-BJLX2Arx.js';
10
- import { M as MutableArray, E as EmberObject, a as EmberArray } from '../../shared-chunks/index-PYiGj1jp.js';
11
+ import EmberObject from '../object/index.js';
12
+ import EmberArray, { MutableArray } from './index.js';
11
13
  import { setCustomTagFor } from '../../@glimmer/manager/index.js';
14
+ import { assert } from '../debug/lib/assert.js';
12
15
 
13
16
  /**
14
17
  @module @ember/array/proxy