ember-source 4.5.0-alpha.2 → 4.5.0-alpha.5
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 +4 -0
- package/build-metadata.json +3 -3
- package/dist/dependencies/@glimmer/global-context.js +9 -1
- package/dist/dependencies/@glimmer/manager.js +276 -212
- package/dist/dependencies/@glimmer/runtime.js +2 -2
- package/dist/dependencies/@glimmer/util.js +1 -22
- package/dist/ember-template-compiler.js +35 -28
- 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 +1202 -1429
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/container/index.js +2 -2
- package/dist/packages/@ember/-internals/glimmer/index.js +24 -19
- package/dist/packages/@ember/-internals/metal/index.js +19 -7
- package/dist/packages/@ember/-internals/routing/lib/location/api.js +3 -3
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +5 -1
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +7 -6
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +9 -6
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +6 -9
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +4 -2
- package/dist/packages/@ember/-internals/routing/lib/utils.js +15 -25
- package/dist/packages/@ember/-internals/runtime/lib/compare.js +4 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +14 -15
- package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +32 -44
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +7 -22
- package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +34 -46
- package/dist/packages/@ember/-internals/runtime/lib/mixins/enumerable.js +2 -15
- package/dist/packages/@ember/-internals/runtime/lib/mixins/evented.js +13 -57
- package/dist/packages/@ember/-internals/runtime/lib/mixins/mutable_enumerable.js +2 -16
- package/dist/packages/@ember/-internals/runtime/lib/mixins/observable.js +64 -134
- package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +28 -86
- package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +59 -61
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +17 -24
- package/dist/packages/@ember/-internals/runtime/lib/system/array_proxy.js +59 -85
- package/dist/packages/@ember/-internals/runtime/lib/system/object.js +9 -2
- package/dist/packages/@ember/-internals/runtime/lib/system/object_proxy.js +3 -77
- package/dist/packages/@ember/-internals/utils/index.js +1 -1
- package/dist/packages/@ember/-internals/utils/types.js +1 -0
- package/dist/packages/@ember/-internals/views/lib/compat/attrs.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/component_lookup.js +2 -2
- package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +3 -9
- package/dist/packages/@ember/-internals/views/lib/mixins/child_views_support.js +4 -6
- package/dist/packages/@ember/-internals/views/lib/mixins/class_names_support.js +13 -18
- package/dist/packages/@ember/-internals/views/lib/mixins/view_state_support.js +3 -2
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +57 -58
- package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +142 -120
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/views/states/destroying.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/views/states/has_element.js +2 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/in_dom.js +3 -1
- package/dist/packages/@ember/application/instance.js +1 -0
- package/dist/packages/@ember/application/lib/application.js +8 -1
- package/dist/packages/@ember/canary-features/index.js +4 -2
- package/dist/packages/@ember/engine/instance.js +1 -1
- package/dist/packages/@ember/engine/lib/engine-parent.js +1 -5
- package/dist/packages/@ember/renderer/index.js +28 -0
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +823 -709
- package/package.json +17 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Ember Changelog
|
|
2
2
|
|
|
3
|
+
## v3.28.9 (April 19, 2022)
|
|
4
|
+
|
|
5
|
+
- [#20028](https://github.com/emberjs/ember.js/pull/20028) Fix a memory leak in the Router Service class
|
|
6
|
+
|
|
3
7
|
### v4.4.0-beta.1 (March 24, 2022)
|
|
4
8
|
|
|
5
9
|
- [#19882](https://github.com/emberjs/ember.js/pull/19882) / [#20005](https://github.com/emberjs/ember.js/pull/20005) [FEATURE] Implement the `unique-id` helper per [RFC #0659](https://github.com/emberjs/rfcs/blob/master/text/0659-unique-id-helper.md).
|
package/build-metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.5.0-alpha.
|
|
2
|
+
"version": "4.5.0-alpha.5",
|
|
3
3
|
"buildType": "tag",
|
|
4
|
-
"SHA": "
|
|
5
|
-
"assetPath": "/tag/shas/
|
|
4
|
+
"SHA": "6323e29b9bebcc797136869aadff11f4f1df9dc9",
|
|
5
|
+
"assetPath": "/tag/shas/6323e29b9bebcc797136869aadff11f4f1df9dc9.tgz"
|
|
6
6
|
}
|
|
@@ -15,6 +15,8 @@ import { DEBUG } from '@glimmer/env';
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
let FEATURE_DEFAULT_HELPER_MANAGER = true; //////////
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* Schedules a VM revalidation.
|
|
20
22
|
*
|
|
@@ -108,6 +110,8 @@ let assert;
|
|
|
108
110
|
let deprecate;
|
|
109
111
|
let globalContextWasSet = false;
|
|
110
112
|
function setGlobalContext(context) {
|
|
113
|
+
var _a;
|
|
114
|
+
|
|
111
115
|
if (DEBUG) {
|
|
112
116
|
if (globalContextWasSet) {
|
|
113
117
|
throw new Error('Attempted to set the global context twice. This should only be set once.');
|
|
@@ -128,6 +132,10 @@ function setGlobalContext(context) {
|
|
|
128
132
|
warnIfStyleNotTrusted = context.warnIfStyleNotTrusted;
|
|
129
133
|
assert = context.assert;
|
|
130
134
|
deprecate = context.deprecate;
|
|
135
|
+
|
|
136
|
+
if (typeof ((_a = context.FEATURES) === null || _a === void 0 ? void 0 : _a.DEFAULT_HELPER_MANAGER) === 'boolean') {
|
|
137
|
+
FEATURE_DEFAULT_HELPER_MANAGER = context.FEATURES.DEFAULT_HELPER_MANAGER;
|
|
138
|
+
}
|
|
131
139
|
}
|
|
132
140
|
let assertGlobalContextWasSet;
|
|
133
141
|
let testOverrideGlobalContext;
|
|
@@ -180,4 +188,4 @@ if (DEBUG) {
|
|
|
180
188
|
}
|
|
181
189
|
|
|
182
190
|
export default setGlobalContext;
|
|
183
|
-
export { scheduleRevalidate, scheduleDestroy, scheduleDestroyed, toIterator, toBool, getProp, setProp, getPath, setPath, warnIfStyleNotTrusted, assert, deprecate, assertGlobalContextWasSet, testOverrideGlobalContext };
|
|
191
|
+
export { FEATURE_DEFAULT_HELPER_MANAGER, scheduleRevalidate, scheduleDestroy, scheduleDestroyed, toIterator, toBool, getProp, setProp, getPath, setPath, warnIfStyleNotTrusted, assert, deprecate, assertGlobalContextWasSet, testOverrideGlobalContext };
|
|
@@ -1,115 +1,9 @@
|
|
|
1
1
|
import { DEBUG } from '@glimmer/env';
|
|
2
|
-
import {
|
|
3
|
-
import { valueForRef,
|
|
2
|
+
import { _WeakSet, HAS_NATIVE_PROXY, debugToString } from '@glimmer/util';
|
|
3
|
+
import { valueForRef, createComputeRef, createConstRef, UNDEFINED_REFERENCE } from '@glimmer/reference';
|
|
4
4
|
import { track, createUpdatableTag, untrack } from '@glimmer/validator';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
const COMPONENT_MANAGERS = new WeakMap();
|
|
8
|
-
const MODIFIER_MANAGERS = new WeakMap();
|
|
9
|
-
const HELPER_MANAGERS = new WeakMap(); ///////////
|
|
10
|
-
|
|
11
|
-
const getPrototypeOf = Object.getPrototypeOf;
|
|
12
|
-
|
|
13
|
-
function setManager(map, manager, obj) {
|
|
14
|
-
if (DEBUG && (typeof obj !== 'object' || obj === null) && typeof obj !== 'function') {
|
|
15
|
-
throw new Error(`Attempted to set a manager on a non-object value. Managers can only be associated with objects or functions. Value was ${debugToString(obj)}`);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (DEBUG && map.has(obj)) {
|
|
19
|
-
throw new Error(`Attempted to set the same type of manager multiple times on a value. You can only associate one manager of each type with a given value. Value was ${debugToString(obj)}`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
map.set(obj, manager);
|
|
23
|
-
return obj;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getManager(map, obj) {
|
|
27
|
-
let pointer = obj;
|
|
28
|
-
|
|
29
|
-
while (pointer !== undefined && pointer !== null) {
|
|
30
|
-
const manager = map.get(pointer);
|
|
31
|
-
|
|
32
|
-
if (manager !== undefined) {
|
|
33
|
-
return manager;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
pointer = getPrototypeOf(pointer);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return undefined;
|
|
40
|
-
} ///////////
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
function setInternalModifierManager(manager, definition) {
|
|
44
|
-
return setManager(MODIFIER_MANAGERS, manager, definition);
|
|
45
|
-
}
|
|
46
|
-
function getInternalModifierManager(definition, isOptional) {
|
|
47
|
-
if (DEBUG && typeof definition !== 'function' && (typeof definition !== 'object' || definition === null)) {
|
|
48
|
-
throw new Error(`Attempted to use a value as a modifier, but it was not an object or function. Modifier definitions must be objects or functions with an associated modifier manager. The value was: ${definition}`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const manager = getManager(MODIFIER_MANAGERS, definition);
|
|
52
|
-
|
|
53
|
-
if (manager === undefined) {
|
|
54
|
-
if (isOptional === true) {
|
|
55
|
-
return null;
|
|
56
|
-
} else if (DEBUG) {
|
|
57
|
-
throw new Error(`Attempted to load a modifier, but there wasn't a modifier manager associated with the definition. The definition was: ${debugToString(definition)}`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return manager;
|
|
62
|
-
}
|
|
63
|
-
function setInternalHelperManager(manager, definition) {
|
|
64
|
-
return setManager(HELPER_MANAGERS, manager, definition);
|
|
65
|
-
}
|
|
66
|
-
function getInternalHelperManager(definition, isOptional) {
|
|
67
|
-
if (DEBUG && typeof definition !== 'function' && (typeof definition !== 'object' || definition === null)) {
|
|
68
|
-
throw new Error(`Attempted to use a value as a helper, but it was not an object or function. Helper definitions must be objects or functions with an associated helper manager. The value was: ${definition}`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const manager = getManager(HELPER_MANAGERS, definition);
|
|
72
|
-
|
|
73
|
-
if (manager === undefined) {
|
|
74
|
-
if (isOptional === true) {
|
|
75
|
-
return null;
|
|
76
|
-
} else if (DEBUG) {
|
|
77
|
-
throw new Error(`Attempted to load a helper, but there wasn't a helper manager associated with the definition. The definition was: ${debugToString(definition)}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return manager;
|
|
82
|
-
}
|
|
83
|
-
function setInternalComponentManager(factory, obj) {
|
|
84
|
-
return setManager(COMPONENT_MANAGERS, factory, obj);
|
|
85
|
-
}
|
|
86
|
-
function getInternalComponentManager(definition, isOptional) {
|
|
87
|
-
if (DEBUG && typeof definition !== 'function' && (typeof definition !== 'object' || definition === null)) {
|
|
88
|
-
throw new Error(`Attempted to use a value as a component, but it was not an object or function. Component definitions must be objects or functions with an associated component manager. The value was: ${definition}`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const manager = getManager(COMPONENT_MANAGERS, definition);
|
|
92
|
-
|
|
93
|
-
if (manager === undefined) {
|
|
94
|
-
if (isOptional === true) {
|
|
95
|
-
return null;
|
|
96
|
-
} else if (DEBUG) {
|
|
97
|
-
throw new Error(`Attempted to load a component, but there wasn't a component manager associated with the definition. The definition was: ${debugToString(definition)}`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return manager;
|
|
102
|
-
} ///////////
|
|
103
|
-
|
|
104
|
-
function hasInternalComponentManager(definition) {
|
|
105
|
-
return getManager(COMPONENT_MANAGERS, definition) !== undefined;
|
|
106
|
-
}
|
|
107
|
-
function hasInternalHelperManager(definition) {
|
|
108
|
-
return getManager(HELPER_MANAGERS, definition) !== undefined;
|
|
109
|
-
}
|
|
110
|
-
function hasInternalModifierManager(definition) {
|
|
111
|
-
return getManager(MODIFIER_MANAGERS, definition) !== undefined;
|
|
112
|
-
}
|
|
5
|
+
import { associateDestroyableChild, registerDestructor } from '@glimmer/destroyable';
|
|
6
|
+
import { FEATURE_DEFAULT_HELPER_MANAGER } from '@glimmer/global-context';
|
|
113
7
|
|
|
114
8
|
const FROM_CAPABILITIES = DEBUG ? new _WeakSet() : undefined;
|
|
115
9
|
function buildCapabilities(capabilities) {
|
|
@@ -291,7 +185,7 @@ if (HAS_NATIVE_PROXY) {
|
|
|
291
185
|
|
|
292
186
|
if (DEBUG) {
|
|
293
187
|
const setHandler = function (_target, prop) {
|
|
294
|
-
throw new Error(`You attempted to set ${String(prop)} on the arguments of a component, helper, or modifier. Arguments are immutable and cannot be updated directly
|
|
188
|
+
throw new Error(`You attempted to set ${String(prop)} on the arguments of a component, helper, or modifier. Arguments are immutable and cannot be updated directly; they always represent the values that are passed down. If you want to set default values, you should use a getter and local tracked state instead.`);
|
|
295
189
|
};
|
|
296
190
|
|
|
297
191
|
const forInDebugHandler = () => {
|
|
@@ -365,6 +259,277 @@ if (HAS_NATIVE_PROXY) {
|
|
|
365
259
|
};
|
|
366
260
|
}
|
|
367
261
|
|
|
262
|
+
function helperCapabilities(managerAPI, options = {}) {
|
|
263
|
+
if (DEBUG && managerAPI !== '3.23') {
|
|
264
|
+
throw new Error('Invalid helper manager compatibility specified');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (DEBUG && (!(options.hasValue || options.hasScheduledEffect) || options.hasValue && options.hasScheduledEffect)) {
|
|
268
|
+
throw new Error('You must pass either the `hasValue` OR the `hasScheduledEffect` capability when defining a helper manager. Passing neither, or both, is not permitted.');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (DEBUG && options.hasScheduledEffect) {
|
|
272
|
+
throw new Error('The `hasScheduledEffect` capability has not yet been implemented for helper managers. Please pass `hasValue` instead');
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return buildCapabilities({
|
|
276
|
+
hasValue: Boolean(options.hasValue),
|
|
277
|
+
hasDestroyable: Boolean(options.hasDestroyable),
|
|
278
|
+
hasScheduledEffect: Boolean(options.hasScheduledEffect)
|
|
279
|
+
});
|
|
280
|
+
} ////////////
|
|
281
|
+
|
|
282
|
+
function hasValue(manager) {
|
|
283
|
+
return manager.capabilities.hasValue;
|
|
284
|
+
}
|
|
285
|
+
function hasDestroyable(manager) {
|
|
286
|
+
return manager.capabilities.hasDestroyable;
|
|
287
|
+
} ////////////
|
|
288
|
+
|
|
289
|
+
class CustomHelperManager {
|
|
290
|
+
constructor(factory) {
|
|
291
|
+
this.factory = factory;
|
|
292
|
+
this.helperManagerDelegates = new WeakMap();
|
|
293
|
+
this.undefinedDelegate = null;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
getDelegateForOwner(owner) {
|
|
297
|
+
let delegate = this.helperManagerDelegates.get(owner);
|
|
298
|
+
|
|
299
|
+
if (delegate === undefined) {
|
|
300
|
+
let {
|
|
301
|
+
factory
|
|
302
|
+
} = this;
|
|
303
|
+
delegate = factory(owner);
|
|
304
|
+
|
|
305
|
+
if (DEBUG && !FROM_CAPABILITIES.has(delegate.capabilities)) {
|
|
306
|
+
// TODO: This error message should make sense in both Ember and Glimmer https://github.com/glimmerjs/glimmer-vm/issues/1200
|
|
307
|
+
throw new Error(`Custom helper managers must have a \`capabilities\` property that is the result of calling the \`capabilities('3.23')\` (imported via \`import { capabilities } from '@ember/helper';\`). Received: \`${JSON.stringify(delegate.capabilities)}\` for: \`${delegate}\``);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
this.helperManagerDelegates.set(owner, delegate);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return delegate;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
getDelegateFor(owner) {
|
|
317
|
+
if (owner === undefined) {
|
|
318
|
+
let {
|
|
319
|
+
undefinedDelegate
|
|
320
|
+
} = this;
|
|
321
|
+
|
|
322
|
+
if (undefinedDelegate === null) {
|
|
323
|
+
let {
|
|
324
|
+
factory
|
|
325
|
+
} = this;
|
|
326
|
+
this.undefinedDelegate = undefinedDelegate = factory(undefined);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return undefinedDelegate;
|
|
330
|
+
} else {
|
|
331
|
+
return this.getDelegateForOwner(owner);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
getHelper(definition) {
|
|
336
|
+
return (capturedArgs, owner) => {
|
|
337
|
+
var _a, _b;
|
|
338
|
+
|
|
339
|
+
let manager = this.getDelegateFor(owner);
|
|
340
|
+
const args = argsProxyFor(capturedArgs, 'helper');
|
|
341
|
+
const bucket = manager.createHelper(definition, args);
|
|
342
|
+
|
|
343
|
+
if (hasValue(manager)) {
|
|
344
|
+
let cache = createComputeRef(() => manager.getValue(bucket), null, DEBUG && manager.getDebugName && manager.getDebugName(definition));
|
|
345
|
+
|
|
346
|
+
if (hasDestroyable(manager)) {
|
|
347
|
+
associateDestroyableChild(cache, manager.getDestroyable(bucket));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return cache;
|
|
351
|
+
} else if (hasDestroyable(manager)) {
|
|
352
|
+
let ref = createConstRef(undefined, DEBUG && ((_b = (_a = manager.getDebugName) === null || _a === void 0 ? void 0 : _a.call(manager, definition)) !== null && _b !== void 0 ? _b : 'unknown helper'));
|
|
353
|
+
associateDestroyableChild(ref, manager.getDestroyable(bucket));
|
|
354
|
+
return ref;
|
|
355
|
+
} else {
|
|
356
|
+
return UNDEFINED_REFERENCE;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
class FunctionHelperManager {
|
|
364
|
+
constructor() {
|
|
365
|
+
this.capabilities = buildCapabilities({
|
|
366
|
+
hasValue: true,
|
|
367
|
+
hasDestroyable: false,
|
|
368
|
+
hasScheduledEffect: false
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
createHelper(fn, args) {
|
|
373
|
+
return {
|
|
374
|
+
fn,
|
|
375
|
+
args
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
getValue({
|
|
380
|
+
fn,
|
|
381
|
+
args
|
|
382
|
+
}) {
|
|
383
|
+
if (Object.keys(args.named).length > 0) {
|
|
384
|
+
let argsForFn = [...args.positional, args.named];
|
|
385
|
+
return fn(...argsForFn);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return fn(...args.positional);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
getDebugName(fn) {
|
|
392
|
+
if (fn.name) {
|
|
393
|
+
return `(helper function ${fn.name})`;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return '(anonymous helper function)';
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const COMPONENT_MANAGERS = new WeakMap();
|
|
402
|
+
const MODIFIER_MANAGERS = new WeakMap();
|
|
403
|
+
const HELPER_MANAGERS = new WeakMap(); ///////////
|
|
404
|
+
|
|
405
|
+
const getPrototypeOf = Object.getPrototypeOf;
|
|
406
|
+
|
|
407
|
+
function setManager(map, manager, obj) {
|
|
408
|
+
if (DEBUG && (typeof obj !== 'object' || obj === null) && typeof obj !== 'function') {
|
|
409
|
+
throw new Error(`Attempted to set a manager on a non-object value. Managers can only be associated with objects or functions. Value was ${debugToString(obj)}`);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (DEBUG && map.has(obj)) {
|
|
413
|
+
throw new Error(`Attempted to set the same type of manager multiple times on a value. You can only associate one manager of each type with a given value. Value was ${debugToString(obj)}`);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
map.set(obj, manager);
|
|
417
|
+
return obj;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function getManager(map, obj) {
|
|
421
|
+
let pointer = obj;
|
|
422
|
+
|
|
423
|
+
while (pointer !== undefined && pointer !== null) {
|
|
424
|
+
const manager = map.get(pointer);
|
|
425
|
+
|
|
426
|
+
if (manager !== undefined) {
|
|
427
|
+
return manager;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
pointer = getPrototypeOf(pointer);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return undefined;
|
|
434
|
+
} ///////////
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
function setInternalModifierManager(manager, definition) {
|
|
438
|
+
return setManager(MODIFIER_MANAGERS, manager, definition);
|
|
439
|
+
}
|
|
440
|
+
function getInternalModifierManager(definition, isOptional) {
|
|
441
|
+
if (DEBUG && typeof definition !== 'function' && (typeof definition !== 'object' || definition === null)) {
|
|
442
|
+
throw new Error(`Attempted to use a value as a modifier, but it was not an object or function. Modifier definitions must be objects or functions with an associated modifier manager. The value was: ${definition}`);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const manager = getManager(MODIFIER_MANAGERS, definition);
|
|
446
|
+
|
|
447
|
+
if (manager === undefined) {
|
|
448
|
+
if (isOptional === true) {
|
|
449
|
+
return null;
|
|
450
|
+
} else if (DEBUG) {
|
|
451
|
+
throw new Error(`Attempted to load a modifier, but there wasn't a modifier manager associated with the definition. The definition was: ${debugToString(definition)}`);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
return manager;
|
|
456
|
+
}
|
|
457
|
+
function setInternalHelperManager(manager, definition) {
|
|
458
|
+
return setManager(HELPER_MANAGERS, manager, definition);
|
|
459
|
+
}
|
|
460
|
+
const DEFAULT_MANAGER = new CustomHelperManager(() => new FunctionHelperManager());
|
|
461
|
+
function getInternalHelperManager(definition, isOptional) {
|
|
462
|
+
if (DEBUG && typeof definition !== 'function' && (typeof definition !== 'object' || definition === null)) {
|
|
463
|
+
throw new Error(`Attempted to use a value as a helper, but it was not an object or function. Helper definitions must be objects or functions with an associated helper manager. The value was: ${definition}`);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
let manager = getManager(HELPER_MANAGERS, definition);
|
|
467
|
+
|
|
468
|
+
if (FEATURE_DEFAULT_HELPER_MANAGER) {
|
|
469
|
+
// Functions are special-cased because functions are defined
|
|
470
|
+
// as the "default" helper, per: https://github.com/emberjs/rfcs/pull/756
|
|
471
|
+
if (manager === undefined && typeof definition === 'function') {
|
|
472
|
+
manager = DEFAULT_MANAGER;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (manager) {
|
|
477
|
+
return manager;
|
|
478
|
+
} else if (isOptional === true) {
|
|
479
|
+
return null;
|
|
480
|
+
} else if (DEBUG) {
|
|
481
|
+
throw new Error(`Attempted to load a helper, but there wasn't a helper manager associated with the definition. The definition was: ${debugToString(definition)}`);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
function setInternalComponentManager(factory, obj) {
|
|
487
|
+
return setManager(COMPONENT_MANAGERS, factory, obj);
|
|
488
|
+
}
|
|
489
|
+
function getInternalComponentManager(definition, isOptional) {
|
|
490
|
+
if (DEBUG && typeof definition !== 'function' && (typeof definition !== 'object' || definition === null)) {
|
|
491
|
+
throw new Error(`Attempted to use a value as a component, but it was not an object or function. Component definitions must be objects or functions with an associated component manager. The value was: ${definition}`);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const manager = getManager(COMPONENT_MANAGERS, definition);
|
|
495
|
+
|
|
496
|
+
if (manager === undefined) {
|
|
497
|
+
if (isOptional === true) {
|
|
498
|
+
return null;
|
|
499
|
+
} else if (DEBUG) {
|
|
500
|
+
throw new Error(`Attempted to load a component, but there wasn't a component manager associated with the definition. The definition was: ${debugToString(definition)}`);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
return manager;
|
|
505
|
+
} ///////////
|
|
506
|
+
|
|
507
|
+
function hasInternalComponentManager(definition) {
|
|
508
|
+
return hasDefaultComponentManager(definition) || getManager(COMPONENT_MANAGERS, definition) !== undefined;
|
|
509
|
+
}
|
|
510
|
+
function hasInternalHelperManager(definition) {
|
|
511
|
+
return hasDefaultHelperManager(definition) || getManager(HELPER_MANAGERS, definition) !== undefined;
|
|
512
|
+
}
|
|
513
|
+
function hasInternalModifierManager(definition) {
|
|
514
|
+
return hasDefaultModifierManager(definition) || getManager(MODIFIER_MANAGERS, definition) !== undefined;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function hasDefaultComponentManager(_definition) {
|
|
518
|
+
return false;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function hasDefaultHelperManager(definition) {
|
|
522
|
+
if (FEATURE_DEFAULT_HELPER_MANAGER) {
|
|
523
|
+
return typeof definition === 'function';
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function hasDefaultModifierManager(_definition) {
|
|
530
|
+
return false;
|
|
531
|
+
}
|
|
532
|
+
|
|
368
533
|
const CAPABILITIES = {
|
|
369
534
|
dynamicLayout: false,
|
|
370
535
|
dynamicTag: false,
|
|
@@ -683,107 +848,6 @@ class CustomModifierManager {
|
|
|
683
848
|
|
|
684
849
|
}
|
|
685
850
|
|
|
686
|
-
function helperCapabilities(managerAPI, options = {}) {
|
|
687
|
-
if (DEBUG && managerAPI !== '3.23') {
|
|
688
|
-
throw new Error('Invalid helper manager compatibility specified');
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
if (DEBUG && (!(options.hasValue || options.hasScheduledEffect) || options.hasValue && options.hasScheduledEffect)) {
|
|
692
|
-
throw new Error('You must pass either the `hasValue` OR the `hasScheduledEffect` capability when defining a helper manager. Passing neither, or both, is not permitted.');
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
if (DEBUG && options.hasScheduledEffect) {
|
|
696
|
-
throw new Error('The `hasScheduledEffect` capability has not yet been implemented for helper managers. Please pass `hasValue` instead');
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
return buildCapabilities({
|
|
700
|
-
hasValue: Boolean(options.hasValue),
|
|
701
|
-
hasDestroyable: Boolean(options.hasDestroyable),
|
|
702
|
-
hasScheduledEffect: Boolean(options.hasScheduledEffect)
|
|
703
|
-
});
|
|
704
|
-
} ////////////
|
|
705
|
-
|
|
706
|
-
function hasValue(manager) {
|
|
707
|
-
return manager.capabilities.hasValue;
|
|
708
|
-
}
|
|
709
|
-
function hasDestroyable(manager) {
|
|
710
|
-
return manager.capabilities.hasDestroyable;
|
|
711
|
-
} ////////////
|
|
712
|
-
|
|
713
|
-
class CustomHelperManager {
|
|
714
|
-
constructor(factory) {
|
|
715
|
-
this.factory = factory;
|
|
716
|
-
this.helperManagerDelegates = new WeakMap();
|
|
717
|
-
this.undefinedDelegate = null;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
getDelegateForOwner(owner) {
|
|
721
|
-
let delegate = this.helperManagerDelegates.get(owner);
|
|
722
|
-
|
|
723
|
-
if (delegate === undefined) {
|
|
724
|
-
let {
|
|
725
|
-
factory
|
|
726
|
-
} = this;
|
|
727
|
-
delegate = factory(owner);
|
|
728
|
-
|
|
729
|
-
if (DEBUG && !FROM_CAPABILITIES.has(delegate.capabilities)) {
|
|
730
|
-
// TODO: This error message should make sense in both Ember and Glimmer https://github.com/glimmerjs/glimmer-vm/issues/1200
|
|
731
|
-
throw new Error(`Custom helper managers must have a \`capabilities\` property that is the result of calling the \`capabilities('3.23')\` (imported via \`import { capabilities } from '@ember/helper';\`). Received: \`${JSON.stringify(delegate.capabilities)}\` for: \`${delegate}\``);
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
this.helperManagerDelegates.set(owner, delegate);
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
return delegate;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
getDelegateFor(owner) {
|
|
741
|
-
if (owner === undefined) {
|
|
742
|
-
let {
|
|
743
|
-
undefinedDelegate
|
|
744
|
-
} = this;
|
|
745
|
-
|
|
746
|
-
if (undefinedDelegate === null) {
|
|
747
|
-
let {
|
|
748
|
-
factory
|
|
749
|
-
} = this;
|
|
750
|
-
this.undefinedDelegate = undefinedDelegate = factory(undefined);
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
return undefinedDelegate;
|
|
754
|
-
} else {
|
|
755
|
-
return this.getDelegateForOwner(owner);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
getHelper(definition) {
|
|
760
|
-
return (capturedArgs, owner) => {
|
|
761
|
-
var _a, _b;
|
|
762
|
-
|
|
763
|
-
let manager = this.getDelegateFor(owner);
|
|
764
|
-
const args = argsProxyFor(capturedArgs, 'helper');
|
|
765
|
-
const bucket = manager.createHelper(definition, args);
|
|
766
|
-
|
|
767
|
-
if (hasValue(manager)) {
|
|
768
|
-
let cache = createComputeRef(() => manager.getValue(bucket), null, DEBUG && manager.getDebugName && manager.getDebugName(definition));
|
|
769
|
-
|
|
770
|
-
if (hasDestroyable(manager)) {
|
|
771
|
-
associateDestroyableChild(cache, manager.getDestroyable(bucket));
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
return cache;
|
|
775
|
-
} else if (hasDestroyable(manager)) {
|
|
776
|
-
let ref = createConstRef(undefined, DEBUG && ((_b = (_a = manager.getDebugName) === null || _a === void 0 ? void 0 : _a.call(manager, definition)) !== null && _b !== void 0 ? _b : 'unknown helper'));
|
|
777
|
-
associateDestroyableChild(ref, manager.getDestroyable(bucket));
|
|
778
|
-
return ref;
|
|
779
|
-
} else {
|
|
780
|
-
return UNDEFINED_REFERENCE;
|
|
781
|
-
}
|
|
782
|
-
};
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
}
|
|
786
|
-
|
|
787
851
|
function setComponentManager(factory, obj) {
|
|
788
852
|
return setInternalComponentManager(new CustomComponentManager(factory), obj);
|
|
789
853
|
}
|
|
@@ -6609,7 +6609,7 @@ var fn = internalHelper(({
|
|
|
6609
6609
|
|
|
6610
6610
|
function assertCallbackIsFn(callbackRef) {
|
|
6611
6611
|
if (!(callbackRef && (isInvokableRef(callbackRef) || typeof valueForRef(callbackRef) === 'function'))) {
|
|
6612
|
-
throw new Error(`You must pass a function as the \`fn\`
|
|
6612
|
+
throw new Error(`You must pass a function as the \`fn\` helper's first argument, you passed ${callbackRef ? valueForRef(callbackRef) : callbackRef}. While rendering:\n\n${callbackRef === null || callbackRef === void 0 ? void 0 : callbackRef.debugLabel}`);
|
|
6613
6613
|
}
|
|
6614
6614
|
}
|
|
6615
6615
|
|
|
@@ -6974,7 +6974,7 @@ class OnModifierState {
|
|
|
6974
6974
|
let value = valueForRef(userProvidedCallbackReference);
|
|
6975
6975
|
|
|
6976
6976
|
if (typeof value !== 'function') {
|
|
6977
|
-
throw new Error(`You must pass a function as the second argument to the \`on\` modifier
|
|
6977
|
+
throw new Error(`You must pass a function as the second argument to the \`on\` modifier; you passed ${value === null ? 'null' : typeof value}. While rendering:\n\n${userProvidedCallbackReference.debugLabel}`);
|
|
6978
6978
|
}
|
|
6979
6979
|
}
|
|
6980
6980
|
|
|
@@ -91,28 +91,7 @@ function isSerializationFirstNode(node) {
|
|
|
91
91
|
return node.nodeValue === SERIALIZATION_FIRST_NODE_STRING;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const {
|
|
97
|
-
keys: objKeys
|
|
98
|
-
} = Object;
|
|
99
|
-
|
|
100
|
-
function assignFn(obj) {
|
|
101
|
-
for (let i = 1; i < arguments.length; i++) {
|
|
102
|
-
let assignment = arguments[i];
|
|
103
|
-
if (assignment === null || typeof assignment !== 'object') continue;
|
|
104
|
-
let keys = objKeys(assignment);
|
|
105
|
-
|
|
106
|
-
for (let j = 0; j < keys.length; j++) {
|
|
107
|
-
let key = keys[j];
|
|
108
|
-
obj[key] = assignment[key];
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return obj;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
let assign = (_a = Object.assign) !== null && _a !== void 0 ? _a : assignFn;
|
|
94
|
+
let assign = Object.assign;
|
|
116
95
|
function fillNulls(count) {
|
|
117
96
|
let arr = new Array(count);
|
|
118
97
|
|