ember-source 7.2.0-beta.1 → 7.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-metadata.json +3 -3
- package/dist/dev/packages/@ember/-internals/deprecations/index.js +10 -0
- package/dist/dev/packages/@ember/-internals/glimmer/index.js +3 -3
- package/dist/dev/packages/@ember/-internals/routing/index.js +1 -1
- package/dist/dev/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
- package/dist/dev/packages/@ember/-internals/runtime/lib/mixins/comparable.js +5 -0
- package/dist/dev/packages/@ember/application/index.js +2 -2
- package/dist/dev/packages/@ember/application/instance.js +21 -1
- package/dist/dev/packages/@ember/component/helper.js +321 -1
- package/dist/dev/packages/@ember/component/index.js +1 -1
- package/dist/dev/packages/@ember/engine/index.js +2 -2
- package/dist/dev/packages/@ember/renderer/index.js +1 -1
- package/dist/dev/packages/@ember/routing/-internals.js +1 -1
- package/dist/dev/packages/@ember/routing/lib/routing-service.js +0 -1
- package/dist/dev/packages/@ember/routing/lib/utils.js +1 -1
- package/dist/dev/packages/@ember/routing/route.js +1 -1
- package/dist/dev/packages/@ember/routing/router-service.js +0 -1
- package/dist/dev/packages/@ember/routing/router.js +1 -1
- package/dist/dev/packages/@ember/utils/lib/compare.js +5 -2
- package/dist/dev/packages/ember/version.js +1 -1
- package/dist/dev/packages/router_js/index.js +2 -2
- package/dist/dev/packages/shared-chunks/{curly-Ei5G8jhk.js → curly-DGUCLOud.js} +4 -5
- package/dist/dev/packages/shared-chunks/curly-brand-B_F79Dep.js +12 -0
- package/dist/dev/packages/shared-chunks/helper-brand-C9_8vvOf.js +12 -0
- package/dist/dev/packages/shared-chunks/{index-B3pPx1fL.js → index-CCyXUNBa.js} +616 -1573
- package/dist/dev/packages/shared-chunks/outlet-CHFL7tun.js +135 -0
- package/dist/dev/packages/shared-chunks/setup-registry-BHdDJATP.js +951 -0
- package/dist/dev/packages/shared-chunks/{unrecognized-url-error-BJHjL30Q.js → unrecognized-url-error-B8loxkay.js} +1 -1
- package/dist/prod/packages/@ember/-internals/deprecations/index.js +10 -0
- package/dist/prod/packages/@ember/-internals/glimmer/index.js +3 -3
- package/dist/prod/packages/@ember/-internals/routing/index.js +1 -1
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/comparable.js +5 -0
- package/dist/prod/packages/@ember/application/index.js +2 -2
- package/dist/prod/packages/@ember/application/instance.js +17 -2
- package/dist/prod/packages/@ember/component/helper.js +305 -1
- package/dist/prod/packages/@ember/component/index.js +1 -1
- package/dist/prod/packages/@ember/engine/index.js +2 -2
- package/dist/prod/packages/@ember/renderer/index.js +1 -1
- package/dist/prod/packages/@ember/routing/lib/routing-service.js +0 -1
- package/dist/prod/packages/@ember/routing/lib/utils.js +1 -1
- package/dist/prod/packages/@ember/routing/route.js +1 -1
- package/dist/prod/packages/@ember/routing/router-service.js +0 -1
- package/dist/prod/packages/@ember/routing/router.js +1 -1
- package/dist/prod/packages/@ember/utils/lib/compare.js +5 -2
- package/dist/prod/packages/ember/version.js +1 -1
- package/dist/prod/packages/router_js/index.js +2 -2
- package/dist/prod/packages/shared-chunks/{curly-IY06zACp.js → curly-a6DP7r87.js} +4 -5
- package/dist/prod/packages/shared-chunks/curly-brand-B_F79Dep.js +12 -0
- package/dist/prod/packages/shared-chunks/helper-brand-C9_8vvOf.js +12 -0
- package/dist/prod/packages/shared-chunks/{index-CslMfEpb.js → index-npr2B-vu.js} +546 -1449
- package/dist/prod/packages/shared-chunks/outlet--lIm3q7t.js +132 -0
- package/dist/prod/packages/shared-chunks/setup-registry-Dfu8EyLU.js +886 -0
- package/dist/prod/packages/shared-chunks/{unrecognized-url-error-EgNrnFu_.js → unrecognized-url-error-jjQ-FqKB.js} +1 -1
- package/docs/data.json +279 -214
- package/package.json +6 -6
- package/types/stable/@ember/-internals/deprecations/index.d.ts +6 -0
- package/types/stable/@ember/-internals/glimmer/lib/base-renderer.d.ts +150 -0
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/curly-brand.d.ts +10 -0
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/curly.d.ts +3 -2
- package/types/stable/@ember/-internals/glimmer/lib/helper-brand.d.ts +10 -0
- package/types/stable/@ember/-internals/glimmer/lib/helper.d.ts +4 -6
- package/types/stable/@ember/-internals/glimmer/lib/renderer.d.ts +7 -154
- package/types/stable/@ember/-internals/glimmer/lib/router-resolver.d.ts +17 -0
- package/types/stable/@ember/renderer/index.d.ts +2 -2
- package/types/stable/index.d.ts +590 -586
- package/dist/dev/packages/shared-chunks/helper-DIj85_-f.js +0 -326
- package/dist/dev/packages/shared-chunks/setup-registry-9DCmHTFF.js +0 -77
- package/dist/prod/packages/shared-chunks/helper-DkXiTBjc.js +0 -310
- package/dist/prod/packages/shared-chunks/setup-registry-U-6VaNQG.js +0 -74
|
@@ -1,241 +1,153 @@
|
|
|
1
|
-
import { privatize } from '../@ember/-internals/container/index.js';
|
|
2
1
|
import { E as ENV } from './env-g-kaAFLN.js';
|
|
3
|
-
import { isFactory, getOwner } from '../@ember/-internals/owner/index.js';
|
|
4
|
-
import { g as guidFor } from './guid-Cbq2sNV_.js';
|
|
5
|
-
import { constructStyleDeprecationMessage, getViewId, getViewElement } from '../@ember/-internals/views/lib/system/utils.js';
|
|
6
2
|
import { deprecate, warn } from '../@ember/debug/index.js';
|
|
7
3
|
import { schedule, _backburner, _getCurrentRunLoop } from '../@ember/runloop/index.js';
|
|
8
|
-
import { associateDestroyableChild,
|
|
4
|
+
import { associateDestroyableChild, destroy, registerDestructor, isDestroyed, isDestroying } from '../@glimmer/destroyable/index.js';
|
|
9
5
|
import { artifacts } from '../@glimmer/program/index.js';
|
|
10
6
|
import { R as RuntimeOpImpl } from './program-DlgjqLa6.js';
|
|
11
|
-
import { v as valueForRef, U as UNDEFINED_REFERENCE, c as createComputeRef, i as isConstRef, a as createConstRef, d as isUpdatableRef, j as createInvokableRef, k as createReadOnlyRef, l as createUnboundRef, h as createDebugAliasRef, g as childRefFromParts, u as updateRef } from './reference-BqOLhKFy.js';
|
|
12
7
|
import { c as clientBuilder } from './api-C0PAtEgQ.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { d as dict } from './collections-DPkjqeA3.js';
|
|
16
|
-
import { u as unwrapTemplate, a as CurlyComponentManager, i as initialRenderInstrumentDetails, p as processComponentInitializationAssertions, b as ComponentStateBucket, D as DIRTY_TAG, c as isCurlyManager, B as BOUNDS } from './curly-Ei5G8jhk.js';
|
|
17
|
-
import { C as CONSTANT_TAG, c as consumeTag, z as isTracking, e as debug, D as DIRTY_TAG$1, r as createTag, a as valueForTag, k as CURRENT_TAG, v as validateTag } from './cache-DGDPVCpC.js';
|
|
8
|
+
import { g as runtimeOptions, i as inTransaction, r as renderComponent$1 } from './render-87_sKZ_k.js';
|
|
9
|
+
import { c as consumeTag, z as isTracking, e as debug, a as valueForTag, k as CURRENT_TAG, v as validateTag } from './cache-DGDPVCpC.js';
|
|
18
10
|
import { h as hasDOM } from './index-BGP1rw3B.js';
|
|
19
|
-
import {
|
|
20
|
-
import { c as capabilityFlagsFrom } from './capabilities-CajW4QjE.js';
|
|
21
|
-
import { t as templateFactory } from './index-DaFzpTIE.js';
|
|
22
|
-
import { assert } from '../@ember/debug/lib/assert.js';
|
|
23
|
-
import { g as getFactoryFor } from './container-BzzHmCNj.js';
|
|
24
|
-
import { g as get, b as _getProp } from './property_get-CRP7MFz_.js';
|
|
11
|
+
import { g as get$1, b as _getProp } from './property_get-CRP7MFz_.js';
|
|
25
12
|
import { _ as _setProp, s as set } from './property_set-qCUylPEK.js';
|
|
26
13
|
import { g as getDebugName } from './get-debug-name-CSniHBsn.js';
|
|
14
|
+
import { constructStyleDeprecationMessage } from '../@ember/-internals/views/lib/system/utils.js';
|
|
27
15
|
import setGlobalContext from '../@glimmer/global-context/index.js';
|
|
28
|
-
import {
|
|
16
|
+
import { a as tagForProperty, t as tagForObject, o as objectAt } from './chain-tags-uWSImHzB.js';
|
|
29
17
|
import { isEmberArray } from '../@ember/array/-internals.js';
|
|
30
18
|
import { i as isObject } from './spec-BXl1reqK.js';
|
|
31
19
|
import { t as tagFor } from './meta-BqC7f9Ia.js';
|
|
32
20
|
import { contentFor } from '../@ember/-internals/runtime/lib/mixins/-proxy.js';
|
|
33
21
|
import { i as isProxy } from './is_proxy-Bzg0d4m4.js';
|
|
22
|
+
import { v as valueForRef, c as createComputeRef, i as isConstRef, a as createConstRef, d as isUpdatableRef, j as createInvokableRef, k as createReadOnlyRef, l as createUnboundRef } from './reference-BqOLhKFy.js';
|
|
34
23
|
import { i as internalHelper } from './internal-helper-CKrni0b_.js';
|
|
24
|
+
import { assert } from '../@ember/debug/lib/assert.js';
|
|
35
25
|
import { i as isHTMLSafe } from './index-D-xTBV4B.js';
|
|
36
26
|
import isArray from '../@ember/array/lib/is-array.js';
|
|
27
|
+
import { isFactory } from '../@ember/-internals/owner/index.js';
|
|
28
|
+
import { _instrumentStart } from '../@ember/instrumentation/index.js';
|
|
37
29
|
import { g as getComponentTemplate } from './template-R_5UMHhb.js';
|
|
38
|
-
import {
|
|
30
|
+
import { a as getInternalHelperManager, j as setInternalHelperManager, g as getInternalComponentManager } from './api-DuLOZMO_.js';
|
|
39
31
|
import { h as hash, f as fn, a as array } from './hash-6NDs_5_f.js';
|
|
40
|
-
import { g as get
|
|
32
|
+
import { g as get, c as concat } from './get-6I3sjd-I.js';
|
|
41
33
|
import { o as on } from './on-DlF0Wy7P.js';
|
|
42
34
|
import { T as TEMPLATE_ONLY_COMPONENT_MANAGER, t as templateOnlyComponent } from './template-only-Cu639ICT.js';
|
|
43
|
-
import { i as
|
|
35
|
+
import { i as isCurlyManager } from './curly-brand-B_F79Dep.js';
|
|
36
|
+
import { i as isClassicHelper } from './helper-brand-C9_8vvOf.js';
|
|
44
37
|
import { dasherize } from '../@ember/-internals/string/index.js';
|
|
45
38
|
import { a as uniqueId } from './unique-id-DQOhouG1.js';
|
|
46
|
-
import { generateControllerFactory } from '../@ember/routing/lib/generate_controller.js';
|
|
47
39
|
import { E as EvaluationContextImpl } from './program-context-Dq8xN2HI.js';
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
object: `${def.name}:main`
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
const CAPABILITIES$2 = {
|
|
56
|
-
dynamicLayout: false,
|
|
57
|
-
dynamicTag: false,
|
|
58
|
-
prepareArgs: false,
|
|
59
|
-
createArgs: false,
|
|
60
|
-
attributeHook: false,
|
|
61
|
-
elementHook: false,
|
|
62
|
-
createCaller: false,
|
|
63
|
-
dynamicScope: true,
|
|
64
|
-
updateHook: false,
|
|
65
|
-
createInstance: true,
|
|
66
|
-
wrapped: false,
|
|
67
|
-
willDestroy: false,
|
|
68
|
-
hasSubOwner: false
|
|
69
|
-
};
|
|
70
|
-
const CAPABILITIES_MASK$1 = capabilityFlagsFrom(CAPABILITIES$2);
|
|
71
|
-
class OutletComponentManager {
|
|
72
|
-
create(_owner, definition, _args, env, dynamicScope) {
|
|
73
|
-
let parentStateRef = dynamicScope.get('outletState');
|
|
74
|
-
let currentStateRef = definition.ref;
|
|
75
|
-
|
|
76
|
-
// This is the actual primary responsibility of the outlet component –
|
|
77
|
-
// it represents the switching from one route component/template into
|
|
78
|
-
// the next. The rest only exists to support the debug render tree and
|
|
79
|
-
// the old-school (and unreliable) instrumentation.
|
|
80
|
-
dynamicScope.set('outletState', currentStateRef);
|
|
81
|
-
let state = {
|
|
82
|
-
finalize: _instrumentStart('render.outlet', instrumentationPayload$1, definition)
|
|
83
|
-
};
|
|
84
|
-
if (env.debugRenderTree !== undefined) {
|
|
85
|
-
let parentState = valueForRef(parentStateRef);
|
|
86
|
-
let parentOwner = parentState?.render?.owner;
|
|
87
|
-
let currentState = valueForRef(currentStateRef);
|
|
88
|
-
let currentOwner = currentState?.render?.owner;
|
|
89
|
-
if (parentOwner && parentOwner !== currentOwner) {
|
|
90
|
-
(!(currentOwner != null && 'buildChildEngineInstance' in currentOwner) && assert('Expected currentOwner to be an EngineInstance', currentOwner != null && 'buildChildEngineInstance' in currentOwner));
|
|
91
|
-
let engineInstance = currentOwner;
|
|
92
|
-
let {
|
|
93
|
-
mountPoint
|
|
94
|
-
} = engineInstance;
|
|
95
|
-
if (mountPoint) {
|
|
96
|
-
state.engine = {
|
|
97
|
-
mountPoint,
|
|
98
|
-
instance: engineInstance
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return state;
|
|
104
|
-
}
|
|
105
|
-
getDebugName({
|
|
106
|
-
name
|
|
107
|
-
}) {
|
|
108
|
-
return `{{outlet}} for ${name}`;
|
|
109
|
-
}
|
|
110
|
-
getDebugCustomRenderTree(_definition, state) {
|
|
111
|
-
let nodes = [];
|
|
112
|
-
nodes.push({
|
|
113
|
-
bucket: state,
|
|
114
|
-
type: 'outlet',
|
|
115
|
-
// "main" used to be the outlet name, keeping it around for compatibility
|
|
116
|
-
name: 'main',
|
|
117
|
-
args: EMPTY_ARGS,
|
|
118
|
-
instance: undefined
|
|
119
|
-
});
|
|
120
|
-
if (state.engine) {
|
|
121
|
-
nodes.push({
|
|
122
|
-
bucket: state.engine,
|
|
123
|
-
type: 'engine',
|
|
124
|
-
name: state.engine.mountPoint,
|
|
125
|
-
args: EMPTY_ARGS,
|
|
126
|
-
instance: state.engine.instance
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
return nodes;
|
|
130
|
-
}
|
|
131
|
-
getCapabilities() {
|
|
132
|
-
return CAPABILITIES$2;
|
|
133
|
-
}
|
|
134
|
-
getSelf() {
|
|
135
|
-
return UNDEFINED_REFERENCE;
|
|
136
|
-
}
|
|
137
|
-
didCreate() {}
|
|
138
|
-
didUpdate() {}
|
|
139
|
-
didRenderLayout(state) {
|
|
140
|
-
state.finalize();
|
|
141
|
-
}
|
|
142
|
-
didUpdateLayout() {}
|
|
143
|
-
getDestroyable() {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
const OUTLET_MANAGER = new OutletComponentManager();
|
|
148
|
-
const OUTLET_COMPONENT_TEMPLATE = templateFactory(
|
|
149
|
-
/*
|
|
150
|
-
<@Component @controller={{@controller}} @model={{@model}} />
|
|
41
|
+
/**
|
|
42
|
+
@module ember
|
|
151
43
|
*/
|
|
152
|
-
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
44
|
+
const disallowDynamicResolution = internalHelper(({
|
|
45
|
+
positional,
|
|
46
|
+
named
|
|
47
|
+
}) => {
|
|
48
|
+
const nameOrValueRef = positional[0];
|
|
49
|
+
(!(positional.length === 1 && nameOrValueRef) && assert(`[BUG] wrong number of positional arguments, expecting 1, got ${positional.length}`, positional.length === 1 && nameOrValueRef));
|
|
50
|
+
let typeRef = named['type'];
|
|
51
|
+
let locRef = named['loc'];
|
|
52
|
+
let originalRef = named['original'];
|
|
53
|
+
(!(typeRef) && assert(`[BUG] expecting \`type\` named argument`, typeRef));
|
|
54
|
+
(!(locRef) && assert(`[BUG] expecting \`loc\` named argument`, locRef));
|
|
55
|
+
(!(originalRef) && assert(`[BUG] expecting \`original\` named argument`, originalRef)); // Bug: why do these fail?
|
|
56
|
+
// assert('[BUG] expecting a string literal for the `type` argument', isConstRef(typeRef));
|
|
57
|
+
// assert('[BUG] expecting a string literal for the `loc` argument', isConstRef(locRef));
|
|
58
|
+
// assert('[BUG] expecting a string literal for the `original` argument', isConstRef(originalRef));
|
|
59
|
+
const type = valueForRef(typeRef);
|
|
60
|
+
const loc = valueForRef(locRef);
|
|
61
|
+
const original = valueForRef(originalRef);
|
|
62
|
+
(!(typeof type === 'string') && assert('[BUG] expecting a string literal for the `type` argument', typeof type === 'string'));
|
|
63
|
+
(!(typeof loc === 'string') && assert('[BUG] expecting a string literal for the `loc` argument', typeof loc === 'string'));
|
|
64
|
+
(!(typeof original === 'string') && assert('[BUG] expecting a string literal for the `original` argument', typeof original === 'string'));
|
|
65
|
+
return createComputeRef(() => {
|
|
66
|
+
let nameOrValue = valueForRef(nameOrValueRef);
|
|
67
|
+
(!(typeof nameOrValue !== 'string') && assert(`Passing a dynamic string to the \`(${type})\` keyword is disallowed. ` + `(You specified \`(${type} ${original})\` and \`${original}\` evaluated into "${nameOrValue}".) ` + `This ensures we can statically analyze the template and determine which ${type}s are used. ` + `If the ${type} name is always the same, use a string literal instead, i.e. \`(${type} "${nameOrValue}")\`. ` + `Otherwise, import the ${type}s into JavaScript and pass them directly. ` + 'See https://github.com/emberjs/rfcs/blob/master/text/0496-handlebars-strict-mode.md#4-no-dynamic-resolution for details. ' + loc, typeof nameOrValue !== 'string'));
|
|
68
|
+
return nameOrValue;
|
|
69
|
+
});
|
|
157
70
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
function createRootOutlet(outletView) {
|
|
171
|
-
return new OutletComponent(outletView.owner, outletView.state);
|
|
71
|
+
|
|
72
|
+
let helper;
|
|
73
|
+
{
|
|
74
|
+
helper = args => {
|
|
75
|
+
const inner = args.positional[0];
|
|
76
|
+
(!(inner) && assert('expected at least one positional arg', inner));
|
|
77
|
+
return createComputeRef(() => {
|
|
78
|
+
let value = valueForRef(inner);
|
|
79
|
+
(!(value !== null && value !== undefined) && assert('You cannot pass a null or undefined destination element to in-element', value !== null && value !== undefined));
|
|
80
|
+
return value;
|
|
81
|
+
});
|
|
82
|
+
};
|
|
172
83
|
}
|
|
84
|
+
const inElementNullCheckHelper = internalHelper(helper);
|
|
173
85
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
let
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
component.trigger('willRender');
|
|
192
|
-
}
|
|
193
|
-
component._transitionTo('hasElement');
|
|
194
|
-
if (isInteractive) {
|
|
195
|
-
component.trigger('willInsertElement');
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
{
|
|
199
|
-
processComponentInitializationAssertions(component, {});
|
|
86
|
+
const normalizeClassHelper = internalHelper(({
|
|
87
|
+
positional
|
|
88
|
+
}) => {
|
|
89
|
+
return createComputeRef(() => {
|
|
90
|
+
let classNameArg = positional[0];
|
|
91
|
+
let valueArg = positional[1];
|
|
92
|
+
(!(classNameArg && valueArg) && assert('expected at least two positional args', classNameArg && valueArg));
|
|
93
|
+
let classNameParts = valueForRef(classNameArg).split('.');
|
|
94
|
+
let className = classNameParts[classNameParts.length - 1];
|
|
95
|
+
(!(className) && assert('has className', className)); // Always at least one split result
|
|
96
|
+
let value = valueForRef(valueArg);
|
|
97
|
+
if (value === true) {
|
|
98
|
+
return dasherize(className);
|
|
99
|
+
} else if (!value && value !== 0) {
|
|
100
|
+
return '';
|
|
101
|
+
} else {
|
|
102
|
+
return String(value);
|
|
200
103
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return bucket;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
206
106
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
// handle is not used by this custom definition
|
|
226
|
-
handle = -1;
|
|
227
|
-
resolvedName = '-top-level';
|
|
228
|
-
state;
|
|
229
|
-
manager;
|
|
230
|
-
capabilities = capabilityFlagsFrom(ROOT_CAPABILITIES);
|
|
231
|
-
compilable = null;
|
|
232
|
-
constructor(component) {
|
|
233
|
-
this.manager = new RootComponentManager(component);
|
|
234
|
-
let factory = getFactoryFor(component);
|
|
235
|
-
(!(factory !== undefined) && assert('missing factory for component', factory !== undefined));
|
|
236
|
-
this.state = factory;
|
|
107
|
+
/**
|
|
108
|
+
@module ember
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
const resolve = internalHelper(({
|
|
112
|
+
positional
|
|
113
|
+
}, owner) => {
|
|
114
|
+
// why is this allowed to be undefined in the first place?
|
|
115
|
+
(!(owner) && assert('[BUG] missing owner', owner));
|
|
116
|
+
(!(positional.length === 1) && assert(`[BUG] wrong number of positional arguments, expecting 1, got ${positional.length}`, positional.length === 1));
|
|
117
|
+
let fullNameRef = positional[0];
|
|
118
|
+
(!(fullNameRef && isConstRef(fullNameRef)) && assert('[BUG] expecting a string literal as argument', fullNameRef && isConstRef(fullNameRef)));
|
|
119
|
+
let fullName = valueForRef(fullNameRef);
|
|
120
|
+
(!(typeof fullName === 'string') && assert('[BUG] expecting a string literal as argument', typeof fullName === 'string'));
|
|
121
|
+
(!((s => s.split(':').length === 2)(fullName)) && assert('[BUG] expecting a valid full name', (s => s.split(':').length === 2)(fullName)));
|
|
122
|
+
{
|
|
123
|
+
let [type, name] = fullName.split(':');
|
|
124
|
+
(!(owner.hasRegistration(fullName)) && assert(`Attempted to invoke \`(-resolve "${fullName}")\`, but ${name} was not a valid ${type} name.`, owner.hasRegistration(fullName)));
|
|
237
125
|
}
|
|
238
|
-
}
|
|
126
|
+
return createConstRef(owner.factoryFor(fullName)?.class, `(-resolve "${fullName}")`);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
@module ember
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
This reference is used to get the `[]` tag of iterables, so we can trigger
|
|
135
|
+
updates to `{{each}}` when it changes. It is put into place by a template
|
|
136
|
+
transform at build time, similar to the (-each-in) helper
|
|
137
|
+
*/
|
|
138
|
+
const trackArray = internalHelper(({
|
|
139
|
+
positional
|
|
140
|
+
}) => {
|
|
141
|
+
const inner = positional[0];
|
|
142
|
+
(!(inner) && assert('expected at least one positional arg', inner));
|
|
143
|
+
return createComputeRef(() => {
|
|
144
|
+
let iterable = valueForRef(inner);
|
|
145
|
+
if (isObject(iterable)) {
|
|
146
|
+
consumeTag(tagForProperty(iterable, '[]'));
|
|
147
|
+
}
|
|
148
|
+
return iterable;
|
|
149
|
+
});
|
|
150
|
+
});
|
|
239
151
|
|
|
240
152
|
/**
|
|
241
153
|
@module ember
|
|
@@ -418,540 +330,104 @@ const eachIn = internalHelper(({
|
|
|
418
330
|
});
|
|
419
331
|
});
|
|
420
332
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
333
|
+
/**
|
|
334
|
+
@module ember
|
|
335
|
+
*/
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
The `mut` helper is a shortcut for updating for args.
|
|
339
|
+
|
|
340
|
+
However, defining update functions on your backing class is preferable to using `mut`.
|
|
341
|
+
|
|
342
|
+
More directly: Don't use `mut`.
|
|
343
|
+
|
|
344
|
+
The `mut` helper, when used with `fn`, will return a function that
|
|
345
|
+
sets the value passed to `mut` to its first argument. As an example, we can create a
|
|
346
|
+
button that increments a value passing the value directly to the `fn`:
|
|
347
|
+
|
|
348
|
+
```handlebars
|
|
349
|
+
<MyChild @childClickCount={{this.totalClicks}} @clickCountChange={{fn (mut this.totalClicks)}} />
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
The child `Component` would invoke the function with the new click count:
|
|
353
|
+
|
|
354
|
+
```app/components/my-child.gjs
|
|
355
|
+
import Component from '@glimmer/component';
|
|
356
|
+
import { action } from '@ember/object';
|
|
357
|
+
|
|
358
|
+
export default class MyChild extends Component {
|
|
359
|
+
@action
|
|
360
|
+
update() {
|
|
361
|
+
this.args.clickCountChange(this.args.childClickCount + 1);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
<template>
|
|
365
|
+
<button {{on "click" this.update}}>
|
|
366
|
+
Click me!
|
|
367
|
+
</button>
|
|
368
|
+
</template>
|
|
426
369
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
The `mut` helper changes the `totalClicks` value to what was provided as the `fn` argument.
|
|
373
|
+
|
|
374
|
+
@method mut
|
|
375
|
+
@param {Object} [attr] the "two-way" attribute that can be modified.
|
|
376
|
+
@for Ember.Templates.helpers
|
|
377
|
+
@public
|
|
378
|
+
*/
|
|
379
|
+
|
|
380
|
+
const mut = internalHelper(({
|
|
381
|
+
positional
|
|
382
|
+
}) => {
|
|
383
|
+
let ref = positional[0];
|
|
384
|
+
(!(ref) && assert('expected at least one positional arg', ref)); // TODO: Improve this error message. This covers at least two distinct
|
|
385
|
+
// cases:
|
|
386
|
+
//
|
|
387
|
+
// 1. (mut "not a path") – passing a literal, result from a helper
|
|
388
|
+
// invocation, etc
|
|
389
|
+
//
|
|
390
|
+
// 2. (mut receivedValue) – passing a value received from the caller
|
|
391
|
+
// that was originally derived from a literal, result from a helper
|
|
392
|
+
// invocation, etc
|
|
393
|
+
//
|
|
394
|
+
// This message is alright for the first case, but could be quite
|
|
395
|
+
// confusing for the second case.
|
|
396
|
+
(!(isUpdatableRef(ref)) && assert('You can only pass a path to mut', isUpdatableRef(ref)));
|
|
397
|
+
return createInvokableRef(ref);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
@module ember
|
|
402
|
+
*/
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
The `readonly` helper let's you specify that a binding is one-way only,
|
|
407
|
+
instead of two-way.
|
|
408
|
+
|
|
409
|
+
This is a vestigial helper from the days of `@ember/component` and does not apply to
|
|
410
|
+
components extending from `@glimmer/component`.
|
|
411
|
+
|
|
412
|
+
When you pass a `readonly` binding from an outer context (e.g. parent component),
|
|
413
|
+
to to an inner context (e.g. child component), you are saying that changing that
|
|
414
|
+
property in the inner context does not change the value in the outer context.
|
|
415
|
+
|
|
416
|
+
To specify that a binding is read-only, when invoking the child `Component`:
|
|
417
|
+
|
|
418
|
+
```app/components/my-parent.js
|
|
419
|
+
export default class MyParent extends Component {
|
|
420
|
+
totalClicks = 3;
|
|
431
421
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
function toEachIterator(iterable) {
|
|
443
|
-
if (!isObject(iterable)) {
|
|
444
|
-
return null;
|
|
445
|
-
}
|
|
446
|
-
if (Array.isArray(iterable)) {
|
|
447
|
-
return ArrayIterator.from(iterable);
|
|
448
|
-
} else if (isEmberArray(iterable)) {
|
|
449
|
-
return EmberArrayIterator.from(iterable);
|
|
450
|
-
} else if (isNativeIterable(iterable)) {
|
|
451
|
-
return ArrayLikeNativeIterator.from(iterable);
|
|
452
|
-
} else if (hasForEach(iterable)) {
|
|
453
|
-
return ArrayIterator.fromForEachable(iterable);
|
|
454
|
-
} else {
|
|
455
|
-
return null;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
class BoundedIterator {
|
|
459
|
-
position = 0;
|
|
460
|
-
constructor(length) {
|
|
461
|
-
this.length = length;
|
|
462
|
-
}
|
|
463
|
-
isEmpty() {
|
|
464
|
-
return false;
|
|
465
|
-
}
|
|
466
|
-
memoFor(position) {
|
|
467
|
-
return position;
|
|
468
|
-
}
|
|
469
|
-
next() {
|
|
470
|
-
let {
|
|
471
|
-
length,
|
|
472
|
-
position
|
|
473
|
-
} = this;
|
|
474
|
-
if (position >= length) {
|
|
475
|
-
return null;
|
|
476
|
-
}
|
|
477
|
-
let value = this.valueFor(position);
|
|
478
|
-
let memo = this.memoFor(position);
|
|
479
|
-
this.position++;
|
|
480
|
-
return {
|
|
481
|
-
value,
|
|
482
|
-
memo
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
class ArrayIterator extends BoundedIterator {
|
|
487
|
-
static from(iterable) {
|
|
488
|
-
return iterable.length > 0 ? new this(iterable) : null;
|
|
489
|
-
}
|
|
490
|
-
static fromForEachable(object) {
|
|
491
|
-
let array = [];
|
|
492
|
-
object.forEach(item => array.push(item));
|
|
493
|
-
return this.from(array);
|
|
494
|
-
}
|
|
495
|
-
constructor(array) {
|
|
496
|
-
super(array.length);
|
|
497
|
-
this.array = array;
|
|
498
|
-
}
|
|
499
|
-
valueFor(position) {
|
|
500
|
-
return this.array[position];
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
class EmberArrayIterator extends BoundedIterator {
|
|
504
|
-
static from(iterable) {
|
|
505
|
-
return iterable.length > 0 ? new this(iterable) : null;
|
|
506
|
-
}
|
|
507
|
-
constructor(array) {
|
|
508
|
-
super(array.length);
|
|
509
|
-
this.array = array;
|
|
510
|
-
}
|
|
511
|
-
valueFor(position) {
|
|
512
|
-
return objectAt(this.array, position);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
class ObjectIterator extends BoundedIterator {
|
|
516
|
-
static fromIndexable(obj) {
|
|
517
|
-
let keys = Object.keys(obj);
|
|
518
|
-
if (keys.length === 0) {
|
|
519
|
-
return null;
|
|
520
|
-
} else {
|
|
521
|
-
let values = [];
|
|
522
|
-
for (let key of keys) {
|
|
523
|
-
let value;
|
|
524
|
-
value = obj[key];
|
|
525
|
-
|
|
526
|
-
// Add the tag of the returned value if it is an array, since arrays
|
|
527
|
-
// should always cause updates if they are consumed and then changed
|
|
528
|
-
if (isTracking()) {
|
|
529
|
-
consumeTag(tagFor(obj, key));
|
|
530
|
-
if (Array.isArray(value)) {
|
|
531
|
-
consumeTag(tagFor(value, '[]'));
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
values.push(value);
|
|
535
|
-
}
|
|
536
|
-
return new this(keys, values);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
static fromForEachable(obj) {
|
|
540
|
-
let keys = [];
|
|
541
|
-
let values = [];
|
|
542
|
-
let length = 0;
|
|
543
|
-
let isMapLike = false;
|
|
544
|
-
|
|
545
|
-
// Not using an arrow function here so we can get an accurate `arguments`
|
|
546
|
-
obj.forEach(function (value, key) {
|
|
547
|
-
isMapLike = isMapLike || arguments.length >= 2;
|
|
548
|
-
if (isMapLike) {
|
|
549
|
-
keys.push(key);
|
|
550
|
-
}
|
|
551
|
-
values.push(value);
|
|
552
|
-
length++;
|
|
553
|
-
});
|
|
554
|
-
if (length === 0) {
|
|
555
|
-
return null;
|
|
556
|
-
} else if (isMapLike) {
|
|
557
|
-
return new this(keys, values);
|
|
558
|
-
} else {
|
|
559
|
-
return new ArrayIterator(values);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
constructor(keys, values) {
|
|
563
|
-
super(values.length);
|
|
564
|
-
this.keys = keys;
|
|
565
|
-
this.values = values;
|
|
566
|
-
}
|
|
567
|
-
valueFor(position) {
|
|
568
|
-
return this.values[position];
|
|
569
|
-
}
|
|
570
|
-
memoFor(position) {
|
|
571
|
-
return this.keys[position];
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
class NativeIterator {
|
|
575
|
-
static from(iterable) {
|
|
576
|
-
let iterator = iterable[Symbol.iterator]();
|
|
577
|
-
let result = iterator.next();
|
|
578
|
-
let {
|
|
579
|
-
done
|
|
580
|
-
} = result;
|
|
581
|
-
if (done) {
|
|
582
|
-
return null;
|
|
583
|
-
} else {
|
|
584
|
-
return new this(iterator, result);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
position = 0;
|
|
588
|
-
constructor(iterable, result) {
|
|
589
|
-
this.iterable = iterable;
|
|
590
|
-
this.result = result;
|
|
591
|
-
}
|
|
592
|
-
isEmpty() {
|
|
593
|
-
return false;
|
|
594
|
-
}
|
|
595
|
-
next() {
|
|
596
|
-
let {
|
|
597
|
-
iterable,
|
|
598
|
-
result,
|
|
599
|
-
position
|
|
600
|
-
} = this;
|
|
601
|
-
if (result.done) {
|
|
602
|
-
return null;
|
|
603
|
-
}
|
|
604
|
-
let value = this.valueFor(result, position);
|
|
605
|
-
let memo = this.memoFor(result, position);
|
|
606
|
-
this.position++;
|
|
607
|
-
this.result = iterable.next();
|
|
608
|
-
return {
|
|
609
|
-
value,
|
|
610
|
-
memo
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
class ArrayLikeNativeIterator extends NativeIterator {
|
|
615
|
-
valueFor(result) {
|
|
616
|
-
return result.value;
|
|
617
|
-
}
|
|
618
|
-
memoFor(_result, position) {
|
|
619
|
-
return position;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
class MapLikeNativeIterator extends NativeIterator {
|
|
623
|
-
valueFor(result) {
|
|
624
|
-
return result.value[1];
|
|
625
|
-
}
|
|
626
|
-
memoFor(result) {
|
|
627
|
-
return result.value[0];
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
function hasForEach(value) {
|
|
631
|
-
return value != null && typeof value['forEach'] === 'function';
|
|
632
|
-
}
|
|
633
|
-
function isNativeIterable(value) {
|
|
634
|
-
return value != null && typeof value[Symbol.iterator] === 'function';
|
|
635
|
-
}
|
|
636
|
-
function isIndexable(value) {
|
|
637
|
-
return value !== null && (typeof value === 'object' || typeof value === 'function');
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
function toBool(predicate) {
|
|
641
|
-
if (isProxy(predicate)) {
|
|
642
|
-
consumeTag(tagForProperty(predicate, 'content'));
|
|
643
|
-
return Boolean(get(predicate, 'isTruthy'));
|
|
644
|
-
} else if (isArray(predicate)) {
|
|
645
|
-
consumeTag(tagForProperty(predicate, '[]'));
|
|
646
|
-
return predicate.length !== 0;
|
|
647
|
-
} else if (isHTMLSafe(predicate)) {
|
|
648
|
-
return Boolean(predicate.toString());
|
|
649
|
-
} else {
|
|
650
|
-
return Boolean(predicate);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
///////////
|
|
655
|
-
|
|
656
|
-
// Setup global context
|
|
657
|
-
|
|
658
|
-
setGlobalContext({
|
|
659
|
-
scheduleRevalidate() {
|
|
660
|
-
_backburner.ensureInstance();
|
|
661
|
-
},
|
|
662
|
-
toBool,
|
|
663
|
-
toIterator,
|
|
664
|
-
getProp: _getProp,
|
|
665
|
-
setProp: _setProp,
|
|
666
|
-
getPath: get,
|
|
667
|
-
setPath: set,
|
|
668
|
-
scheduleDestroy(destroyable, destructor) {
|
|
669
|
-
schedule('actions', null, destructor, destroyable);
|
|
670
|
-
},
|
|
671
|
-
scheduleDestroyed(finalizeDestructor) {
|
|
672
|
-
schedule('destroy', null, finalizeDestructor);
|
|
673
|
-
},
|
|
674
|
-
warnIfStyleNotTrusted(value) {
|
|
675
|
-
(warn(constructStyleDeprecationMessage(String(value)), (() => {
|
|
676
|
-
if (value === null || value === undefined || isHTMLSafe(value)) {
|
|
677
|
-
return true;
|
|
678
|
-
}
|
|
679
|
-
return false;
|
|
680
|
-
})(), {
|
|
681
|
-
id: 'ember-htmlbars.style-xss-warning'
|
|
682
|
-
}));
|
|
683
|
-
},
|
|
684
|
-
assert(test, msg, options) {
|
|
685
|
-
{
|
|
686
|
-
let id = options?.id;
|
|
687
|
-
let override = VM_ASSERTION_OVERRIDES.filter(o => o.id === id)[0];
|
|
688
|
-
(!(test) && assert(override?.message ?? msg, test));
|
|
689
|
-
}
|
|
690
|
-
},
|
|
691
|
-
deprecate(msg, test, options) {
|
|
692
|
-
{
|
|
693
|
-
let {
|
|
694
|
-
id
|
|
695
|
-
} = options;
|
|
696
|
-
if (id === 'argument-less-helper-paren-less-invocation') {
|
|
697
|
-
throw new Error(`A resolved helper cannot be passed as a named argument as the syntax is ` + `ambiguously a pass-by-reference or invocation. Use the ` + `\`{{helper 'foo-helper}}\` helper to pass by reference or explicitly ` + `invoke the helper with parens: \`{{(fooHelper)}}\`.`);
|
|
698
|
-
}
|
|
699
|
-
let override = VM_DEPRECATION_OVERRIDES.filter(o => o.id === id)[0];
|
|
700
|
-
if (!override) throw new Error(`deprecation override for ${id} not found`);
|
|
701
|
-
|
|
702
|
-
// allow deprecations to be disabled in the VM_DEPRECATION_OVERRIDES array below
|
|
703
|
-
if (!override.disabled) {
|
|
704
|
-
(!(Boolean(test)) && deprecate(override.message ?? msg, Boolean(test), override));
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
});
|
|
709
|
-
{
|
|
710
|
-
debug?.setTrackingTransactionEnv?.({
|
|
711
|
-
debugMessage(obj, keyName) {
|
|
712
|
-
let dirtyString = keyName ? `\`${keyName}\` on \`${getDebugName?.(obj)}\`` : `\`${getDebugName?.(obj)}\``;
|
|
713
|
-
return `You attempted to update ${dirtyString}, but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.`;
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
///////////
|
|
719
|
-
|
|
720
|
-
// VM Assertion/Deprecation overrides
|
|
721
|
-
|
|
722
|
-
const VM_DEPRECATION_OVERRIDES = [{
|
|
723
|
-
id: 'setting-on-hash',
|
|
724
|
-
until: '4.4.0',
|
|
725
|
-
for: 'ember-source',
|
|
726
|
-
since: {
|
|
727
|
-
available: '3.28.0',
|
|
728
|
-
enabled: '3.28.0'
|
|
729
|
-
}
|
|
730
|
-
}];
|
|
731
|
-
const VM_ASSERTION_OVERRIDES = [];
|
|
732
|
-
|
|
733
|
-
///////////
|
|
734
|
-
|
|
735
|
-
// Define environment delegate
|
|
736
|
-
|
|
737
|
-
class EmberEnvironmentDelegate {
|
|
738
|
-
enableDebugTooling = ENV._DEBUG_RENDER_TREE;
|
|
739
|
-
constructor(owner, isInteractive) {
|
|
740
|
-
this.owner = owner;
|
|
741
|
-
this.isInteractive = isInteractive;
|
|
742
|
-
}
|
|
743
|
-
onTransactionCommit() {}
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
/**
|
|
747
|
-
@module ember
|
|
748
|
-
*/
|
|
749
|
-
const disallowDynamicResolution = internalHelper(({
|
|
750
|
-
positional,
|
|
751
|
-
named
|
|
752
|
-
}) => {
|
|
753
|
-
const nameOrValueRef = positional[0];
|
|
754
|
-
(!(positional.length === 1 && nameOrValueRef) && assert(`[BUG] wrong number of positional arguments, expecting 1, got ${positional.length}`, positional.length === 1 && nameOrValueRef));
|
|
755
|
-
let typeRef = named['type'];
|
|
756
|
-
let locRef = named['loc'];
|
|
757
|
-
let originalRef = named['original'];
|
|
758
|
-
(!(typeRef) && assert(`[BUG] expecting \`type\` named argument`, typeRef));
|
|
759
|
-
(!(locRef) && assert(`[BUG] expecting \`loc\` named argument`, locRef));
|
|
760
|
-
(!(originalRef) && assert(`[BUG] expecting \`original\` named argument`, originalRef)); // Bug: why do these fail?
|
|
761
|
-
// assert('[BUG] expecting a string literal for the `type` argument', isConstRef(typeRef));
|
|
762
|
-
// assert('[BUG] expecting a string literal for the `loc` argument', isConstRef(locRef));
|
|
763
|
-
// assert('[BUG] expecting a string literal for the `original` argument', isConstRef(originalRef));
|
|
764
|
-
const type = valueForRef(typeRef);
|
|
765
|
-
const loc = valueForRef(locRef);
|
|
766
|
-
const original = valueForRef(originalRef);
|
|
767
|
-
(!(typeof type === 'string') && assert('[BUG] expecting a string literal for the `type` argument', typeof type === 'string'));
|
|
768
|
-
(!(typeof loc === 'string') && assert('[BUG] expecting a string literal for the `loc` argument', typeof loc === 'string'));
|
|
769
|
-
(!(typeof original === 'string') && assert('[BUG] expecting a string literal for the `original` argument', typeof original === 'string'));
|
|
770
|
-
return createComputeRef(() => {
|
|
771
|
-
let nameOrValue = valueForRef(nameOrValueRef);
|
|
772
|
-
(!(typeof nameOrValue !== 'string') && assert(`Passing a dynamic string to the \`(${type})\` keyword is disallowed. ` + `(You specified \`(${type} ${original})\` and \`${original}\` evaluated into "${nameOrValue}".) ` + `This ensures we can statically analyze the template and determine which ${type}s are used. ` + `If the ${type} name is always the same, use a string literal instead, i.e. \`(${type} "${nameOrValue}")\`. ` + `Otherwise, import the ${type}s into JavaScript and pass them directly. ` + 'See https://github.com/emberjs/rfcs/blob/master/text/0496-handlebars-strict-mode.md#4-no-dynamic-resolution for details. ' + loc, typeof nameOrValue !== 'string'));
|
|
773
|
-
return nameOrValue;
|
|
774
|
-
});
|
|
775
|
-
});
|
|
776
|
-
|
|
777
|
-
let helper;
|
|
778
|
-
{
|
|
779
|
-
helper = args => {
|
|
780
|
-
const inner = args.positional[0];
|
|
781
|
-
(!(inner) && assert('expected at least one positional arg', inner));
|
|
782
|
-
return createComputeRef(() => {
|
|
783
|
-
let value = valueForRef(inner);
|
|
784
|
-
(!(value !== null && value !== undefined) && assert('You cannot pass a null or undefined destination element to in-element', value !== null && value !== undefined));
|
|
785
|
-
return value;
|
|
786
|
-
});
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
const inElementNullCheckHelper = internalHelper(helper);
|
|
790
|
-
|
|
791
|
-
const normalizeClassHelper = internalHelper(({
|
|
792
|
-
positional
|
|
793
|
-
}) => {
|
|
794
|
-
return createComputeRef(() => {
|
|
795
|
-
let classNameArg = positional[0];
|
|
796
|
-
let valueArg = positional[1];
|
|
797
|
-
(!(classNameArg && valueArg) && assert('expected at least two positional args', classNameArg && valueArg));
|
|
798
|
-
let classNameParts = valueForRef(classNameArg).split('.');
|
|
799
|
-
let className = classNameParts[classNameParts.length - 1];
|
|
800
|
-
(!(className) && assert('has className', className)); // Always at least one split result
|
|
801
|
-
let value = valueForRef(valueArg);
|
|
802
|
-
if (value === true) {
|
|
803
|
-
return dasherize(className);
|
|
804
|
-
} else if (!value && value !== 0) {
|
|
805
|
-
return '';
|
|
806
|
-
} else {
|
|
807
|
-
return String(value);
|
|
808
|
-
}
|
|
809
|
-
});
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
/**
|
|
813
|
-
@module ember
|
|
814
|
-
*/
|
|
815
|
-
|
|
816
|
-
const resolve = internalHelper(({
|
|
817
|
-
positional
|
|
818
|
-
}, owner) => {
|
|
819
|
-
// why is this allowed to be undefined in the first place?
|
|
820
|
-
(!(owner) && assert('[BUG] missing owner', owner));
|
|
821
|
-
(!(positional.length === 1) && assert(`[BUG] wrong number of positional arguments, expecting 1, got ${positional.length}`, positional.length === 1));
|
|
822
|
-
let fullNameRef = positional[0];
|
|
823
|
-
(!(fullNameRef && isConstRef(fullNameRef)) && assert('[BUG] expecting a string literal as argument', fullNameRef && isConstRef(fullNameRef)));
|
|
824
|
-
let fullName = valueForRef(fullNameRef);
|
|
825
|
-
(!(typeof fullName === 'string') && assert('[BUG] expecting a string literal as argument', typeof fullName === 'string'));
|
|
826
|
-
(!((s => s.split(':').length === 2)(fullName)) && assert('[BUG] expecting a valid full name', (s => s.split(':').length === 2)(fullName)));
|
|
827
|
-
{
|
|
828
|
-
let [type, name] = fullName.split(':');
|
|
829
|
-
(!(owner.hasRegistration(fullName)) && assert(`Attempted to invoke \`(-resolve "${fullName}")\`, but ${name} was not a valid ${type} name.`, owner.hasRegistration(fullName)));
|
|
830
|
-
}
|
|
831
|
-
return createConstRef(owner.factoryFor(fullName)?.class, `(-resolve "${fullName}")`);
|
|
832
|
-
});
|
|
833
|
-
|
|
834
|
-
/**
|
|
835
|
-
@module ember
|
|
836
|
-
*/
|
|
837
|
-
|
|
838
|
-
/**
|
|
839
|
-
This reference is used to get the `[]` tag of iterables, so we can trigger
|
|
840
|
-
updates to `{{each}}` when it changes. It is put into place by a template
|
|
841
|
-
transform at build time, similar to the (-each-in) helper
|
|
842
|
-
*/
|
|
843
|
-
const trackArray = internalHelper(({
|
|
844
|
-
positional
|
|
845
|
-
}) => {
|
|
846
|
-
const inner = positional[0];
|
|
847
|
-
(!(inner) && assert('expected at least one positional arg', inner));
|
|
848
|
-
return createComputeRef(() => {
|
|
849
|
-
let iterable = valueForRef(inner);
|
|
850
|
-
if (isObject(iterable)) {
|
|
851
|
-
consumeTag(tagForProperty(iterable, '[]'));
|
|
852
|
-
}
|
|
853
|
-
return iterable;
|
|
854
|
-
});
|
|
855
|
-
});
|
|
856
|
-
|
|
857
|
-
/**
|
|
858
|
-
@module ember
|
|
859
|
-
*/
|
|
860
|
-
|
|
861
|
-
/**
|
|
862
|
-
The `mut` helper is a shortcut for updating for args.
|
|
863
|
-
|
|
864
|
-
However, defining update functions on your backing class is preferable to using `mut`.
|
|
865
|
-
|
|
866
|
-
More directly: Don't use `mut`.
|
|
867
|
-
|
|
868
|
-
The `mut` helper, when used with `fn`, will return a function that
|
|
869
|
-
sets the value passed to `mut` to its first argument. As an example, we can create a
|
|
870
|
-
button that increments a value passing the value directly to the `fn`:
|
|
871
|
-
|
|
872
|
-
```handlebars
|
|
873
|
-
<MyChild @childClickCount={{this.totalClicks}} @clickCountChange={{fn (mut this.totalClicks)}} />
|
|
874
|
-
```
|
|
875
|
-
|
|
876
|
-
The child `Component` would invoke the function with the new click count:
|
|
877
|
-
|
|
878
|
-
```app/components/my-child.gjs
|
|
879
|
-
import Component from '@glimmer/component';
|
|
880
|
-
import { action } from '@ember/object';
|
|
881
|
-
|
|
882
|
-
export default class MyChild extends Component {
|
|
883
|
-
@action
|
|
884
|
-
update() {
|
|
885
|
-
this.args.clickCountChange(this.args.childClickCount + 1);
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
<template>
|
|
889
|
-
<button {{on "click" this.update}}>
|
|
890
|
-
Click me!
|
|
891
|
-
</button>
|
|
892
|
-
</template>
|
|
893
|
-
}
|
|
894
|
-
```
|
|
895
|
-
|
|
896
|
-
The `mut` helper changes the `totalClicks` value to what was provided as the `fn` argument.
|
|
897
|
-
|
|
898
|
-
@method mut
|
|
899
|
-
@param {Object} [attr] the "two-way" attribute that can be modified.
|
|
900
|
-
@for Ember.Templates.helpers
|
|
901
|
-
@public
|
|
902
|
-
*/
|
|
903
|
-
|
|
904
|
-
const mut = internalHelper(({
|
|
905
|
-
positional
|
|
906
|
-
}) => {
|
|
907
|
-
let ref = positional[0];
|
|
908
|
-
(!(ref) && assert('expected at least one positional arg', ref)); // TODO: Improve this error message. This covers at least two distinct
|
|
909
|
-
// cases:
|
|
910
|
-
//
|
|
911
|
-
// 1. (mut "not a path") – passing a literal, result from a helper
|
|
912
|
-
// invocation, etc
|
|
913
|
-
//
|
|
914
|
-
// 2. (mut receivedValue) – passing a value received from the caller
|
|
915
|
-
// that was originally derived from a literal, result from a helper
|
|
916
|
-
// invocation, etc
|
|
917
|
-
//
|
|
918
|
-
// This message is alright for the first case, but could be quite
|
|
919
|
-
// confusing for the second case.
|
|
920
|
-
(!(isUpdatableRef(ref)) && assert('You can only pass a path to mut', isUpdatableRef(ref)));
|
|
921
|
-
return createInvokableRef(ref);
|
|
922
|
-
});
|
|
923
|
-
|
|
924
|
-
/**
|
|
925
|
-
@module ember
|
|
926
|
-
*/
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
/**
|
|
930
|
-
The `readonly` helper let's you specify that a binding is one-way only,
|
|
931
|
-
instead of two-way.
|
|
932
|
-
|
|
933
|
-
This is a vestigial helper from the days of `@ember/component` and does not apply to
|
|
934
|
-
components extending from `@glimmer/component`.
|
|
935
|
-
|
|
936
|
-
When you pass a `readonly` binding from an outer context (e.g. parent component),
|
|
937
|
-
to to an inner context (e.g. child component), you are saying that changing that
|
|
938
|
-
property in the inner context does not change the value in the outer context.
|
|
939
|
-
|
|
940
|
-
To specify that a binding is read-only, when invoking the child `Component`:
|
|
941
|
-
|
|
942
|
-
```app/components/my-parent.js
|
|
943
|
-
export default class MyParent extends Component {
|
|
944
|
-
totalClicks = 3;
|
|
945
|
-
}
|
|
946
|
-
```
|
|
947
|
-
|
|
948
|
-
Now, when you update `childClickCount`:
|
|
949
|
-
|
|
950
|
-
```app/components/my-child.js
|
|
951
|
-
export default class MyChild extends Component {
|
|
952
|
-
click() {
|
|
953
|
-
this.incrementProperty('childClickCount');
|
|
954
|
-
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
Now, when you update `childClickCount`:
|
|
425
|
+
|
|
426
|
+
```app/components/my-child.js
|
|
427
|
+
export default class MyChild extends Component {
|
|
428
|
+
click() {
|
|
429
|
+
this.incrementProperty('childClickCount');
|
|
430
|
+
}
|
|
955
431
|
}
|
|
956
432
|
```
|
|
957
433
|
|
|
@@ -1047,520 +523,44 @@ const readonly = internalHelper(({
|
|
|
1047
523
|
|
|
1048
524
|
/**
|
|
1049
525
|
@module ember
|
|
1050
|
-
*/
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
/**
|
|
1054
|
-
The `{{unbound}}` helper disconnects the one-way binding of a property,
|
|
1055
|
-
essentially freezing its value at the moment of rendering. For example,
|
|
1056
|
-
in this example the display of the variable `name` will not change even
|
|
1057
|
-
if it is set with a new value:
|
|
1058
|
-
|
|
1059
|
-
```handlebars
|
|
1060
|
-
{{unbound this.name}}
|
|
1061
|
-
```
|
|
1062
|
-
|
|
1063
|
-
Like any helper, the `unbound` helper can accept a nested helper expression.
|
|
1064
|
-
This allows for custom helpers to be rendered unbound:
|
|
1065
|
-
|
|
1066
|
-
```handlebars
|
|
1067
|
-
{{unbound (some-custom-helper)}}
|
|
1068
|
-
{{unbound (capitalize this.name)}}
|
|
1069
|
-
{{! You can use any helper, including unbound, in a nested expression }}
|
|
1070
|
-
{{capitalize (unbound this.name)}}
|
|
1071
|
-
```
|
|
1072
|
-
|
|
1073
|
-
The `unbound` helper only accepts a single argument, and it return an
|
|
1074
|
-
unbound value.
|
|
1075
|
-
|
|
1076
|
-
@method unbound
|
|
1077
|
-
@for Ember.Templates.helpers
|
|
1078
|
-
@public
|
|
1079
|
-
*/
|
|
1080
|
-
|
|
1081
|
-
const unbound = internalHelper(({
|
|
1082
|
-
positional,
|
|
1083
|
-
named
|
|
1084
|
-
}) => {
|
|
1085
|
-
(!(positional.length === 1 && Object.keys(named).length === 0) && assert('unbound helper cannot be called with multiple params or hash params', positional.length === 1 && Object.keys(named).length === 0));
|
|
1086
|
-
return createUnboundRef(valueForRef(positional[0]), '(result of an `unbound` helper)');
|
|
1087
|
-
});
|
|
1088
|
-
|
|
1089
|
-
const CAPABILITIES$1 = {
|
|
1090
|
-
dynamicLayout: true,
|
|
1091
|
-
dynamicTag: false,
|
|
1092
|
-
prepareArgs: false,
|
|
1093
|
-
createArgs: true,
|
|
1094
|
-
attributeHook: false,
|
|
1095
|
-
elementHook: false,
|
|
1096
|
-
createCaller: true,
|
|
1097
|
-
dynamicScope: true,
|
|
1098
|
-
updateHook: true,
|
|
1099
|
-
createInstance: true,
|
|
1100
|
-
wrapped: false,
|
|
1101
|
-
willDestroy: false,
|
|
1102
|
-
hasSubOwner: true
|
|
1103
|
-
};
|
|
1104
|
-
class MountManager {
|
|
1105
|
-
getDynamicLayout(state) {
|
|
1106
|
-
let templateFactory = state.engine.lookup('template:application');
|
|
1107
|
-
return unwrapTemplate(templateFactory(state.engine)).asLayout();
|
|
1108
|
-
}
|
|
1109
|
-
getCapabilities() {
|
|
1110
|
-
return CAPABILITIES$1;
|
|
1111
|
-
}
|
|
1112
|
-
getOwner(state) {
|
|
1113
|
-
return state.engine;
|
|
1114
|
-
}
|
|
1115
|
-
create(owner, {
|
|
1116
|
-
name
|
|
1117
|
-
}, args, env) {
|
|
1118
|
-
// TODO
|
|
1119
|
-
// mount is a runtime helper, this shouldn't use dynamic layout
|
|
1120
|
-
// we should resolve the engine app template in the helper
|
|
1121
|
-
// it also should use the owner that looked up the mount helper.
|
|
1122
|
-
(!('buildChildEngineInstance' in owner) && assert('Expected owner to be an EngineInstance', 'buildChildEngineInstance' in owner));
|
|
1123
|
-
let engine = owner.buildChildEngineInstance(name);
|
|
1124
|
-
engine.boot();
|
|
1125
|
-
let applicationFactory = engine.factoryFor(`controller:application`);
|
|
1126
|
-
let controllerFactory = applicationFactory || generateControllerFactory(engine, 'application');
|
|
1127
|
-
let controller;
|
|
1128
|
-
let self;
|
|
1129
|
-
let bucket;
|
|
1130
|
-
let modelRef;
|
|
1131
|
-
if (args.named.has('model')) {
|
|
1132
|
-
modelRef = args.named.get('model');
|
|
1133
|
-
}
|
|
1134
|
-
if (modelRef === undefined) {
|
|
1135
|
-
controller = controllerFactory.create();
|
|
1136
|
-
self = createConstRef(controller, 'this');
|
|
1137
|
-
bucket = {
|
|
1138
|
-
engine,
|
|
1139
|
-
controller,
|
|
1140
|
-
self,
|
|
1141
|
-
modelRef
|
|
1142
|
-
};
|
|
1143
|
-
} else {
|
|
1144
|
-
let model = valueForRef(modelRef);
|
|
1145
|
-
controller = controllerFactory.create({
|
|
1146
|
-
model
|
|
1147
|
-
});
|
|
1148
|
-
self = createConstRef(controller, 'this');
|
|
1149
|
-
bucket = {
|
|
1150
|
-
engine,
|
|
1151
|
-
controller,
|
|
1152
|
-
self,
|
|
1153
|
-
modelRef
|
|
1154
|
-
};
|
|
1155
|
-
}
|
|
1156
|
-
if (env.debugRenderTree) {
|
|
1157
|
-
associateDestroyableChild(engine, controller);
|
|
1158
|
-
}
|
|
1159
|
-
return bucket;
|
|
1160
|
-
}
|
|
1161
|
-
getDebugName({
|
|
1162
|
-
name
|
|
1163
|
-
}) {
|
|
1164
|
-
return name;
|
|
1165
|
-
}
|
|
1166
|
-
getDebugCustomRenderTree(definition, state, args) {
|
|
1167
|
-
return [{
|
|
1168
|
-
bucket: state.engine,
|
|
1169
|
-
instance: state.engine,
|
|
1170
|
-
type: 'engine',
|
|
1171
|
-
name: definition.name,
|
|
1172
|
-
args
|
|
1173
|
-
}, {
|
|
1174
|
-
bucket: state.controller,
|
|
1175
|
-
instance: state.controller,
|
|
1176
|
-
type: 'route-template',
|
|
1177
|
-
name: 'application',
|
|
1178
|
-
args
|
|
1179
|
-
}];
|
|
1180
|
-
}
|
|
1181
|
-
getSelf({
|
|
1182
|
-
self
|
|
1183
|
-
}) {
|
|
1184
|
-
return self;
|
|
1185
|
-
}
|
|
1186
|
-
getDestroyable(bucket) {
|
|
1187
|
-
return bucket.engine;
|
|
1188
|
-
}
|
|
1189
|
-
didCreate() {}
|
|
1190
|
-
didUpdate() {}
|
|
1191
|
-
didRenderLayout() {}
|
|
1192
|
-
didUpdateLayout() {}
|
|
1193
|
-
update(bucket) {
|
|
1194
|
-
let {
|
|
1195
|
-
controller,
|
|
1196
|
-
modelRef
|
|
1197
|
-
} = bucket;
|
|
1198
|
-
if (modelRef !== undefined) {
|
|
1199
|
-
controller.set('model', valueForRef(modelRef));
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
const MOUNT_MANAGER = new MountManager();
|
|
1204
|
-
class MountDefinition {
|
|
1205
|
-
// handle is not used by this custom definition
|
|
1206
|
-
handle = -1;
|
|
1207
|
-
state;
|
|
1208
|
-
manager = MOUNT_MANAGER;
|
|
1209
|
-
compilable = null;
|
|
1210
|
-
capabilities = capabilityFlagsFrom(CAPABILITIES$1);
|
|
1211
|
-
constructor(resolvedName) {
|
|
1212
|
-
this.resolvedName = resolvedName;
|
|
1213
|
-
this.state = {
|
|
1214
|
-
name: resolvedName
|
|
1215
|
-
};
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
/**
|
|
1220
|
-
@module ember
|
|
1221
|
-
*/
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
/**
|
|
1225
|
-
The `{{mount}}` helper lets you embed a routeless engine in a template.
|
|
1226
|
-
Mounting an engine will cause an instance to be booted and its `application`
|
|
1227
|
-
template to be rendered.
|
|
1228
|
-
|
|
1229
|
-
For example, the following template mounts the `ember-chat` engine:
|
|
1230
|
-
|
|
1231
|
-
```app/templates/application.gjs
|
|
1232
|
-
{{mount "ember-chat"}}
|
|
1233
|
-
```
|
|
1234
|
-
|
|
1235
|
-
Additionally, you can also pass in a `model` argument that will be
|
|
1236
|
-
set as the engines model. This can be an existing object:
|
|
1237
|
-
|
|
1238
|
-
```hbs
|
|
1239
|
-
<div>
|
|
1240
|
-
{{mount 'admin' model=userSettings}}
|
|
1241
|
-
</div>
|
|
1242
|
-
```
|
|
1243
|
-
|
|
1244
|
-
Or an inline `hash`, and you can even pass components:
|
|
1245
|
-
|
|
1246
|
-
```gjs
|
|
1247
|
-
import SignInButton from '../components/sign-in-button';
|
|
1248
|
-
<template>
|
|
1249
|
-
<div>
|
|
1250
|
-
<h1>Application template!</h1>
|
|
1251
|
-
{{mount 'admin' model=(hash
|
|
1252
|
-
title='Secret Admin'
|
|
1253
|
-
signInButton=SignInButton
|
|
1254
|
-
)}}
|
|
1255
|
-
</div>
|
|
1256
|
-
</template>
|
|
1257
|
-
```
|
|
1258
|
-
|
|
1259
|
-
`mount` is built-in and does not need to be imported.
|
|
1260
|
-
|
|
1261
|
-
@method mount
|
|
1262
|
-
@param {String} name Name of the engine to mount.
|
|
1263
|
-
@param {Object} [model] Object that will be set as
|
|
1264
|
-
the model of the engine.
|
|
1265
|
-
@for Ember.Templates.helpers
|
|
1266
|
-
@public
|
|
1267
|
-
*/
|
|
1268
|
-
const mountHelper = internalHelper((args, owner) => {
|
|
1269
|
-
(!(owner) && assert('{{mount}} must be used within a component that has an owner', owner));
|
|
1270
|
-
let nameRef = args.positional[0];
|
|
1271
|
-
let captured;
|
|
1272
|
-
(!(args.positional.length === 1) && assert('You can only pass a single positional argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}.', args.positional.length === 1));
|
|
1273
|
-
if (args.named) {
|
|
1274
|
-
let keys = Object.keys(args.named);
|
|
1275
|
-
let extra = keys.filter(k => k !== 'model');
|
|
1276
|
-
(!(extra.length === 0) && assert('You can only pass a `model` argument to the {{mount}} helper, ' + 'e.g. {{mount "profile-engine" model=this.profile}}. ' + `You passed ${extra.join(',')}.`, extra.length === 0));
|
|
1277
|
-
}
|
|
1278
|
-
captured = createCapturedArgs(args.named, EMPTY_POSITIONAL);
|
|
1279
|
-
let lastName, lastDef;
|
|
1280
|
-
return createComputeRef(() => {
|
|
1281
|
-
let name = valueForRef(nameRef);
|
|
1282
|
-
if (typeof name === 'string') {
|
|
1283
|
-
if (lastName === name) {
|
|
1284
|
-
return lastDef;
|
|
1285
|
-
}
|
|
1286
|
-
(!(owner.hasRegistration(`engine:${name}`)) && assert(`You used \`{{mount '${name}'}}\`, but the engine '${name}' can not be found.`, owner.hasRegistration(`engine:${name}`)));
|
|
1287
|
-
lastName = name;
|
|
1288
|
-
lastDef = curry(0, new MountDefinition(name), owner, captured, true);
|
|
1289
|
-
return lastDef;
|
|
1290
|
-
} else {
|
|
1291
|
-
(!(name === null || name === undefined) && assert(`Invalid engine name '${name}' specified, engine name must be either a string, null or undefined.`, name === null || name === undefined));
|
|
1292
|
-
lastDef = null;
|
|
1293
|
-
lastName = null;
|
|
1294
|
-
return null;
|
|
1295
|
-
}
|
|
1296
|
-
});
|
|
1297
|
-
});
|
|
1298
|
-
|
|
1299
|
-
const CAPABILITIES = {
|
|
1300
|
-
dynamicLayout: false,
|
|
1301
|
-
dynamicTag: false,
|
|
1302
|
-
prepareArgs: false,
|
|
1303
|
-
createArgs: true,
|
|
1304
|
-
attributeHook: false,
|
|
1305
|
-
elementHook: false,
|
|
1306
|
-
createCaller: false,
|
|
1307
|
-
dynamicScope: false,
|
|
1308
|
-
updateHook: false,
|
|
1309
|
-
createInstance: true,
|
|
1310
|
-
wrapped: false,
|
|
1311
|
-
willDestroy: false,
|
|
1312
|
-
hasSubOwner: false
|
|
1313
|
-
};
|
|
1314
|
-
const CAPABILITIES_MASK = capabilityFlagsFrom(CAPABILITIES);
|
|
1315
|
-
class RouteTemplateManager {
|
|
1316
|
-
create(_owner, _definition, args) {
|
|
1317
|
-
let self = args.named.get('controller');
|
|
1318
|
-
{
|
|
1319
|
-
self = createDebugAliasRef('this', self);
|
|
1320
|
-
}
|
|
1321
|
-
let controller = valueForRef(self);
|
|
1322
|
-
return {
|
|
1323
|
-
self,
|
|
1324
|
-
controller
|
|
1325
|
-
};
|
|
1326
|
-
}
|
|
1327
|
-
getSelf({
|
|
1328
|
-
self
|
|
1329
|
-
}) {
|
|
1330
|
-
return self;
|
|
1331
|
-
}
|
|
1332
|
-
getDebugName({
|
|
1333
|
-
name
|
|
1334
|
-
}) {
|
|
1335
|
-
return `route-template (${name})`;
|
|
1336
|
-
}
|
|
1337
|
-
getDebugCustomRenderTree({
|
|
1338
|
-
name
|
|
1339
|
-
}, state, args) {
|
|
1340
|
-
return [{
|
|
1341
|
-
bucket: state,
|
|
1342
|
-
type: 'route-template',
|
|
1343
|
-
name,
|
|
1344
|
-
args,
|
|
1345
|
-
instance: state.controller
|
|
1346
|
-
}];
|
|
1347
|
-
}
|
|
1348
|
-
getCapabilities() {
|
|
1349
|
-
return CAPABILITIES;
|
|
1350
|
-
}
|
|
1351
|
-
didRenderLayout() {}
|
|
1352
|
-
didUpdateLayout() {}
|
|
1353
|
-
didCreate() {}
|
|
1354
|
-
didUpdate() {}
|
|
1355
|
-
getDestroyable() {
|
|
1356
|
-
return null;
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
const ROUTE_TEMPLATE_MANAGER = new RouteTemplateManager();
|
|
526
|
+
*/
|
|
527
|
+
|
|
1360
528
|
|
|
1361
529
|
/**
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
*/
|
|
1367
|
-
class RouteTemplate {
|
|
1368
|
-
// handle is not used by this custom definition
|
|
1369
|
-
handle = -1;
|
|
1370
|
-
resolvedName;
|
|
1371
|
-
state;
|
|
1372
|
-
manager = ROUTE_TEMPLATE_MANAGER;
|
|
1373
|
-
capabilities = CAPABILITIES_MASK;
|
|
1374
|
-
compilable;
|
|
1375
|
-
constructor(name, template) {
|
|
1376
|
-
let unwrapped = unwrapTemplate(template);
|
|
1377
|
-
// TODO This actually seems inaccurate – it ultimately came from the
|
|
1378
|
-
// outlet's name. Also, setting this overrides `getDebugName()` in that
|
|
1379
|
-
// message. Is that desirable?
|
|
1380
|
-
this.resolvedName = name;
|
|
1381
|
-
this.state = {
|
|
1382
|
-
name
|
|
1383
|
-
};
|
|
1384
|
-
this.compilable = unwrapped.asLayout();
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
530
|
+
The `{{unbound}}` helper disconnects the one-way binding of a property,
|
|
531
|
+
essentially freezing its value at the moment of rendering. For example,
|
|
532
|
+
in this example the display of the variable `name` will not change even
|
|
533
|
+
if it is set with a new value:
|
|
1387
534
|
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
// be used with `curry` which probably isn't necessary here. It could be the
|
|
1392
|
-
// case that we just want to do something more similar to `InternalComponent`
|
|
1393
|
-
// (the one we used to implement `Input` and `LinkTo`). For now it follows
|
|
1394
|
-
// the same pattern to get things going.
|
|
1395
|
-
function makeRouteTemplate(owner, name, template) {
|
|
1396
|
-
let routeTemplate = new RouteTemplate(name, template);
|
|
1397
|
-
return curry(0, routeTemplate, owner, null, true);
|
|
1398
|
-
}
|
|
535
|
+
```handlebars
|
|
536
|
+
{{unbound this.name}}
|
|
537
|
+
```
|
|
1399
538
|
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
your template. An important use of the `{{outlet}}` helper is in your
|
|
1403
|
-
application's `application.gjs` file:
|
|
539
|
+
Like any helper, the `unbound` helper can accept a nested helper expression.
|
|
540
|
+
This allows for custom helpers to be rendered unbound:
|
|
1404
541
|
|
|
1405
|
-
```
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
<MyHeader />
|
|
1411
|
-
|
|
1412
|
-
<div class="my-dynamic-content">
|
|
1413
|
-
<!-- this content will change based on the current route, which depends on the current URL -->
|
|
1414
|
-
{{outlet}}
|
|
1415
|
-
</div>
|
|
1416
|
-
|
|
1417
|
-
<MyFooter />
|
|
1418
|
-
</template>
|
|
542
|
+
```handlebars
|
|
543
|
+
{{unbound (some-custom-helper)}}
|
|
544
|
+
{{unbound (capitalize this.name)}}
|
|
545
|
+
{{! You can use any helper, including unbound, in a nested expression }}
|
|
546
|
+
{{capitalize (unbound this.name)}}
|
|
1419
547
|
```
|
|
1420
548
|
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
Note: Your content __will not render__ if there isn't an `{{outlet}}` for it.
|
|
549
|
+
The `unbound` helper only accepts a single argument, and it return an
|
|
550
|
+
unbound value.
|
|
1424
551
|
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
@method outlet
|
|
552
|
+
@method unbound
|
|
1428
553
|
@for Ember.Templates.helpers
|
|
1429
554
|
@public
|
|
1430
555
|
*/
|
|
1431
|
-
const outletHelper = internalHelper((_args, owner, scope) => {
|
|
1432
|
-
(!(owner) && assert('Expected owner to be present, {{outlet}} requires an owner', owner));
|
|
1433
|
-
(!(scope) && assert('Expected dynamic scope to be present. You may have attempted to use the {{outlet}} keyword dynamically. This keyword cannot be used dynamically.', scope));
|
|
1434
|
-
let outletRef = createComputeRef(() => {
|
|
1435
|
-
let state = valueForRef(scope.get('outletState'));
|
|
1436
|
-
return state?.outlets?.main;
|
|
1437
|
-
});
|
|
1438
|
-
let lastState = null;
|
|
1439
|
-
let outlet = null;
|
|
1440
|
-
return createComputeRef(() => {
|
|
1441
|
-
let outletState = valueForRef(outletRef);
|
|
1442
|
-
let state = stateFor(outletRef, outletState);
|
|
1443
|
-
|
|
1444
|
-
// This code is deliberately using the behavior in glimmer-vm where in
|
|
1445
|
-
// <@Component />, the component is considered stabled via `===`, and
|
|
1446
|
-
// will continue to re-render in-place as long as the `===` holds, but
|
|
1447
|
-
// when it changes to a different object, it teardown the old component
|
|
1448
|
-
// (running destructors, etc), and render the component in its place (or
|
|
1449
|
-
// nothing if the new value is nullish. Here we are carefully exploiting
|
|
1450
|
-
// that fact, and returns the same stable object so long as it is the
|
|
1451
|
-
// same route, but return a different one when the route changes. On the
|
|
1452
|
-
// other hand, changing the model only intentionally do not teardown the
|
|
1453
|
-
// component and instead re-render in-place.
|
|
1454
|
-
if (!isStable(state, lastState)) {
|
|
1455
|
-
lastState = state;
|
|
1456
|
-
if (state !== null) {
|
|
1457
|
-
// If we are crossing an engine mount point, this is how the owner
|
|
1458
|
-
// gets switched.
|
|
1459
|
-
let outletOwner = outletState?.render?.owner ?? owner;
|
|
1460
|
-
let named = dict();
|
|
1461
|
-
|
|
1462
|
-
// Here we either have a raw template that needs to be normalized,
|
|
1463
|
-
// or a component that we can render as-is. `RouteTemplate` upgrades
|
|
1464
|
-
// the template into a component so we can have a unified code path.
|
|
1465
|
-
// We still store the original `template` value, because we rely on
|
|
1466
|
-
// its identity for the stability check, and the `RouteTemplate`
|
|
1467
|
-
// wrapper doesn't dedup for us.
|
|
1468
|
-
let template = state.template;
|
|
1469
|
-
let component;
|
|
1470
|
-
if (hasInternalComponentManager(template)) {
|
|
1471
|
-
component = template;
|
|
1472
|
-
} else {
|
|
1473
|
-
{
|
|
1474
|
-
// We don't appear to have a standard way or a brand to check, but for the
|
|
1475
|
-
// purpose of avoiding obvious user errors, this probably gets you close
|
|
1476
|
-
// enough.
|
|
1477
|
-
let isTemplate = template => {
|
|
1478
|
-
if (template === null || typeof template !== 'object') {
|
|
1479
|
-
return false;
|
|
1480
|
-
} else {
|
|
1481
|
-
let t = template;
|
|
1482
|
-
return t.result === 'ok' || t.result === 'error';
|
|
1483
|
-
}
|
|
1484
|
-
};
|
|
1485
|
-
|
|
1486
|
-
// We made it past the `TemplateFactory` instantiation before
|
|
1487
|
-
// getting here, so either we got unlucky where the invalid type
|
|
1488
|
-
// happens to be a function that didn't mind taking owner as an
|
|
1489
|
-
// argument, or this was directly set by something like test
|
|
1490
|
-
// helpers.
|
|
1491
|
-
if (!isTemplate(template)) {
|
|
1492
|
-
let label;
|
|
1493
|
-
try {
|
|
1494
|
-
label = `\`${String(template)}\``;
|
|
1495
|
-
} catch {
|
|
1496
|
-
label = 'an unknown object';
|
|
1497
|
-
}
|
|
1498
|
-
(assert(`Failed to render the \`${state.name}\` route: expected ` + `a component or Template object, but got ${label}.`));
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
component = makeRouteTemplate(outletOwner, state.name, template);
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
// Component is stable for the lifetime of the outlet
|
|
1505
|
-
named['Component'] = createConstRef(component, '@Component');
|
|
1506
|
-
|
|
1507
|
-
// Controller is stable for the lifetime of the outlet
|
|
1508
|
-
named['controller'] = createConstRef(state.controller, '@controller');
|
|
1509
|
-
|
|
1510
|
-
// Create a ref for the model
|
|
1511
|
-
let modelRef = childRefFromParts(outletRef, ['render', 'model']);
|
|
1512
|
-
|
|
1513
|
-
// Store the value of the model
|
|
1514
|
-
let model = valueForRef(modelRef);
|
|
1515
|
-
|
|
1516
|
-
// Create a compute ref which we pass in as the `{{@model}}` reference
|
|
1517
|
-
// for the outlet. This ref will update and return the value of the
|
|
1518
|
-
// model _until_ the outlet itself changes. Once the outlet changes,
|
|
1519
|
-
// dynamic scope also changes, and so the original model ref would not
|
|
1520
|
-
// provide the correct updated value. So we stop updating and return
|
|
1521
|
-
// the _last_ model value for that outlet.
|
|
1522
|
-
named['model'] = createComputeRef(() => {
|
|
1523
|
-
if (lastState === state) {
|
|
1524
|
-
model = valueForRef(modelRef);
|
|
1525
|
-
}
|
|
1526
|
-
return model;
|
|
1527
|
-
});
|
|
1528
|
-
{
|
|
1529
|
-
named['model'] = createDebugAliasRef('@model', named['model']);
|
|
1530
|
-
}
|
|
1531
|
-
let args = createCapturedArgs(named, EMPTY_POSITIONAL);
|
|
1532
556
|
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
return outlet;
|
|
1540
|
-
});
|
|
557
|
+
const unbound = internalHelper(({
|
|
558
|
+
positional,
|
|
559
|
+
named
|
|
560
|
+
}) => {
|
|
561
|
+
(!(positional.length === 1 && Object.keys(named).length === 0) && assert('unbound helper cannot be called with multiple params or hash params', positional.length === 1 && Object.keys(named).length === 0));
|
|
562
|
+
return createUnboundRef(valueForRef(positional[0]), '(result of an `unbound` helper)');
|
|
1541
563
|
});
|
|
1542
|
-
function stateFor(ref, outlet) {
|
|
1543
|
-
if (outlet === undefined) return null;
|
|
1544
|
-
let render = outlet.render;
|
|
1545
|
-
if (render === undefined) return null;
|
|
1546
|
-
let template = render.template;
|
|
1547
|
-
// The type doesn't actually allow for `null`, but if we make it past this
|
|
1548
|
-
// point it is really important that we have _something_ to render. We could
|
|
1549
|
-
// assert, but that is probably overly strict for very little to gain.
|
|
1550
|
-
if (template === undefined || template === null) return null;
|
|
1551
|
-
return {
|
|
1552
|
-
ref,
|
|
1553
|
-
name: render.name,
|
|
1554
|
-
template,
|
|
1555
|
-
controller: render.controller
|
|
1556
|
-
};
|
|
1557
|
-
}
|
|
1558
|
-
function isStable(state, lastState) {
|
|
1559
|
-
if (state === null || lastState === null) {
|
|
1560
|
-
return false;
|
|
1561
|
-
}
|
|
1562
|
-
return state.template === lastState.template && state.controller === lastState.controller;
|
|
1563
|
-
}
|
|
1564
564
|
|
|
1565
565
|
function instrumentationPayload(name) {
|
|
1566
566
|
return {
|
|
@@ -1600,8 +600,6 @@ const BUILTIN_KEYWORD_HELPERS = {
|
|
|
1600
600
|
'-normalize-class': normalizeClassHelper,
|
|
1601
601
|
'-resolve': resolve,
|
|
1602
602
|
'-track-array': trackArray,
|
|
1603
|
-
'-mount': mountHelper,
|
|
1604
|
-
'-outlet': outletHelper,
|
|
1605
603
|
'-in-el-null': inElementNullCheckHelper
|
|
1606
604
|
};
|
|
1607
605
|
const BUILTIN_HELPERS = {
|
|
@@ -1609,13 +607,19 @@ const BUILTIN_HELPERS = {
|
|
|
1609
607
|
array,
|
|
1610
608
|
concat,
|
|
1611
609
|
fn,
|
|
1612
|
-
get
|
|
610
|
+
get,
|
|
1613
611
|
hash,
|
|
1614
|
-
'unique-id': uniqueId
|
|
612
|
+
'unique-id': uniqueId,
|
|
613
|
+
// In prod builds, this is a no-op helper and is unused in practice. We shouldn't need
|
|
614
|
+
// to add it at all, but the current test build doesn't produce a "prod compiler", so
|
|
615
|
+
// we ended up running the debug-build for the template compliler in prod tests. Once
|
|
616
|
+
// that is fixed, this can be conditionally included only in DEBUG. For now, this
|
|
617
|
+
// allows the test to work and does not really harm anything, since it's just a no-op
|
|
618
|
+
// pass-through helper. Keeping it inside the object literal (rather than a top-level
|
|
619
|
+
// conditional assignment) keeps this module free of top-level side effects so that
|
|
620
|
+
// consumers that never resolve anything dynamically can tree-shake the whole table.
|
|
621
|
+
'-disallow-dynamic-resolution': disallowDynamicResolution
|
|
1615
622
|
};
|
|
1616
|
-
{
|
|
1617
|
-
BUILTIN_HELPERS['-disallow-dynamic-resolution'] = disallowDynamicResolution;
|
|
1618
|
-
}
|
|
1619
623
|
|
|
1620
624
|
// With the implementation of RFC #1006(https://rfcs.emberjs.com/id/1006-deprecate-action-template-helper), the `action` modifer was removed. It was the
|
|
1621
625
|
// only built-in keyword modifier, so this object is currently empty.
|
|
@@ -1649,12 +653,17 @@ class ResolverImpl {
|
|
|
1649
653
|
// than the raw value (`factoryFor(...).class`). This is because injections are already
|
|
1650
654
|
// bound in the factoryFor result, including type-based injections
|
|
1651
655
|
|
|
656
|
+
// The classic helper manager is registered on the classic `Helper` base
|
|
657
|
+
// class; deriving it from the definition (rather than importing it from
|
|
658
|
+
// the module that defines `Helper`) keeps this module from pulling in
|
|
659
|
+
// the classic object model when no classic helpers are in use.
|
|
660
|
+
let manager = getInternalHelperManager(definition);
|
|
1652
661
|
{
|
|
1653
662
|
// In DEBUG we need to only set the associated value once, otherwise
|
|
1654
663
|
// we'll trigger an assertion
|
|
1655
664
|
if (!CLASSIC_HELPER_MANAGER_ASSOCIATED.has(factory)) {
|
|
1656
665
|
CLASSIC_HELPER_MANAGER_ASSOCIATED.add(factory);
|
|
1657
|
-
setInternalHelperManager(
|
|
666
|
+
setInternalHelperManager(manager, factory);
|
|
1658
667
|
}
|
|
1659
668
|
}
|
|
1660
669
|
return factory;
|
|
@@ -1662,6 +671,7 @@ class ResolverImpl {
|
|
|
1662
671
|
return definition;
|
|
1663
672
|
}
|
|
1664
673
|
lookupBuiltInHelper(name) {
|
|
674
|
+
(!(name !== '-outlet' && name !== '-mount') && assert(`The \`{{${name.slice(1)}}}\` keyword requires the router, which is not available here. ` + `It is only supported in templates rendered by an Ember application (e.g. not via \`renderComponent\`).`, name !== '-outlet' && name !== '-mount'));
|
|
1665
675
|
return BUILTIN_KEYWORD_HELPERS[name] ?? null;
|
|
1666
676
|
}
|
|
1667
677
|
lookupModifier(name, owner) {
|
|
@@ -1678,159 +688,377 @@ class ResolverImpl {
|
|
|
1678
688
|
lookupBuiltInModifier(name) {
|
|
1679
689
|
return BUILTIN_KEYWORD_MODIFIERS[name] ?? null;
|
|
1680
690
|
}
|
|
1681
|
-
lookupComponent(name, owner) {
|
|
1682
|
-
let pair = lookupComponentPair(owner, name);
|
|
1683
|
-
if (pair === null) {
|
|
1684
|
-
(!(name !== 'text-area') && assert('Could not find component `<TextArea />` (did you mean `<Textarea />`?)', name !== 'text-area'));
|
|
691
|
+
lookupComponent(name, owner) {
|
|
692
|
+
let pair = lookupComponentPair(owner, name);
|
|
693
|
+
if (pair === null) {
|
|
694
|
+
(!(name !== 'text-area') && assert('Could not find component `<TextArea />` (did you mean `<Textarea />`?)', name !== 'text-area'));
|
|
695
|
+
return null;
|
|
696
|
+
}
|
|
697
|
+
let template = null;
|
|
698
|
+
let key;
|
|
699
|
+
if (pair.component === null) {
|
|
700
|
+
key = template = pair.layout(owner);
|
|
701
|
+
} else {
|
|
702
|
+
key = pair.component;
|
|
703
|
+
}
|
|
704
|
+
let cachedComponentDefinition = this.componentDefinitionCache.get(key);
|
|
705
|
+
if (cachedComponentDefinition !== undefined) {
|
|
706
|
+
return cachedComponentDefinition;
|
|
707
|
+
}
|
|
708
|
+
if (template === null && pair.layout !== null) {
|
|
709
|
+
template = pair.layout(owner);
|
|
710
|
+
}
|
|
711
|
+
let finalizer = _instrumentStart('render.getComponentDefinition', instrumentationPayload, name);
|
|
712
|
+
let definition = null;
|
|
713
|
+
if (pair.component === null) {
|
|
714
|
+
definition = {
|
|
715
|
+
state: templateOnlyComponent(undefined, name),
|
|
716
|
+
manager: TEMPLATE_ONLY_COMPONENT_MANAGER,
|
|
717
|
+
template
|
|
718
|
+
};
|
|
719
|
+
} else {
|
|
720
|
+
let factory = pair.component;
|
|
721
|
+
(!(factory.class !== undefined) && assert(`missing component class ${name}`, factory.class !== undefined));
|
|
722
|
+
let ComponentClass = factory.class;
|
|
723
|
+
let manager = getInternalComponentManager(ComponentClass);
|
|
724
|
+
definition = {
|
|
725
|
+
state: isCurlyManager(manager) ? factory : ComponentClass,
|
|
726
|
+
manager,
|
|
727
|
+
template
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
finalizer();
|
|
731
|
+
this.componentDefinitionCache.set(key, definition);
|
|
732
|
+
(!(!(definition === null && name === 'text-area')) && assert('Could not find component `<TextArea />` (did you mean `<Textarea />`?)', !(definition === null && name === 'text-area')));
|
|
733
|
+
return definition;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
function toIterator(iterable) {
|
|
738
|
+
if (iterable instanceof EachInWrapper) {
|
|
739
|
+
return toEachInIterator(iterable.inner);
|
|
740
|
+
} else {
|
|
741
|
+
return toEachIterator(iterable);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
function toEachInIterator(iterable) {
|
|
745
|
+
if (!isIndexable(iterable)) {
|
|
746
|
+
return null;
|
|
747
|
+
}
|
|
748
|
+
if (Array.isArray(iterable) || isEmberArray(iterable)) {
|
|
749
|
+
return ObjectIterator.fromIndexable(iterable);
|
|
750
|
+
} else if (isNativeIterable(iterable)) {
|
|
751
|
+
return MapLikeNativeIterator.from(iterable);
|
|
752
|
+
} else if (hasForEach(iterable)) {
|
|
753
|
+
return ObjectIterator.fromForEachable(iterable);
|
|
754
|
+
} else {
|
|
755
|
+
return ObjectIterator.fromIndexable(iterable);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
function toEachIterator(iterable) {
|
|
759
|
+
if (!isObject(iterable)) {
|
|
760
|
+
return null;
|
|
761
|
+
}
|
|
762
|
+
if (Array.isArray(iterable)) {
|
|
763
|
+
return ArrayIterator.from(iterable);
|
|
764
|
+
} else if (isEmberArray(iterable)) {
|
|
765
|
+
return EmberArrayIterator.from(iterable);
|
|
766
|
+
} else if (isNativeIterable(iterable)) {
|
|
767
|
+
return ArrayLikeNativeIterator.from(iterable);
|
|
768
|
+
} else if (hasForEach(iterable)) {
|
|
769
|
+
return ArrayIterator.fromForEachable(iterable);
|
|
770
|
+
} else {
|
|
771
|
+
return null;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
class BoundedIterator {
|
|
775
|
+
position = 0;
|
|
776
|
+
constructor(length) {
|
|
777
|
+
this.length = length;
|
|
778
|
+
}
|
|
779
|
+
isEmpty() {
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
782
|
+
memoFor(position) {
|
|
783
|
+
return position;
|
|
784
|
+
}
|
|
785
|
+
next() {
|
|
786
|
+
let {
|
|
787
|
+
length,
|
|
788
|
+
position
|
|
789
|
+
} = this;
|
|
790
|
+
if (position >= length) {
|
|
791
|
+
return null;
|
|
792
|
+
}
|
|
793
|
+
let value = this.valueFor(position);
|
|
794
|
+
let memo = this.memoFor(position);
|
|
795
|
+
this.position++;
|
|
796
|
+
return {
|
|
797
|
+
value,
|
|
798
|
+
memo
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
class ArrayIterator extends BoundedIterator {
|
|
803
|
+
static from(iterable) {
|
|
804
|
+
return iterable.length > 0 ? new this(iterable) : null;
|
|
805
|
+
}
|
|
806
|
+
static fromForEachable(object) {
|
|
807
|
+
let array = [];
|
|
808
|
+
object.forEach(item => array.push(item));
|
|
809
|
+
return this.from(array);
|
|
810
|
+
}
|
|
811
|
+
constructor(array) {
|
|
812
|
+
super(array.length);
|
|
813
|
+
this.array = array;
|
|
814
|
+
}
|
|
815
|
+
valueFor(position) {
|
|
816
|
+
return this.array[position];
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
class EmberArrayIterator extends BoundedIterator {
|
|
820
|
+
static from(iterable) {
|
|
821
|
+
return iterable.length > 0 ? new this(iterable) : null;
|
|
822
|
+
}
|
|
823
|
+
constructor(array) {
|
|
824
|
+
super(array.length);
|
|
825
|
+
this.array = array;
|
|
826
|
+
}
|
|
827
|
+
valueFor(position) {
|
|
828
|
+
return objectAt(this.array, position);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
class ObjectIterator extends BoundedIterator {
|
|
832
|
+
static fromIndexable(obj) {
|
|
833
|
+
let keys = Object.keys(obj);
|
|
834
|
+
if (keys.length === 0) {
|
|
835
|
+
return null;
|
|
836
|
+
} else {
|
|
837
|
+
let values = [];
|
|
838
|
+
for (let key of keys) {
|
|
839
|
+
let value;
|
|
840
|
+
value = obj[key];
|
|
841
|
+
|
|
842
|
+
// Add the tag of the returned value if it is an array, since arrays
|
|
843
|
+
// should always cause updates if they are consumed and then changed
|
|
844
|
+
if (isTracking()) {
|
|
845
|
+
consumeTag(tagFor(obj, key));
|
|
846
|
+
if (Array.isArray(value)) {
|
|
847
|
+
consumeTag(tagFor(value, '[]'));
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
values.push(value);
|
|
851
|
+
}
|
|
852
|
+
return new this(keys, values);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
static fromForEachable(obj) {
|
|
856
|
+
let keys = [];
|
|
857
|
+
let values = [];
|
|
858
|
+
let length = 0;
|
|
859
|
+
let isMapLike = false;
|
|
860
|
+
|
|
861
|
+
// Not using an arrow function here so we can get an accurate `arguments`
|
|
862
|
+
obj.forEach(function (value, key) {
|
|
863
|
+
isMapLike = isMapLike || arguments.length >= 2;
|
|
864
|
+
if (isMapLike) {
|
|
865
|
+
keys.push(key);
|
|
866
|
+
}
|
|
867
|
+
values.push(value);
|
|
868
|
+
length++;
|
|
869
|
+
});
|
|
870
|
+
if (length === 0) {
|
|
871
|
+
return null;
|
|
872
|
+
} else if (isMapLike) {
|
|
873
|
+
return new this(keys, values);
|
|
874
|
+
} else {
|
|
875
|
+
return new ArrayIterator(values);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
constructor(keys, values) {
|
|
879
|
+
super(values.length);
|
|
880
|
+
this.keys = keys;
|
|
881
|
+
this.values = values;
|
|
882
|
+
}
|
|
883
|
+
valueFor(position) {
|
|
884
|
+
return this.values[position];
|
|
885
|
+
}
|
|
886
|
+
memoFor(position) {
|
|
887
|
+
return this.keys[position];
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
class NativeIterator {
|
|
891
|
+
static from(iterable) {
|
|
892
|
+
let iterator = iterable[Symbol.iterator]();
|
|
893
|
+
let result = iterator.next();
|
|
894
|
+
let {
|
|
895
|
+
done
|
|
896
|
+
} = result;
|
|
897
|
+
if (done) {
|
|
1685
898
|
return null;
|
|
1686
|
-
}
|
|
1687
|
-
let template = null;
|
|
1688
|
-
let key;
|
|
1689
|
-
if (pair.component === null) {
|
|
1690
|
-
key = template = pair.layout(owner);
|
|
1691
|
-
} else {
|
|
1692
|
-
key = pair.component;
|
|
1693
|
-
}
|
|
1694
|
-
let cachedComponentDefinition = this.componentDefinitionCache.get(key);
|
|
1695
|
-
if (cachedComponentDefinition !== undefined) {
|
|
1696
|
-
return cachedComponentDefinition;
|
|
1697
|
-
}
|
|
1698
|
-
if (template === null && pair.layout !== null) {
|
|
1699
|
-
template = pair.layout(owner);
|
|
1700
|
-
}
|
|
1701
|
-
let finalizer = _instrumentStart('render.getComponentDefinition', instrumentationPayload, name);
|
|
1702
|
-
let definition = null;
|
|
1703
|
-
if (pair.component === null) {
|
|
1704
|
-
definition = {
|
|
1705
|
-
state: templateOnlyComponent(undefined, name),
|
|
1706
|
-
manager: TEMPLATE_ONLY_COMPONENT_MANAGER,
|
|
1707
|
-
template
|
|
1708
|
-
};
|
|
1709
899
|
} else {
|
|
1710
|
-
|
|
1711
|
-
(!(factory.class !== undefined) && assert(`missing component class ${name}`, factory.class !== undefined));
|
|
1712
|
-
let ComponentClass = factory.class;
|
|
1713
|
-
let manager = getInternalComponentManager(ComponentClass);
|
|
1714
|
-
definition = {
|
|
1715
|
-
state: isCurlyManager(manager) ? factory : ComponentClass,
|
|
1716
|
-
manager,
|
|
1717
|
-
template
|
|
1718
|
-
};
|
|
900
|
+
return new this(iterator, result);
|
|
1719
901
|
}
|
|
1720
|
-
finalizer();
|
|
1721
|
-
this.componentDefinitionCache.set(key, definition);
|
|
1722
|
-
(!(!(definition === null && name === 'text-area')) && assert('Could not find component `<TextArea />` (did you mean `<Textarea />`?)', !(definition === null && name === 'text-area')));
|
|
1723
|
-
return definition;
|
|
1724
902
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
// We use `getOwner` from our internal home for it rather than the narrower
|
|
1730
|
-
// public API for the same reason.
|
|
1731
|
-
const TOP_LEVEL_NAME = '-top-level';
|
|
1732
|
-
class OutletView {
|
|
1733
|
-
static extend(injections) {
|
|
1734
|
-
return class extends OutletView {
|
|
1735
|
-
static create(options) {
|
|
1736
|
-
if (options) {
|
|
1737
|
-
return super.create(Object.assign({}, injections, options));
|
|
1738
|
-
} else {
|
|
1739
|
-
return super.create(injections);
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
};
|
|
903
|
+
position = 0;
|
|
904
|
+
constructor(iterable, result) {
|
|
905
|
+
this.iterable = iterable;
|
|
906
|
+
this.result = result;
|
|
1743
907
|
}
|
|
1744
|
-
|
|
1745
|
-
|
|
908
|
+
isEmpty() {
|
|
909
|
+
return false;
|
|
1746
910
|
}
|
|
1747
|
-
|
|
911
|
+
next() {
|
|
1748
912
|
let {
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
} =
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
this.template = template;
|
|
1764
|
-
this.namespace = namespace;
|
|
1765
|
-
let outletStateTag = createTag();
|
|
1766
|
-
let outletState = {
|
|
1767
|
-
outlets: {
|
|
1768
|
-
main: undefined
|
|
1769
|
-
},
|
|
1770
|
-
render: {
|
|
1771
|
-
owner: owner,
|
|
1772
|
-
name: TOP_LEVEL_NAME,
|
|
1773
|
-
controller: undefined,
|
|
1774
|
-
model: undefined,
|
|
1775
|
-
template
|
|
1776
|
-
}
|
|
1777
|
-
};
|
|
1778
|
-
let ref = this.ref = createComputeRef(() => {
|
|
1779
|
-
consumeTag(outletStateTag);
|
|
1780
|
-
return outletState;
|
|
1781
|
-
}, state => {
|
|
1782
|
-
DIRTY_TAG$1(outletStateTag);
|
|
1783
|
-
outletState.outlets['main'] = state;
|
|
1784
|
-
});
|
|
1785
|
-
this.state = {
|
|
1786
|
-
ref,
|
|
1787
|
-
name: TOP_LEVEL_NAME,
|
|
1788
|
-
template,
|
|
1789
|
-
controller: undefined
|
|
913
|
+
iterable,
|
|
914
|
+
result,
|
|
915
|
+
position
|
|
916
|
+
} = this;
|
|
917
|
+
if (result.done) {
|
|
918
|
+
return null;
|
|
919
|
+
}
|
|
920
|
+
let value = this.valueFor(result, position);
|
|
921
|
+
let memo = this.memoFor(result, position);
|
|
922
|
+
this.position++;
|
|
923
|
+
this.result = iterable.next();
|
|
924
|
+
return {
|
|
925
|
+
value,
|
|
926
|
+
memo
|
|
1790
927
|
};
|
|
1791
928
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
} else {
|
|
1797
|
-
target = selector;
|
|
1798
|
-
}
|
|
1799
|
-
let renderer = this.owner.lookup('renderer:-dom');
|
|
1800
|
-
|
|
1801
|
-
// SAFETY: It's not clear that this cast is safe.
|
|
1802
|
-
// The types for appendOutletView may be incorrect or this is a potential bug.
|
|
1803
|
-
schedule('render', renderer, 'appendOutletView', this, target);
|
|
929
|
+
}
|
|
930
|
+
class ArrayLikeNativeIterator extends NativeIterator {
|
|
931
|
+
valueFor(result) {
|
|
932
|
+
return result.value;
|
|
1804
933
|
}
|
|
1805
|
-
|
|
1806
|
-
|
|
934
|
+
memoFor(_result, position) {
|
|
935
|
+
return position;
|
|
1807
936
|
}
|
|
1808
|
-
|
|
1809
|
-
|
|
937
|
+
}
|
|
938
|
+
class MapLikeNativeIterator extends NativeIterator {
|
|
939
|
+
valueFor(result) {
|
|
940
|
+
return result.value[1];
|
|
1810
941
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
942
|
+
memoFor(result) {
|
|
943
|
+
return result.value[0];
|
|
1813
944
|
}
|
|
1814
945
|
}
|
|
946
|
+
function hasForEach(value) {
|
|
947
|
+
return value != null && typeof value['forEach'] === 'function';
|
|
948
|
+
}
|
|
949
|
+
function isNativeIterable(value) {
|
|
950
|
+
return value != null && typeof value[Symbol.iterator] === 'function';
|
|
951
|
+
}
|
|
952
|
+
function isIndexable(value) {
|
|
953
|
+
return value !== null && (typeof value === 'object' || typeof value === 'function');
|
|
954
|
+
}
|
|
1815
955
|
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
956
|
+
function toBool(predicate) {
|
|
957
|
+
if (isProxy(predicate)) {
|
|
958
|
+
consumeTag(tagForProperty(predicate, 'content'));
|
|
959
|
+
return Boolean(get$1(predicate, 'isTruthy'));
|
|
960
|
+
} else if (isArray(predicate)) {
|
|
961
|
+
consumeTag(tagForProperty(predicate, '[]'));
|
|
962
|
+
return predicate.length !== 0;
|
|
963
|
+
} else if (isHTMLSafe(predicate)) {
|
|
964
|
+
return Boolean(predicate.toString());
|
|
965
|
+
} else {
|
|
966
|
+
return Boolean(predicate);
|
|
1820
967
|
}
|
|
1821
|
-
|
|
1822
|
-
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
///////////
|
|
971
|
+
|
|
972
|
+
// Setup global context
|
|
973
|
+
|
|
974
|
+
setGlobalContext({
|
|
975
|
+
scheduleRevalidate() {
|
|
976
|
+
_backburner.ensureInstance();
|
|
977
|
+
},
|
|
978
|
+
toBool,
|
|
979
|
+
toIterator,
|
|
980
|
+
getProp: _getProp,
|
|
981
|
+
setProp: _setProp,
|
|
982
|
+
getPath: get$1,
|
|
983
|
+
setPath: set,
|
|
984
|
+
scheduleDestroy(destroyable, destructor) {
|
|
985
|
+
schedule('actions', null, destructor, destroyable);
|
|
986
|
+
},
|
|
987
|
+
scheduleDestroyed(finalizeDestructor) {
|
|
988
|
+
schedule('destroy', null, finalizeDestructor);
|
|
989
|
+
},
|
|
990
|
+
warnIfStyleNotTrusted(value) {
|
|
991
|
+
(warn(constructStyleDeprecationMessage(String(value)), (() => {
|
|
992
|
+
if (value === null || value === undefined || isHTMLSafe(value)) {
|
|
993
|
+
return true;
|
|
994
|
+
}
|
|
995
|
+
return false;
|
|
996
|
+
})(), {
|
|
997
|
+
id: 'ember-htmlbars.style-xss-warning'
|
|
998
|
+
}));
|
|
999
|
+
},
|
|
1000
|
+
assert(test, msg, options) {
|
|
1001
|
+
{
|
|
1002
|
+
let id = options?.id;
|
|
1003
|
+
let override = VM_ASSERTION_OVERRIDES.filter(o => o.id === id)[0];
|
|
1004
|
+
(!(test) && assert(override?.message ?? msg, test));
|
|
1005
|
+
}
|
|
1006
|
+
},
|
|
1007
|
+
deprecate(msg, test, options) {
|
|
1008
|
+
{
|
|
1009
|
+
let {
|
|
1010
|
+
id
|
|
1011
|
+
} = options;
|
|
1012
|
+
if (id === 'argument-less-helper-paren-less-invocation') {
|
|
1013
|
+
throw new Error(`A resolved helper cannot be passed as a named argument as the syntax is ` + `ambiguously a pass-by-reference or invocation. Use the ` + `\`{{helper 'foo-helper}}\` helper to pass by reference or explicitly ` + `invoke the helper with parens: \`{{(fooHelper)}}\`.`);
|
|
1014
|
+
}
|
|
1015
|
+
let override = VM_DEPRECATION_OVERRIDES.filter(o => o.id === id)[0];
|
|
1016
|
+
if (!override) throw new Error(`deprecation override for ${id} not found`);
|
|
1017
|
+
|
|
1018
|
+
// allow deprecations to be disabled in the VM_DEPRECATION_OVERRIDES array below
|
|
1019
|
+
if (!override.disabled) {
|
|
1020
|
+
(!(Boolean(test)) && deprecate(override.message ?? msg, Boolean(test), override));
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1823
1023
|
}
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1024
|
+
});
|
|
1025
|
+
{
|
|
1026
|
+
debug?.setTrackingTransactionEnv?.({
|
|
1027
|
+
debugMessage(obj, keyName) {
|
|
1028
|
+
let dirtyString = keyName ? `\`${keyName}\` on \`${getDebugName?.(obj)}\`` : `\`${getDebugName?.(obj)}\``;
|
|
1029
|
+
return `You attempted to update ${dirtyString}, but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.`;
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
///////////
|
|
1035
|
+
|
|
1036
|
+
// VM Assertion/Deprecation overrides
|
|
1037
|
+
|
|
1038
|
+
const VM_DEPRECATION_OVERRIDES = [{
|
|
1039
|
+
id: 'setting-on-hash',
|
|
1040
|
+
until: '4.4.0',
|
|
1041
|
+
for: 'ember-source',
|
|
1042
|
+
since: {
|
|
1043
|
+
available: '3.28.0',
|
|
1044
|
+
enabled: '3.28.0'
|
|
1827
1045
|
}
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1046
|
+
}];
|
|
1047
|
+
const VM_ASSERTION_OVERRIDES = [];
|
|
1048
|
+
|
|
1049
|
+
///////////
|
|
1050
|
+
|
|
1051
|
+
// Define environment delegate
|
|
1052
|
+
|
|
1053
|
+
class EmberEnvironmentDelegate {
|
|
1054
|
+
enableDebugTooling = ENV._DEBUG_RENDER_TREE;
|
|
1055
|
+
constructor(owner, isInteractive) {
|
|
1056
|
+
this.owner = owner;
|
|
1057
|
+
this.isInteractive = isInteractive;
|
|
1832
1058
|
}
|
|
1059
|
+
onTransactionCommit() {}
|
|
1833
1060
|
}
|
|
1061
|
+
|
|
1834
1062
|
const NO_OP = () => {};
|
|
1835
1063
|
|
|
1836
1064
|
// This wrapper logic prevents us from rerendering in case of a hard failure
|
|
@@ -1856,6 +1084,13 @@ function errorLoopTransaction(fn) {
|
|
|
1856
1084
|
};
|
|
1857
1085
|
}
|
|
1858
1086
|
}
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* The interface the `RendererState` needs from a render root. The base
|
|
1090
|
+
* renderer only ever creates `ComponentRootState`s; the classic renderer
|
|
1091
|
+
* (`./renderer`) adds `ClassicRootState` for outlet/classic-component roots.
|
|
1092
|
+
*/
|
|
1093
|
+
|
|
1859
1094
|
class ComponentRootState {
|
|
1860
1095
|
type = 'component';
|
|
1861
1096
|
#result;
|
|
@@ -1873,7 +1108,7 @@ class ComponentRootState {
|
|
|
1873
1108
|
});
|
|
1874
1109
|
});
|
|
1875
1110
|
}
|
|
1876
|
-
isFor(
|
|
1111
|
+
isFor(_possibleRoot) {
|
|
1877
1112
|
return false;
|
|
1878
1113
|
}
|
|
1879
1114
|
render() {
|
|
@@ -1889,62 +1124,6 @@ class ComponentRootState {
|
|
|
1889
1124
|
return this.#result;
|
|
1890
1125
|
}
|
|
1891
1126
|
}
|
|
1892
|
-
class ClassicRootState {
|
|
1893
|
-
type = 'classic';
|
|
1894
|
-
id;
|
|
1895
|
-
result;
|
|
1896
|
-
destroyed;
|
|
1897
|
-
render;
|
|
1898
|
-
env;
|
|
1899
|
-
constructor(root, context, owner, template, self, parentElement, dynamicScope, builder) {
|
|
1900
|
-
this.root = root;
|
|
1901
|
-
(!(template !== undefined) && assert(`You cannot render \`${valueForRef(self)}\` without a template.`, template !== undefined));
|
|
1902
|
-
this.id = root instanceof OutletView ? guidFor(root) : getViewId(root);
|
|
1903
|
-
this.result = undefined;
|
|
1904
|
-
this.destroyed = false;
|
|
1905
|
-
this.env = context.env;
|
|
1906
|
-
this.render = errorLoopTransaction(() => {
|
|
1907
|
-
let layout = unwrapTemplate(template).asLayout();
|
|
1908
|
-
let iterator = renderMain(context, owner, self, builder(context.env, {
|
|
1909
|
-
element: parentElement,
|
|
1910
|
-
nextSibling: null
|
|
1911
|
-
}), layout, dynamicScope);
|
|
1912
|
-
let result = this.result = iterator.sync();
|
|
1913
|
-
associateDestroyableChild(this, result);
|
|
1914
|
-
this.render = errorLoopTransaction(() => {
|
|
1915
|
-
if (isDestroying(result) || isDestroyed(result)) return;
|
|
1916
|
-
return result.rerender({
|
|
1917
|
-
alwaysRevalidate: false
|
|
1918
|
-
});
|
|
1919
|
-
});
|
|
1920
|
-
});
|
|
1921
|
-
}
|
|
1922
|
-
isFor(possibleRoot) {
|
|
1923
|
-
return this.root === possibleRoot;
|
|
1924
|
-
}
|
|
1925
|
-
destroy() {
|
|
1926
|
-
let {
|
|
1927
|
-
result,
|
|
1928
|
-
env
|
|
1929
|
-
} = this;
|
|
1930
|
-
this.destroyed = true;
|
|
1931
|
-
this.root = null;
|
|
1932
|
-
this.result = undefined;
|
|
1933
|
-
this.render = undefined;
|
|
1934
|
-
if (result !== undefined) {
|
|
1935
|
-
/*
|
|
1936
|
-
Handles these scenarios:
|
|
1937
|
-
* When roots are removed during standard rendering process, a transaction exists already
|
|
1938
|
-
`.begin()` / `.commit()` are not needed.
|
|
1939
|
-
* When roots are being destroyed manually (`component.append(); component.destroy() case), no
|
|
1940
|
-
transaction exists already.
|
|
1941
|
-
* When roots are being destroyed during `Renderer#destroy`, no transaction exists
|
|
1942
|
-
*/
|
|
1943
|
-
|
|
1944
|
-
inTransaction(env, () => destroy(result));
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
1127
|
const renderers = [];
|
|
1949
1128
|
function _resetRenderers() {
|
|
1950
1129
|
renderers.length = 0;
|
|
@@ -2338,142 +1517,6 @@ class BaseRenderer {
|
|
|
2338
1517
|
rerender() {
|
|
2339
1518
|
this.state.scheduleRevalidate(this);
|
|
2340
1519
|
}
|
|
2341
|
-
|
|
2342
|
-
// render(component: Component, options: { into: Cursor; args?: Record<string, unknown> }): void {
|
|
2343
|
-
// this.state.renderRoot(component);
|
|
2344
|
-
// }
|
|
2345
|
-
}
|
|
2346
|
-
class Renderer extends BaseRenderer {
|
|
2347
|
-
static strict(owner, document, options) {
|
|
2348
|
-
return new BaseRenderer(owner, {
|
|
2349
|
-
hasDOM: hasDOM,
|
|
2350
|
-
...options
|
|
2351
|
-
}, document, new ResolverImpl(), clientBuilder);
|
|
2352
|
-
}
|
|
2353
|
-
_rootTemplate;
|
|
2354
|
-
_viewRegistry;
|
|
2355
|
-
static create(props) {
|
|
2356
|
-
let {
|
|
2357
|
-
_viewRegistry
|
|
2358
|
-
} = props;
|
|
2359
|
-
let owner = getOwner(props);
|
|
2360
|
-
(!(owner) && assert('Renderer is unexpectedly missing an owner', owner));
|
|
2361
|
-
let document = owner.lookup('service:-document');
|
|
2362
|
-
let env = owner.lookup('-environment:main');
|
|
2363
|
-
let rootTemplate = owner.lookup(privatize`template:-root`);
|
|
2364
|
-
let builder = owner.lookup('service:-dom-builder');
|
|
2365
|
-
return new this(owner, document, env, rootTemplate, _viewRegistry, builder);
|
|
2366
|
-
}
|
|
2367
|
-
constructor(owner, document, env, rootTemplate, viewRegistry, builder = clientBuilder, resolver = new ResolverImpl()) {
|
|
2368
|
-
super(owner, env, document, resolver, builder);
|
|
2369
|
-
this._rootTemplate = rootTemplate(owner);
|
|
2370
|
-
this._viewRegistry = viewRegistry || owner.lookup('-view-registry:main');
|
|
2371
|
-
}
|
|
2372
|
-
|
|
2373
|
-
// renderer HOOKS
|
|
2374
|
-
|
|
2375
|
-
appendOutletView(view, target) {
|
|
2376
|
-
// TODO: This bypasses the {{outlet}} syntax so logically duplicates
|
|
2377
|
-
// some of the set up code. Since this is all internal (or is it?),
|
|
2378
|
-
// we can refactor this to do something more direct/less convoluted
|
|
2379
|
-
// and with less setup, but get it working first
|
|
2380
|
-
let outlet = createRootOutlet(view);
|
|
2381
|
-
let {
|
|
2382
|
-
name,
|
|
2383
|
-
/* controller, */template
|
|
2384
|
-
} = view.state;
|
|
2385
|
-
let named = dict();
|
|
2386
|
-
named['Component'] = createConstRef(makeRouteTemplate(view.owner, name, template), '@Component');
|
|
2387
|
-
|
|
2388
|
-
// TODO: is this guaranteed to be undefined? It seems to be the
|
|
2389
|
-
// case in the `OutletView` class. Investigate how much that class
|
|
2390
|
-
// exists as an internal implementation detail only, or if it was
|
|
2391
|
-
// used outside of core. As far as I can tell, test-helpers uses
|
|
2392
|
-
// it but only for `setOutletState`.
|
|
2393
|
-
// named['controller'] = createConstRef(controller, '@controller');
|
|
2394
|
-
// Update: at least according to the debug render tree tests, we
|
|
2395
|
-
// appear to always expect this to be undefined. Not a definitive
|
|
2396
|
-
// source by any means, but is useful evidence
|
|
2397
|
-
named['controller'] = UNDEFINED_REFERENCE;
|
|
2398
|
-
named['model'] = UNDEFINED_REFERENCE;
|
|
2399
|
-
let args = createCapturedArgs(named, EMPTY_POSITIONAL);
|
|
2400
|
-
this._appendDefinition(view, curry(0, outlet, view.owner, args, true), target);
|
|
2401
|
-
}
|
|
2402
|
-
appendTo(view, target) {
|
|
2403
|
-
let definition = new RootComponentDefinition(view);
|
|
2404
|
-
this._appendDefinition(view, curry(0, definition, this.state.owner, null, true), target);
|
|
2405
|
-
}
|
|
2406
|
-
_appendDefinition(root, definition, target) {
|
|
2407
|
-
let self = createConstRef(definition, 'this');
|
|
2408
|
-
let dynamicScope = new DynamicScope(null, UNDEFINED_REFERENCE);
|
|
2409
|
-
let rootState = new ClassicRootState(root, this.state.context, this.state.owner, this._rootTemplate, self, target, dynamicScope, this.state.builder);
|
|
2410
|
-
this.state.renderRoot(rootState, this);
|
|
2411
|
-
}
|
|
2412
|
-
cleanupRootFor(component) {
|
|
2413
|
-
// no need to cleanup roots if we have already been destroyed
|
|
2414
|
-
if (isDestroyed(this)) {
|
|
2415
|
-
return;
|
|
2416
|
-
}
|
|
2417
|
-
let roots = this.state.roots;
|
|
2418
|
-
|
|
2419
|
-
// traverse in reverse so we can remove items
|
|
2420
|
-
// without mucking up the index
|
|
2421
|
-
let i = roots.length;
|
|
2422
|
-
while (i--) {
|
|
2423
|
-
let root = roots[i];
|
|
2424
|
-
(!(root) && assert('has root', root));
|
|
2425
|
-
if (root.type === 'classic' && root.isFor(component)) {
|
|
2426
|
-
root.destroy();
|
|
2427
|
-
roots.splice(i, 1);
|
|
2428
|
-
}
|
|
2429
|
-
}
|
|
2430
|
-
}
|
|
2431
|
-
remove(view) {
|
|
2432
|
-
view._transitionTo('destroying');
|
|
2433
|
-
this.cleanupRootFor(view);
|
|
2434
|
-
if (this.state.isInteractive) {
|
|
2435
|
-
view.trigger('didDestroyElement');
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
|
-
get _roots() {
|
|
2439
|
-
return this.state.debug.roots;
|
|
2440
|
-
}
|
|
2441
|
-
get _inRenderTransaction() {
|
|
2442
|
-
return this.state.debug.inRenderTransaction;
|
|
2443
|
-
}
|
|
2444
|
-
get _isInteractive() {
|
|
2445
|
-
return this.state.debug.isInteractive;
|
|
2446
|
-
}
|
|
2447
|
-
get _context() {
|
|
2448
|
-
return this.state.context;
|
|
2449
|
-
}
|
|
2450
|
-
register(view) {
|
|
2451
|
-
let id = getViewId(view);
|
|
2452
|
-
(!(!this._viewRegistry[id]) && assert('Attempted to register a view with an id already in use: ' + id, !this._viewRegistry[id]));
|
|
2453
|
-
this._viewRegistry[id] = view;
|
|
2454
|
-
}
|
|
2455
|
-
unregister(view) {
|
|
2456
|
-
delete this._viewRegistry[getViewId(view)];
|
|
2457
|
-
}
|
|
2458
|
-
getElement(component) {
|
|
2459
|
-
if (this._isInteractive) {
|
|
2460
|
-
return getViewElement(component);
|
|
2461
|
-
} else {
|
|
2462
|
-
throw new Error('Accessing `this.element` is not allowed in non-interactive environments (such as FastBoot).');
|
|
2463
|
-
}
|
|
2464
|
-
}
|
|
2465
|
-
getBounds(component) {
|
|
2466
|
-
let bounds = component[BOUNDS];
|
|
2467
|
-
(!(bounds) && assert('object passed to getBounds must have the BOUNDS symbol as a property', bounds));
|
|
2468
|
-
let parentElement = bounds.parentElement();
|
|
2469
|
-
let firstNode = bounds.firstNode();
|
|
2470
|
-
let lastNode = bounds.lastNode();
|
|
2471
|
-
return {
|
|
2472
|
-
parentElement,
|
|
2473
|
-
firstNode,
|
|
2474
|
-
lastNode
|
|
2475
|
-
};
|
|
2476
|
-
}
|
|
2477
1520
|
}
|
|
2478
1521
|
|
|
2479
|
-
export {
|
|
1522
|
+
export { BaseRenderer as B, ResolverImpl as R, _resetRenderers as _, renderSettled as a, errorLoopTransaction as e, renderComponent as r };
|