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