ember-source 5.6.0-alpha.2 → 5.6.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-metadata.json +3 -3
- package/dist/dependencies/@glimmer/debug.js +1533 -0
- package/dist/dependencies/@glimmer/destroyable.js +30 -59
- package/dist/dependencies/@glimmer/encoder.js +13 -24
- package/dist/dependencies/@glimmer/global-context.js +38 -41
- package/dist/dependencies/@glimmer/manager.js +144 -326
- package/dist/dependencies/@glimmer/node.js +14 -46
- package/dist/dependencies/@glimmer/opcode-compiler.js +1673 -2478
- package/dist/dependencies/@glimmer/owner.js +2 -5
- package/dist/dependencies/@glimmer/program.js +102 -185
- package/dist/dependencies/@glimmer/reference.js +58 -126
- package/dist/dependencies/@glimmer/runtime.js +4674 -5639
- package/dist/dependencies/@glimmer/util.js +340 -326
- package/dist/dependencies/@glimmer/validator.js +160 -217
- package/dist/dependencies/@glimmer/vm.js +174 -23
- package/dist/dependencies/@glimmer/wire-format.js +91 -34
- package/dist/dependencies/@simple-dom/document.js +1 -1
- package/dist/dependencies/backburner.js.js +1 -1
- package/dist/dependencies/router_js.js +15 -16
- package/dist/dependencies/rsvp.js +89 -88
- package/dist/ember-template-compiler.js +8574 -8350
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +107 -107
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +11216 -9634
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/glimmer/index.js +109 -80
- package/dist/packages/@ember/-internals/metal/index.js +5 -4
- package/dist/packages/@ember/-internals/utils/index.js +3 -4
- package/dist/packages/@ember/array/-internals.js +1 -2
- package/dist/packages/@ember/debug/lib/inspect.js +0 -1
- package/dist/packages/@ember/object/core.js +0 -1
- package/dist/packages/@ember/object/mixin.js +1 -2
- package/dist/packages/@ember/routing/route.js +23 -101
- package/dist/packages/@ember/routing/router.js +25 -84
- package/dist/packages/ember/version.js +1 -1
- package/dist/packages/ember-babel.js +13 -0
- package/docs/data.json +217 -242
- package/lib/index.js +1 -5
- package/package.json +26 -21
- package/types/stable/@ember/-internals/glimmer/index.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/curly.d.ts +4 -4
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/mount.d.ts +3 -3
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/outlet.d.ts +5 -8
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/root.d.ts +3 -3
- package/types/stable/@ember/-internals/glimmer/lib/renderer.d.ts +3 -3
- package/types/stable/@ember/-internals/glimmer/lib/resolver.d.ts +3 -3
- package/types/stable/@ember/-internals/glimmer/lib/syntax/utils.d.ts +3 -2
- package/types/stable/@ember/-internals/glimmer/lib/utils/iterator.d.ts +2 -2
- package/types/stable/@ember/-internals/glimmer/lib/utils/outlet.d.ts +39 -18
- package/types/stable/@ember/-internals/utility-types/index.d.ts +1 -0
- package/types/stable/@ember/-internals/views/lib/system/utils.d.ts +4 -3
- package/types/stable/@ember/routing/route.d.ts +6 -28
- package/dist/dependencies/@glimmer/low-level.js +0 -77
|
@@ -1,58 +1,10 @@
|
|
|
1
1
|
import { DEBUG } from '@glimmer/env';
|
|
2
|
-
import {
|
|
3
|
-
import { FEATURE_DEFAULT_HELPER_MANAGER } from '@glimmer/global-context';
|
|
2
|
+
import { debugToString, castToBrowser } from '@glimmer/util';
|
|
4
3
|
import { associateDestroyableChild, registerDestructor } from '@glimmer/destroyable';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function buildCapabilities(capabilities) {
|
|
10
|
-
if (DEBUG) {
|
|
11
|
-
FROM_CAPABILITIES.add(capabilities);
|
|
12
|
-
Object.freeze(capabilities);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return capabilities;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Converts a ComponentCapabilities object into a 32-bit integer representation.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
function capabilityFlagsFrom(capabilities) {
|
|
22
|
-
return 0 | (capabilities.dynamicLayout ? 1
|
|
23
|
-
/* DynamicLayout */
|
|
24
|
-
: 0) | (capabilities.dynamicTag ? 2
|
|
25
|
-
/* DynamicTag */
|
|
26
|
-
: 0) | (capabilities.prepareArgs ? 4
|
|
27
|
-
/* PrepareArgs */
|
|
28
|
-
: 0) | (capabilities.createArgs ? 8
|
|
29
|
-
/* CreateArgs */
|
|
30
|
-
: 0) | (capabilities.attributeHook ? 16
|
|
31
|
-
/* AttributeHook */
|
|
32
|
-
: 0) | (capabilities.elementHook ? 32
|
|
33
|
-
/* ElementHook */
|
|
34
|
-
: 0) | (capabilities.dynamicScope ? 64
|
|
35
|
-
/* DynamicScope */
|
|
36
|
-
: 0) | (capabilities.createCaller ? 128
|
|
37
|
-
/* CreateCaller */
|
|
38
|
-
: 0) | (capabilities.updateHook ? 256
|
|
39
|
-
/* UpdateHook */
|
|
40
|
-
: 0) | (capabilities.createInstance ? 512
|
|
41
|
-
/* CreateInstance */
|
|
42
|
-
: 0) | (capabilities.wrapped ? 1024
|
|
43
|
-
/* Wrapped */
|
|
44
|
-
: 0) | (capabilities.willDestroy ? 2048
|
|
45
|
-
/* WillDestroy */
|
|
46
|
-
: 0) | (capabilities.hasSubOwner ? 4096
|
|
47
|
-
/* HasSubOwner */
|
|
48
|
-
: 0);
|
|
49
|
-
}
|
|
50
|
-
function managerHasCapability(_manager, capabilities, capability) {
|
|
51
|
-
return !!(capabilities & capability);
|
|
52
|
-
}
|
|
53
|
-
function hasCapability(capabilities, capability) {
|
|
54
|
-
return !!(capabilities & capability);
|
|
55
|
-
}
|
|
4
|
+
import { createComputeRef, createConstRef, UNDEFINED_REFERENCE, valueForRef } from '@glimmer/reference';
|
|
5
|
+
import { createUpdatableTag, untrack, track } from '@glimmer/validator';
|
|
6
|
+
import { check, CheckNumber } from '@glimmer/debug';
|
|
7
|
+
import { InternalComponentCapabilities } from '@glimmer/vm';
|
|
56
8
|
|
|
57
9
|
const CUSTOM_TAG_FOR = new WeakMap();
|
|
58
10
|
function getCustomTagFor(obj) {
|
|
@@ -61,14 +13,12 @@ function getCustomTagFor(obj) {
|
|
|
61
13
|
function setCustomTagFor(obj, customTagFn) {
|
|
62
14
|
CUSTOM_TAG_FOR.set(obj, customTagFn);
|
|
63
15
|
}
|
|
64
|
-
|
|
65
16
|
function convertToInt(prop) {
|
|
66
17
|
if (typeof prop === 'symbol') return null;
|
|
67
18
|
const num = Number(prop);
|
|
68
19
|
if (isNaN(num)) return null;
|
|
69
20
|
return num % 1 === 0 ? num : null;
|
|
70
21
|
}
|
|
71
|
-
|
|
72
22
|
function tagForNamedArg(namedArgs, key) {
|
|
73
23
|
return track(() => {
|
|
74
24
|
if (key in namedArgs) {
|
|
@@ -76,280 +26,211 @@ function tagForNamedArg(namedArgs, key) {
|
|
|
76
26
|
}
|
|
77
27
|
});
|
|
78
28
|
}
|
|
79
|
-
|
|
80
29
|
function tagForPositionalArg(positionalArgs, key) {
|
|
81
30
|
return track(() => {
|
|
82
31
|
if (key === '[]') {
|
|
83
32
|
// consume all of the tags in the positional array
|
|
84
33
|
positionalArgs.forEach(valueForRef);
|
|
85
34
|
}
|
|
86
|
-
|
|
87
35
|
const parsed = convertToInt(key);
|
|
88
|
-
|
|
89
36
|
if (parsed !== null && parsed < positionalArgs.length) {
|
|
90
37
|
// consume the tag of the referenced index
|
|
91
38
|
valueForRef(positionalArgs[parsed]);
|
|
92
39
|
}
|
|
93
40
|
});
|
|
94
41
|
}
|
|
95
|
-
|
|
96
|
-
let argsProxyFor;
|
|
97
|
-
|
|
98
42
|
class NamedArgsProxy {
|
|
99
43
|
constructor(named) {
|
|
100
44
|
this.named = named;
|
|
101
45
|
}
|
|
102
|
-
|
|
103
46
|
get(_target, prop) {
|
|
104
47
|
const ref = this.named[prop];
|
|
105
|
-
|
|
106
48
|
if (ref !== undefined) {
|
|
107
49
|
return valueForRef(ref);
|
|
108
50
|
}
|
|
109
51
|
}
|
|
110
|
-
|
|
111
52
|
has(_target, prop) {
|
|
112
53
|
return prop in this.named;
|
|
113
54
|
}
|
|
114
|
-
|
|
115
55
|
ownKeys() {
|
|
116
56
|
return Object.keys(this.named);
|
|
117
57
|
}
|
|
118
|
-
|
|
119
58
|
isExtensible() {
|
|
120
59
|
return false;
|
|
121
60
|
}
|
|
122
|
-
|
|
123
61
|
getOwnPropertyDescriptor(_target, prop) {
|
|
124
62
|
if (DEBUG && !(prop in this.named)) {
|
|
125
63
|
throw new Error(`args proxies do not have real property descriptors, so you should never need to call getOwnPropertyDescriptor yourself. This code exists for enumerability, such as in for-in loops and Object.keys(). Attempted to get the descriptor for \`${String(prop)}\``);
|
|
126
64
|
}
|
|
127
|
-
|
|
128
65
|
return {
|
|
129
66
|
enumerable: true,
|
|
130
67
|
configurable: true
|
|
131
68
|
};
|
|
132
69
|
}
|
|
133
|
-
|
|
134
70
|
}
|
|
135
|
-
|
|
136
71
|
class PositionalArgsProxy {
|
|
137
72
|
constructor(positional) {
|
|
138
73
|
this.positional = positional;
|
|
139
74
|
}
|
|
140
|
-
|
|
141
75
|
get(target, prop) {
|
|
142
76
|
let {
|
|
143
77
|
positional
|
|
144
78
|
} = this;
|
|
145
|
-
|
|
146
79
|
if (prop === 'length') {
|
|
147
80
|
return positional.length;
|
|
148
81
|
}
|
|
149
|
-
|
|
150
82
|
const parsed = convertToInt(prop);
|
|
151
|
-
|
|
152
83
|
if (parsed !== null && parsed < positional.length) {
|
|
153
84
|
return valueForRef(positional[parsed]);
|
|
154
85
|
}
|
|
155
|
-
|
|
156
86
|
return target[prop];
|
|
157
87
|
}
|
|
158
|
-
|
|
159
88
|
isExtensible() {
|
|
160
89
|
return false;
|
|
161
90
|
}
|
|
162
|
-
|
|
163
91
|
has(_target, prop) {
|
|
164
92
|
const parsed = convertToInt(prop);
|
|
165
93
|
return parsed !== null && parsed < this.positional.length;
|
|
166
94
|
}
|
|
167
|
-
|
|
168
95
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
const namedTarget = Object.create(null);
|
|
184
|
-
const positionalTarget = [];
|
|
185
|
-
|
|
186
|
-
if (DEBUG) {
|
|
187
|
-
const setHandler = function (_target, prop) {
|
|
188
|
-
throw new Error(`You attempted to set ${String(prop)} on the arguments of a component, helper, or modifier. Arguments are immutable and cannot be updated directly; they always represent the values that are passed down. If you want to set default values, you should use a getter and local tracked state instead.`);
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const forInDebugHandler = () => {
|
|
192
|
-
throw new Error(`Object.keys() was called on the positional arguments array for a ${type}, which is not supported. This function is a low-level function that should not need to be called for positional argument arrays. You may be attempting to iterate over the array using for...in instead of for...of.`);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
namedHandler.set = setHandler;
|
|
196
|
-
positionalHandler.set = setHandler;
|
|
197
|
-
positionalHandler.ownKeys = forInDebugHandler;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const namedProxy = new Proxy(namedTarget, namedHandler);
|
|
201
|
-
const positionalProxy = new Proxy(positionalTarget, positionalHandler);
|
|
202
|
-
setCustomTagFor(namedProxy, getNamedTag);
|
|
203
|
-
setCustomTagFor(positionalProxy, getPositionalTag);
|
|
204
|
-
return {
|
|
205
|
-
named: namedProxy,
|
|
206
|
-
positional: positionalProxy
|
|
96
|
+
const argsProxyFor = (capturedArgs, type) => {
|
|
97
|
+
const {
|
|
98
|
+
named,
|
|
99
|
+
positional
|
|
100
|
+
} = capturedArgs;
|
|
101
|
+
let getNamedTag = (_obj, key) => tagForNamedArg(named, key);
|
|
102
|
+
let getPositionalTag = (_obj, key) => tagForPositionalArg(positional, key);
|
|
103
|
+
const namedHandler = new NamedArgsProxy(named);
|
|
104
|
+
const positionalHandler = new PositionalArgsProxy(positional);
|
|
105
|
+
const namedTarget = Object.create(null);
|
|
106
|
+
const positionalTarget = [];
|
|
107
|
+
if (DEBUG) {
|
|
108
|
+
const setHandler = function (_target, prop) {
|
|
109
|
+
throw new Error(`You attempted to set ${String(prop)} on the arguments of a component, helper, or modifier. Arguments are immutable and cannot be updated directly; they always represent the values that are passed down. If you want to set default values, you should use a getter and local tracked state instead.`);
|
|
207
110
|
};
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
argsProxyFor = (capturedArgs, _type) => {
|
|
211
|
-
const {
|
|
212
|
-
named,
|
|
213
|
-
positional
|
|
214
|
-
} = capturedArgs;
|
|
215
|
-
|
|
216
|
-
let getNamedTag = (_obj, key) => tagForNamedArg(named, key);
|
|
217
|
-
|
|
218
|
-
let getPositionalTag = (_obj, key) => tagForPositionalArg(positional, key);
|
|
219
|
-
|
|
220
|
-
let namedProxy = {};
|
|
221
|
-
let positionalProxy = [];
|
|
222
|
-
setCustomTagFor(namedProxy, getNamedTag);
|
|
223
|
-
setCustomTagFor(positionalProxy, getPositionalTag);
|
|
224
|
-
Object.keys(named).forEach(name => {
|
|
225
|
-
Object.defineProperty(namedProxy, name, {
|
|
226
|
-
enumerable: true,
|
|
227
|
-
configurable: true,
|
|
228
|
-
|
|
229
|
-
get() {
|
|
230
|
-
return valueForRef(named[name]);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
positional.forEach((ref, index) => {
|
|
236
|
-
Object.defineProperty(positionalProxy, index, {
|
|
237
|
-
enumerable: true,
|
|
238
|
-
configurable: true,
|
|
239
|
-
|
|
240
|
-
get() {
|
|
241
|
-
return valueForRef(ref);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
if (DEBUG) {
|
|
248
|
-
// Prevent mutations in development mode. This will not prevent the
|
|
249
|
-
// proxy from updating, but will prevent assigning new values or pushing
|
|
250
|
-
// for instance.
|
|
251
|
-
Object.freeze(namedProxy);
|
|
252
|
-
Object.freeze(positionalProxy);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return {
|
|
256
|
-
named: namedProxy,
|
|
257
|
-
positional: positionalProxy
|
|
111
|
+
const forInDebugHandler = () => {
|
|
112
|
+
throw new Error(`Object.keys() was called on the positional arguments array for a ${type}, which is not supported. This function is a low-level function that should not need to be called for positional argument arrays. You may be attempting to iterate over the array using for...in instead of for...of.`);
|
|
258
113
|
};
|
|
114
|
+
namedHandler.set = setHandler;
|
|
115
|
+
positionalHandler.set = setHandler;
|
|
116
|
+
positionalHandler.ownKeys = forInDebugHandler;
|
|
117
|
+
}
|
|
118
|
+
const namedProxy = new Proxy(namedTarget, namedHandler);
|
|
119
|
+
const positionalProxy = new Proxy(positionalTarget, positionalHandler);
|
|
120
|
+
setCustomTagFor(namedProxy, getNamedTag);
|
|
121
|
+
setCustomTagFor(positionalProxy, getPositionalTag);
|
|
122
|
+
return {
|
|
123
|
+
named: namedProxy,
|
|
124
|
+
positional: positionalProxy
|
|
259
125
|
};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const FROM_CAPABILITIES = DEBUG ? new WeakSet() : undefined;
|
|
129
|
+
function buildCapabilities(capabilities) {
|
|
130
|
+
if (DEBUG) {
|
|
131
|
+
FROM_CAPABILITIES.add(capabilities);
|
|
132
|
+
Object.freeze(capabilities);
|
|
133
|
+
}
|
|
134
|
+
return capabilities;
|
|
135
|
+
}
|
|
136
|
+
const EMPTY = InternalComponentCapabilities.Empty;
|
|
137
|
+
/**
|
|
138
|
+
* Converts a ComponentCapabilities object into a 32-bit integer representation.
|
|
139
|
+
*/
|
|
140
|
+
function capabilityFlagsFrom(capabilities) {
|
|
141
|
+
return EMPTY | capability(capabilities, 'dynamicLayout') | capability(capabilities, 'dynamicTag') | capability(capabilities, 'prepareArgs') | capability(capabilities, 'createArgs') | capability(capabilities, 'attributeHook') | capability(capabilities, 'elementHook') | capability(capabilities, 'dynamicScope') | capability(capabilities, 'createCaller') | capability(capabilities, 'updateHook') | capability(capabilities, 'createInstance') | capability(capabilities, 'wrapped') | capability(capabilities, 'willDestroy') | capability(capabilities, 'hasSubOwner');
|
|
142
|
+
}
|
|
143
|
+
function capability(capabilities, capability) {
|
|
144
|
+
return capabilities[capability] ? InternalComponentCapabilities[capability] : EMPTY;
|
|
145
|
+
}
|
|
146
|
+
function managerHasCapability(_manager, capabilities, capability) {
|
|
147
|
+
check(capabilities, CheckNumber);
|
|
148
|
+
return !!(capabilities & capability);
|
|
149
|
+
}
|
|
150
|
+
function hasCapability(capabilities, capability) {
|
|
151
|
+
check(capabilities, CheckNumber);
|
|
152
|
+
return !!(capabilities & capability);
|
|
260
153
|
}
|
|
261
154
|
|
|
262
|
-
function helperCapabilities(managerAPI
|
|
155
|
+
function helperCapabilities(managerAPI) {
|
|
156
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
263
157
|
if (DEBUG && managerAPI !== '3.23') {
|
|
264
158
|
throw new Error('Invalid helper manager compatibility specified');
|
|
265
159
|
}
|
|
266
|
-
|
|
267
160
|
if (DEBUG && (!(options.hasValue || options.hasScheduledEffect) || options.hasValue && options.hasScheduledEffect)) {
|
|
268
161
|
throw new Error('You must pass either the `hasValue` OR the `hasScheduledEffect` capability when defining a helper manager. Passing neither, or both, is not permitted.');
|
|
269
162
|
}
|
|
270
|
-
|
|
271
163
|
if (DEBUG && options.hasScheduledEffect) {
|
|
272
164
|
throw new Error('The `hasScheduledEffect` capability has not yet been implemented for helper managers. Please pass `hasValue` instead');
|
|
273
165
|
}
|
|
274
|
-
|
|
275
166
|
return buildCapabilities({
|
|
276
167
|
hasValue: Boolean(options.hasValue),
|
|
277
168
|
hasDestroyable: Boolean(options.hasDestroyable),
|
|
278
169
|
hasScheduledEffect: Boolean(options.hasScheduledEffect)
|
|
279
170
|
});
|
|
280
|
-
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
////////////
|
|
281
174
|
|
|
282
175
|
function hasValue(manager) {
|
|
283
176
|
return manager.capabilities.hasValue;
|
|
284
177
|
}
|
|
285
178
|
function hasDestroyable(manager) {
|
|
286
179
|
return manager.capabilities.hasDestroyable;
|
|
287
|
-
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
////////////
|
|
288
183
|
|
|
289
184
|
class CustomHelperManager {
|
|
290
185
|
constructor(factory) {
|
|
291
186
|
this.factory = factory;
|
|
292
|
-
this.helperManagerDelegates = new WeakMap();
|
|
293
|
-
this.undefinedDelegate = null;
|
|
294
187
|
}
|
|
295
|
-
|
|
188
|
+
helperManagerDelegates = new WeakMap();
|
|
189
|
+
undefinedDelegate = null;
|
|
296
190
|
getDelegateForOwner(owner) {
|
|
297
191
|
let delegate = this.helperManagerDelegates.get(owner);
|
|
298
|
-
|
|
299
192
|
if (delegate === undefined) {
|
|
300
193
|
let {
|
|
301
194
|
factory
|
|
302
195
|
} = this;
|
|
303
196
|
delegate = factory(owner);
|
|
304
|
-
|
|
305
197
|
if (DEBUG && !FROM_CAPABILITIES.has(delegate.capabilities)) {
|
|
306
198
|
// TODO: This error message should make sense in both Ember and Glimmer https://github.com/glimmerjs/glimmer-vm/issues/1200
|
|
307
199
|
throw new Error(`Custom helper managers must have a \`capabilities\` property that is the result of calling the \`capabilities('3.23')\` (imported via \`import { capabilities } from '@ember/helper';\`). Received: \`${JSON.stringify(delegate.capabilities)}\` for: \`${delegate}\``);
|
|
308
200
|
}
|
|
309
|
-
|
|
310
201
|
this.helperManagerDelegates.set(owner, delegate);
|
|
311
202
|
}
|
|
312
|
-
|
|
313
203
|
return delegate;
|
|
314
204
|
}
|
|
315
|
-
|
|
316
205
|
getDelegateFor(owner) {
|
|
317
206
|
if (owner === undefined) {
|
|
318
207
|
let {
|
|
319
208
|
undefinedDelegate
|
|
320
209
|
} = this;
|
|
321
|
-
|
|
322
210
|
if (undefinedDelegate === null) {
|
|
323
211
|
let {
|
|
324
212
|
factory
|
|
325
213
|
} = this;
|
|
326
214
|
this.undefinedDelegate = undefinedDelegate = factory(undefined);
|
|
327
215
|
}
|
|
328
|
-
|
|
329
216
|
return undefinedDelegate;
|
|
330
217
|
} else {
|
|
331
218
|
return this.getDelegateForOwner(owner);
|
|
332
219
|
}
|
|
333
220
|
}
|
|
334
|
-
|
|
335
221
|
getHelper(definition) {
|
|
336
222
|
return (capturedArgs, owner) => {
|
|
337
|
-
var _a, _b;
|
|
338
|
-
|
|
339
223
|
let manager = this.getDelegateFor(owner);
|
|
340
224
|
const args = argsProxyFor(capturedArgs, 'helper');
|
|
341
225
|
const bucket = manager.createHelper(definition, args);
|
|
342
|
-
|
|
343
226
|
if (hasValue(manager)) {
|
|
344
227
|
let cache = createComputeRef(() => manager.getValue(bucket), null, DEBUG && manager.getDebugName && manager.getDebugName(definition));
|
|
345
|
-
|
|
346
228
|
if (hasDestroyable(manager)) {
|
|
347
229
|
associateDestroyableChild(cache, manager.getDestroyable(bucket));
|
|
348
230
|
}
|
|
349
|
-
|
|
350
231
|
return cache;
|
|
351
232
|
} else if (hasDestroyable(manager)) {
|
|
352
|
-
let ref = createConstRef(undefined, DEBUG && (
|
|
233
|
+
let ref = createConstRef(undefined, DEBUG && (manager.getDebugName?.(definition) ?? 'unknown helper'));
|
|
353
234
|
associateDestroyableChild(ref, manager.getDestroyable(bucket));
|
|
354
235
|
return ref;
|
|
355
236
|
} else {
|
|
@@ -357,82 +238,69 @@ class CustomHelperManager {
|
|
|
357
238
|
}
|
|
358
239
|
};
|
|
359
240
|
}
|
|
360
|
-
|
|
361
241
|
}
|
|
362
242
|
|
|
363
243
|
class FunctionHelperManager {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
|
|
244
|
+
capabilities = buildCapabilities({
|
|
245
|
+
hasValue: true,
|
|
246
|
+
hasDestroyable: false,
|
|
247
|
+
hasScheduledEffect: false
|
|
248
|
+
});
|
|
372
249
|
createHelper(fn, args) {
|
|
373
250
|
return {
|
|
374
251
|
fn,
|
|
375
252
|
args
|
|
376
253
|
};
|
|
377
254
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
255
|
+
getValue(_ref) {
|
|
256
|
+
let {
|
|
257
|
+
fn,
|
|
258
|
+
args
|
|
259
|
+
} = _ref;
|
|
383
260
|
if (Object.keys(args.named).length > 0) {
|
|
384
261
|
let argsForFn = [...args.positional, args.named];
|
|
385
262
|
return fn(...argsForFn);
|
|
386
263
|
}
|
|
387
|
-
|
|
388
264
|
return fn(...args.positional);
|
|
389
265
|
}
|
|
390
|
-
|
|
391
266
|
getDebugName(fn) {
|
|
392
267
|
if (fn.name) {
|
|
393
268
|
return `(helper function ${fn.name})`;
|
|
394
269
|
}
|
|
395
|
-
|
|
396
270
|
return '(anonymous helper function)';
|
|
397
271
|
}
|
|
398
|
-
|
|
399
272
|
}
|
|
400
273
|
|
|
401
274
|
const COMPONENT_MANAGERS = new WeakMap();
|
|
402
275
|
const MODIFIER_MANAGERS = new WeakMap();
|
|
403
|
-
const HELPER_MANAGERS = new WeakMap();
|
|
276
|
+
const HELPER_MANAGERS = new WeakMap();
|
|
404
277
|
|
|
405
|
-
|
|
278
|
+
///////////
|
|
406
279
|
|
|
280
|
+
const getPrototypeOf$1 = Object.getPrototypeOf;
|
|
407
281
|
function setManager(map, manager, obj) {
|
|
408
282
|
if (DEBUG && (typeof obj !== 'object' || obj === null) && typeof obj !== 'function') {
|
|
409
283
|
throw new Error(`Attempted to set a manager on a non-object value. Managers can only be associated with objects or functions. Value was ${debugToString(obj)}`);
|
|
410
284
|
}
|
|
411
|
-
|
|
412
285
|
if (DEBUG && map.has(obj)) {
|
|
413
286
|
throw new Error(`Attempted to set the same type of manager multiple times on a value. You can only associate one manager of each type with a given value. Value was ${debugToString(obj)}`);
|
|
414
287
|
}
|
|
415
|
-
|
|
416
288
|
map.set(obj, manager);
|
|
417
289
|
return obj;
|
|
418
290
|
}
|
|
419
|
-
|
|
420
291
|
function getManager(map, obj) {
|
|
421
292
|
let pointer = obj;
|
|
422
|
-
|
|
423
293
|
while (pointer !== undefined && pointer !== null) {
|
|
424
294
|
const manager = map.get(pointer);
|
|
425
|
-
|
|
426
295
|
if (manager !== undefined) {
|
|
427
296
|
return manager;
|
|
428
297
|
}
|
|
429
|
-
|
|
430
|
-
pointer = getPrototypeOf(pointer);
|
|
298
|
+
pointer = getPrototypeOf$1(pointer);
|
|
431
299
|
}
|
|
432
|
-
|
|
433
300
|
return undefined;
|
|
434
|
-
}
|
|
301
|
+
}
|
|
435
302
|
|
|
303
|
+
///////////
|
|
436
304
|
|
|
437
305
|
function setInternalModifierManager(manager, definition) {
|
|
438
306
|
return setManager(MODIFIER_MANAGERS, manager, definition);
|
|
@@ -441,9 +309,7 @@ function getInternalModifierManager(definition, isOptional) {
|
|
|
441
309
|
if (DEBUG && typeof definition !== 'function' && (typeof definition !== 'object' || definition === null)) {
|
|
442
310
|
throw new Error(`Attempted to use a value as a modifier, but it was not an object or function. Modifier definitions must be objects or functions with an associated modifier manager. The value was: ${definition}`);
|
|
443
311
|
}
|
|
444
|
-
|
|
445
312
|
const manager = getManager(MODIFIER_MANAGERS, definition);
|
|
446
|
-
|
|
447
313
|
if (manager === undefined) {
|
|
448
314
|
if (isOptional === true) {
|
|
449
315
|
return null;
|
|
@@ -451,7 +317,6 @@ function getInternalModifierManager(definition, isOptional) {
|
|
|
451
317
|
throw new Error(`Attempted to load a modifier, but there wasn't a modifier manager associated with the definition. The definition was: ${debugToString(definition)}`);
|
|
452
318
|
}
|
|
453
319
|
}
|
|
454
|
-
|
|
455
320
|
return manager;
|
|
456
321
|
}
|
|
457
322
|
function setInternalHelperManager(manager, definition) {
|
|
@@ -462,17 +327,13 @@ function getInternalHelperManager(definition, isOptional) {
|
|
|
462
327
|
if (DEBUG && typeof definition !== 'function' && (typeof definition !== 'object' || definition === null)) {
|
|
463
328
|
throw new Error(`Attempted to use a value as a helper, but it was not an object or function. Helper definitions must be objects or functions with an associated helper manager. The value was: ${definition}`);
|
|
464
329
|
}
|
|
465
|
-
|
|
466
330
|
let manager = getManager(HELPER_MANAGERS, definition);
|
|
467
331
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
manager = DEFAULT_MANAGER;
|
|
473
|
-
}
|
|
332
|
+
// Functions are special-cased because functions are defined
|
|
333
|
+
// as the "default" helper, per: https://github.com/emberjs/rfcs/pull/756
|
|
334
|
+
if (manager === undefined && typeof definition === 'function') {
|
|
335
|
+
manager = DEFAULT_MANAGER;
|
|
474
336
|
}
|
|
475
|
-
|
|
476
337
|
if (manager) {
|
|
477
338
|
return manager;
|
|
478
339
|
} else if (isOptional === true) {
|
|
@@ -480,7 +341,6 @@ function getInternalHelperManager(definition, isOptional) {
|
|
|
480
341
|
} else if (DEBUG) {
|
|
481
342
|
throw new Error(`Attempted to load a helper, but there wasn't a helper manager associated with the definition. The definition was: ${debugToString(definition)}`);
|
|
482
343
|
}
|
|
483
|
-
|
|
484
344
|
return null;
|
|
485
345
|
}
|
|
486
346
|
function setInternalComponentManager(factory, obj) {
|
|
@@ -490,9 +350,7 @@ function getInternalComponentManager(definition, isOptional) {
|
|
|
490
350
|
if (DEBUG && typeof definition !== 'function' && (typeof definition !== 'object' || definition === null)) {
|
|
491
351
|
throw new Error(`Attempted to use a value as a component, but it was not an object or function. Component definitions must be objects or functions with an associated component manager. The value was: ${definition}`);
|
|
492
352
|
}
|
|
493
|
-
|
|
494
353
|
const manager = getManager(COMPONENT_MANAGERS, definition);
|
|
495
|
-
|
|
496
354
|
if (manager === undefined) {
|
|
497
355
|
if (isOptional === true) {
|
|
498
356
|
return null;
|
|
@@ -500,26 +358,22 @@ function getInternalComponentManager(definition, isOptional) {
|
|
|
500
358
|
throw new Error(`Attempted to load a component, but there wasn't a component manager associated with the definition. The definition was: ${debugToString(definition)}`);
|
|
501
359
|
}
|
|
502
360
|
}
|
|
503
|
-
|
|
504
361
|
return manager;
|
|
505
|
-
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
///////////
|
|
506
365
|
|
|
507
366
|
function hasInternalComponentManager(definition) {
|
|
508
|
-
return
|
|
367
|
+
return getManager(COMPONENT_MANAGERS, definition) !== undefined;
|
|
509
368
|
}
|
|
510
369
|
function hasInternalHelperManager(definition) {
|
|
511
370
|
return hasDefaultHelperManager(definition) || getManager(HELPER_MANAGERS, definition) !== undefined;
|
|
512
371
|
}
|
|
513
372
|
function hasInternalModifierManager(definition) {
|
|
514
|
-
return
|
|
373
|
+
return getManager(MODIFIER_MANAGERS, definition) !== undefined;
|
|
515
374
|
}
|
|
516
|
-
|
|
517
375
|
function hasDefaultHelperManager(definition) {
|
|
518
|
-
|
|
519
|
-
return typeof definition === 'function';
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
return false;
|
|
376
|
+
return typeof definition === 'function';
|
|
523
377
|
}
|
|
524
378
|
|
|
525
379
|
const CAPABILITIES = {
|
|
@@ -537,11 +391,11 @@ const CAPABILITIES = {
|
|
|
537
391
|
willDestroy: false,
|
|
538
392
|
hasSubOwner: false
|
|
539
393
|
};
|
|
540
|
-
function componentCapabilities(managerAPI
|
|
394
|
+
function componentCapabilities(managerAPI) {
|
|
395
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
541
396
|
if (DEBUG && managerAPI !== '3.13') {
|
|
542
397
|
throw new Error('Invalid component manager compatibility specified');
|
|
543
398
|
}
|
|
544
|
-
|
|
545
399
|
let updateHook = Boolean(options.updateHook);
|
|
546
400
|
return buildCapabilities({
|
|
547
401
|
asyncLifeCycleCallbacks: Boolean(options.asyncLifecycleCallbacks),
|
|
@@ -561,6 +415,7 @@ function hasAsyncUpdateHook(delegate) {
|
|
|
561
415
|
function hasDestructors(delegate) {
|
|
562
416
|
return delegate.capabilities.destructor;
|
|
563
417
|
}
|
|
418
|
+
|
|
564
419
|
/**
|
|
565
420
|
The CustomComponentManager allows addons to provide custom component
|
|
566
421
|
implementations that integrate seamlessly into Ember. This is accomplished
|
|
@@ -586,52 +441,42 @@ function hasDestructors(delegate) {
|
|
|
586
441
|
* `update()` - invoked when the arguments passed to a component change
|
|
587
442
|
* `getContext()` - returns the object that should be
|
|
588
443
|
*/
|
|
589
|
-
|
|
590
444
|
class CustomComponentManager {
|
|
445
|
+
componentManagerDelegates = new WeakMap();
|
|
591
446
|
constructor(factory) {
|
|
592
447
|
this.factory = factory;
|
|
593
|
-
this.componentManagerDelegates = new WeakMap();
|
|
594
448
|
}
|
|
595
|
-
|
|
596
449
|
getDelegateFor(owner) {
|
|
597
450
|
let {
|
|
598
451
|
componentManagerDelegates
|
|
599
452
|
} = this;
|
|
600
453
|
let delegate = componentManagerDelegates.get(owner);
|
|
601
|
-
|
|
602
454
|
if (delegate === undefined) {
|
|
603
455
|
let {
|
|
604
456
|
factory
|
|
605
457
|
} = this;
|
|
606
458
|
delegate = factory(owner);
|
|
607
|
-
|
|
608
459
|
if (DEBUG && !FROM_CAPABILITIES.has(delegate.capabilities)) {
|
|
609
460
|
// TODO: This error message should make sense in both Ember and Glimmer https://github.com/glimmerjs/glimmer-vm/issues/1200
|
|
610
461
|
throw new Error(`Custom component managers must have a \`capabilities\` property that is the result of calling the \`capabilities('3.13')\` (imported via \`import { capabilities } from '@ember/component';\`). Received: \`${JSON.stringify(delegate.capabilities)}\` for: \`${delegate}\``);
|
|
611
462
|
}
|
|
612
|
-
|
|
613
463
|
componentManagerDelegates.set(owner, delegate);
|
|
614
464
|
}
|
|
615
|
-
|
|
616
465
|
return delegate;
|
|
617
466
|
}
|
|
618
|
-
|
|
619
467
|
create(owner, definition, vmArgs) {
|
|
620
468
|
let delegate = this.getDelegateFor(owner);
|
|
621
469
|
let args = argsProxyFor(vmArgs.capture(), 'component');
|
|
622
470
|
let component = delegate.createComponent(definition, args);
|
|
623
471
|
return new CustomComponentState(component, delegate, args);
|
|
624
472
|
}
|
|
625
|
-
|
|
626
473
|
getDebugName(definition) {
|
|
627
474
|
return typeof definition === 'function' ? definition.name : definition.toString();
|
|
628
475
|
}
|
|
629
|
-
|
|
630
476
|
update(bucket) {
|
|
631
477
|
let {
|
|
632
478
|
delegate
|
|
633
479
|
} = bucket;
|
|
634
|
-
|
|
635
480
|
if (hasUpdateHook(delegate)) {
|
|
636
481
|
let {
|
|
637
482
|
component,
|
|
@@ -640,41 +485,37 @@ class CustomComponentManager {
|
|
|
640
485
|
delegate.updateComponent(component, args);
|
|
641
486
|
}
|
|
642
487
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
488
|
+
didCreate(_ref) {
|
|
489
|
+
let {
|
|
490
|
+
component,
|
|
491
|
+
delegate
|
|
492
|
+
} = _ref;
|
|
648
493
|
if (hasAsyncLifeCycleCallbacks(delegate)) {
|
|
649
494
|
delegate.didCreateComponent(component);
|
|
650
495
|
}
|
|
651
496
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
497
|
+
didUpdate(_ref2) {
|
|
498
|
+
let {
|
|
499
|
+
component,
|
|
500
|
+
delegate
|
|
501
|
+
} = _ref2;
|
|
657
502
|
if (hasAsyncUpdateHook(delegate)) {
|
|
658
503
|
delegate.didUpdateComponent(component);
|
|
659
504
|
}
|
|
660
505
|
}
|
|
661
|
-
|
|
662
506
|
didRenderLayout() {}
|
|
663
|
-
|
|
664
507
|
didUpdateLayout() {}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
508
|
+
getSelf(_ref3) {
|
|
509
|
+
let {
|
|
510
|
+
component,
|
|
511
|
+
delegate
|
|
512
|
+
} = _ref3;
|
|
670
513
|
return createConstRef(delegate.getContext(component), 'this');
|
|
671
514
|
}
|
|
672
|
-
|
|
673
515
|
getDestroyable(bucket) {
|
|
674
516
|
const {
|
|
675
517
|
delegate
|
|
676
518
|
} = bucket;
|
|
677
|
-
|
|
678
519
|
if (hasDestructors(delegate)) {
|
|
679
520
|
const {
|
|
680
521
|
component
|
|
@@ -682,33 +523,29 @@ class CustomComponentManager {
|
|
|
682
523
|
registerDestructor(bucket, () => delegate.destroyComponent(component));
|
|
683
524
|
return bucket;
|
|
684
525
|
}
|
|
685
|
-
|
|
686
526
|
return null;
|
|
687
527
|
}
|
|
688
|
-
|
|
689
528
|
getCapabilities() {
|
|
690
529
|
return CAPABILITIES;
|
|
691
530
|
}
|
|
692
|
-
|
|
693
531
|
}
|
|
532
|
+
|
|
694
533
|
/**
|
|
695
534
|
* Stores internal state about a component instance after it's been created.
|
|
696
535
|
*/
|
|
697
|
-
|
|
698
536
|
class CustomComponentState {
|
|
699
537
|
constructor(component, delegate, args) {
|
|
700
538
|
this.component = component;
|
|
701
539
|
this.delegate = delegate;
|
|
702
540
|
this.args = args;
|
|
703
541
|
}
|
|
704
|
-
|
|
705
542
|
}
|
|
706
543
|
|
|
707
|
-
function modifierCapabilities(managerAPI
|
|
544
|
+
function modifierCapabilities(managerAPI) {
|
|
545
|
+
let optionalFeatures = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
708
546
|
if (DEBUG && managerAPI !== '3.22') {
|
|
709
547
|
throw new Error('Invalid modifier manager compatibility specified');
|
|
710
548
|
}
|
|
711
|
-
|
|
712
549
|
return buildCapabilities({
|
|
713
550
|
disableAutoTracking: Boolean(optionalFeatures.disableAutoTracking)
|
|
714
551
|
});
|
|
@@ -737,36 +574,29 @@ function modifierCapabilities(managerAPI, optionalFeatures = {}) {
|
|
|
737
574
|
* `updateModifier()` - invoked when the arguments passed to a modifier change
|
|
738
575
|
* `destroyModifier()` - invoked when the modifier is about to be destroyed
|
|
739
576
|
*/
|
|
740
|
-
|
|
741
577
|
class CustomModifierManager {
|
|
578
|
+
componentManagerDelegates = new WeakMap();
|
|
742
579
|
constructor(factory) {
|
|
743
580
|
this.factory = factory;
|
|
744
|
-
this.componentManagerDelegates = new WeakMap();
|
|
745
581
|
}
|
|
746
|
-
|
|
747
582
|
getDelegateFor(owner) {
|
|
748
583
|
let {
|
|
749
584
|
componentManagerDelegates
|
|
750
585
|
} = this;
|
|
751
586
|
let delegate = componentManagerDelegates.get(owner);
|
|
752
|
-
|
|
753
587
|
if (delegate === undefined) {
|
|
754
588
|
let {
|
|
755
589
|
factory
|
|
756
590
|
} = this;
|
|
757
591
|
delegate = factory(owner);
|
|
758
|
-
|
|
759
592
|
if (DEBUG && !FROM_CAPABILITIES.has(delegate.capabilities)) {
|
|
760
593
|
// TODO: This error message should make sense in both Ember and Glimmer https://github.com/glimmerjs/glimmer-vm/issues/1200
|
|
761
594
|
throw new Error(`Custom modifier managers must have a \`capabilities\` property that is the result of calling the \`capabilities('3.22')\` (imported via \`import { capabilities } from '@ember/modifier';\`). Received: \`${JSON.stringify(delegate.capabilities)}\` for: \`${delegate}\``);
|
|
762
595
|
}
|
|
763
|
-
|
|
764
596
|
componentManagerDelegates.set(owner, delegate);
|
|
765
597
|
}
|
|
766
|
-
|
|
767
598
|
return delegate;
|
|
768
599
|
}
|
|
769
|
-
|
|
770
600
|
create(owner, element, definition, capturedArgs) {
|
|
771
601
|
let delegate = this.getDelegateFor(owner);
|
|
772
602
|
let args = argsProxyFor(capturedArgs, 'modifier');
|
|
@@ -780,64 +610,58 @@ class CustomModifierManager {
|
|
|
780
610
|
args,
|
|
781
611
|
modifier: instance
|
|
782
612
|
};
|
|
783
|
-
|
|
784
613
|
if (DEBUG) {
|
|
785
614
|
state.debugName = typeof definition === 'function' ? definition.name : definition.toString();
|
|
786
615
|
}
|
|
787
|
-
|
|
788
616
|
registerDestructor(state, () => delegate.destroyModifier(instance, args));
|
|
789
617
|
return state;
|
|
790
618
|
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
619
|
+
getDebugName(_ref) {
|
|
620
|
+
let {
|
|
621
|
+
debugName
|
|
622
|
+
} = _ref;
|
|
795
623
|
return debugName;
|
|
796
624
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
625
|
+
getTag(_ref2) {
|
|
626
|
+
let {
|
|
627
|
+
tag
|
|
628
|
+
} = _ref2;
|
|
801
629
|
return tag;
|
|
802
630
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
631
|
+
install(_ref3) {
|
|
632
|
+
let {
|
|
633
|
+
element,
|
|
634
|
+
args,
|
|
635
|
+
modifier,
|
|
636
|
+
delegate
|
|
637
|
+
} = _ref3;
|
|
810
638
|
let {
|
|
811
639
|
capabilities
|
|
812
640
|
} = delegate;
|
|
813
|
-
|
|
814
641
|
if (capabilities.disableAutoTracking === true) {
|
|
815
|
-
untrack(() => delegate.installModifier(modifier, element, args));
|
|
642
|
+
untrack(() => delegate.installModifier(modifier, castToBrowser(element, 'ELEMENT'), args));
|
|
816
643
|
} else {
|
|
817
|
-
delegate.installModifier(modifier, element, args);
|
|
644
|
+
delegate.installModifier(modifier, castToBrowser(element, 'ELEMENT'), args);
|
|
818
645
|
}
|
|
819
646
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
647
|
+
update(_ref4) {
|
|
648
|
+
let {
|
|
649
|
+
args,
|
|
650
|
+
modifier,
|
|
651
|
+
delegate
|
|
652
|
+
} = _ref4;
|
|
826
653
|
let {
|
|
827
654
|
capabilities
|
|
828
655
|
} = delegate;
|
|
829
|
-
|
|
830
656
|
if (capabilities.disableAutoTracking === true) {
|
|
831
657
|
untrack(() => delegate.updateModifier(modifier, args));
|
|
832
658
|
} else {
|
|
833
659
|
delegate.updateModifier(modifier, args);
|
|
834
660
|
}
|
|
835
661
|
}
|
|
836
|
-
|
|
837
662
|
getDestroyable(state) {
|
|
838
663
|
return state;
|
|
839
664
|
}
|
|
840
|
-
|
|
841
665
|
}
|
|
842
666
|
|
|
843
667
|
function setComponentManager(factory, obj) {
|
|
@@ -851,32 +675,26 @@ function setHelperManager(factory, obj) {
|
|
|
851
675
|
}
|
|
852
676
|
|
|
853
677
|
const TEMPLATES = new WeakMap();
|
|
854
|
-
const getPrototypeOf
|
|
678
|
+
const getPrototypeOf = Object.getPrototypeOf;
|
|
855
679
|
function setComponentTemplate(factory, obj) {
|
|
856
680
|
if (DEBUG && !(obj !== null && (typeof obj === 'object' || typeof obj === 'function'))) {
|
|
857
681
|
throw new Error(`Cannot call \`setComponentTemplate\` on \`${debugToString(obj)}\``);
|
|
858
682
|
}
|
|
859
|
-
|
|
860
683
|
if (DEBUG && TEMPLATES.has(obj)) {
|
|
861
684
|
throw new Error(`Cannot call \`setComponentTemplate\` multiple times on the same class (\`${debugToString(obj)}\`)`);
|
|
862
685
|
}
|
|
863
|
-
|
|
864
686
|
TEMPLATES.set(obj, factory);
|
|
865
687
|
return obj;
|
|
866
688
|
}
|
|
867
689
|
function getComponentTemplate(obj) {
|
|
868
690
|
let pointer = obj;
|
|
869
|
-
|
|
870
691
|
while (pointer !== null) {
|
|
871
692
|
let template = TEMPLATES.get(pointer);
|
|
872
|
-
|
|
873
693
|
if (template !== undefined) {
|
|
874
694
|
return template;
|
|
875
695
|
}
|
|
876
|
-
|
|
877
|
-
pointer = getPrototypeOf$1(pointer);
|
|
696
|
+
pointer = getPrototypeOf(pointer);
|
|
878
697
|
}
|
|
879
|
-
|
|
880
698
|
return undefined;
|
|
881
699
|
}
|
|
882
700
|
|