ember-source 5.0.0 → 5.1.0-alpha.2

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 (176) hide show
  1. package/build-metadata.json +3 -3
  2. package/dist/ember-template-compiler.js +19 -35
  3. package/dist/ember-template-compiler.map +1 -1
  4. package/dist/ember-testing.js +8 -31
  5. package/dist/ember-testing.map +1 -1
  6. package/dist/ember.debug.js +798 -436
  7. package/dist/ember.debug.map +1 -1
  8. package/dist/header/license.js +1 -1
  9. package/dist/packages/@ember/-internals/glimmer/index.js +44 -89
  10. package/dist/packages/@ember/-internals/metal/index.js +7 -66
  11. package/dist/packages/@ember/-internals/utility-types/index.js +1 -1
  12. package/dist/packages/@ember/array/proxy.js +0 -1
  13. package/dist/packages/@ember/component/template-only.js +15 -27
  14. package/dist/packages/@ember/debug/index.js +6 -30
  15. package/dist/packages/@ember/debug/lib/warn.js +1 -0
  16. package/dist/packages/@ember/helper/index.js +139 -3
  17. package/dist/packages/@ember/modifier/index.js +11 -3
  18. package/dist/packages/@ember/object/core.js +37 -0
  19. package/dist/packages/@ember/object/mixin.js +1 -1
  20. package/dist/packages/@ember/object/proxy.js +1 -0
  21. package/dist/packages/@ember/routing/lib/utils.js +0 -1
  22. package/dist/packages/@ember/routing/route.js +8 -0
  23. package/dist/packages/@ember/routing/router-service.js +0 -1
  24. package/dist/packages/@ember/runloop/-private/backburner.js +10 -0
  25. package/dist/packages/@ember/runloop/index.js +6 -2
  26. package/dist/packages/@ember/test/index.js +5 -3
  27. package/dist/packages/ember/index.js +229 -220
  28. package/dist/packages/ember/version.js +1 -1
  29. package/dist/packages/ember-testing/lib/test/waiters.js +4 -1
  30. package/docs/data.json +478 -327
  31. package/package.json +26 -23
  32. package/types/publish.mjs +147 -354
  33. package/types/stable/@ember/-internals/glimmer/index.d.ts +6 -1
  34. package/types/stable/@ember/-internals/glimmer/lib/component.d.ts +256 -132
  35. package/types/stable/@ember/-internals/glimmer/lib/components/input.d.ts +5 -2
  36. package/types/stable/@ember/-internals/glimmer/lib/components/link-to.d.ts +5 -2
  37. package/types/stable/@ember/-internals/glimmer/lib/components/textarea.d.ts +8 -2
  38. package/types/stable/@ember/-internals/glimmer/lib/helper.d.ts +66 -56
  39. package/types/stable/@ember/-internals/glimmer/lib/templates/empty.d.ts +5 -0
  40. package/types/stable/@ember/-internals/glimmer/lib/templates/input.d.ts +5 -0
  41. package/types/stable/@ember/-internals/glimmer/lib/templates/link-to.d.ts +5 -0
  42. package/types/stable/@ember/-internals/glimmer/lib/templates/outlet.d.ts +5 -0
  43. package/types/stable/@ember/-internals/glimmer/lib/templates/root.d.ts +5 -0
  44. package/types/stable/@ember/-internals/glimmer/lib/templates/textarea.d.ts +5 -0
  45. package/types/stable/@ember/-internals/metal/lib/computed.d.ts +2 -1
  46. package/types/stable/@ember/-internals/metal/lib/computed_cache.d.ts +1 -0
  47. package/types/stable/@ember/-internals/metal/lib/get_properties.d.ts +4 -2
  48. package/types/stable/@ember/-internals/metal/lib/set_properties.d.ts +3 -5
  49. package/types/stable/@ember/-internals/utility-types/index.d.ts +5 -0
  50. package/types/stable/@ember/-internals/views/lib/component_lookup.d.ts +8 -1
  51. package/types/stable/@ember/-internals/views/lib/system/action_manager.d.ts +3 -4
  52. package/types/stable/@ember/-internals/views/lib/views/core_view.d.ts +4 -6
  53. package/types/stable/@ember/application/instance.d.ts +1 -1
  54. package/types/stable/@ember/array/index.d.ts +1 -1
  55. package/types/stable/@ember/array/proxy.d.ts +11 -13
  56. package/types/stable/@ember/component/helper.d.ts +6 -1
  57. package/types/stable/@ember/component/template-only.d.ts +36 -1
  58. package/types/stable/@ember/controller/index.d.ts +6 -5
  59. package/types/stable/@ember/debug/data-adapter.d.ts +10 -3
  60. package/types/stable/@ember/debug/index.d.ts +4 -1
  61. package/types/stable/@ember/debug/lib/warn.d.ts +6 -1
  62. package/types/stable/@ember/engine/index.d.ts +2 -1
  63. package/types/stable/@ember/engine/instance.d.ts +2 -1
  64. package/types/stable/@ember/helper/index.d.ts +141 -3
  65. package/types/stable/@ember/modifier/index.d.ts +11 -2
  66. package/types/stable/@ember/object/core.d.ts +14 -9
  67. package/types/stable/@ember/object/index.d.ts +3 -2
  68. package/types/stable/@ember/object/lib/computed/reduce_computed_macros.d.ts +1 -1
  69. package/types/stable/@ember/object/mixin.d.ts +2 -2
  70. package/types/stable/@ember/object/observable.d.ts +21 -1
  71. package/types/stable/@ember/object/proxy.d.ts +26 -2
  72. package/types/stable/@ember/routing/hash-location.d.ts +0 -6
  73. package/types/stable/@ember/routing/history-location.d.ts +0 -6
  74. package/types/stable/@ember/routing/lib/controller_for.d.ts +2 -7
  75. package/types/stable/@ember/routing/lib/router_state.d.ts +10 -6
  76. package/types/stable/@ember/routing/lib/routing-service.d.ts +3 -3
  77. package/types/stable/@ember/routing/lib/utils.d.ts +14 -15
  78. package/types/stable/@ember/routing/location-ext.d.ts +18 -0
  79. package/types/stable/@ember/routing/location.d.ts +0 -6
  80. package/types/stable/@ember/routing/none-location.d.ts +0 -6
  81. package/types/stable/@ember/routing/owner-ext.d.ts +11 -0
  82. package/types/stable/@ember/routing/route.d.ts +39 -24
  83. package/types/stable/@ember/routing/router-service.d.ts +18 -15
  84. package/types/stable/@ember/routing/router.d.ts +42 -44
  85. package/types/stable/@ember/routing/service-ext.d.ts +14 -0
  86. package/types/stable/@ember/runloop/-private/backburner.d.ts +7 -0
  87. package/types/stable/@ember/runloop/index.d.ts +12 -4
  88. package/types/stable/@ember/service/index.d.ts +20 -7
  89. package/types/stable/@ember/service/owner-ext.d.ts +11 -0
  90. package/types/stable/@ember/template-compilation/index.d.ts +16 -1
  91. package/types/stable/@ember/test/index.d.ts +6 -6
  92. package/types/stable/@ember/utils/lib/compare.d.ts +1 -1
  93. package/types/stable/ember/index.d.ts +320 -246
  94. package/types/stable/ember/version.d.ts +4 -0
  95. package/types/stable/ember-template-compiler/index.d.ts +1 -8
  96. package/types/stable/ember-template-compiler/lib/types.d.ts +20 -0
  97. package/types/stable/ember-testing/lib/adapters/adapter.d.ts +37 -1
  98. package/types/stable/ember-testing/lib/adapters/qunit.d.ts +18 -3
  99. package/types/stable/ember-testing/lib/test/helpers.d.ts +5 -1
  100. package/types/stable/ember-testing/lib/test/promise.d.ts +1 -1
  101. package/types/stable/index.d.ts +298 -4
  102. package/types/stable/loader/lib/index.d.ts +4 -0
  103. package/types/stable/require.d.ts +4 -0
  104. package/types/preview/@ember/application/-private/event-dispatcher.d.ts +0 -18
  105. package/types/preview/@ember/application/-private/registry.d.ts +0 -15
  106. package/types/preview/@ember/application/index.d.ts +0 -136
  107. package/types/preview/@ember/application/instance.d.ts +0 -9
  108. package/types/preview/@ember/application/types.d.ts +0 -29
  109. package/types/preview/@ember/array/-private/enumerable.d.ts +0 -13
  110. package/types/preview/@ember/array/-private/mutable-enumerable.d.ts +0 -13
  111. package/types/preview/@ember/array/-private/native-array.d.ts +0 -181
  112. package/types/preview/@ember/array/index.d.ts +0 -251
  113. package/types/preview/@ember/array/mutable.d.ts +0 -94
  114. package/types/preview/@ember/array/proxy.d.ts +0 -29
  115. package/types/preview/@ember/component/-private/class-names-support.d.ts +0 -27
  116. package/types/preview/@ember/component/-private/core-view.d.ts +0 -14
  117. package/types/preview/@ember/component/-private/glimmer-interfaces.d.ts +0 -49
  118. package/types/preview/@ember/component/-private/signature-utils.d.ts +0 -107
  119. package/types/preview/@ember/component/-private/view-mixin.d.ts +0 -59
  120. package/types/preview/@ember/component/helper.d.ts +0 -122
  121. package/types/preview/@ember/component/index.d.ts +0 -164
  122. package/types/preview/@ember/component/template-only.d.ts +0 -47
  123. package/types/preview/@ember/controller/index.d.ts +0 -47
  124. package/types/preview/@ember/debug/container-debug-adapter.d.ts +0 -14
  125. package/types/preview/@ember/debug/data-adapter.d.ts +0 -64
  126. package/types/preview/@ember/debug/index.d.ts +0 -98
  127. package/types/preview/@ember/destroyable/index.d.ts +0 -23
  128. package/types/preview/@ember/engine/-private/container-proxy-mixin.d.ts +0 -11
  129. package/types/preview/@ember/engine/-private/registry-proxy-mixin.d.ts +0 -12
  130. package/types/preview/@ember/engine/-private/types/initializer.d.ts +0 -8
  131. package/types/preview/@ember/engine/index.d.ts +0 -45
  132. package/types/preview/@ember/engine/instance.d.ts +0 -25
  133. package/types/preview/@ember/helper/index.d.ts +0 -49
  134. package/types/preview/@ember/modifier/index.d.ts +0 -33
  135. package/types/preview/@ember/object/-private/action-handler.d.ts +0 -31
  136. package/types/preview/@ember/object/-private/types.d.ts +0 -63
  137. package/types/preview/@ember/object/compat.d.ts +0 -9
  138. package/types/preview/@ember/object/computed.d.ts +0 -263
  139. package/types/preview/@ember/object/core.d.ts +0 -89
  140. package/types/preview/@ember/object/evented.d.ts +0 -45
  141. package/types/preview/@ember/object/events.d.ts +0 -47
  142. package/types/preview/@ember/object/index.d.ts +0 -126
  143. package/types/preview/@ember/object/internals.d.ts +0 -17
  144. package/types/preview/@ember/object/mixin.d.ts +0 -19
  145. package/types/preview/@ember/object/observable.d.ts +0 -89
  146. package/types/preview/@ember/object/observers.d.ts +0 -34
  147. package/types/preview/@ember/object/promise-proxy-mixin.d.ts +0 -37
  148. package/types/preview/@ember/object/proxy.d.ts +0 -27
  149. package/types/preview/@ember/routing/-private/router-dsl.d.ts +0 -20
  150. package/types/preview/@ember/routing/hash-location.d.ts +0 -26
  151. package/types/preview/@ember/routing/history-location.d.ts +0 -25
  152. package/types/preview/@ember/routing/index.d.ts +0 -17
  153. package/types/preview/@ember/routing/location.d.ts +0 -104
  154. package/types/preview/@ember/routing/none-location.d.ts +0 -27
  155. package/types/preview/@ember/routing/route-info.d.ts +0 -73
  156. package/types/preview/@ember/routing/route.d.ts +0 -532
  157. package/types/preview/@ember/routing/router-service.d.ts +0 -359
  158. package/types/preview/@ember/routing/router.d.ts +0 -41
  159. package/types/preview/@ember/routing/transition.d.ts +0 -126
  160. package/types/preview/@ember/routing/types.d.ts +0 -15
  161. package/types/preview/@ember/runloop/-private/backburner.d.ts +0 -43
  162. package/types/preview/@ember/runloop/-private/types.d.ts +0 -9
  163. package/types/preview/@ember/runloop/index.d.ts +0 -175
  164. package/types/preview/@ember/runloop/types.d.ts +0 -5
  165. package/types/preview/@ember/service/index.d.ts +0 -32
  166. package/types/preview/@ember/template/-private/handlebars.d.ts +0 -7
  167. package/types/preview/@ember/template/index.d.ts +0 -6
  168. package/types/preview/@ember/template-compilation/index.d.ts +0 -28
  169. package/types/preview/@ember/test/adapter.d.ts +0 -22
  170. package/types/preview/@ember/test/index.d.ts +0 -49
  171. package/types/preview/@ember/utils/-private/types.d.ts +0 -39
  172. package/types/preview/@ember/utils/index.d.ts +0 -42
  173. package/types/preview/ember/-private/type-utils.d.ts +0 -57
  174. package/types/preview/ember/index.d.ts +0 -347
  175. package/types/preview/index.d.ts +0 -121
  176. /package/dist/dependencies/{backburner.js → backburner.js.js} +0 -0
@@ -5,5 +5,5 @@
5
5
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6
6
  * @license Licensed under MIT license
7
7
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
8
- * @version 5.0.0
8
+ * @version 5.1.0-alpha.2
9
9
  */
@@ -3,7 +3,7 @@ export { templateFactory as template, templateCacheCounters } from '@glimmer/opc
3
3
  import { hasDOM } from '@ember/-internals/browser-environment';
4
4
  import { assert, warn, debugFreeze, inspect, deprecate } from '@ember/debug';
5
5
  import { action as action$1 } from '@ember/object';
6
- import { isConstRef, valueForRef, createConstRef, isUpdatableRef, updateRef, createComputeRef, createPrimitiveRef, childRefFor, childRefFromParts, isInvokableRef, createUnboundRef, createInvokableRef, createReadOnlyRef, createDebugAliasRef, UNDEFINED_REFERENCE } from '@glimmer/reference';
6
+ import { valueForRef, isConstRef, createConstRef, isUpdatableRef, updateRef, createComputeRef, createPrimitiveRef, childRefFor, childRefFromParts, isInvokableRef, createUnboundRef, createInvokableRef, createReadOnlyRef, createDebugAliasRef, UNDEFINED_REFERENCE } from '@glimmer/reference';
7
7
  import { untrack, createCache, consumeTag, tagFor, getValue, valueForTag, beginUntrackFrame, endUntrackFrame, beginTrackFrame, endTrackFrame, validateTag, createTag, dirtyTag, CONSTANT_TAG, isTracking, setTrackingTransactionEnv, createUpdatableTag, CURRENT_TAG } from '@glimmer/validator';
8
8
  import { tracked, get, PROPERTY_DID_CHANGE, tagForObject, objectAt, tagForProperty, _getProp, _setProp, set } from '@ember/-internals/metal';
9
9
  import { setOwner, getOwner, isFactory } from '@ember/-internals/owner';
@@ -462,7 +462,7 @@ if (hasDOM) {
462
462
  @param {Hash} options
463
463
  @public
464
464
  */
465
- class Input extends AbstractInput {
465
+ class _Input extends AbstractInput {
466
466
  constructor() {
467
467
  super(...arguments);
468
468
  this._checked = valueFrom(this.args.named['checked']);
@@ -532,10 +532,10 @@ class Input extends AbstractInput {
532
532
  return supportedArguments.indexOf(name) !== -1 || super.isSupportedArgument(name);
533
533
  }
534
534
  }
535
- __decorate$1([action$1], Input.prototype, "change", null);
536
- __decorate$1([action$1], Input.prototype, "input", null);
537
- __decorate$1([action$1], Input.prototype, "checkedDidChange", null);
538
- var Input$1 = opaquify(Input, InputTemplate);
535
+ __decorate$1([action$1], _Input.prototype, "change", null);
536
+ __decorate$1([action$1], _Input.prototype, "input", null);
537
+ __decorate$1([action$1], _Input.prototype, "checkedDidChange", null);
538
+ const Input = opaquify(_Input, InputTemplate);
539
539
 
540
540
  var LinkToTemplate = templateFactory({
541
541
  "id": "CVwkBtGh",
@@ -793,7 +793,7 @@ function isQueryParams(value) {
793
793
  @see {Ember.Templates.components.LinkTo}
794
794
  @public
795
795
  **/
796
- class LinkTo extends InternalComponent {
796
+ class _LinkTo extends InternalComponent {
797
797
  constructor() {
798
798
  super(...arguments);
799
799
  // GH #17963
@@ -1020,11 +1020,11 @@ class LinkTo extends InternalComponent {
1020
1020
  return supportedArguments.indexOf(name) !== -1 || super.isSupportedArgument(name);
1021
1021
  }
1022
1022
  }
1023
- __decorate$2([service('-routing')], LinkTo.prototype, "routing", void 0);
1024
- __decorate$2([action$1], LinkTo.prototype, "click", null);
1023
+ __decorate$2([service('-routing')], _LinkTo.prototype, "routing", void 0);
1024
+ __decorate$2([action$1], _LinkTo.prototype, "click", null);
1025
1025
  let {
1026
1026
  prototype
1027
- } = LinkTo;
1027
+ } = _LinkTo;
1028
1028
  let descriptorFor = (target, property) => {
1029
1029
  if (target) {
1030
1030
  return Object.getOwnPropertyDescriptor(target, property) || descriptorFor(Object.getPrototypeOf(target), property);
@@ -1105,7 +1105,7 @@ let descriptorFor = (target, property) => {
1105
1105
  }
1106
1106
  });
1107
1107
  }
1108
- var LinkTo$1 = opaquify(LinkTo, LinkToTemplate);
1108
+ const LinkTo = opaquify(_LinkTo, LinkToTemplate);
1109
1109
 
1110
1110
  var TextareaTemplate = templateFactory({
1111
1111
  "id": "OpzctQXz",
@@ -1252,7 +1252,7 @@ var __decorate$3 = undefined && undefined.__decorate || function (decorators, ta
1252
1252
  @see {Ember.Templates.components.Textarea}
1253
1253
  @public
1254
1254
  **/
1255
- class Textarea extends AbstractInput {
1255
+ class _Textarea extends AbstractInput {
1256
1256
  static toString() {
1257
1257
  return 'Textarea';
1258
1258
  }
@@ -1271,9 +1271,9 @@ class Textarea extends AbstractInput {
1271
1271
  return supportedArguments.indexOf(name) !== -1 || super.isSupportedArgument(name);
1272
1272
  }
1273
1273
  }
1274
- __decorate$3([action$1], Textarea.prototype, "change", null);
1275
- __decorate$3([action$1], Textarea.prototype, "input", null);
1276
- var Textarea$1 = opaquify(Textarea, TextareaTemplate);
1274
+ __decorate$3([action$1], _Textarea.prototype, "change", null);
1275
+ __decorate$3([action$1], _Textarea.prototype, "input", null);
1276
+ const Textarea = opaquify(_Textarea, TextareaTemplate);
1277
1277
 
1278
1278
  function isTemplateFactory(template) {
1279
1279
  return typeof template === 'function';
@@ -2336,49 +2336,6 @@ class Component extends CoreView.extend(ChildViewsSupport, ViewStateSupport, Cla
2336
2336
  Component.isComponentFactory = true;
2337
2337
  // We continue to use reopenClass here so that positionalParams can be overridden with reopenClass in subclasses.
2338
2338
  Component.reopenClass({
2339
- /**
2340
- Enables components to take a list of parameters as arguments.
2341
- For example, a component that takes two parameters with the names
2342
- `name` and `age`:
2343
- ```app/components/my-component.js
2344
- import Component from '@ember/component';
2345
- let MyComponent = Component.extend();
2346
- MyComponent.reopenClass({
2347
- positionalParams: ['name', 'age']
2348
- });
2349
- export default MyComponent;
2350
- ```
2351
- It can then be invoked like this:
2352
- ```hbs
2353
- {{my-component "John" 38}}
2354
- ```
2355
- The parameters can be referred to just like named parameters:
2356
- ```hbs
2357
- Name: {{name}}, Age: {{age}}.
2358
- ```
2359
- Using a string instead of an array allows for an arbitrary number of
2360
- parameters:
2361
- ```app/components/my-component.js
2362
- import Component from '@ember/component';
2363
- let MyComponent = Component.extend();
2364
- MyComponent.reopenClass({
2365
- positionalParams: 'names'
2366
- });
2367
- export default MyComponent;
2368
- ```
2369
- It can then be invoked like this:
2370
- ```hbs
2371
- {{my-component "John" "Michael" "Scott"}}
2372
- ```
2373
- The parameters can then be referred to by enumerating over the list:
2374
- ```hbs
2375
- {{#each names as |name|}}{{name}}{{/each}}
2376
- ```
2377
- @static
2378
- @public
2379
- @property positionalParams
2380
- @since 1.13.0
2381
- */
2382
2339
  positionalParams: []
2383
2340
  });
2384
2341
  setInternalComponentManager(CURLY_COMPONENT_MANAGER, Component);
@@ -2389,29 +2346,6 @@ setInternalComponentManager(CURLY_COMPONENT_MANAGER, Component);
2389
2346
  var _a;
2390
2347
  const RECOMPUTE_TAG = Symbol('RECOMPUTE_TAG');
2391
2348
  const IS_CLASSIC_HELPER = Symbol('IS_CLASSIC_HELPER');
2392
- /**
2393
- In many cases it is not necessary to use the full `Helper` class.
2394
- The `helper` method create pure-function helpers without instances.
2395
- For example:
2396
-
2397
- ```app/helpers/format-currency.js
2398
- import { helper } from '@ember/component/helper';
2399
-
2400
- export default helper(function([cents], {currency}) {
2401
- return `${currency}${cents * 0.01}`;
2402
- });
2403
- ```
2404
-
2405
- @static
2406
- @param {Function} helper The helper function
2407
- @method helper
2408
- @for @ember/component/helper
2409
- @public
2410
- @since 1.13.0
2411
- */
2412
- function helper(helperFn) {
2413
- return new Wrapper(helperFn);
2414
- }
2415
2349
  class Helper extends FrameworkObject {
2416
2350
  init(properties) {
2417
2351
  super.init(properties);
@@ -2453,6 +2387,7 @@ Helper[_a] = true;
2453
2387
  // here, but it should definitely be reviewed and probably removed.
2454
2388
  /** @deprecated */
2455
2389
  Helper.helper = helper;
2390
+ /* eslint-enable import/export */
2456
2391
  function isClassicHelper(obj) {
2457
2392
  return obj[IS_CLASSIC_HELPER] === true;
2458
2393
  }
@@ -2528,10 +2463,7 @@ class SimpleClassicHelperManager {
2528
2463
  });
2529
2464
  }
2530
2465
  createHelper(definition, args) {
2531
- let {
2532
- compute
2533
- } = definition;
2534
- return () => compute.call(null, args.positional, args.named);
2466
+ return () => definition.compute.call(null, args.positional, args.named);
2535
2467
  }
2536
2468
  getValue(fn) {
2537
2469
  return fn();
@@ -2542,6 +2474,29 @@ class SimpleClassicHelperManager {
2542
2474
  }
2543
2475
  const SIMPLE_CLASSIC_HELPER_MANAGER = new SimpleClassicHelperManager();
2544
2476
  setHelperManager(() => SIMPLE_CLASSIC_HELPER_MANAGER, Wrapper.prototype);
2477
+ function helper(helperFn
2478
+ // At the implementation site, we don't care about the actual underlying type
2479
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2480
+ ) {
2481
+ // SAFETY: this is completely lies, in two ways:
2482
+ //
2483
+ // 1. `Wrapper` is a `Factory<SimpleHelper<S>>`, but from the perspective of
2484
+ // any external callers (i.e. Ember *users*), it is quite important that
2485
+ // the `Factory` relationship be hidden, because it is not public API for
2486
+ // an end user to call `.create()` on a helper created this way. Instead,
2487
+ // we provide them an `abstract new` signature (which means it cannot be
2488
+ // directly constructed by calling `new` on it) and which does not have the
2489
+ // `.create()` signature on it anymore.
2490
+ //
2491
+ // 2. The produced type here ends up being a subtype of `Helper`, which is not
2492
+ // strictly true. This is necessary for the sake of Glint, which provides
2493
+ // its information by way of a "declaration merge" with `Helper<S>` in the
2494
+ // case of items produced by `helper()`.
2495
+ //
2496
+ // Long-term, this entire construct can go away in favor of deprecating the
2497
+ // `helper()` invocation in favor of using plain functions.
2498
+ return new Wrapper(helperFn);
2499
+ }
2545
2500
 
2546
2501
  /**
2547
2502
  @module @ember/template
@@ -5022,9 +4977,9 @@ function setupEngineRegistry(registry) {
5022
4977
  registry.optionsForType('helper', {
5023
4978
  instantiate: false
5024
4979
  });
5025
- registry.register('component:input', Input$1);
5026
- registry.register('component:link-to', LinkTo$1);
5027
- registry.register('component:textarea', Textarea$1);
4980
+ registry.register('component:input', Input);
4981
+ registry.register('component:link-to', LinkTo);
4982
+ registry.register('component:textarea', Textarea);
5028
4983
  if (!ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS) {
5029
4984
  registry.register(privatize`component:-default`, Component);
5030
4985
  }
@@ -5047,4 +5002,4 @@ function setComponentManager(manager, obj) {
5047
5002
  let componentCapabilities = componentCapabilities$1;
5048
5003
  let modifierCapabilities = modifierCapabilities$1;
5049
5004
 
5050
- export { Component, Helper, Input$1 as Input, LinkTo$1 as LinkTo, OutletView, Renderer, RootTemplate, SafeString, Textarea$1 as Textarea, _resetRenderers, componentCapabilities, escapeExpression, getTemplate, getTemplates, hasTemplate, helper, htmlSafe, isHTMLSafe, modifierCapabilities, renderSettled, setComponentManager, setTemplate, setTemplates, setupApplicationRegistry, setupEngineRegistry };
5005
+ export { Component, Helper, Input, LinkTo, OutletView, Renderer, RootTemplate, SafeString, Textarea, _resetRenderers, componentCapabilities, escapeExpression, getTemplate, getTemplates, hasTemplate, helper, htmlSafe, isHTMLSafe, modifierCapabilities, renderSettled, setComponentManager, setTemplate, setTemplates, setupApplicationRegistry, setupEngineRegistry };
@@ -1369,44 +1369,6 @@ class ComputedDecoratorImpl extends Function {
1369
1369
  desc._readOnly = true;
1370
1370
  return this;
1371
1371
  }
1372
- /**
1373
- In some cases, you may want to annotate computed properties with additional
1374
- metadata about how they function or what values they operate on. For example,
1375
- computed property functions may close over variables that are then no longer
1376
- available for introspection. You can pass a hash of these values to a
1377
- computed property.
1378
- Example:
1379
- ```javascript
1380
- import { computed } from '@ember/object';
1381
- import Person from 'my-app/utils/person';
1382
- class Store {
1383
- @computed().meta({ type: Person })
1384
- get person() {
1385
- let personId = this.personId;
1386
- return Person.create({ id: personId });
1387
- }
1388
- }
1389
- ```
1390
- Classic Class Example:
1391
- ```javascript
1392
- import { computed } from '@ember/object';
1393
- import Person from 'my-app/utils/person';
1394
- const Store = EmberObject.extend({
1395
- person: computed(function() {
1396
- let personId = this.get('personId');
1397
- return Person.create({ id: personId });
1398
- }).meta({ type: Person })
1399
- });
1400
- ```
1401
- The hash that you pass to the `meta()` function will be saved on the
1402
- computed property descriptor under the `_meta` key. Ember runtime
1403
- exposes a public API for retrieving these values from classes,
1404
- via the `metaForProperty()` function.
1405
- @method meta
1406
- @param {Object} meta
1407
- @chainable
1408
- @public
1409
- */
1410
1372
  meta(meta) {
1411
1373
  let prop = descriptorForDecorator(this);
1412
1374
  if (arguments.length === 0) {
@@ -1961,38 +1923,14 @@ function getProperties(obj, keys) {
1961
1923
  propertyNames = Array.from(arguments);
1962
1924
  }
1963
1925
  for (; i < propertyNames.length; i++) {
1964
- ret[propertyNames[i]] = get(obj, propertyNames[i]);
1926
+ // SAFETY: we are just walking the list of property names, so we know the
1927
+ // index access never produces `undefined`.
1928
+ let name = propertyNames[i];
1929
+ ret[name] = get(obj, name);
1965
1930
  }
1966
1931
  return ret;
1967
1932
  }
1968
1933
 
1969
- /**
1970
- @module @ember/object
1971
- */
1972
- /**
1973
- Set a list of properties on an object. These properties are set inside
1974
- a single `beginPropertyChanges` and `endPropertyChanges` batch, so
1975
- observers will be buffered.
1976
-
1977
- ```javascript
1978
- import EmberObject from '@ember/object';
1979
- let anObject = EmberObject.create();
1980
-
1981
- anObject.setProperties({
1982
- firstName: 'Stanley',
1983
- lastName: 'Stuart',
1984
- age: 21
1985
- });
1986
- ```
1987
-
1988
- @method setProperties
1989
- @static
1990
- @for @ember/object
1991
- @param obj
1992
- @param {Object} properties
1993
- @return properties
1994
- @public
1995
- */
1996
1934
  function setProperties(obj, properties) {
1997
1935
  if (properties === null || typeof properties !== 'object') {
1998
1936
  return properties;
@@ -2000,6 +1938,9 @@ function setProperties(obj, properties) {
2000
1938
  changeProperties(() => {
2001
1939
  let props = Object.keys(properties);
2002
1940
  for (let propertyName of props) {
1941
+ // SAFETY: casting `properties` this way is safe because any object in JS
1942
+ // can be indexed this way, and the result will be `unknown`, making it
1943
+ // safe for callers.
2003
1944
  set(obj, propertyName, properties[propertyName]);
2004
1945
  }
2005
1946
  });
@@ -1 +1 @@
1
- export {};
1
+ export class Opaque {}
@@ -150,7 +150,6 @@ class ArrayProxy extends EmberObject {
150
150
  }
151
151
  _addArrangedContentArrayObserver(arrangedContent) {
152
152
  if (arrangedContent && !arrangedContent.isDestroyed) {
153
- // @ts-expect-error This check is still good for ensuring correctness
154
153
  assert("Can't set ArrayProxy's content to itself", arrangedContent !== this);
155
154
  assert(`ArrayProxy expects a native Array, EmberArray, or ArrayProxy, but you passed ${typeof arrangedContent}`, function (arr) {
156
155
  return Array.isArray(arr) || EmberArray.detect(arr);
@@ -2,30 +2,18 @@
2
2
  @module @ember/component/template-only
3
3
  @public
4
4
  */
5
- /**
6
- This utility function is used to declare a given component has no backing class. When the rendering engine detects this it
7
- is able to perform a number of optimizations. Templates that are associated with `templateOnly()` will be rendered _as is_
8
- without adding a wrapping `<div>` (or any of the other element customization behaviors of [@ember/component](/ember/release/classes/Component)).
9
- Specifically, this means that the template will be rendered as "outer HTML".
10
-
11
- In general, this method will be used by build time tooling and would not be directly written in an application. However,
12
- at times it may be useful to use directly to leverage the "outer HTML" semantics mentioned above. For example, if an addon would like
13
- to use these semantics for its templates but cannot be certain it will only be consumed by applications that have enabled the
14
- `template-only-glimmer-components` optional feature.
15
-
16
- @example
17
-
18
- ```js
19
- import templateOnly from '@ember/component/template-only';
20
-
21
- export default templateOnly();
22
- ```
23
-
24
- @public
25
- @static
26
- @method templateOnly
27
- @param {String} moduleName the module name that the template only component represents, this will be used for debugging purposes
28
- @for @ember/component/template-only
29
- @category EMBER_GLIMMER_SET_COMPONENT_TEMPLATE
30
- */
31
- export { templateOnlyComponent as default } from '@glimmer/runtime';
5
+ import { templateOnlyComponent as glimmerTemplateOnlyComponent } from '@glimmer/runtime';
6
+ // NOTES:
7
+ //
8
+ // 1. The generic here is for a *signature: a way to hang information for tools
9
+ // like Glint which can provide typey checking for component templates using
10
+ // information supplied via this generic. While it may appear useless on this
11
+ // class definition and extension, it is used by external tools and should
12
+ // not be removed.
13
+ // 2. SAFETY: this cast is *throwing away* information that is not part of the
14
+ // public API and replacing it with something which has the same calling
15
+ // contract, but much less information (since we do not want to expose the
16
+ // internal APIs like `moduleName` etc.).
17
+ // prettier-ignore
18
+ const templateOnly = glimmerTemplateOnlyComponent;
19
+ export default templateOnly;
@@ -10,6 +10,8 @@ export { isTesting, setTesting } from './lib/testing';
10
10
  export { default as captureRenderTree } from './lib/capture-render-tree';
11
11
  // These are the default production build versions:
12
12
  const noop = () => {};
13
+ // SAFETY: these casts are just straight-up lies, but the point is that they do
14
+ // not do anything in production builds.
13
15
  let assert = noop;
14
16
  let info = noop;
15
17
  let warn = noop;
@@ -73,39 +75,13 @@ if (DEBUG) {
73
75
  @module @ember/debug
74
76
  */
75
77
  if (DEBUG) {
76
- /**
77
- Verify that a certain expectation is met, or throw a exception otherwise.
78
- This is useful for communicating assumptions in the code to other human
79
- readers as well as catching bugs that accidentally violates these
80
- expectations.
81
- Assertions are removed from production builds, so they can be freely added
82
- for documentation and debugging purposes without worries of incuring any
83
- performance penalty. However, because of that, they should not be used for
84
- checks that could reasonably fail during normal usage. Furthermore, care
85
- should be taken to avoid accidentally relying on side-effects produced from
86
- evaluating the condition itself, since the code will not run in production.
87
- ```javascript
88
- import { assert } from '@ember/debug';
89
- // Test for truthiness
90
- assert('Must pass a string', typeof str === 'string');
91
- // Fail unconditionally
92
- assert('This code path should never be run');
93
- ```
94
- @method assert
95
- @static
96
- @for @ember/debug
97
- @param {String} description Describes the expectation. This will become the
98
- text of the Error thrown if the assertion fails.
99
- @param {any} condition Must be truthy for the assertion to pass. If
100
- falsy, an exception will be thrown.
101
- @public
102
- @since 1.0.0
103
- */
104
- setDebugFunction('assert', function assert(desc, test) {
78
+ // eslint-disable-next-line no-inner-declarations
79
+ function assert(desc, test) {
105
80
  if (!test) {
106
81
  throw new Error(`Assertion Failed: ${desc}`);
107
82
  }
108
- });
83
+ }
84
+ setDebugFunction('assert', assert);
109
85
  /**
110
86
  Display a debug notice.
111
87
  Calls to this function are not invoked in production builds.
@@ -78,6 +78,7 @@ if (DEBUG) {
78
78
  }
79
79
  assert(missingOptionsDeprecation, Boolean(options));
80
80
  assert(missingOptionsIdDeprecation, Boolean(options && options.id));
81
+ // SAFETY: we checked this by way of the `arguments` check above.
81
82
  invoke('warn', message, test, options);
82
83
  };
83
84
  }
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  @module @ember/helper
3
3
  */
4
+ import { setHelperManager as glimmerSetHelperManager, helperCapabilities } from '@glimmer/manager';
5
+ import { invokeHelper as glimmerInvokeHelper, hash as glimmerHash, array as glimmerArray, concat as glimmerConcat, get as glimmerGet, fn as glimmerFn } from '@glimmer/runtime';
4
6
  /**
5
7
  `capabilities` returns a capabilities configuration which can be used to modify
6
8
  the behavior of the manager. Manager capabilities _must_ be provided using the
@@ -53,6 +55,7 @@
53
55
  @return {Capabilities} The capabilities object instance
54
56
  @public
55
57
  */
58
+ export const capabilities = helperCapabilities;
56
59
  /**
57
60
  Sets the helper manager for an object or function.
58
61
 
@@ -245,6 +248,7 @@
245
248
  @return {object} The definition passed into setHelperManager
246
249
  @public
247
250
  */
251
+ export const setHelperManager = glimmerSetHelperManager;
248
252
  /**
249
253
  The `invokeHelper` function can be used to create a helper instance in
250
254
  JavaScript.
@@ -277,7 +281,7 @@
277
281
  }
278
282
  }
279
283
  ```
280
- ```hbs
284
+ ```js
281
285
  {{this.value}}
282
286
  ```
283
287
 
@@ -308,5 +312,137 @@
308
312
  @returns
309
313
  @public
310
314
  */
311
- export { setHelperManager, helperCapabilities as capabilities } from '@glimmer/manager';
312
- export { invokeHelper, hash, array, concat, get, fn } from '@glimmer/runtime';
315
+ export const invokeHelper = glimmerInvokeHelper;
316
+ // SAFETY: we need to provide interfaces that Glint can declaration-merge with
317
+ // to provide appropriate completions. In each case, the imported item is
318
+ // currently typed only as `object`, and we are replacing it with a similarly
319
+ // low-information interface type: these are empty objects which are simply able
320
+ // to be distinguished so that Glint can provide the relevant extensions.
321
+ /* eslint-disable @typescript-eslint/no-empty-interface */
322
+ /**
323
+ * Using the `{{hash}}` helper, you can pass objects directly from the template
324
+ * as an argument to your components.
325
+ *
326
+ * ```
327
+ * import { hash } from '@ember/helper';
328
+ *
329
+ * <template>
330
+ * {{#each-in (hash givenName='Jen' familyName='Weber') as |key value|}}
331
+ * <p>{{key}}: {{value}}</p>
332
+ * {{/each-in}}
333
+ * </template>
334
+ * ```
335
+ *
336
+ * **NOTE:** this example uses the experimental `<template>` feature, which is
337
+ * the only place you need to import `hash` to use it (it is a built-in when
338
+ * writing standalone `.hbs` files).
339
+ */
340
+ export const hash = glimmerHash;
341
+ /**
342
+ * Using the `{{array}}` helper, you can pass arrays directly from the template
343
+ * as an argument to your components.
344
+ *
345
+ * ```js
346
+ * import { array } from '@ember/helper';
347
+ *
348
+ * <template>
349
+ * <ul>
350
+ * {{#each (array 'Tom Dale' 'Yehuda Katz' @anotherPerson) as |person|}}
351
+ * <li>{{person}}</li>
352
+ * {{/each}}
353
+ * </ul>
354
+ * </template>
355
+ *
356
+ * **NOTE:** this example uses the experimental `<template>` feature, which is
357
+ * the only place you need to import `array` to use it (it is a built-in when
358
+ * writing standalone `.hbs` files).
359
+ * ```
360
+ */
361
+ export const array = glimmerArray;
362
+ /**
363
+ * The `{{concat}}` helper makes it easy to dynamically send a number of
364
+ * parameters to a component or helper as a single parameter in the format of a
365
+ * concatenated string.
366
+ *
367
+ * For example:
368
+ *
369
+ * ```js
370
+ * import { concat } from '@ember/helper';
371
+ *
372
+ * <template>
373
+ * {{get @foo (concat "item" @index)}}
374
+ * </template>
375
+ * ```
376
+ *
377
+ * This will display the result of `@foo.item1` when `index` is `1`, and
378
+ * `this.foo.item2` when `index` is `2`, etc.
379
+ *
380
+ * **NOTE:** this example uses the experimental `<template>` feature, which is
381
+ * the only place you need to import `concat` to use it (it is a built-in when
382
+ * writing standalone `.hbs` files).
383
+ */
384
+ export const concat = glimmerConcat;
385
+ /**
386
+ * The `{{get}}` helper makes it easy to dynamically look up a property on an
387
+ * object or an element in an array. The second argument to `{{get}}` can be a
388
+ * string or a number, depending on the object being accessed.
389
+ *
390
+ * To access a property on an object with a string key:
391
+ *
392
+ * ```js
393
+ * import { get } from '@ember/helper';
394
+ *
395
+ * <template>
396
+ * {{get @someObject "objectKey"}}
397
+ * </template>
398
+ * ```
399
+ *
400
+ * To access the first element in an array:
401
+ *
402
+ * ```js
403
+ * import { get } from '@ember/helper';
404
+ *
405
+ * <template>
406
+ * {{get @someArray 0}}
407
+ * </template>
408
+ * ```
409
+ *
410
+ * To access a property on an object with a dynamic key:
411
+ *
412
+ * ```js
413
+ * import { get } from '@ember/helper';
414
+ *
415
+ * <template>
416
+ * {{get @address @field}}
417
+ * </template>
418
+ * ```
419
+ *
420
+ * This will display the result of `@foo.item1` when `index` is `1`, and
421
+ * `this.foo.item2` when `index` is `2`, etc.
422
+ *
423
+ * **NOTE:** this example uses the experimental `<template>` feature, which is
424
+ * the only place you need to import `concat` to use it (it is a built-in when
425
+ * writing standalone `.hbs` files).
426
+ */
427
+ export const get = glimmerGet;
428
+ /**
429
+ * `{{fn}}` is a helper that receives a function and some arguments, and returns
430
+ * a new function that combines. This allows you to pass parameters along to
431
+ * functions in your templates:
432
+ *
433
+ * ```js
434
+ * import { fn } from '@ember/helper';
435
+ *
436
+ * function showAlert(message) {
437
+ * alert(`The message is: '${message}'`);
438
+ * }
439
+ *
440
+ * <template>
441
+ * <button type="button" {{on "click" (fn showAlert "Hello!")}}>
442
+ * Click me!
443
+ * </button>
444
+ * </template>
445
+ * ```
446
+ */
447
+ export const fn = glimmerFn;
448
+ /* eslint-enable @typescript-eslint/no-empty-interface */
@@ -1,3 +1,11 @@
1
- export { setModifierManager } from '@glimmer/manager';
2
- export { modifierCapabilities as capabilities } from '@ember/-internals/glimmer';
3
- export { on } from '@glimmer/runtime';
1
+ import { on as glimmerOn } from '@glimmer/runtime';
2
+ import { setModifierManager as glimmerSetModifierManager } from '@glimmer/manager';
3
+ // SAFETY: at the time of writing, the cast here is from `{}` to `OnModifier`,
4
+ // which makes it strictly safer to use outside this module because it is not
5
+ // usable as "any non-null item", which is what `{}` means, without loss of any
6
+ // information from the type itself.
7
+ export const on = glimmerOn;
8
+ // NOTE: this uses assignment to *require* that the `glimmerSetModifierManager`
9
+ // is legally assignable to this type, i.e. that variance is properly upheld.
10
+ export const setModifierManager = glimmerSetModifierManager;
11
+ export { modifierCapabilities as capabilities } from '@ember/-internals/glimmer';