ember-source 6.0.0-alpha.9 → 6.0.0
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/blueprints/component/index.js +8 -71
- package/blueprints/component-class/index.js +8 -47
- package/build-metadata.json +3 -3
- package/dist/ember-template-compiler.js +4200 -6302
- package/dist/ember-testing.js +1 -1
- package/dist/ember.debug.js +4040 -8666
- package/dist/ember.prod.js +3734 -8082
- package/dist/packages/@glimmer/debug/index.js +87 -1440
- package/dist/packages/@glimmer/destroyable/index.js +59 -113
- package/dist/packages/@glimmer/encoder/index.js +4 -11
- package/dist/packages/@glimmer/global-context/index.js +40 -144
- package/dist/packages/@glimmer/manager/index.js +191 -312
- package/dist/packages/@glimmer/node/index.js +34 -76
- package/dist/packages/@glimmer/opcode-compiler/index.js +794 -1422
- package/dist/packages/@glimmer/owner/index.js +2 -1
- package/dist/packages/@glimmer/program/index.js +105 -192
- package/dist/packages/@glimmer/reference/index.js +109 -237
- package/dist/packages/@glimmer/runtime/index.js +1939 -3715
- package/dist/packages/@glimmer/util/index.js +114 -241
- package/dist/packages/@glimmer/validator/index.js +203 -409
- package/dist/packages/@glimmer/vm/index.js +163 -176
- package/dist/packages/@glimmer/wire-format/index.js +70 -71
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +1 -1
- package/lib/browsers.js +40 -68
- package/package.json +21 -24
|
@@ -2,169 +2,115 @@ import { scheduleDestroyed, scheduleDestroy } from '../global-context/index.js';
|
|
|
2
2
|
import { debugToString as debugToString$1 } from '../util/index.js';
|
|
3
3
|
import { isDevelopingApp } from '@embroider/macros';
|
|
4
4
|
|
|
5
|
-
var DestroyingState =
|
|
6
|
-
DestroyingState[DestroyingState
|
|
7
|
-
DestroyingState[DestroyingState["Destroying"] = 1] = "Destroying";
|
|
8
|
-
DestroyingState[DestroyingState["Destroyed"] = 2] = "Destroyed";
|
|
9
|
-
return DestroyingState;
|
|
5
|
+
var DestroyingState = function (DestroyingState) {
|
|
6
|
+
return DestroyingState[DestroyingState.Live = 0] = "Live", DestroyingState[DestroyingState.Destroying = 1] = "Destroying", DestroyingState[DestroyingState.Destroyed = 2] = "Destroyed", DestroyingState;
|
|
10
7
|
}(DestroyingState || {});
|
|
11
|
-
let
|
|
8
|
+
let enableDestroyableTracking,
|
|
9
|
+
assertDestroyablesDestroyed,
|
|
10
|
+
DESTROYABLE_META = new WeakMap();
|
|
12
11
|
function push(collection, newItem) {
|
|
13
|
-
|
|
14
|
-
return newItem;
|
|
15
|
-
} else if (Array.isArray(collection)) {
|
|
16
|
-
collection.push(newItem);
|
|
17
|
-
return collection;
|
|
18
|
-
} else {
|
|
19
|
-
return [collection, newItem];
|
|
20
|
-
}
|
|
12
|
+
return null === collection ? newItem : Array.isArray(collection) ? (collection.push(newItem), collection) : [collection, newItem];
|
|
21
13
|
}
|
|
22
14
|
function iterate(collection, fn) {
|
|
23
|
-
|
|
24
|
-
collection.forEach(fn);
|
|
25
|
-
} else if (collection !== null) {
|
|
26
|
-
fn(collection);
|
|
27
|
-
}
|
|
15
|
+
Array.isArray(collection) ? collection.forEach(fn) : null !== collection && fn(collection);
|
|
28
16
|
}
|
|
29
17
|
function remove(collection, item, message) {
|
|
30
18
|
if (isDevelopingApp()) {
|
|
31
|
-
let collectionIsItem = collection === item
|
|
32
|
-
|
|
33
|
-
if (!collectionIsItem && !collectionContainsItem)
|
|
34
|
-
throw new Error(String(message));
|
|
35
|
-
}
|
|
19
|
+
let collectionIsItem = collection === item,
|
|
20
|
+
collectionContainsItem = Array.isArray(collection) && -1 !== collection.indexOf(item);
|
|
21
|
+
if (!collectionIsItem && !collectionContainsItem) throw new Error(String(message));
|
|
36
22
|
}
|
|
37
23
|
if (Array.isArray(collection) && collection.length > 1) {
|
|
38
24
|
let index = collection.indexOf(item);
|
|
39
|
-
collection.splice(index, 1);
|
|
40
|
-
return collection;
|
|
41
|
-
} else {
|
|
42
|
-
return null;
|
|
25
|
+
return collection.splice(index, 1), collection;
|
|
43
26
|
}
|
|
27
|
+
return null;
|
|
44
28
|
}
|
|
45
29
|
function getDestroyableMeta(destroyable) {
|
|
46
30
|
let meta = DESTROYABLE_META.get(destroyable);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
if (isDevelopingApp()) {
|
|
56
|
-
meta.source = destroyable;
|
|
57
|
-
}
|
|
58
|
-
DESTROYABLE_META.set(destroyable, meta);
|
|
59
|
-
}
|
|
60
|
-
return meta;
|
|
31
|
+
return void 0 === meta && (meta = {
|
|
32
|
+
parents: null,
|
|
33
|
+
children: null,
|
|
34
|
+
eagerDestructors: null,
|
|
35
|
+
destructors: null,
|
|
36
|
+
state: DestroyingState.Live
|
|
37
|
+
}, isDevelopingApp() && (meta.source = destroyable), DESTROYABLE_META.set(destroyable, meta)), meta;
|
|
61
38
|
}
|
|
62
39
|
function associateDestroyableChild(parent, child) {
|
|
63
|
-
if (isDevelopingApp() && isDestroying(parent))
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
let childMeta = getDestroyableMeta(child);
|
|
68
|
-
parentMeta.children = push(parentMeta.children, child);
|
|
69
|
-
childMeta.parents = push(childMeta.parents, parent);
|
|
70
|
-
return child;
|
|
40
|
+
if (isDevelopingApp() && isDestroying(parent)) throw new Error("Attempted to associate a destroyable child with an object that is already destroying or destroyed");
|
|
41
|
+
let parentMeta = getDestroyableMeta(parent),
|
|
42
|
+
childMeta = getDestroyableMeta(child);
|
|
43
|
+
return parentMeta.children = push(parentMeta.children, child), childMeta.parents = push(childMeta.parents, parent), child;
|
|
71
44
|
}
|
|
72
|
-
function registerDestructor(destroyable, destructor, eager =
|
|
73
|
-
if (isDevelopingApp() && isDestroying(destroyable))
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
let destructorsKey = eager === true ? 'eagerDestructors' : 'destructors';
|
|
78
|
-
meta[destructorsKey] = push(meta[destructorsKey], destructor);
|
|
79
|
-
return destructor;
|
|
45
|
+
function registerDestructor(destroyable, destructor, eager = !1) {
|
|
46
|
+
if (isDevelopingApp() && isDestroying(destroyable)) throw new Error("Attempted to register a destructor with an object that is already destroying or destroyed");
|
|
47
|
+
let meta = getDestroyableMeta(destroyable),
|
|
48
|
+
destructorsKey = !0 === eager ? "eagerDestructors" : "destructors";
|
|
49
|
+
return meta[destructorsKey] = push(meta[destructorsKey], destructor), destructor;
|
|
80
50
|
}
|
|
81
|
-
function unregisterDestructor(destroyable, destructor, eager =
|
|
82
|
-
if (isDevelopingApp() && isDestroying(destroyable))
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
let destructorsKey = eager === true ? 'eagerDestructors' : 'destructors';
|
|
87
|
-
meta[destructorsKey] = remove(meta[destructorsKey], destructor, isDevelopingApp() && 'attempted to remove a destructor that was not registered with the destroyable');
|
|
51
|
+
function unregisterDestructor(destroyable, destructor, eager = !1) {
|
|
52
|
+
if (isDevelopingApp() && isDestroying(destroyable)) throw new Error("Attempted to unregister a destructor with an object that is already destroying or destroyed");
|
|
53
|
+
let meta = getDestroyableMeta(destroyable),
|
|
54
|
+
destructorsKey = !0 === eager ? "eagerDestructors" : "destructors";
|
|
55
|
+
meta[destructorsKey] = remove(meta[destructorsKey], destructor, isDevelopingApp() && "attempted to remove a destructor that was not registered with the destroyable");
|
|
88
56
|
}
|
|
89
57
|
|
|
90
58
|
////////////
|
|
91
|
-
|
|
92
59
|
function destroy(destroyable) {
|
|
93
60
|
let meta = getDestroyableMeta(destroyable);
|
|
94
61
|
if (meta.state >= DestroyingState.Destroying) return;
|
|
95
62
|
let {
|
|
96
|
-
parents,
|
|
97
|
-
children,
|
|
98
|
-
eagerDestructors,
|
|
99
|
-
destructors
|
|
63
|
+
parents: parents,
|
|
64
|
+
children: children,
|
|
65
|
+
eagerDestructors: eagerDestructors,
|
|
66
|
+
destructors: destructors
|
|
100
67
|
} = meta;
|
|
101
|
-
meta.state = DestroyingState.Destroying
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
iterate(parents, parent => removeChildFromParent(destroyable, parent));
|
|
107
|
-
meta.state = DestroyingState.Destroyed;
|
|
68
|
+
meta.state = DestroyingState.Destroying, iterate(children, destroy), iterate(eagerDestructors, destructor => destructor(destroyable)), iterate(destructors, destructor => scheduleDestroy(destroyable, destructor)), scheduleDestroyed(() => {
|
|
69
|
+
iterate(parents, parent => function (child, parent) {
|
|
70
|
+
let parentMeta = getDestroyableMeta(parent);
|
|
71
|
+
parentMeta.state === DestroyingState.Live && (parentMeta.children = remove(parentMeta.children, child, isDevelopingApp() && "attempted to remove child from parent, but the parent's children did not contain the child. This is likely a bug with destructors."));
|
|
72
|
+
}(destroyable, parent)), meta.state = DestroyingState.Destroyed;
|
|
108
73
|
});
|
|
109
74
|
}
|
|
110
|
-
function removeChildFromParent(child, parent) {
|
|
111
|
-
let parentMeta = getDestroyableMeta(parent);
|
|
112
|
-
if (parentMeta.state === DestroyingState.Live) {
|
|
113
|
-
parentMeta.children = remove(parentMeta.children, child, isDevelopingApp() && "attempted to remove child from parent, but the parent's children did not contain the child. This is likely a bug with destructors.");
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
75
|
function destroyChildren(destroyable) {
|
|
117
76
|
let {
|
|
118
|
-
children
|
|
77
|
+
children: children
|
|
119
78
|
} = getDestroyableMeta(destroyable);
|
|
120
79
|
iterate(children, destroy);
|
|
121
80
|
}
|
|
122
81
|
function _hasDestroyableChildren(destroyable) {
|
|
123
82
|
let meta = DESTROYABLE_META.get(destroyable);
|
|
124
|
-
return
|
|
83
|
+
return void 0 !== meta && null !== meta.children;
|
|
125
84
|
}
|
|
126
85
|
function isDestroying(destroyable) {
|
|
127
86
|
let meta = DESTROYABLE_META.get(destroyable);
|
|
128
|
-
return
|
|
87
|
+
return void 0 !== meta && meta.state >= DestroyingState.Destroying;
|
|
129
88
|
}
|
|
130
89
|
function isDestroyed(destroyable) {
|
|
131
90
|
let meta = DESTROYABLE_META.get(destroyable);
|
|
132
|
-
return
|
|
91
|
+
return void 0 !== meta && meta.state >= DestroyingState.Destroyed;
|
|
133
92
|
}
|
|
134
93
|
|
|
135
94
|
////////////
|
|
136
|
-
|
|
137
|
-
let enableDestroyableTracking;
|
|
138
|
-
let assertDestroyablesDestroyed;
|
|
139
95
|
if (isDevelopingApp()) {
|
|
140
|
-
let isTesting =
|
|
96
|
+
let isTesting = !1;
|
|
141
97
|
enableDestroyableTracking = () => {
|
|
142
|
-
if (isTesting)
|
|
98
|
+
if (isTesting)
|
|
143
99
|
// Reset destroyable meta just in case, before throwing the error
|
|
144
|
-
DESTROYABLE_META = new WeakMap();
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
isTesting
|
|
148
|
-
|
|
149
|
-
};
|
|
150
|
-
assertDestroyablesDestroyed = () => {
|
|
151
|
-
if (!isTesting) {
|
|
152
|
-
throw new Error('Attempted to assert destroyables destroyed, but you did not start a destroyable test. Did you forget to call `enableDestroyableTracking()`');
|
|
153
|
-
}
|
|
154
|
-
isTesting = false;
|
|
100
|
+
throw DESTROYABLE_META = new WeakMap(), new Error("Attempted to start destroyable testing, but you did not end the previous destroyable test. Did you forget to call `assertDestroyablesDestroyed()`");
|
|
101
|
+
isTesting = !0, DESTROYABLE_META = new Map();
|
|
102
|
+
}, assertDestroyablesDestroyed = () => {
|
|
103
|
+
if (!isTesting) throw new Error("Attempted to assert destroyables destroyed, but you did not start a destroyable test. Did you forget to call `enableDestroyableTracking()`");
|
|
104
|
+
isTesting = !1;
|
|
155
105
|
let map = DESTROYABLE_META;
|
|
156
106
|
DESTROYABLE_META = new WeakMap();
|
|
157
107
|
let undestroyed = [];
|
|
158
|
-
map.forEach(meta => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
let objectsToString = undestroyed.map(debugToString$1).join('\n ');
|
|
165
|
-
let error = new Error(`Some destroyables were not destroyed during this test:\n ${objectsToString}`);
|
|
166
|
-
error.destroyables = undestroyed;
|
|
167
|
-
throw error;
|
|
108
|
+
if (map.forEach(meta => {
|
|
109
|
+
meta.state !== DestroyingState.Destroyed && undestroyed.push(meta.source);
|
|
110
|
+
}), undestroyed.length > 0) {
|
|
111
|
+
let objectsToString = undestroyed.map(debugToString$1).join("\n "),
|
|
112
|
+
error = new Error(`Some destroyables were not destroyed during this test:\n ${objectsToString}`);
|
|
113
|
+
throw error.destroyables = undestroyed, error;
|
|
168
114
|
}
|
|
169
115
|
};
|
|
170
116
|
}
|
|
@@ -7,25 +7,18 @@ class InstructionEncoderImpl {
|
|
|
7
7
|
}
|
|
8
8
|
size = 0;
|
|
9
9
|
encode(type, machine, ...args) {
|
|
10
|
-
if (type > TYPE_SIZE) {
|
|
11
|
-
throw new Error(`Opcode type over 8-bits. Got ${type}.`);
|
|
12
|
-
}
|
|
10
|
+
if (type > TYPE_SIZE) throw new Error(`Opcode type over 8-bits. Got ${type}.`);
|
|
13
11
|
let first = type | machine | arguments.length - 2 << ARG_SHIFT;
|
|
14
12
|
this.buffer.push(first);
|
|
15
13
|
for (const op of args) {
|
|
16
|
-
if (isDevelopingApp() && typeof op
|
|
17
|
-
throw new Error(`Operand over 32-bits. Got ${op}.`);
|
|
18
|
-
}
|
|
14
|
+
if (isDevelopingApp() && "number" == typeof op && op > MAX_SIZE) throw new Error(`Operand over 32-bits. Got ${op}.`);
|
|
19
15
|
this.buffer.push(op);
|
|
20
16
|
}
|
|
21
17
|
this.size = this.buffer.length;
|
|
22
18
|
}
|
|
23
19
|
patch(position, target) {
|
|
24
|
-
if (this.buffer[position + 1]
|
|
25
|
-
|
|
26
|
-
} else {
|
|
27
|
-
throw new Error('Trying to patch operand in populated slot instead of a reserved slot.');
|
|
28
|
-
}
|
|
20
|
+
if (-1 !== this.buffer[position + 1]) throw new Error("Trying to patch operand in populated slot instead of a reserved slot.");
|
|
21
|
+
this.buffer[position + 1] = target;
|
|
29
22
|
}
|
|
30
23
|
}
|
|
31
24
|
|
|
@@ -27,7 +27,21 @@ import { isDevelopingApp } from '@embroider/macros';
|
|
|
27
27
|
*
|
|
28
28
|
* Note: this has a default value so that tags can warm themselves when first loaded.
|
|
29
29
|
*/
|
|
30
|
-
let
|
|
30
|
+
let scheduleDestroy,
|
|
31
|
+
scheduleDestroyed,
|
|
32
|
+
toIterator,
|
|
33
|
+
toBool,
|
|
34
|
+
getProp,
|
|
35
|
+
setProp,
|
|
36
|
+
getPath,
|
|
37
|
+
setPath,
|
|
38
|
+
warnIfStyleNotTrusted,
|
|
39
|
+
assert,
|
|
40
|
+
deprecate,
|
|
41
|
+
assertGlobalContextWasSet,
|
|
42
|
+
testOverrideGlobalContext,
|
|
43
|
+
scheduleRevalidate = () => {},
|
|
44
|
+
globalContextWasSet = !1;
|
|
31
45
|
|
|
32
46
|
/**
|
|
33
47
|
* Schedules a destructor to run
|
|
@@ -35,152 +49,34 @@ let scheduleRevalidate = () => {};
|
|
|
35
49
|
* @param destroyable The destroyable being destroyed
|
|
36
50
|
* @param destructor The destructor being scheduled
|
|
37
51
|
*/
|
|
38
|
-
let scheduleDestroy;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Finalizes destruction
|
|
42
|
-
*
|
|
43
|
-
* @param finalizer finalizer function
|
|
44
|
-
*/
|
|
45
|
-
let scheduleDestroyed;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Hook to provide iterators for `{{each}}` loops
|
|
49
|
-
*
|
|
50
|
-
* @param value The value to create an iterator for
|
|
51
|
-
*/
|
|
52
|
-
let toIterator;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Hook to specify truthiness within Glimmer templates
|
|
56
|
-
*
|
|
57
|
-
* @param value The value to convert to a boolean
|
|
58
|
-
*/
|
|
59
|
-
let toBool;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Hook for specifying how Glimmer should access properties in cases where it
|
|
63
|
-
* needs to. For instance, accessing an object's values in templates.
|
|
64
|
-
*
|
|
65
|
-
* @param obj The object provided to get a value from
|
|
66
|
-
* @param path The path to get the value from
|
|
67
|
-
*/
|
|
68
|
-
let getProp;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Hook for specifying how Glimmer should update props in cases where it needs
|
|
72
|
-
* to. For instance, when updating a template reference (e.g. 2-way-binding)
|
|
73
|
-
*
|
|
74
|
-
* @param obj The object provided to get a value from
|
|
75
|
-
* @param prop The prop to set the value at
|
|
76
|
-
* @param value The value to set the value to
|
|
77
|
-
*/
|
|
78
|
-
let setProp;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Hook for specifying how Glimmer should access paths in cases where it needs
|
|
82
|
-
* to. For instance, the `key` value of `{{each}}` loops.
|
|
83
|
-
*
|
|
84
|
-
* @param obj The object provided to get a value from
|
|
85
|
-
* @param path The path to get the value from
|
|
86
|
-
*/
|
|
87
|
-
let getPath;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Hook for specifying how Glimmer should update paths in cases where it needs
|
|
91
|
-
* to. For instance, when updating a template reference (e.g. 2-way-binding)
|
|
92
|
-
*
|
|
93
|
-
* @param obj The object provided to get a value from
|
|
94
|
-
* @param path The path to get the value from
|
|
95
|
-
*/
|
|
96
|
-
let setPath;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Hook to warn if a style binding string or value was not marked as trusted
|
|
100
|
-
* (e.g. HTMLSafe)
|
|
101
|
-
*/
|
|
102
|
-
let warnIfStyleNotTrusted;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Hook to customize assertion messages in the VM. Usages can be stripped out
|
|
106
|
-
* by using the @glimmer/vm-babel-plugins package.
|
|
107
|
-
*/
|
|
108
|
-
let assert;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Hook to customize deprecation messages in the VM. Usages can be stripped out
|
|
112
|
-
* by using the @glimmer/vm-babel-plugins package.
|
|
113
|
-
*/
|
|
114
|
-
let deprecate;
|
|
115
|
-
|
|
116
|
-
//////////
|
|
117
|
-
|
|
118
|
-
let globalContextWasSet = false;
|
|
119
52
|
function setGlobalContext(context) {
|
|
120
53
|
if (isDevelopingApp()) {
|
|
121
|
-
if (globalContextWasSet)
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
globalContextWasSet = true;
|
|
54
|
+
if (globalContextWasSet) throw new Error("Attempted to set the global context twice. This should only be set once.");
|
|
55
|
+
globalContextWasSet = !0;
|
|
125
56
|
}
|
|
126
|
-
scheduleRevalidate = context.scheduleRevalidate;
|
|
127
|
-
scheduleDestroy = context.scheduleDestroy;
|
|
128
|
-
scheduleDestroyed = context.scheduleDestroyed;
|
|
129
|
-
toIterator = context.toIterator;
|
|
130
|
-
toBool = context.toBool;
|
|
131
|
-
getProp = context.getProp;
|
|
132
|
-
setProp = context.setProp;
|
|
133
|
-
getPath = context.getPath;
|
|
134
|
-
setPath = context.setPath;
|
|
135
|
-
warnIfStyleNotTrusted = context.warnIfStyleNotTrusted;
|
|
136
|
-
assert = context.assert;
|
|
137
|
-
deprecate = context.deprecate;
|
|
138
|
-
}
|
|
139
|
-
let assertGlobalContextWasSet;
|
|
140
|
-
let testOverrideGlobalContext;
|
|
141
|
-
if (isDevelopingApp()) {
|
|
142
|
-
assertGlobalContextWasSet = () => {
|
|
143
|
-
if (globalContextWasSet === false) {
|
|
144
|
-
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`');
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
testOverrideGlobalContext = context => {
|
|
148
|
-
let originalGlobalContext = globalContextWasSet ? {
|
|
149
|
-
scheduleRevalidate,
|
|
150
|
-
scheduleDestroy,
|
|
151
|
-
scheduleDestroyed,
|
|
152
|
-
toIterator,
|
|
153
|
-
toBool,
|
|
154
|
-
getProp,
|
|
155
|
-
setProp,
|
|
156
|
-
getPath,
|
|
157
|
-
setPath,
|
|
158
|
-
warnIfStyleNotTrusted,
|
|
159
|
-
assert,
|
|
160
|
-
deprecate
|
|
161
|
-
} : null;
|
|
162
|
-
if (context === null) {
|
|
163
|
-
globalContextWasSet = false;
|
|
164
|
-
} else {
|
|
165
|
-
globalContextWasSet = true;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// We use `undefined as any` here to unset the values when resetting the
|
|
169
|
-
// context at the end of a test.
|
|
170
|
-
scheduleRevalidate = context?.scheduleRevalidate || undefined;
|
|
171
|
-
scheduleDestroy = context?.scheduleDestroy || undefined;
|
|
172
|
-
scheduleDestroyed = context?.scheduleDestroyed || undefined;
|
|
173
|
-
toIterator = context?.toIterator || undefined;
|
|
174
|
-
toBool = context?.toBool || undefined;
|
|
175
|
-
getProp = context?.getProp || undefined;
|
|
176
|
-
setProp = context?.setProp || undefined;
|
|
177
|
-
getPath = context?.getPath || undefined;
|
|
178
|
-
setPath = context?.setPath || undefined;
|
|
179
|
-
warnIfStyleNotTrusted = context?.warnIfStyleNotTrusted || undefined;
|
|
180
|
-
assert = context?.assert || undefined;
|
|
181
|
-
deprecate = context?.deprecate || undefined;
|
|
182
|
-
return originalGlobalContext;
|
|
183
|
-
};
|
|
57
|
+
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;
|
|
184
58
|
}
|
|
59
|
+
isDevelopingApp() && (assertGlobalContextWasSet = () => {
|
|
60
|
+
if (!1 === 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
|
+
}, testOverrideGlobalContext = context => {
|
|
62
|
+
let originalGlobalContext = globalContextWasSet ? {
|
|
63
|
+
scheduleRevalidate: scheduleRevalidate,
|
|
64
|
+
scheduleDestroy: scheduleDestroy,
|
|
65
|
+
scheduleDestroyed: scheduleDestroyed,
|
|
66
|
+
toIterator: toIterator,
|
|
67
|
+
toBool: toBool,
|
|
68
|
+
getProp: getProp,
|
|
69
|
+
setProp: setProp,
|
|
70
|
+
getPath: getPath,
|
|
71
|
+
setPath: setPath,
|
|
72
|
+
warnIfStyleNotTrusted: warnIfStyleNotTrusted,
|
|
73
|
+
assert: assert,
|
|
74
|
+
deprecate: deprecate
|
|
75
|
+
} : null;
|
|
76
|
+
return globalContextWasSet = null !== context,
|
|
77
|
+
// We use `undefined as any` here to unset the values when resetting the
|
|
78
|
+
// context at the end of a test.
|
|
79
|
+
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
|
+
});
|
|
185
81
|
|
|
186
82
|
export { assert, assertGlobalContextWasSet, setGlobalContext as default, deprecate, getPath, getProp, scheduleDestroy, scheduleDestroyed, scheduleRevalidate, setPath, setProp, testOverrideGlobalContext, toBool, toIterator, warnIfStyleNotTrusted };
|