ember-source 6.4.0-alpha.2 → 6.4.0-alpha.3
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/ember-template-compiler.js +907 -1527
- package/dist/ember-testing.js +1 -1
- package/dist/ember.debug.js +3574 -4029
- package/dist/ember.prod.js +3408 -3984
- package/dist/packages/@ember/-internals/glimmer/index.js +2 -2
- package/dist/packages/@ember/-internals/owner/index.js +1 -0
- package/dist/packages/@ember/application/index.js +2 -2
- package/dist/packages/@ember/application/instance.js +1 -1
- package/dist/packages/@ember/component/helper.js +1 -1
- package/dist/packages/@ember/component/index.js +1 -1
- package/dist/packages/@ember/debug/lib/capture-render-tree.js +5 -3
- package/dist/packages/@ember/engine/index.js +2 -2
- package/dist/packages/@ember/helper/index.js +1 -1
- package/dist/packages/@ember/modifier/index.js +1 -1
- package/dist/packages/@ember/renderer/index.js +1 -1
- package/dist/packages/@ember/routing/index.js +1 -1
- package/dist/packages/@ember/template/index.js +1 -1
- package/dist/packages/@ember/template-compiler/lib/plugins/index.js +1 -1
- package/dist/packages/@ember/template-compiler/lib/plugins/transform-resolutions.js +1 -1
- package/dist/packages/@ember/template-compiler/lib/template.js +73 -89
- package/dist/packages/@glimmer/destroyable/index.js +45 -16
- package/dist/packages/@glimmer/encoder/index.js +1 -2
- package/dist/packages/@glimmer/global-context/index.js +15 -27
- package/dist/packages/@glimmer/manager/index.js +137 -84
- package/dist/packages/@glimmer/node/index.js +7 -4
- package/dist/packages/@glimmer/opcode-compiler/index.js +564 -534
- package/dist/packages/@glimmer/owner/index.js +1 -0
- package/dist/packages/@glimmer/program/index.js +42 -109
- package/dist/packages/@glimmer/reference/index.js +18 -29
- package/dist/packages/@glimmer/runtime/index.js +3435 -3263
- package/dist/packages/@glimmer/util/index.js +32 -273
- package/dist/packages/@glimmer/validator/index.js +36 -43
- package/dist/packages/@glimmer/vm/index.js +2 -140
- package/dist/packages/@glimmer/wire-format/index.js +1 -2
- package/dist/packages/ember/barrel.js +1 -1
- package/dist/packages/ember/version.js +1 -1
- package/dist/packages/ember-testing/lib/initializers.js +1 -1
- package/dist/packages/shared-chunks/{index-CQygUgr9.js → index-y5ClupI2.js} +50 -45
- package/dist/packages/shared-chunks/{setup-registry-DXuvS1Rj.js → setup-registry-8yPevDL_.js} +1 -1
- package/dist/packages/shared-chunks/{transform-resolutions-O6uYv8DS.js → transform-resolutions-Dpc2ClA0.js} +298 -441
- package/docs/data.json +40 -22
- package/package.json +21 -22
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/outlet.d.ts +1 -1
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/unwrap-template.d.ts +7 -0
- package/types/stable/@ember/-internals/glimmer/lib/renderer.d.ts +7 -9
- package/types/stable/@ember/-internals/glimmer/lib/resolver.d.ts +2 -5
- package/types/stable/index.d.ts +1 -0
- package/dist/packages/@glimmer/debug/index.js +0 -168
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import { isDevelopingApp } from '@embroider/macros';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* This package contains global context functions for Glimmer. These functions
|
|
5
|
-
* are set by the embedding environment and must be set before initial render.
|
|
6
|
-
*
|
|
7
|
-
* These functions should meet the following criteria:
|
|
8
|
-
*
|
|
9
|
-
* - Must be provided by the embedder, due to having framework specific
|
|
10
|
-
* behaviors (e.g. interop with classic Ember behaviors that should not be
|
|
11
|
-
* upstreamed) or to being out of scope for the VM (e.g. scheduling a
|
|
12
|
-
* revalidation)
|
|
13
|
-
* - Never differ between render roots
|
|
14
|
-
* - Never change over time
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
//////////
|
|
18
|
-
/**
|
|
19
|
-
* Interfaces
|
|
20
|
-
*
|
|
21
|
-
* TODO: Move these into @glimmer/interfaces, move @glimmer/interfaces to
|
|
22
|
-
* @glimmer/internal-interfaces.
|
|
23
|
-
*/
|
|
24
3
|
//////////
|
|
25
4
|
/**
|
|
26
5
|
* Schedules a VM revalidation.
|
|
@@ -38,10 +17,7 @@ let scheduleDestroy,
|
|
|
38
17
|
warnIfStyleNotTrusted,
|
|
39
18
|
assert,
|
|
40
19
|
deprecate,
|
|
41
|
-
|
|
42
|
-
testOverrideGlobalContext,
|
|
43
|
-
scheduleRevalidate = () => {},
|
|
44
|
-
globalContextWasSet = !1;
|
|
20
|
+
scheduleRevalidate = () => {};
|
|
45
21
|
|
|
46
22
|
/**
|
|
47
23
|
* Schedules a destructor to run
|
|
@@ -49,6 +25,18 @@ let scheduleDestroy,
|
|
|
49
25
|
* @param destroyable The destroyable being destroyed
|
|
50
26
|
* @param destructor The destructor being scheduled
|
|
51
27
|
*/
|
|
28
|
+
function debugAssert(test, msg, options) {
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
30
|
+
isDevelopingApp() && assert && assert(test, "string" == typeof msg ? msg : msg(), options);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Hook to customize deprecation messages in the VM. Usages can be stripped out
|
|
35
|
+
* by using the @glimmer/vm-babel-plugins package.
|
|
36
|
+
*/
|
|
37
|
+
let assertGlobalContextWasSet,
|
|
38
|
+
testOverrideGlobalContext,
|
|
39
|
+
globalContextWasSet = !1;
|
|
52
40
|
function setGlobalContext(context) {
|
|
53
41
|
if (isDevelopingApp()) {
|
|
54
42
|
if (globalContextWasSet) throw new Error("Attempted to set the global context twice. This should only be set once.");
|
|
@@ -57,7 +45,7 @@ function setGlobalContext(context) {
|
|
|
57
45
|
scheduleRevalidate = context.scheduleRevalidate, scheduleDestroy = context.scheduleDestroy, scheduleDestroyed = context.scheduleDestroyed, toIterator = context.toIterator, toBool = context.toBool, getProp = context.getProp, setProp = context.setProp, getPath = context.getPath, setPath = context.setPath, warnIfStyleNotTrusted = context.warnIfStyleNotTrusted, assert = context.assert, deprecate = context.deprecate;
|
|
58
46
|
}
|
|
59
47
|
isDevelopingApp() && (assertGlobalContextWasSet = () => {
|
|
60
|
-
if (!
|
|
48
|
+
if (!globalContextWasSet) throw new Error("The global context for Glimmer VM was not set. You must set these global context functions to let Glimmer VM know how to accomplish certain operations. You can do this by importing `setGlobalContext` from `@glimmer/global-context`");
|
|
61
49
|
}, testOverrideGlobalContext = context => {
|
|
62
50
|
let originalGlobalContext = globalContextWasSet ? {
|
|
63
51
|
scheduleRevalidate: scheduleRevalidate,
|
|
@@ -79,4 +67,4 @@ isDevelopingApp() && (assertGlobalContextWasSet = () => {
|
|
|
79
67
|
scheduleRevalidate = context?.scheduleRevalidate || void 0, scheduleDestroy = context?.scheduleDestroy || void 0, scheduleDestroyed = context?.scheduleDestroyed || void 0, toIterator = context?.toIterator || void 0, toBool = context?.toBool || void 0, getProp = context?.getProp || void 0, setProp = context?.setProp || void 0, getPath = context?.getPath || void 0, setPath = context?.setPath || void 0, warnIfStyleNotTrusted = context?.warnIfStyleNotTrusted || void 0, assert = context?.assert || void 0, deprecate = context?.deprecate || void 0, originalGlobalContext;
|
|
80
68
|
});
|
|
81
69
|
|
|
82
|
-
export { assert, assertGlobalContextWasSet, setGlobalContext as default, deprecate, getPath, getProp, scheduleDestroy, scheduleDestroyed, scheduleRevalidate, setPath, setProp, testOverrideGlobalContext, toBool, toIterator, warnIfStyleNotTrusted };
|
|
70
|
+
export { assert, assertGlobalContextWasSet, debugAssert, setGlobalContext as default, deprecate, getPath, getProp, scheduleDestroy, scheduleDestroyed, scheduleRevalidate, setPath, setProp, testOverrideGlobalContext, toBool, toIterator, warnIfStyleNotTrusted };
|
|
@@ -1,10 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { debugAssert } from '../global-context/index.js';
|
|
2
2
|
import { associateDestroyableChild, registerDestructor } from '../destroyable/index.js';
|
|
3
3
|
import { createComputeRef, createConstRef, UNDEFINED_REFERENCE, valueForRef } from '../reference/index.js';
|
|
4
|
-
import { untrack, track
|
|
5
|
-
import {
|
|
4
|
+
import { createUpdatableTag, untrack, track } from '../validator/index.js';
|
|
5
|
+
import { InternalComponentCapabilities } from '../vm/index.js';
|
|
6
6
|
import { isDevelopingApp } from '@embroider/macros';
|
|
7
7
|
|
|
8
|
+
let debugToString;
|
|
9
|
+
if (isDevelopingApp()) {
|
|
10
|
+
let getFunctionName = fn => {
|
|
11
|
+
let functionName = fn.name;
|
|
12
|
+
if ("" === functionName) {
|
|
13
|
+
let match = /function (\w+)\s*\(/u.exec(String(fn));
|
|
14
|
+
functionName = match && match[1] || "";
|
|
15
|
+
}
|
|
16
|
+
return functionName.replace(/^bound /u, "");
|
|
17
|
+
},
|
|
18
|
+
getObjectName = obj => {
|
|
19
|
+
let name, className;
|
|
20
|
+
// If the class has a decent looking name, and the `toString` is one of the
|
|
21
|
+
// default Ember toStrings, replace the constructor portion of the toString
|
|
22
|
+
// with the class name. We check the length of the class name to prevent doing
|
|
23
|
+
// this when the value is minified.
|
|
24
|
+
return "function" == typeof obj.constructor && (className = getFunctionName(obj.constructor)), "toString" in obj && obj.toString !== Object.prototype.toString && obj.toString !== Function.prototype.toString && (
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
26
|
+
name = obj.toString()), name && /<.*:ember\d+>/u.test(name) && className && "_" !== className[0] && className.length > 2 && "Class" !== className ? name.replace(/<.*:/u, `<${className}:`) : name || className;
|
|
27
|
+
},
|
|
28
|
+
getPrimitiveName = value => String(value);
|
|
29
|
+
debugToString = value => "function" == typeof value ? getFunctionName(value) || "(unknown function)" : "object" == typeof value && null !== value ? getObjectName(value) || "(unknown object)" : getPrimitiveName(value);
|
|
30
|
+
}
|
|
31
|
+
var debugToString$1 = debugToString;
|
|
8
32
|
const CUSTOM_TAG_FOR = new WeakMap();
|
|
9
33
|
function getCustomTagFor(obj) {
|
|
10
34
|
return CUSTOM_TAG_FOR.get(obj);
|
|
@@ -17,14 +41,18 @@ function convertToInt(prop) {
|
|
|
17
41
|
const num = Number(prop);
|
|
18
42
|
return isNaN(num) ? null : num % 1 == 0 ? num : null;
|
|
19
43
|
}
|
|
44
|
+
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- @fixme
|
|
20
46
|
class NamedArgsProxy {
|
|
21
47
|
constructor(named) {
|
|
22
48
|
this.named = named;
|
|
23
49
|
}
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- @fixme
|
|
24
51
|
get(_target, prop) {
|
|
25
52
|
const ref = this.named[prop];
|
|
26
53
|
if (void 0 !== ref) return valueForRef(ref);
|
|
27
54
|
}
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- @fixme
|
|
28
56
|
has(_target, prop) {
|
|
29
57
|
return prop in this.named;
|
|
30
58
|
}
|
|
@@ -34,6 +62,7 @@ class NamedArgsProxy {
|
|
|
34
62
|
isExtensible() {
|
|
35
63
|
return !1;
|
|
36
64
|
}
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- @fixme
|
|
37
66
|
getOwnPropertyDescriptor(_target, prop) {
|
|
38
67
|
if (isDevelopingApp() && !(prop in this.named)) 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)}\``);
|
|
39
68
|
return {
|
|
@@ -53,6 +82,7 @@ class PositionalArgsProxy {
|
|
|
53
82
|
if ("length" === prop) return positional.length;
|
|
54
83
|
const parsed = convertToInt(prop);
|
|
55
84
|
return null !== parsed && parsed < positional.length ? valueForRef(positional[parsed]) : target[prop];
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
|
|
56
86
|
}
|
|
57
87
|
isExtensible() {
|
|
58
88
|
return !1;
|
|
@@ -63,49 +93,54 @@ class PositionalArgsProxy {
|
|
|
63
93
|
}
|
|
64
94
|
}
|
|
65
95
|
const argsProxyFor = (capturedArgs, type) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
const {
|
|
97
|
+
named: named,
|
|
98
|
+
positional: positional
|
|
99
|
+
} = capturedArgs,
|
|
100
|
+
namedHandler = new NamedArgsProxy(named),
|
|
101
|
+
positionalHandler = new PositionalArgsProxy(positional),
|
|
102
|
+
namedTarget = Object.create(null);
|
|
103
|
+
if (isDevelopingApp()) {
|
|
104
|
+
const setHandler = function (_target, prop) {
|
|
105
|
+
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.`);
|
|
106
|
+
},
|
|
107
|
+
forInDebugHandler = () => {
|
|
108
|
+
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.`);
|
|
109
|
+
};
|
|
110
|
+
namedHandler.set = setHandler, positionalHandler.set = setHandler, positionalHandler.ownKeys = forInDebugHandler;
|
|
111
|
+
}
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
113
|
+
const namedProxy = new Proxy(namedTarget, namedHandler),
|
|
114
|
+
positionalProxy = new Proxy([], positionalHandler);
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
116
|
+
return setCustomTagFor(namedProxy, (_obj, key) => function (namedArgs, key) {
|
|
117
|
+
return track(() => {
|
|
118
|
+
key in namedArgs &&
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
120
|
+
valueForRef(namedArgs[key]);
|
|
121
|
+
});
|
|
122
|
+
}(named, key)), setCustomTagFor(positionalProxy, (_obj, key) => function (positionalArgs, key) {
|
|
123
|
+
return track(() => {
|
|
124
|
+
"[]" === key &&
|
|
125
|
+
// consume all of the tags in the positional array
|
|
126
|
+
positionalArgs.forEach(valueForRef);
|
|
127
|
+
const parsed = convertToInt(key);
|
|
128
|
+
null !== parsed && parsed < positionalArgs.length &&
|
|
129
|
+
// consume the tag of the referenced index
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
131
|
+
valueForRef(positionalArgs[parsed]);
|
|
132
|
+
});
|
|
133
|
+
}(positional, key)), {
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
135
|
+
named: namedProxy,
|
|
136
|
+
positional: positionalProxy
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
FROM_CAPABILITIES = isDevelopingApp() ? new WeakSet() : void 0;
|
|
107
140
|
function buildCapabilities(capabilities) {
|
|
108
|
-
return isDevelopingApp() && (
|
|
141
|
+
return isDevelopingApp() && (
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
143
|
+
FROM_CAPABILITIES.add(capabilities), Object.freeze(capabilities)), capabilities;
|
|
109
144
|
}
|
|
110
145
|
const EMPTY = InternalComponentCapabilities.Empty;
|
|
111
146
|
|
|
@@ -125,8 +160,9 @@ function hasCapability(capabilities, capability) {
|
|
|
125
160
|
return !!(capabilities & capability);
|
|
126
161
|
}
|
|
127
162
|
function helperCapabilities(managerAPI, options = {}) {
|
|
128
|
-
if (
|
|
129
|
-
|
|
163
|
+
if (debugAssert(
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- JS-only check
|
|
165
|
+
"3.23" === managerAPI, () => `Invalid helper manager compatibility specified; you specified ${managerAPI}, but only '3.23' is supported.`), isDevelopingApp() && (!options.hasValue && !options.hasScheduledEffect || options.hasValue && options.hasScheduledEffect)) 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.");
|
|
130
166
|
if (isDevelopingApp() && options.hasScheduledEffect) throw new Error("The `hasScheduledEffect` capability has not yet been implemented for helper managers. Please pass `hasValue` instead");
|
|
131
167
|
return buildCapabilities({
|
|
132
168
|
hasValue: Boolean(options.hasValue),
|
|
@@ -146,16 +182,15 @@ function hasDestroyable(manager) {
|
|
|
146
182
|
////////////
|
|
147
183
|
class CustomHelperManager {
|
|
148
184
|
constructor(factory) {
|
|
149
|
-
this.factory = factory;
|
|
185
|
+
this.factory = factory, this.helperManagerDelegates = new WeakMap(), this.undefinedDelegate = null;
|
|
150
186
|
}
|
|
151
|
-
helperManagerDelegates = new WeakMap();
|
|
152
|
-
undefinedDelegate = null;
|
|
153
187
|
getDelegateForOwner(owner) {
|
|
154
188
|
let delegate = this.helperManagerDelegates.get(owner);
|
|
155
189
|
if (void 0 === delegate) {
|
|
156
190
|
let {
|
|
157
191
|
factory: factory
|
|
158
192
|
} = this;
|
|
193
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
159
194
|
if (delegate = factory(owner), isDevelopingApp() && !FROM_CAPABILITIES.has(delegate.capabilities))
|
|
160
195
|
// TODO: This error message should make sense in both Ember and Glimmer https://github.com/glimmerjs/glimmer-vm/issues/1200
|
|
161
196
|
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}\``);
|
|
@@ -196,11 +231,6 @@ class CustomHelperManager {
|
|
|
196
231
|
}
|
|
197
232
|
}
|
|
198
233
|
class FunctionHelperManager {
|
|
199
|
-
capabilities = buildCapabilities({
|
|
200
|
-
hasValue: !0,
|
|
201
|
-
hasDestroyable: !1,
|
|
202
|
-
hasScheduledEffect: !1
|
|
203
|
-
});
|
|
204
234
|
createHelper(fn, args) {
|
|
205
235
|
return {
|
|
206
236
|
fn: fn,
|
|
@@ -216,19 +246,28 @@ class FunctionHelperManager {
|
|
|
216
246
|
getDebugName(fn) {
|
|
217
247
|
return fn.name ? `(helper function ${fn.name})` : "(anonymous helper function)";
|
|
218
248
|
}
|
|
249
|
+
constructor() {
|
|
250
|
+
this.capabilities = buildCapabilities({
|
|
251
|
+
hasValue: !0,
|
|
252
|
+
hasDestroyable: !1,
|
|
253
|
+
hasScheduledEffect: !1
|
|
254
|
+
});
|
|
255
|
+
}
|
|
219
256
|
}
|
|
220
257
|
const COMPONENT_MANAGERS = new WeakMap(),
|
|
221
258
|
MODIFIER_MANAGERS = new WeakMap(),
|
|
222
259
|
HELPER_MANAGERS = new WeakMap(),
|
|
223
260
|
getPrototypeOf$1 = Object.getPrototypeOf;
|
|
224
261
|
function setManager(map, manager, obj) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
262
|
+
return isDevelopingApp() && (debugAssert(
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- JS-only check
|
|
264
|
+
null !== obj && ("object" == typeof obj || "function" == typeof obj),
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
266
|
+
`Attempted to set a manager on a non-object value. Managers can only be associated with objects or functions. Value was ${debugToString$1(obj)}`), debugAssert(!map.has(obj), `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$1(obj)}`)), map.set(obj, manager), obj;
|
|
228
267
|
}
|
|
229
268
|
function getManager(map, obj) {
|
|
230
269
|
let pointer = obj;
|
|
231
|
-
for (; null
|
|
270
|
+
for (; null !== pointer;) {
|
|
232
271
|
const manager = map.get(pointer);
|
|
233
272
|
if (void 0 !== manager) return manager;
|
|
234
273
|
pointer = getPrototypeOf$1(pointer);
|
|
@@ -240,39 +279,49 @@ function setInternalModifierManager(manager, definition) {
|
|
|
240
279
|
return setManager(MODIFIER_MANAGERS, manager, definition);
|
|
241
280
|
}
|
|
242
281
|
function getInternalModifierManager(definition, isOptional) {
|
|
243
|
-
|
|
282
|
+
isDevelopingApp() && debugAssert(
|
|
283
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- JS-only check
|
|
284
|
+
"object" == typeof definition && null !== definition || "function" == typeof definition, () =>
|
|
285
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- @fixme
|
|
286
|
+
`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}`);
|
|
244
287
|
const manager = getManager(MODIFIER_MANAGERS, definition);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
return manager;
|
|
288
|
+
return void 0 === manager ? (isDevelopingApp() && debugAssert(isOptional,
|
|
289
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
290
|
+
`Attempted to load a modifier, but there wasn't a modifier manager associated with the definition. The definition was: ${debugToString$1(definition)}`), null) : manager;
|
|
250
291
|
}
|
|
251
292
|
function setInternalHelperManager(manager, definition) {
|
|
252
293
|
return setManager(HELPER_MANAGERS, manager, definition);
|
|
253
294
|
}
|
|
254
295
|
const DEFAULT_MANAGER = new CustomHelperManager(() => new FunctionHelperManager());
|
|
255
296
|
function getInternalHelperManager(definition, isOptional) {
|
|
256
|
-
|
|
297
|
+
debugAssert(
|
|
298
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- JS-only check
|
|
299
|
+
"object" == typeof definition && null !== definition || "function" == typeof definition, () =>
|
|
300
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- @fixme
|
|
301
|
+
`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}`);
|
|
257
302
|
let manager = getManager(HELPER_MANAGERS, definition);
|
|
258
303
|
// Functions are special-cased because functions are defined
|
|
259
304
|
// as the "default" helper, per: https://github.com/emberjs/rfcs/pull/756
|
|
260
305
|
if (void 0 === manager && "function" == typeof definition && (manager = DEFAULT_MANAGER), manager) return manager;
|
|
261
306
|
if (!0 === isOptional) return null;
|
|
262
|
-
if (isDevelopingApp()) throw new Error(
|
|
307
|
+
if (isDevelopingApp()) throw new Error(
|
|
308
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
309
|
+
`Attempted to load a helper, but there wasn't a helper manager associated with the definition. The definition was: ${debugToString$1(definition)}`);
|
|
263
310
|
return null;
|
|
264
311
|
}
|
|
265
312
|
function setInternalComponentManager(factory, obj) {
|
|
266
313
|
return setManager(COMPONENT_MANAGERS, factory, obj);
|
|
267
314
|
}
|
|
268
315
|
function getInternalComponentManager(definition, isOptional) {
|
|
269
|
-
|
|
316
|
+
debugAssert(
|
|
317
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- JS-only check
|
|
318
|
+
"object" == typeof definition && null !== definition || "function" == typeof definition, () =>
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- @fixme
|
|
320
|
+
`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}`);
|
|
270
321
|
const manager = getManager(COMPONENT_MANAGERS, definition);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
return manager;
|
|
322
|
+
return void 0 === manager ? (debugAssert(isOptional, () =>
|
|
323
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
324
|
+
`Attempted to load a component, but there wasn't a component manager associated with the definition. The definition was: ${debugToString$1(definition)}`), null) : manager;
|
|
276
325
|
}
|
|
277
326
|
|
|
278
327
|
///////////
|
|
@@ -344,9 +393,8 @@ function hasUpdateHook(delegate) {
|
|
|
344
393
|
* `getContext()` - returns the object that should be
|
|
345
394
|
*/
|
|
346
395
|
class CustomComponentManager {
|
|
347
|
-
componentManagerDelegates = new WeakMap();
|
|
348
396
|
constructor(factory) {
|
|
349
|
-
this.factory = factory;
|
|
397
|
+
this.factory = factory, this.componentManagerDelegates = new WeakMap();
|
|
350
398
|
}
|
|
351
399
|
getDelegateFor(owner) {
|
|
352
400
|
let {
|
|
@@ -357,6 +405,7 @@ class CustomComponentManager {
|
|
|
357
405
|
let {
|
|
358
406
|
factory: factory
|
|
359
407
|
} = this;
|
|
408
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
360
409
|
if (delegate = factory(owner), isDevelopingApp() && !FROM_CAPABILITIES.has(delegate.capabilities))
|
|
361
410
|
// TODO: This error message should make sense in both Ember and Glimmer https://github.com/glimmerjs/glimmer-vm/issues/1200
|
|
362
411
|
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}\``);
|
|
@@ -371,6 +420,7 @@ class CustomComponentManager {
|
|
|
371
420
|
return new CustomComponentState(component, delegate, args);
|
|
372
421
|
}
|
|
373
422
|
getDebugName(definition) {
|
|
423
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
374
424
|
return "function" == typeof definition ? definition.name : definition.toString();
|
|
375
425
|
}
|
|
376
426
|
update(bucket) {
|
|
@@ -435,8 +485,7 @@ class CustomComponentState {
|
|
|
435
485
|
}
|
|
436
486
|
}
|
|
437
487
|
function modifierCapabilities(managerAPI, optionalFeatures = {}) {
|
|
438
|
-
|
|
439
|
-
return buildCapabilities({
|
|
488
|
+
return debugAssert("3.22" === managerAPI, () => `Invalid modifier manager compatibility specified; you specified ${managerAPI}, but only '3.22' is supported.`), buildCapabilities({
|
|
440
489
|
disableAutoTracking: Boolean(optionalFeatures.disableAutoTracking)
|
|
441
490
|
});
|
|
442
491
|
}
|
|
@@ -466,9 +515,8 @@ function modifierCapabilities(managerAPI, optionalFeatures = {}) {
|
|
|
466
515
|
* `destroyModifier()` - invoked when the modifier is about to be destroyed
|
|
467
516
|
*/
|
|
468
517
|
class CustomModifierManager {
|
|
469
|
-
componentManagerDelegates = new WeakMap();
|
|
470
518
|
constructor(factory) {
|
|
471
|
-
this.factory = factory;
|
|
519
|
+
this.factory = factory, this.componentManagerDelegates = new WeakMap();
|
|
472
520
|
}
|
|
473
521
|
getDelegateFor(owner) {
|
|
474
522
|
let {
|
|
@@ -479,6 +527,7 @@ class CustomModifierManager {
|
|
|
479
527
|
let {
|
|
480
528
|
factory: factory
|
|
481
529
|
} = this;
|
|
530
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
482
531
|
if (delegate = factory(owner), isDevelopingApp() && !FROM_CAPABILITIES.has(delegate.capabilities))
|
|
483
532
|
// TODO: This error message should make sense in both Ember and Glimmer https://github.com/glimmerjs/glimmer-vm/issues/1200
|
|
484
533
|
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}\``);
|
|
@@ -521,7 +570,7 @@ class CustomModifierManager {
|
|
|
521
570
|
let {
|
|
522
571
|
capabilities: capabilities
|
|
523
572
|
} = delegate;
|
|
524
|
-
|
|
573
|
+
capabilities.disableAutoTracking ? untrack(() => delegate.installModifier(modifier, element, args)) : delegate.installModifier(modifier, element, args);
|
|
525
574
|
}
|
|
526
575
|
update({
|
|
527
576
|
args: args,
|
|
@@ -531,7 +580,7 @@ class CustomModifierManager {
|
|
|
531
580
|
let {
|
|
532
581
|
capabilities: capabilities
|
|
533
582
|
} = delegate;
|
|
534
|
-
|
|
583
|
+
capabilities.disableAutoTracking ? untrack(() => delegate.updateModifier(modifier, args)) : delegate.updateModifier(modifier, args);
|
|
535
584
|
}
|
|
536
585
|
getDestroyable(state) {
|
|
537
586
|
return state;
|
|
@@ -547,10 +596,14 @@ function setHelperManager(factory, obj) {
|
|
|
547
596
|
return setInternalHelperManager(new CustomHelperManager(factory), obj);
|
|
548
597
|
}
|
|
549
598
|
const TEMPLATES = new WeakMap(),
|
|
550
|
-
getPrototypeOf =
|
|
599
|
+
getPrototypeOf = Reflect.getPrototypeOf;
|
|
551
600
|
function setComponentTemplate(factory, obj) {
|
|
552
|
-
if (isDevelopingApp() && (null === obj || "object" != typeof obj && "function" != typeof obj))
|
|
553
|
-
|
|
601
|
+
if (isDevelopingApp() && (null === obj || "object" != typeof obj && "function" != typeof obj))
|
|
602
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
603
|
+
throw new Error(`Cannot call \`setComponentTemplate\` on \`${debugToString$1(obj)}\``);
|
|
604
|
+
if (isDevelopingApp() && TEMPLATES.has(obj)) throw new Error(
|
|
605
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
606
|
+
`Cannot call \`setComponentTemplate\` multiple times on the same class (\`${debugToString$1(obj)}\`)`);
|
|
554
607
|
return TEMPLATES.set(obj, factory), obj;
|
|
555
608
|
}
|
|
556
609
|
function getComponentTemplate(obj) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { DOMTreeConstruction, ConcreteBounds,
|
|
1
|
+
import { DOMTreeConstruction, ConcreteBounds, NewTreeBuilder } from '../runtime/index.js';
|
|
2
2
|
import createHTMLDocument from '../../@simple-dom/document/index.js';
|
|
3
3
|
|
|
4
4
|
class NodeDOMTreeConstruction extends DOMTreeConstruction {
|
|
5
|
-
// Hides property on base class
|
|
6
5
|
constructor(doc) {
|
|
7
6
|
super(doc || createHTMLDocument());
|
|
8
7
|
}
|
|
9
8
|
// override to prevent usage of `this.document` until after the constructor
|
|
10
9
|
setupUselessElement() {}
|
|
11
10
|
insertHTMLBefore(parent, reference, html) {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated, @typescript-eslint/no-non-null-assertion
|
|
12
12
|
let raw = this.document.createRawHTMLSection(html);
|
|
13
13
|
return parent.insertBefore(raw, reference), new ConcreteBounds(parent, raw, raw);
|
|
14
14
|
}
|
|
@@ -22,8 +22,7 @@ class NodeDOMTreeConstruction extends DOMTreeConstruction {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
const NEEDS_EXTRA_CLOSE = new WeakMap();
|
|
25
|
-
class SerializeBuilder extends
|
|
26
|
-
serializeBlockDepth = 0;
|
|
25
|
+
class SerializeBuilder extends NewTreeBuilder {
|
|
27
26
|
__openBlock() {
|
|
28
27
|
let {
|
|
29
28
|
tagName: tagName
|
|
@@ -80,6 +79,7 @@ class SerializeBuilder extends NewElementBuilder {
|
|
|
80
79
|
// under the auto inserted tbody. Rehydration builder needs to
|
|
81
80
|
// account for the insertion since it is injected here and not
|
|
82
81
|
// really in the template.
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
83
83
|
NEEDS_EXTRA_CLOSE.set(this.constructing, !0), this.flushElement(null)), super.openElement(tag);
|
|
84
84
|
}
|
|
85
85
|
pushRemoteElement(element, cursorId, insertBefore = null) {
|
|
@@ -89,6 +89,9 @@ class SerializeBuilder extends NewElementBuilder {
|
|
|
89
89
|
script = dom.createElement("script");
|
|
90
90
|
return script.setAttribute("glmr", cursorId), dom.insertBefore(element, script, insertBefore), super.pushRemoteElement(element, cursorId, insertBefore);
|
|
91
91
|
}
|
|
92
|
+
constructor(...args) {
|
|
93
|
+
super(...args), this.serializeBlockDepth = 0;
|
|
94
|
+
}
|
|
92
95
|
}
|
|
93
96
|
function serializeBuilder(env, cursor) {
|
|
94
97
|
return SerializeBuilder.forInitialRender(env, cursor);
|