ember-source 7.2.0-beta.1 → 7.3.0-alpha.1

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 (70) hide show
  1. package/build-metadata.json +3 -3
  2. package/dist/dev/packages/@ember/-internals/deprecations/index.js +10 -0
  3. package/dist/dev/packages/@ember/-internals/glimmer/index.js +3 -3
  4. package/dist/dev/packages/@ember/-internals/routing/index.js +1 -1
  5. package/dist/dev/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
  6. package/dist/dev/packages/@ember/-internals/runtime/lib/mixins/comparable.js +5 -0
  7. package/dist/dev/packages/@ember/application/index.js +2 -2
  8. package/dist/dev/packages/@ember/application/instance.js +21 -1
  9. package/dist/dev/packages/@ember/component/helper.js +321 -1
  10. package/dist/dev/packages/@ember/component/index.js +1 -1
  11. package/dist/dev/packages/@ember/engine/index.js +2 -2
  12. package/dist/dev/packages/@ember/renderer/index.js +1 -1
  13. package/dist/dev/packages/@ember/routing/-internals.js +1 -1
  14. package/dist/dev/packages/@ember/routing/lib/routing-service.js +0 -1
  15. package/dist/dev/packages/@ember/routing/lib/utils.js +1 -1
  16. package/dist/dev/packages/@ember/routing/route.js +1 -1
  17. package/dist/dev/packages/@ember/routing/router-service.js +0 -1
  18. package/dist/dev/packages/@ember/routing/router.js +1 -1
  19. package/dist/dev/packages/@ember/utils/lib/compare.js +5 -2
  20. package/dist/dev/packages/ember/version.js +1 -1
  21. package/dist/dev/packages/router_js/index.js +2 -2
  22. package/dist/dev/packages/shared-chunks/{curly-Ei5G8jhk.js → curly-DGUCLOud.js} +4 -5
  23. package/dist/dev/packages/shared-chunks/curly-brand-B_F79Dep.js +12 -0
  24. package/dist/dev/packages/shared-chunks/helper-brand-C9_8vvOf.js +12 -0
  25. package/dist/dev/packages/shared-chunks/{index-B3pPx1fL.js → index-CCyXUNBa.js} +616 -1573
  26. package/dist/dev/packages/shared-chunks/outlet-CHFL7tun.js +135 -0
  27. package/dist/dev/packages/shared-chunks/setup-registry-BHdDJATP.js +951 -0
  28. package/dist/dev/packages/shared-chunks/{unrecognized-url-error-BJHjL30Q.js → unrecognized-url-error-B8loxkay.js} +1 -1
  29. package/dist/prod/packages/@ember/-internals/deprecations/index.js +10 -0
  30. package/dist/prod/packages/@ember/-internals/glimmer/index.js +3 -3
  31. package/dist/prod/packages/@ember/-internals/routing/index.js +1 -1
  32. package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
  33. package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/comparable.js +5 -0
  34. package/dist/prod/packages/@ember/application/index.js +2 -2
  35. package/dist/prod/packages/@ember/application/instance.js +17 -2
  36. package/dist/prod/packages/@ember/component/helper.js +305 -1
  37. package/dist/prod/packages/@ember/component/index.js +1 -1
  38. package/dist/prod/packages/@ember/engine/index.js +2 -2
  39. package/dist/prod/packages/@ember/renderer/index.js +1 -1
  40. package/dist/prod/packages/@ember/routing/lib/routing-service.js +0 -1
  41. package/dist/prod/packages/@ember/routing/lib/utils.js +1 -1
  42. package/dist/prod/packages/@ember/routing/route.js +1 -1
  43. package/dist/prod/packages/@ember/routing/router-service.js +0 -1
  44. package/dist/prod/packages/@ember/routing/router.js +1 -1
  45. package/dist/prod/packages/@ember/utils/lib/compare.js +5 -2
  46. package/dist/prod/packages/ember/version.js +1 -1
  47. package/dist/prod/packages/router_js/index.js +2 -2
  48. package/dist/prod/packages/shared-chunks/{curly-IY06zACp.js → curly-a6DP7r87.js} +4 -5
  49. package/dist/prod/packages/shared-chunks/curly-brand-B_F79Dep.js +12 -0
  50. package/dist/prod/packages/shared-chunks/helper-brand-C9_8vvOf.js +12 -0
  51. package/dist/prod/packages/shared-chunks/{index-CslMfEpb.js → index-npr2B-vu.js} +546 -1449
  52. package/dist/prod/packages/shared-chunks/outlet--lIm3q7t.js +132 -0
  53. package/dist/prod/packages/shared-chunks/setup-registry-Dfu8EyLU.js +886 -0
  54. package/dist/prod/packages/shared-chunks/{unrecognized-url-error-EgNrnFu_.js → unrecognized-url-error-jjQ-FqKB.js} +1 -1
  55. package/docs/data.json +279 -214
  56. package/package.json +6 -6
  57. package/types/stable/@ember/-internals/deprecations/index.d.ts +6 -0
  58. package/types/stable/@ember/-internals/glimmer/lib/base-renderer.d.ts +150 -0
  59. package/types/stable/@ember/-internals/glimmer/lib/component-managers/curly-brand.d.ts +10 -0
  60. package/types/stable/@ember/-internals/glimmer/lib/component-managers/curly.d.ts +3 -2
  61. package/types/stable/@ember/-internals/glimmer/lib/helper-brand.d.ts +10 -0
  62. package/types/stable/@ember/-internals/glimmer/lib/helper.d.ts +4 -6
  63. package/types/stable/@ember/-internals/glimmer/lib/renderer.d.ts +7 -154
  64. package/types/stable/@ember/-internals/glimmer/lib/router-resolver.d.ts +17 -0
  65. package/types/stable/@ember/renderer/index.d.ts +2 -2
  66. package/types/stable/index.d.ts +590 -586
  67. package/dist/dev/packages/shared-chunks/helper-DIj85_-f.js +0 -326
  68. package/dist/dev/packages/shared-chunks/setup-registry-9DCmHTFF.js +0 -77
  69. package/dist/prod/packages/shared-chunks/helper-DkXiTBjc.js +0 -310
  70. package/dist/prod/packages/shared-chunks/setup-registry-U-6VaNQG.js +0 -74
@@ -1,326 +0,0 @@
1
- import { setOwner } from '../@ember/-internals/owner/index.js';
2
- import { FrameworkObject } from '../@ember/object/-internals.js';
3
- import { g as getDebugName } from './get-debug-name-CSniHBsn.js';
4
- import '../@ember/debug/index.js';
5
- import { join } from '../@ember/runloop/index.js';
6
- import { a as getInternalHelperManager, i as helperCapabilities } from './api-DuLOZMO_.js';
7
- import { b as setHelperManager } from './api-BlZDPg1n.js';
8
- import { r as createTag, D as DIRTY_TAG, c as consumeTag } from './cache-DGDPVCpC.js';
9
- import { assert } from '../@ember/debug/lib/assert.js';
10
-
11
- /**
12
- @module @ember/component
13
- */
14
-
15
- const RECOMPUTE_TAG = Symbol('RECOMPUTE_TAG');
16
-
17
- // Signature type utilities
18
-
19
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
20
-
21
- // Implements Ember's `Factory` interface and tags it for narrowing/checking.
22
-
23
- const IS_CLASSIC_HELPER = Symbol('IS_CLASSIC_HELPER');
24
-
25
- // A zero-runtime-overhead private symbol to use in branding the component to
26
- // preserve its type parameter.
27
-
28
- /**
29
- Ember Helpers are functions that can compute values, and are used in templates.
30
- For example, this code calls a helper named `format-currency`:
31
-
32
- ```app/templates/application.gjs
33
- import Cost from '../components/cost';
34
-
35
- <template>
36
- <Cost @cents={{230}} />
37
- </template>
38
- ```
39
-
40
- ```app/components/cost.gjs
41
- import formatCurrency from '../helpers/format-currency';
42
-
43
- <template>
44
- <div>{{formatCurrency @cents currency="$"}}</div>
45
- </template>
46
- ```
47
-
48
- Additionally a helper can be called as a nested helper.
49
- In this example, we show the formatted currency value if the `showMoney`
50
- named argument is truthy.
51
-
52
- ```gjs
53
- import formatCurrency from '../helpers/format-currency';
54
-
55
- <template>
56
- {{if @showMoney (formatCurrency @cents currency="$")}}
57
- </template>
58
- ```
59
-
60
- Helpers defined using a class must provide a `compute` function. For example:
61
-
62
- ```app/helpers/format-currency.js
63
- import Helper from '@ember/component/helper';
64
-
65
- export default class extends Helper {
66
- compute([cents], { currency }) {
67
- return `${currency}${cents * 0.01}`;
68
- }
69
- }
70
- ```
71
-
72
- Each time the input to a helper changes, the `compute` function will be
73
- called again.
74
-
75
- As instances, these helpers also have access to the container and will accept
76
- injected dependencies.
77
-
78
- Additionally, class helpers can call `recompute` to force a new computation.
79
-
80
- @class Helper
81
- @extends CoreObject
82
- @public
83
- @since 1.13.0
84
- */
85
- // ESLint doesn't understand declaration merging.
86
- /* eslint-disable import/export */
87
-
88
- class Helper extends FrameworkObject {
89
- static isHelperFactory = true;
90
- static [IS_CLASSIC_HELPER] = true;
91
-
92
- // `packages/ember/index.js` was setting `Helper.helper`. This seems like
93
- // a bad idea and probably not something we want. We've moved that definition
94
- // here, but it should definitely be reviewed and probably removed.
95
- /** @deprecated */
96
- static helper = helper;
97
-
98
- // SAFETY: this is initialized in `init`, rather than `constructor`. It is
99
- // safe to `declare` like this *if and only if* nothing uses the constructor
100
- // directly in this class, since nothing else can run before `init`.
101
-
102
- // SAFETY: this has no runtime existence whatsoever; it is a "phantom type"
103
- // here to preserve the type param.
104
-
105
- init(properties) {
106
- super.init(properties);
107
- this[RECOMPUTE_TAG] = createTag();
108
- (!(this.compute) && assert('expected compute to be defined', this.compute));
109
- }
110
-
111
- /**
112
- On a class-based helper, it may be useful to force a recomputation of that
113
- helpers value. This is akin to `rerender` on a component.
114
- In most cases, `recompute` is not needed because accessing tracked
115
- properties in `compute` will automatically re-run the helper when
116
- those properties change. Use `recompute` only when you need to
117
- trigger a recomputation imperatively, for example in response to an
118
- external event:
119
- ```app/helpers/current-time.js
120
- import Helper from '@ember/component/helper';
121
- export default class CurrentTimeHelper extends Helper {
122
- interval = null;
123
- compute() {
124
- return new Date().toLocaleTimeString();
125
- }
126
- constructor() {
127
- super(...arguments);
128
- this.interval = setInterval(() => this.recompute(), 1000);
129
- }
130
- willDestroy() {
131
- super.willDestroy();
132
- clearInterval(this.interval);
133
- }
134
- }
135
- ```
136
- @method recompute
137
- @public
138
- @since 1.13.0
139
- */
140
- recompute() {
141
- join(() => DIRTY_TAG(this[RECOMPUTE_TAG]));
142
- }
143
- }
144
- /* eslint-enable import/export */
145
-
146
- function isClassicHelper(obj) {
147
- return obj[IS_CLASSIC_HELPER] === true;
148
- }
149
- class ClassicHelperManager {
150
- capabilities = helperCapabilities('3.23', {
151
- hasValue: true,
152
- hasDestroyable: true
153
- });
154
- ownerInjection;
155
- constructor(owner) {
156
- let ownerInjection = {};
157
- setOwner(ownerInjection, owner);
158
- this.ownerInjection = ownerInjection;
159
- }
160
- createHelper(definition, args) {
161
- let instance = isFactoryManager(definition) ? definition.create() : definition.create(this.ownerInjection);
162
- (!(function (instance) {
163
- if (instance !== null && typeof instance === 'object') {
164
- let cast = instance;
165
- return typeof cast.compute === 'function' && typeof cast.destroy === 'function';
166
- }
167
- return false;
168
- }(instance)) && assert('expected HelperInstance', function (instance) {
169
- if (instance !== null && typeof instance === 'object') {
170
- let cast = instance;
171
- return typeof cast.compute === 'function' && typeof cast.destroy === 'function';
172
- }
173
- return false;
174
- }(instance)));
175
- return {
176
- instance,
177
- args
178
- };
179
- }
180
- getDestroyable({
181
- instance
182
- }) {
183
- return instance;
184
- }
185
- getValue({
186
- instance,
187
- args
188
- }) {
189
- let {
190
- positional,
191
- named
192
- } = args;
193
- let ret = instance.compute(positional, named);
194
- consumeTag(instance[RECOMPUTE_TAG]);
195
- return ret;
196
- }
197
- getDebugName(definition) {
198
- return getDebugName((definition.class || definition)['prototype']);
199
- }
200
- }
201
- function isFactoryManager(obj) {
202
- return obj != null && 'class' in obj;
203
- }
204
- setHelperManager(owner => {
205
- return new ClassicHelperManager(owner);
206
- }, Helper);
207
- const CLASSIC_HELPER_MANAGER = getInternalHelperManager(Helper);
208
-
209
- ///////////
210
-
211
- class Wrapper {
212
- isHelperFactory = true;
213
- constructor(compute) {
214
- this.compute = compute;
215
- }
216
- create() {
217
- // needs new instance or will leak containers
218
- return {
219
- compute: this.compute
220
- };
221
- }
222
- }
223
- class SimpleClassicHelperManager {
224
- capabilities = helperCapabilities('3.23', {
225
- hasValue: true
226
- });
227
- createHelper(definition, args) {
228
- return () => definition.compute.call(null, args.positional, args.named);
229
- }
230
- getValue(fn) {
231
- return fn();
232
- }
233
- getDebugName(definition) {
234
- return getDebugName(definition.compute);
235
- }
236
- }
237
- const SIMPLE_CLASSIC_HELPER_MANAGER = new SimpleClassicHelperManager();
238
- setHelperManager(() => SIMPLE_CLASSIC_HELPER_MANAGER, Wrapper.prototype);
239
-
240
- /*
241
- Function-based helpers need to present with a constructor signature so that
242
- type parameters can be preserved when `helper()` is passed a generic function
243
- (this is particularly key for checking helper invocations with Glint).
244
- Accordingly, we define an abstract class and declaration merge it with the
245
- interface; this inherently provides an `abstract` constructor. Since it is
246
- `abstract`, it is not callable, which is important since end users should not
247
- be able to do `let myHelper = helper(someFn); new myHelper()`.
248
- */
249
-
250
- /**
251
- * The type of a function-based helper.
252
- *
253
- * @note This is *not* user-constructible: it is exported only so that the type
254
- * returned by the `helper` function can be named (and indeed can be exported
255
- * like `export default helper(...)` safely).
256
- */
257
- // Making `FunctionBasedHelper` an alias this way allows callers to name it in
258
- // terms meaningful to *them*, while preserving the type behavior described on
259
- // the `abstract class FunctionBasedHelperInstance` below.
260
-
261
- // This abstract class -- specifically, its `protected abstract __concrete__`
262
- // member -- prevents subclasses from doing `class X extends helper(..)`, since
263
- // that is an error at runtime. While it is rare that people would type that, it
264
- // is not impossible and we use this to give them early signal via the types for
265
- // a behavior which will break (and in a somewhat inscrutable way!) at runtime.
266
- //
267
- // This is needful because we lie about what this actually is for Glint's sake:
268
- // a function-based helper returns a `Factory<SimpleHelper>`, which is designed
269
- // to be "opaque" from a consumer's POV, i.e. not user-callable or constructible
270
- // but only useable in a template (or via `invokeHelper()` which also treats it
271
- // as a fully opaque `object` from a type POV). But Glint needs a `Helper<S>` to
272
- // make it work the same way as class-based helpers. (Note that this does not
273
- // hold for plain functions as helpers, which it can handle distinctly.) This
274
- // signature thus makes it so that the item is usable *as* a `Helper` in Glint,
275
- // but without letting end users treat it as a helper class instance.
276
-
277
- /**
278
- In many cases it is not necessary to use the full `Helper` class.
279
- The `helper` method create pure-function helpers without instances.
280
- For example:
281
-
282
- ```app/helpers/format-currency.js
283
- import { helper } from '@ember/component/helper';
284
-
285
- export default helper(function([cents], {currency}) {
286
- return `${currency}${cents * 0.01}`;
287
- });
288
- ```
289
-
290
- @static
291
- @param {Function} helper The helper function
292
- @method helper
293
- @for @ember/component/helper
294
- @public
295
- @since 1.13.0
296
- */
297
- // This overload allows users to write types directly on the callback passed to
298
- // the `helper` function and infer the resulting type correctly.
299
-
300
- // This overload allows users to provide a `Signature` type explicitly at the
301
- // helper definition site, e.g. `helper<Sig>((pos, named) => {...})`. **Note:**
302
- // this overload must appear second, since TS' inference engine will not
303
- // correctly infer the type of `S` here from the types on the supplied callback.
304
-
305
- function helper(helperFn) {
306
- // SAFETY: this is completely lies, in two ways:
307
- //
308
- // 1. `Wrapper` is a `Factory<SimpleHelper<S>>`, but from the perspective of
309
- // any external callers (i.e. Ember *users*), it is quite important that
310
- // the `Factory` relationship be hidden, because it is not public API for
311
- // an end user to call `.create()` on a helper created this way. Instead,
312
- // we provide them an `abstract new` signature (which means it cannot be
313
- // directly constructed by calling `new` on it) and which does not have the
314
- // `.create()` signature on it anymore.
315
- //
316
- // 2. The produced type here ends up being a subtype of `Helper`, which is not
317
- // strictly true. This is necessary for the sake of Glint, which provides
318
- // its information by way of a "declaration merge" with `Helper<S>` in the
319
- // case of items produced by `helper()`.
320
- //
321
- // Long-term, this entire construct can go away in favor of deprecating the
322
- // `helper()` invocation in favor of using plain functions.
323
- return new Wrapper(helperFn);
324
- }
325
-
326
- export { CLASSIC_HELPER_MANAGER as C, Helper as H, helper as h, isClassicHelper as i };
@@ -1,77 +0,0 @@
1
- import { privatize } from '../@ember/-internals/container/index.js';
2
- import { getOwner } from '../@ember/-internals/owner/index.js';
3
- import '../@ember/debug/index.js';
4
- import { I as Input, T as Textarea } from './textarea-C4lYkaHj.js';
5
- import { LinkTo } from '../@ember/routing/index.js';
6
- import './render-87_sKZ_k.js';
7
- import { c as clientBuilder } from './api-C0PAtEgQ.js';
8
- import { r as rehydrationBuilder } from './rehydrate-builder-C6k1XhET.js';
9
- import { s as serializeBuilder } from './serialize-builder-BlxBjwO-.js';
10
- import { o as outletHelper, O as OutletView, R as Renderer } from './index-B3pPx1fL.js';
11
- import { t as templateFactory } from './index-DaFzpTIE.js';
12
- import { assert } from '../@ember/debug/lib/assert.js';
13
-
14
- const RootTemplate = templateFactory(
15
- /*
16
- {{component this}}
17
- */
18
- {
19
- "id": null,
20
- "block": "[[[46,[30,0],null,null,null]],[],[\"component\"]]",
21
- "moduleName": "packages/@ember/-internals/glimmer/lib/templates/root.hbs",
22
- "isStrictMode": true
23
- });
24
-
25
- const OutletTemplate = templateFactory(
26
- /*
27
- {{component (outletHelper)}}
28
- */
29
- {
30
- "id": null,
31
- "block": "[[[46,[28,[32,0],null,null],null,null,null]],[],[\"component\"]]",
32
- "moduleName": "packages/@ember/-internals/glimmer/lib/templates/outlet.hbs",
33
- "scope": () => ({
34
- outletHelper
35
- }),
36
- "isStrictMode": true
37
- });
38
-
39
- function setupApplicationRegistry(registry) {
40
- // because we are using injections we can't use instantiate false
41
- // we need to use bind() to copy the function so factory for
42
- // association won't leak
43
- registry.register('service:-dom-builder', {
44
- // Additionally, we *must* constrain this to require `props` on create, else
45
- // we *know* it cannot have an owner.
46
- create(props) {
47
- let owner = getOwner(props);
48
- (!(owner) && assert('DomBuilderService is unexpectedly missing an owner', owner));
49
- let env = owner.lookup('-environment:main');
50
- switch (env._renderMode) {
51
- case 'serialize':
52
- return serializeBuilder.bind(null);
53
- case 'rehydrate':
54
- return rehydrationBuilder.bind(null);
55
- default:
56
- return clientBuilder.bind(null);
57
- }
58
- }
59
- });
60
- registry.register(privatize`template:-root`, RootTemplate);
61
- registry.register('renderer:-dom', Renderer);
62
- }
63
- function setupEngineRegistry(registry) {
64
- registry.optionsForType('template', {
65
- instantiate: false
66
- });
67
- registry.register('view:-outlet', OutletView);
68
- registry.register('template:-outlet', OutletTemplate);
69
- registry.optionsForType('helper', {
70
- instantiate: false
71
- });
72
- registry.register('component:input', Input);
73
- registry.register('component:link-to', LinkTo);
74
- registry.register('component:textarea', Textarea);
75
- }
76
-
77
- export { RootTemplate as R, setupEngineRegistry as a, setupApplicationRegistry as s };