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