@angular/core 18.1.0-next.1 → 18.1.0-next.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 (31) hide show
  1. package/esm2022/src/core.mjs +1 -1
  2. package/esm2022/src/event_emitter.mjs +20 -11
  3. package/esm2022/src/pending_tasks.mjs +15 -20
  4. package/esm2022/src/render3/after_render_hooks.mjs +67 -132
  5. package/esm2022/src/render3/component_ref.mjs +1 -1
  6. package/esm2022/src/render3/instructions/change_detection.mjs +27 -24
  7. package/esm2022/src/render3/reactive_lview_consumer.mjs +56 -3
  8. package/esm2022/src/version.mjs +1 -1
  9. package/esm2022/testing/src/logger.mjs +3 -3
  10. package/fesm2022/core.mjs +344 -349
  11. package/fesm2022/core.mjs.map +1 -1
  12. package/fesm2022/primitives/event-dispatch.mjs +1 -1
  13. package/fesm2022/primitives/signals.mjs +1 -1
  14. package/fesm2022/rxjs-interop.mjs +1 -1
  15. package/fesm2022/testing.mjs +1 -1
  16. package/index.d.ts +212 -28
  17. package/package.json +1 -1
  18. package/primitives/event-dispatch/index.d.ts +1 -1
  19. package/primitives/signals/index.d.ts +1 -1
  20. package/rxjs-interop/index.d.ts +1 -1
  21. package/schematics/migrations/after-render-phase/bundle.js +602 -0
  22. package/schematics/migrations/after-render-phase/bundle.js.map +7 -0
  23. package/schematics/migrations/http-providers/bundle.js +15 -15
  24. package/schematics/migrations/invalid-two-way-bindings/bundle.js +158 -158
  25. package/schematics/migrations/invalid-two-way-bindings/bundle.js.map +1 -1
  26. package/schematics/migrations.json +5 -0
  27. package/schematics/ng-generate/control-flow-migration/bundle.js +166 -166
  28. package/schematics/ng-generate/control-flow-migration/bundle.js.map +1 -1
  29. package/schematics/ng-generate/standalone-migration/bundle.js +483 -1096
  30. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  31. package/testing/index.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.1.0-next.1
2
+ * @license Angular v18.1.0-next.2
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.1.0-next.1
2
+ * @license Angular v18.1.0-next.2
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.1.0-next.1
2
+ * @license Angular v18.1.0-next.2
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.1.0-next.1
2
+ * @license Angular v18.1.0-next.2
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.1.0-next.1
2
+ * @license Angular v18.1.0-next.2
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -83,19 +83,105 @@ export declare interface AfterContentInit {
83
83
  }
84
84
 
85
85
  /**
86
- * Register a callback to be invoked the next time the application
87
- * finishes rendering.
86
+ * Register callbacks to be invoked the next time the application finishes rendering, during the
87
+ * specified phases. The available phases are:
88
+ * - `earlyRead`
89
+ * Use this phase to **read** from the DOM before a subsequent `write` callback, for example to
90
+ * perform custom layout that the browser doesn't natively support. Prefer the `read` phase if
91
+ * reading can wait until after the write phase. **Never** write to the DOM in this phase.
92
+ * - `write`
93
+ * Use this phase to **write** to the DOM. **Never** read from the DOM in this phase.
94
+ * - `mixedReadWrite`
95
+ * Use this phase to read from and write to the DOM simultaneously. **Never** use this phase if
96
+ * it is possible to divide the work among the other phases instead.
97
+ * - `read`
98
+ * Use this phase to **read** from the DOM. **Never** write to the DOM in this phase.
88
99
  *
89
100
  * <div class="alert is-critical">
90
101
  *
91
- * You should always explicitly specify a non-default [phase](api/core/AfterRenderPhase), or you
92
- * risk significant performance degradation.
102
+ * You should prefer using the `read` and `write` phases over the `earlyRead` and `mixedReadWrite`
103
+ * phases when possible, to avoid performance degradation.
104
+ *
105
+ * </div>
106
+ *
107
+ * Note that:
108
+ * - Callbacks run in the following phase order *once, after the next render*:
109
+ * 1. `earlyRead`
110
+ * 2. `write`
111
+ * 3. `mixedReadWrite`
112
+ * 4. `read`
113
+ * - Callbacks in the same phase run in the order they are registered.
114
+ * - Callbacks run on browser platforms only, they will not run on the server.
115
+ *
116
+ * The first phase callback to run as part of this spec will receive no parameters. Each
117
+ * subsequent phase callback in this spec will receive the return value of the previously run
118
+ * phase callback as a parameter. This can be used to coordinate work across multiple phases.
119
+ *
120
+ * Angular is unable to verify or enforce that phases are used correctly, and instead
121
+ * relies on each developer to follow the guidelines documented for each value and
122
+ * carefully choose the appropriate one, refactoring their code if necessary. By doing
123
+ * so, Angular is better able to minimize the performance degradation associated with
124
+ * manual DOM access, ensuring the best experience for the end users of your application
125
+ * or library.
126
+ *
127
+ * <div class="alert is-important">
128
+ *
129
+ * Components are not guaranteed to be [hydrated](guide/hydration) before the callback runs.
130
+ * You must use caution when directly reading or writing the DOM and layout.
131
+ *
132
+ * </div>
133
+ *
134
+ * @param spec The callback functions to register
135
+ *
136
+ * @usageNotes
137
+ *
138
+ * Use `afterNextRender` to read or write the DOM once,
139
+ * for example to initialize a non-Angular library.
140
+ *
141
+ * ### Example
142
+ * ```ts
143
+ * @Component({
144
+ * selector: 'my-chart-cmp',
145
+ * template: `<div #chart>{{ ... }}</div>`,
146
+ * })
147
+ * export class MyChartCmp {
148
+ * @ViewChild('chart') chartRef: ElementRef;
149
+ * chart: MyChart|null;
150
+ *
151
+ * constructor() {
152
+ * afterNextRender({
153
+ * write: () => {
154
+ * this.chart = new MyChart(this.chartRef.nativeElement);
155
+ * }
156
+ * });
157
+ * }
158
+ * }
159
+ * ```
160
+ *
161
+ * @developerPreview
162
+ */
163
+ export declare function afterNextRender<E = never, W = never, M = never>(spec: {
164
+ earlyRead?: () => E;
165
+ write?: (...args: ɵFirstAvailable<[E]>) => W;
166
+ mixedReadWrite?: (...args: ɵFirstAvailable<[W, E]>) => M;
167
+ read?: (...args: ɵFirstAvailable<[M, W, E]>) => void;
168
+ }, opts?: Omit<AfterRenderOptions, 'phase'>): AfterRenderRef;
169
+
170
+ /**
171
+ * Register a callback to be invoked the next time the application finishes rendering, during the
172
+ * `mixedReadWrite` phase.
173
+ *
174
+ * <div class="alert is-critical">
175
+ *
176
+ * You should prefer specifying an explicit phase for the callback instead, or you risk significant
177
+ * performance degradation.
93
178
  *
94
179
  * </div>
95
180
  *
96
181
  * Note that the callback will run
97
182
  * - in the order it was registered
98
183
  * - on browser platforms only
184
+ * - during the `mixedReadWrite` phase
99
185
  *
100
186
  * <div class="alert is-important">
101
187
  *
@@ -122,9 +208,11 @@ export declare interface AfterContentInit {
122
208
  * chart: MyChart|null;
123
209
  *
124
210
  * constructor() {
125
- * afterNextRender(() => {
126
- * this.chart = new MyChart(this.chartRef.nativeElement);
127
- * }, {phase: AfterRenderPhase.Write});
211
+ * afterNextRender({
212
+ * write: () => {
213
+ * this.chart = new MyChart(this.chartRef.nativeElement);
214
+ * }
215
+ * });
128
216
  * }
129
217
  * }
130
218
  * ```
@@ -134,13 +222,96 @@ export declare interface AfterContentInit {
134
222
  export declare function afterNextRender(callback: VoidFunction, options?: AfterRenderOptions): AfterRenderRef;
135
223
 
136
224
  /**
137
- * Register a callback to be invoked each time the application
138
- * finishes rendering.
225
+ * Register callbacks to be invoked each time the application finishes rendering, during the
226
+ * specified phases. The available phases are:
227
+ * - `earlyRead`
228
+ * Use this phase to **read** from the DOM before a subsequent `write` callback, for example to
229
+ * perform custom layout that the browser doesn't natively support. Prefer the `read` phase if
230
+ * reading can wait until after the write phase. **Never** write to the DOM in this phase.
231
+ * - `write`
232
+ * Use this phase to **write** to the DOM. **Never** read from the DOM in this phase.
233
+ * - `mixedReadWrite`
234
+ * Use this phase to read from and write to the DOM simultaneously. **Never** use this phase if
235
+ * it is possible to divide the work among the other phases instead.
236
+ * - `read`
237
+ * Use this phase to **read** from the DOM. **Never** write to the DOM in this phase.
139
238
  *
140
239
  * <div class="alert is-critical">
141
240
  *
142
- * You should always explicitly specify a non-default [phase](api/core/AfterRenderPhase), or you
143
- * risk significant performance degradation.
241
+ * You should prefer using the `read` and `write` phases over the `earlyRead` and `mixedReadWrite`
242
+ * phases when possible, to avoid performance degradation.
243
+ *
244
+ * </div>
245
+ *
246
+ * Note that:
247
+ * - Callbacks run in the following phase order *after each render*:
248
+ * 1. `earlyRead`
249
+ * 2. `write`
250
+ * 3. `mixedReadWrite`
251
+ * 4. `read`
252
+ * - Callbacks in the same phase run in the order they are registered.
253
+ * - Callbacks run on browser platforms only, they will not run on the server.
254
+ *
255
+ * The first phase callback to run as part of this spec will receive no parameters. Each
256
+ * subsequent phase callback in this spec will receive the return value of the previously run
257
+ * phase callback as a parameter. This can be used to coordinate work across multiple phases.
258
+ *
259
+ * Angular is unable to verify or enforce that phases are used correctly, and instead
260
+ * relies on each developer to follow the guidelines documented for each value and
261
+ * carefully choose the appropriate one, refactoring their code if necessary. By doing
262
+ * so, Angular is better able to minimize the performance degradation associated with
263
+ * manual DOM access, ensuring the best experience for the end users of your application
264
+ * or library.
265
+ *
266
+ * <div class="alert is-important">
267
+ *
268
+ * Components are not guaranteed to be [hydrated](guide/hydration) before the callback runs.
269
+ * You must use caution when directly reading or writing the DOM and layout.
270
+ *
271
+ * </div>
272
+ *
273
+ * @param spec The callback functions to register
274
+ *
275
+ * @usageNotes
276
+ *
277
+ * Use `afterRender` to read or write the DOM after each render.
278
+ *
279
+ * ### Example
280
+ * ```ts
281
+ * @Component({
282
+ * selector: 'my-cmp',
283
+ * template: `<span #content>{{ ... }}</span>`,
284
+ * })
285
+ * export class MyComponent {
286
+ * @ViewChild('content') contentRef: ElementRef;
287
+ *
288
+ * constructor() {
289
+ * afterRender({
290
+ * read: () => {
291
+ * console.log('content height: ' + this.contentRef.nativeElement.scrollHeight);
292
+ * }
293
+ * });
294
+ * }
295
+ * }
296
+ * ```
297
+ *
298
+ * @developerPreview
299
+ */
300
+ export declare function afterRender<E = never, W = never, M = never>(spec: {
301
+ earlyRead?: () => E;
302
+ write?: (...args: ɵFirstAvailable<[E]>) => W;
303
+ mixedReadWrite?: (...args: ɵFirstAvailable<[W, E]>) => M;
304
+ read?: (...args: ɵFirstAvailable<[M, W, E]>) => void;
305
+ }, opts?: Omit<AfterRenderOptions, 'phase'>): AfterRenderRef;
306
+
307
+ /**
308
+ * Register a callback to be invoked each time the application finishes rendering, during the
309
+ * `mixedReadWrite` phase.
310
+ *
311
+ * <div class="alert is-critical">
312
+ *
313
+ * You should prefer specifying an explicit phase for the callback instead, or you risk significant
314
+ * performance degradation.
144
315
  *
145
316
  * </div>
146
317
  *
@@ -148,6 +319,7 @@ export declare function afterNextRender(callback: VoidFunction, options?: AfterR
148
319
  * - in the order it was registered
149
320
  * - once per render
150
321
  * - on browser platforms only
322
+ * - during the `mixedReadWrite` phase
151
323
  *
152
324
  * <div class="alert is-important">
153
325
  *
@@ -172,9 +344,11 @@ export declare function afterNextRender(callback: VoidFunction, options?: AfterR
172
344
  * @ViewChild('content') contentRef: ElementRef;
173
345
  *
174
346
  * constructor() {
175
- * afterRender(() => {
176
- * console.log('content height: ' + this.contentRef.nativeElement.scrollHeight);
177
- * }, {phase: AfterRenderPhase.Read});
347
+ * afterRender({
348
+ * read: () => {
349
+ * console.log('content height: ' + this.contentRef.nativeElement.scrollHeight);
350
+ * }
351
+ * });
178
352
  * }
179
353
  * }
180
354
  * ```
@@ -204,6 +378,9 @@ export declare interface AfterRenderOptions {
204
378
  * phase instead. See `AfterRenderPhase` for more information.
205
379
  *
206
380
  * </div>
381
+ *
382
+ * @deprecated Specify the phase for your callback to run in by passing a spec-object as the first
383
+ * parameter to `afterRender` or `afterNextRender` insetad of a function.
207
384
  */
208
385
  phase?: AfterRenderPhase;
209
386
  }
@@ -226,14 +403,16 @@ export declare interface AfterRenderOptions {
226
403
  * manual DOM access, ensuring the best experience for the end users of your application
227
404
  * or library.
228
405
  *
229
- * @developerPreview
406
+ * @deprecated Specify the phase for your callback to run in by passing a spec-object as the first
407
+ * parameter to `afterRender` or `afterNextRender` insetad of a function.
230
408
  */
231
409
  export declare enum AfterRenderPhase {
232
410
  /**
233
411
  * Use `AfterRenderPhase.EarlyRead` for callbacks that only need to **read** from the
234
412
  * DOM before a subsequent `AfterRenderPhase.Write` callback, for example to perform
235
- * custom layout that the browser doesn't natively support. **Never** use this phase
236
- * for callbacks that can write to the DOM or when `AfterRenderPhase.Read` is adequate.
413
+ * custom layout that the browser doesn't natively support. Prefer the
414
+ * `AfterRenderPhase.EarlyRead` phase if reading can wait until after the write phase.
415
+ * **Never** write to the DOM in this phase.
237
416
  *
238
417
  * <div class="alert is-important">
239
418
  *
@@ -245,25 +424,25 @@ export declare enum AfterRenderPhase {
245
424
  EarlyRead = 0,
246
425
  /**
247
426
  * Use `AfterRenderPhase.Write` for callbacks that only **write** to the DOM. **Never**
248
- * use this phase for callbacks that can read from the DOM.
427
+ * read from the DOM in this phase.
249
428
  */
250
429
  Write = 1,
251
430
  /**
252
431
  * Use `AfterRenderPhase.MixedReadWrite` for callbacks that read from or write to the
253
- * DOM, that haven't been refactored to use a different phase. **Never** use this phase
254
- * for callbacks that can use a different phase instead.
432
+ * DOM, that haven't been refactored to use a different phase. **Never** use this phase if
433
+ * it is possible to divide the work among the other phases instead.
255
434
  *
256
435
  * <div class="alert is-critical">
257
436
  *
258
437
  * Using this value can **significantly** degrade performance.
259
- * Instead, prefer refactoring into multiple callbacks using a more specific phase.
438
+ * Instead, prefer dividing work into the appropriate phase callbacks.
260
439
  *
261
440
  * </div>
262
441
  */
263
442
  MixedReadWrite = 2,
264
443
  /**
265
444
  * Use `AfterRenderPhase.Read` for callbacks that only **read** from the DOM. **Never**
266
- * use this phase for callbacks that can write to the DOM.
445
+ * write to the DOM in this phase.
267
446
  */
268
447
  Read = 3
269
448
  }
@@ -3964,8 +4143,8 @@ export declare class ExperimentalPendingTasks {
3964
4143
  * @returns A cleanup function that removes a task when called.
3965
4144
  */
3966
4145
  add(): () => void;
3967
- static ɵfac: i0.ɵɵFactoryDeclaration<ExperimentalPendingTasks, never>;
3968
- static ɵprov: i0.ɵɵInjectableDeclaration<ExperimentalPendingTasks>;
4146
+ /** @nocollapse */
4147
+ static ɵprov: unknown;
3969
4148
  }
3970
4149
 
3971
4150
  /**
@@ -8675,7 +8854,6 @@ declare const REACTIVE_TEMPLATE_CONSUMER = 23;
8675
8854
 
8676
8855
  declare interface ReactiveLViewConsumer extends ReactiveNode {
8677
8856
  lView: LView | null;
8678
- slot: typeof REACTIVE_TEMPLATE_CONSUMER;
8679
8857
  }
8680
8858
 
8681
8859
  /**
@@ -12624,6 +12802,12 @@ export declare const enum ɵExtraLocaleDataIndex {
12624
12802
  */
12625
12803
  export declare function ɵfindLocaleData(locale: string): any;
12626
12804
 
12805
+ /**
12806
+ * An argument list containing the first non-never type in the given type array, or an empty
12807
+ * argument list if there are no non-never types in the type array.
12808
+ */
12809
+ export declare type ɵFirstAvailable<T extends unknown[]> = T extends [infer H, ...infer R] ? [H] extends [never] ? ɵFirstAvailable<R> : [H] : [];
12810
+
12627
12811
  /**
12628
12812
  * Loops over queued module definitions, if a given module definition has all of its
12629
12813
  * declarations resolved, it dequeues that module definition and sets the scope on
@@ -13184,8 +13368,8 @@ export declare class ɵPendingTasks implements OnDestroy {
13184
13368
  add(): number;
13185
13369
  remove(taskId: number): void;
13186
13370
  ngOnDestroy(): void;
13187
- static ɵfac: i0.ɵɵFactoryDeclaration<ɵPendingTasks, never>;
13188
- static ɵprov: i0.ɵɵInjectableDeclaration<ɵPendingTasks>;
13371
+ /** @nocollapse */
13372
+ static ɵprov: unknown;
13189
13373
  }
13190
13374
 
13191
13375
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/core",
3
- "version": "18.1.0-next.1",
3
+ "version": "18.1.0-next.2",
4
4
  "description": "Angular - the core framework",
5
5
  "author": "angular",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.1.0-next.1
2
+ * @license Angular v18.1.0-next.2
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.1.0-next.1
2
+ * @license Angular v18.1.0-next.2
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.1.0-next.1
2
+ * @license Angular v18.1.0-next.2
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */