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,641 +0,0 @@
1
- import { i as isFirefox, a as isChrome } from './index-BGP1rw3B.js';
2
- import { E as ENV } from './env-BJLX2Arx.js';
3
- import { isTesting } from '../@ember/debug/lib/testing.js';
4
- import { registerHandler as registerHandler$2, invoke } from '../@ember/debug/lib/handlers.js';
5
- import { isDevelopingApp } from '@embroider/macros';
6
- import '../@ember/debug/lib/capture-render-tree.js';
7
-
8
- /**
9
- @module @ember/debug
10
- @public
11
- */
12
- /**
13
- Allows for runtime registration of handler functions that override the default deprecation behavior.
14
- Deprecations are invoked by calls to [@ember/debug/deprecate](/ember/release/classes/@ember%2Fdebug/methods/deprecate?anchor=deprecate).
15
- The following example demonstrates its usage by registering a handler that throws an error if the
16
- message contains the word "should", otherwise defers to the default handler.
17
-
18
- ```javascript
19
- import { registerDeprecationHandler } from '@ember/debug';
20
-
21
- registerDeprecationHandler((message, options, next) => {
22
- if (message.indexOf('should') !== -1) {
23
- throw new Error(`Deprecation message with should: ${message}`);
24
- } else {
25
- // defer to whatever handler was registered before this one
26
- next(message, options);
27
- }
28
- });
29
- ```
30
-
31
- The handler function takes the following arguments:
32
-
33
- <ul>
34
- <li> <code>message</code> - The message received from the deprecation call.</li>
35
- <li> <code>options</code> - An object passed in with the deprecation call containing additional information including:</li>
36
- <ul>
37
- <li> <code>id</code> - An id of the deprecation in the form of <code>package-name.specific-deprecation</code>.</li>
38
- <li> <code>until</code> - The Ember version number the feature and deprecation will be removed in.</li>
39
- </ul>
40
- <li> <code>next</code> - A function that calls into the previously registered handler.</li>
41
- </ul>
42
-
43
- @public
44
- @static
45
- @method registerDeprecationHandler
46
- @for @ember/debug
47
- @param handler {Function} A function to handle deprecation calls.
48
- @since 2.1.0
49
- */
50
- let registerHandler$1 = () => {};
51
- let missingOptionsDeprecation$1;
52
- let missingOptionsIdDeprecation$1;
53
- let missingOptionDeprecation = () => '';
54
- let deprecate$1 = () => {};
55
- if (isDevelopingApp()) {
56
- registerHandler$1 = function registerHandler(handler) {
57
- registerHandler$2('deprecate', handler);
58
- };
59
- let formatMessage = function formatMessage(_message, options) {
60
- let message = _message;
61
- if (options?.id) {
62
- message = message + ` [deprecation id: ${options.id}]`;
63
- }
64
- if (options?.until) {
65
- message = message + ` This will be removed in ${options.for} ${options.until}.`;
66
- }
67
- if (options?.url) {
68
- message += ` See ${options.url} for more details.`;
69
- }
70
- return message;
71
- };
72
- registerHandler$1(function logDeprecationToConsole(message, options) {
73
- let updatedMessage = formatMessage(message, options);
74
- console.warn(`DEPRECATION: ${updatedMessage}`); // eslint-disable-line no-console
75
- });
76
- let captureErrorForStack;
77
- if (new Error().stack) {
78
- captureErrorForStack = () => new Error();
79
- } else {
80
- captureErrorForStack = () => {
81
- try {
82
- __fail__.fail();
83
- return;
84
- } catch (e) {
85
- return e;
86
- }
87
- };
88
- }
89
- registerHandler$1(function logDeprecationStackTrace(message, options, next) {
90
- if (ENV.LOG_STACKTRACE_ON_DEPRECATION) {
91
- let stackStr = '';
92
- let error = captureErrorForStack();
93
- let stack;
94
- if (error instanceof Error) {
95
- if (error.stack) {
96
- if (error['arguments']) {
97
- // Chrome
98
- stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.<anonymous>\s*\(([^)]+)\)/gm, '{anonymous}($1)').split('\n');
99
- stack.shift();
100
- } else {
101
- // Firefox
102
- stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n');
103
- }
104
- stackStr = `\n ${stack.slice(2).join('\n ')}`;
105
- }
106
- }
107
- let updatedMessage = formatMessage(message, options);
108
- console.warn(`DEPRECATION: ${updatedMessage}${stackStr}`); // eslint-disable-line no-console
109
- } else {
110
- next(message, options);
111
- }
112
- });
113
- registerHandler$1(function raiseOnDeprecation(message, options, next) {
114
- if (ENV.RAISE_ON_DEPRECATION) {
115
- let updatedMessage = formatMessage(message);
116
- throw new Error(updatedMessage);
117
- } else {
118
- next(message, options);
119
- }
120
- });
121
- missingOptionsDeprecation$1 = 'When calling `deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.';
122
- missingOptionsIdDeprecation$1 = 'When calling `deprecate` you must provide `id` in options.';
123
- missingOptionDeprecation = (id, missingOption) => {
124
- return `When calling \`deprecate\` you must provide \`${missingOption}\` in options. Missing options.${missingOption} in "${id}" deprecation`;
125
- };
126
- /**
127
- @module @ember/debug
128
- @public
129
- */
130
- /**
131
- Display a deprecation warning with the provided message and a stack trace
132
- (Chrome and Firefox only).
133
- Ember itself leverages [Semantic Versioning](https://semver.org) to aid
134
- projects in keeping up with changes to the framework. Before any
135
- functionality or API is removed, it first flows linearly through a
136
- deprecation staging process. The staging process currently contains two
137
- stages: available and enabled.
138
- Deprecations are initially released into the 'available' stage.
139
- Deprecations will stay in this stage until the replacement API has been
140
- marked as a recommended practice via the RFC process and the addon
141
- ecosystem has generally adopted the change.
142
- Once a deprecation meets the above criteria, it will move into the
143
- 'enabled' stage where it will remain until the functionality or API is
144
- eventually removed.
145
- For application and addon developers, "available" deprecations are not
146
- urgent and "enabled" deprecations require action.
147
- * In a production build, this method is defined as an empty function (NOP).
148
- Uses of this method in Ember itself are stripped from the ember.prod.js build.
149
- ```javascript
150
- import { deprecate } from '@ember/debug';
151
- deprecate(
152
- 'Use of `assign` has been deprecated. Please use `Object.assign` or the spread operator instead.',
153
- false,
154
- {
155
- id: 'ember-polyfills.deprecate-assign',
156
- until: '5.0.0',
157
- url: 'https://deprecations.emberjs.com/v4.x/#toc_ember-polyfills-deprecate-assign',
158
- for: 'ember-source',
159
- since: {
160
- available: '4.0.0',
161
- enabled: '4.0.0',
162
- },
163
- }
164
- );
165
- ```
166
- @method deprecate
167
- @for @ember/debug
168
- @param {String} message A description of the deprecation.
169
- @param {Boolean} test A boolean. If falsy, the deprecation will be displayed.
170
- @param {Object} options
171
- @param {String} options.id A unique id for this deprecation. The id can be
172
- used by Ember debugging tools to change the behavior (raise, log or silence)
173
- for that specific deprecation. The id should be namespaced by dots, e.g.
174
- "view.helper.select".
175
- @param {string} options.until The version of Ember when this deprecation
176
- warning will be removed.
177
- @param {String} options.for A namespace for the deprecation, usually the package name
178
- @param {Object} options.since Describes when the deprecation became available and enabled.
179
- @param {String} [options.url] An optional url to the transition guide on the
180
- emberjs.com website.
181
- @static
182
- @public
183
- @since 1.0.0
184
- */
185
- deprecate$1 = function deprecate(message, test, options) {
186
- assert(missingOptionsDeprecation$1, Boolean(options && (options.id || options.until)));
187
- assert(missingOptionsIdDeprecation$1, Boolean(options.id));
188
- assert(missingOptionDeprecation(options.id, 'until'), Boolean(options.until));
189
- assert(missingOptionDeprecation(options.id, 'for'), Boolean(options.for));
190
- assert(missingOptionDeprecation(options.id, 'since'), Boolean(options.since));
191
- invoke('deprecate', message, test, options);
192
- };
193
- }
194
- const _deprecate = deprecate$1;
195
-
196
- let registerHandler = () => {};
197
- let warn$1 = () => {};
198
- let missingOptionsDeprecation;
199
- let missingOptionsIdDeprecation;
200
-
201
- /**
202
- @module @ember/debug
203
- */
204
-
205
- if (isDevelopingApp()) {
206
- /**
207
- Allows for runtime registration of handler functions that override the default warning behavior.
208
- Warnings are invoked by calls made to [@ember/debug/warn](/ember/release/classes/@ember%2Fdebug/methods/warn?anchor=warn).
209
- The following example demonstrates its usage by registering a handler that does nothing overriding Ember's
210
- default warning behavior.
211
- ```javascript
212
- import { registerWarnHandler } from '@ember/debug';
213
- // next is not called, so no warnings get the default behavior
214
- registerWarnHandler(() => {});
215
- ```
216
- The handler function takes the following arguments:
217
- <ul>
218
- <li> <code>message</code> - The message received from the warn call. </li>
219
- <li> <code>options</code> - An object passed in with the warn call containing additional information including:</li>
220
- <ul>
221
- <li> <code>id</code> - An id of the warning in the form of <code>package-name.specific-warning</code>.</li>
222
- </ul>
223
- <li> <code>next</code> - A function that calls into the previously registered handler.</li>
224
- </ul>
225
- @public
226
- @static
227
- @method registerWarnHandler
228
- @for @ember/debug
229
- @param handler {Function} A function to handle warnings.
230
- @since 2.1.0
231
- */
232
- registerHandler = function registerHandler(handler) {
233
- registerHandler$2('warn', handler);
234
- };
235
- registerHandler(function logWarning(message) {
236
- /* eslint-disable no-console */
237
- console.warn(`WARNING: ${message}`);
238
- /* eslint-enable no-console */
239
- });
240
- missingOptionsDeprecation = 'When calling `warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.';
241
- missingOptionsIdDeprecation = 'When calling `warn` you must provide `id` in options.';
242
-
243
- /**
244
- Display a warning with the provided message.
245
- * In a production build, this method is defined as an empty function (NOP).
246
- Uses of this method in Ember itself are stripped from the ember.prod.js build.
247
- ```javascript
248
- import { warn } from '@ember/debug';
249
- import tomsterCount from './tomster-counter'; // a module in my project
250
- // Log a warning if we have more than 3 tomsters
251
- warn('Too many tomsters!', tomsterCount <= 3, {
252
- id: 'ember-debug.too-many-tomsters'
253
- });
254
- ```
255
- @method warn
256
- @for @ember/debug
257
- @static
258
- @param {String} message A warning to display.
259
- @param {Boolean|Object} test An optional boolean. If falsy, the warning
260
- will be displayed. If `test` is an object, the `test` parameter can
261
- be used as the `options` parameter and the warning is displayed.
262
- @param {Object} options
263
- @param {String} options.id The `id` can be used by Ember debugging tools
264
- to change the behavior (raise, log, or silence) for that specific warning.
265
- The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped"
266
- @public
267
- @since 1.0.0
268
- */
269
- warn$1 = function warn(message, test, options) {
270
- if (arguments.length === 2 && typeof test === 'object') {
271
- options = test;
272
- test = false;
273
- }
274
- assert(missingOptionsDeprecation, Boolean(options));
275
- assert(missingOptionsIdDeprecation, Boolean(options && options.id));
276
-
277
- // SAFETY: we have explicitly assigned `false` if the user invoked the
278
- // arity-2 version of the overload, so we know `test` is always either
279
- // `undefined` or a `boolean` for type-safe callers.
280
- invoke('warn', message, test, options);
281
- };
282
- }
283
- const _warn = warn$1;
284
-
285
- const {
286
- toString: objectToString
287
- } = Object.prototype;
288
- const {
289
- toString: functionToString
290
- } = Function.prototype;
291
- const {
292
- isArray
293
- } = Array;
294
- const {
295
- keys: objectKeys
296
- } = Object;
297
- const {
298
- stringify
299
- } = JSON;
300
- const LIST_LIMIT = 100;
301
- const DEPTH_LIMIT = 4;
302
- const SAFE_KEY = /^[\w$]+$/;
303
-
304
- /**
305
- @module @ember/debug
306
- */
307
- /**
308
- Convenience method to inspect an object. This method will attempt to
309
- convert the object into a useful string description.
310
-
311
- It is a pretty simple implementation. If you want something more robust,
312
- use something like JSDump: https://github.com/NV/jsDump
313
-
314
- @method inspect
315
- @static
316
- @param {Object} obj The object you want to inspect.
317
- @return {String} A description of the object
318
- @since 1.4.0
319
- @private
320
- */
321
- function inspect(obj) {
322
- // detect Node util.inspect call inspect(depth: number, opts: object)
323
- if (typeof obj === 'number' && arguments.length === 2) {
324
- return this;
325
- }
326
- return inspectValue(obj, 0);
327
- }
328
- function inspectValue(value, depth, seen) {
329
- let valueIsArray = false;
330
- switch (typeof value) {
331
- case 'undefined':
332
- return 'undefined';
333
- case 'object':
334
- if (value === null) return 'null';
335
- if (isArray(value)) {
336
- valueIsArray = true;
337
- break;
338
- }
339
- // is toString Object.prototype.toString or undefined then traverse
340
- if (value.toString === objectToString || value.toString === undefined) {
341
- break;
342
- }
343
- // custom toString
344
- return value.toString();
345
- case 'function':
346
- return value.toString === functionToString ? value.name ? `[Function:${value.name}]` : `[Function]` : value.toString();
347
- case 'string':
348
- return stringify(value);
349
- case 'symbol':
350
- case 'boolean':
351
- case 'number':
352
- default:
353
- return value.toString();
354
- }
355
- if (seen === undefined) {
356
- seen = new WeakSet();
357
- } else {
358
- if (seen.has(value)) return `[Circular]`;
359
- }
360
- seen.add(value);
361
- return valueIsArray ? inspectArray(value, depth + 1, seen) : inspectObject(value, depth + 1, seen);
362
- }
363
- function inspectKey(key) {
364
- return SAFE_KEY.test(key) ? key : stringify(key);
365
- }
366
- function inspectObject(obj, depth, seen) {
367
- if (depth > DEPTH_LIMIT) {
368
- return '[Object]';
369
- }
370
- let s = '{';
371
- let keys = objectKeys(obj);
372
- for (let i = 0; i < keys.length; i++) {
373
- s += i === 0 ? ' ' : ', ';
374
- if (i >= LIST_LIMIT) {
375
- s += `... ${keys.length - LIST_LIMIT} more keys`;
376
- break;
377
- }
378
- let key = keys[i];
379
- (isDevelopingApp() && !(key) && assert('has key', key)); // Looping over array
380
- s += `${inspectKey(String(key))}: ${inspectValue(obj[key], depth, seen)}`;
381
- }
382
- s += ' }';
383
- return s;
384
- }
385
- function inspectArray(arr, depth, seen) {
386
- if (depth > DEPTH_LIMIT) {
387
- return '[Array]';
388
- }
389
- let s = '[';
390
- for (let i = 0; i < arr.length; i++) {
391
- s += i === 0 ? ' ' : ', ';
392
- if (i >= LIST_LIMIT) {
393
- s += `... ${arr.length - LIST_LIMIT} more items`;
394
- break;
395
- }
396
- s += inspectValue(arr[i], depth, seen);
397
- }
398
- s += ' ]';
399
- return s;
400
- }
401
-
402
- // These are the default production build versions:
403
- const noop = () => {};
404
-
405
- // SAFETY: these casts are just straight-up lies, but the point is that they do
406
- // not do anything in production builds.
407
- let assert = noop;
408
- let info = noop;
409
- let warn = noop;
410
- let debug = noop;
411
- let deprecate = noop;
412
- let debugSeal = noop;
413
- let debugFreeze = noop;
414
- let runInDebug = noop;
415
- let setDebugFunction = noop;
416
- let getDebugFunction = noop;
417
- let deprecateFunc = function () {
418
- return arguments[arguments.length - 1];
419
- };
420
- if (isDevelopingApp()) {
421
- setDebugFunction = function (type, callback) {
422
- switch (type) {
423
- case 'assert':
424
- return assert = callback;
425
- case 'info':
426
- return info = callback;
427
- case 'warn':
428
- return warn = callback;
429
- case 'debug':
430
- return debug = callback;
431
- case 'deprecate':
432
- return deprecate = callback;
433
- case 'debugSeal':
434
- return debugSeal = callback;
435
- case 'debugFreeze':
436
- return debugFreeze = callback;
437
- case 'runInDebug':
438
- return runInDebug = callback;
439
- case 'deprecateFunc':
440
- return deprecateFunc = callback;
441
- }
442
- };
443
- getDebugFunction = function (type) {
444
- switch (type) {
445
- case 'assert':
446
- return assert;
447
- case 'info':
448
- return info;
449
- case 'warn':
450
- return warn;
451
- case 'debug':
452
- return debug;
453
- case 'deprecate':
454
- return deprecate;
455
- case 'debugSeal':
456
- return debugSeal;
457
- case 'debugFreeze':
458
- return debugFreeze;
459
- case 'runInDebug':
460
- return runInDebug;
461
- case 'deprecateFunc':
462
- return deprecateFunc;
463
- }
464
- };
465
- }
466
-
467
- /**
468
- @module @ember/debug
469
- */
470
-
471
- if (isDevelopingApp()) {
472
- /**
473
- Verify that a certain expectation is met, or throw a exception otherwise.
474
- This is useful for communicating assumptions in the code to other human
475
- readers as well as catching bugs that accidentally violates these
476
- expectations.
477
- Assertions are removed from production builds, so they can be freely added
478
- for documentation and debugging purposes without worries of incuring any
479
- performance penalty. However, because of that, they should not be used for
480
- checks that could reasonably fail during normal usage. Furthermore, care
481
- should be taken to avoid accidentally relying on side-effects produced from
482
- evaluating the condition itself, since the code will not run in production.
483
- ```javascript
484
- import { assert } from '@ember/debug';
485
- // Test for truthiness
486
- assert('Must pass a string', typeof str === 'string');
487
- // Fail unconditionally
488
- assert('This code path should never be run');
489
- ```
490
- @method assert
491
- @static
492
- @for @ember/debug
493
- @param {String} description Describes the expectation. This will become the
494
- text of the Error thrown if the assertion fails.
495
- @param {any} condition Must be truthy for the assertion to pass. If
496
- falsy, an exception will be thrown.
497
- @public
498
- @since 1.0.0
499
- */
500
-
501
- // eslint-disable-next-line no-inner-declarations
502
- function assert(desc, test) {
503
- if (!test) {
504
- throw new Error(`Assertion Failed: ${desc}`);
505
- }
506
- }
507
- setDebugFunction('assert', assert);
508
-
509
- /**
510
- Display a debug notice.
511
- Calls to this function are not invoked in production builds.
512
- ```javascript
513
- import { debug } from '@ember/debug';
514
- debug('I\'m a debug notice!');
515
- ```
516
- @method debug
517
- @for @ember/debug
518
- @static
519
- @param {String} message A debug message to display.
520
- @public
521
- */
522
- setDebugFunction('debug', function debug(message) {
523
- console.debug(`DEBUG: ${message}`); /* eslint-disable-line no-console */
524
- });
525
-
526
- /**
527
- Display an info notice.
528
- Calls to this function are removed from production builds, so they can be
529
- freely added for documentation and debugging purposes without worries of
530
- incuring any performance penalty.
531
- @method info
532
- @private
533
- */
534
- setDebugFunction('info', function info() {
535
- console.info(...arguments); /* eslint-disable-line no-console */
536
- });
537
-
538
- /**
539
- @module @ember/debug
540
- @public
541
- */
542
-
543
- /**
544
- Alias an old, deprecated method with its new counterpart.
545
- Display a deprecation warning with the provided message and a stack trace
546
- (Chrome and Firefox only) when the assigned method is called.
547
- Calls to this function are removed from production builds, so they can be
548
- freely added for documentation and debugging purposes without worries of
549
- incuring any performance penalty.
550
- ```javascript
551
- import { deprecateFunc } from '@ember/debug';
552
- Ember.oldMethod = deprecateFunc('Please use the new, updated method', options, Ember.newMethod);
553
- ```
554
- @method deprecateFunc
555
- @static
556
- @for @ember/debug
557
- @param {String} message A description of the deprecation.
558
- @param {Object} [options] The options object for `deprecate`.
559
- @param {Function} func The new function called to replace its deprecated counterpart.
560
- @return {Function} A new function that wraps the original function with a deprecation warning
561
- @private
562
- */
563
- setDebugFunction('deprecateFunc', function deprecateFunc(...args) {
564
- if (args.length === 3) {
565
- let [message, options, func] = args;
566
- return function (...args) {
567
- deprecate(message, false, options);
568
- return func.apply(this, args);
569
- };
570
- } else {
571
- let [message, func] = args;
572
- return function () {
573
- deprecate(message);
574
- return func.apply(this, arguments);
575
- };
576
- }
577
- });
578
-
579
- /**
580
- @module @ember/debug
581
- @public
582
- */
583
- /**
584
- Run a function meant for debugging.
585
- Calls to this function are removed from production builds, so they can be
586
- freely added for documentation and debugging purposes without worries of
587
- incuring any performance penalty.
588
- ```javascript
589
- import Component from '@ember/component';
590
- import { runInDebug } from '@ember/debug';
591
- runInDebug(() => {
592
- Component.reopen({
593
- didInsertElement() {
594
- console.log("I'm happy");
595
- }
596
- });
597
- });
598
- ```
599
- @method runInDebug
600
- @for @ember/debug
601
- @static
602
- @param {Function} func The function to be executed.
603
- @since 1.5.0
604
- @public
605
- */
606
- setDebugFunction('runInDebug', function runInDebug(func) {
607
- func();
608
- });
609
- setDebugFunction('debugSeal', function debugSeal(obj) {
610
- Object.seal(obj);
611
- });
612
- setDebugFunction('debugFreeze', function debugFreeze(obj) {
613
- // re-freezing an already frozen object introduces a significant
614
- // performance penalty on Chrome (tested through 59).
615
- //
616
- // See: https://bugs.chromium.org/p/v8/issues/detail?id=6450
617
- if (!Object.isFrozen(obj)) {
618
- Object.freeze(obj);
619
- }
620
- });
621
- setDebugFunction('deprecate', _deprecate);
622
- setDebugFunction('warn', _warn);
623
- }
624
- let _warnIfUsingStrippedFeatureFlags;
625
- if (isDevelopingApp() && !isTesting()) {
626
- if (typeof window !== 'undefined' && (isFirefox || isChrome) && window.addEventListener) {
627
- window.addEventListener('load', () => {
628
- if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset['emberExtension']) {
629
- let downloadURL;
630
- if (isChrome) {
631
- downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi';
632
- } else if (isFirefox) {
633
- downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/';
634
- }
635
- debug(`For more advanced debugging, install the Ember Inspector from ${downloadURL}`);
636
- }
637
- }, false);
638
- }
639
- }
640
-
641
- export { _deprecate as _, assert as a, inspect as b, debug as c, deprecate as d, deprecateFunc as e, registerHandler$1 as f, registerHandler as g, debugFreeze as h, info as i, missingOptionsIdDeprecation$1 as j, missingOptionDeprecation as k, _warn as l, missingOptionsDeprecation$1 as m, missingOptionsIdDeprecation as n, missingOptionsDeprecation as o, debugSeal as p, getDebugFunction as q, runInDebug as r, setDebugFunction as s, _warnIfUsingStrippedFeatureFlags as t, warn as w };