@angular/core 17.3.1 → 17.3.3

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 (38) hide show
  1. package/esm2022/rxjs-interop/src/to_signal.mjs +2 -2
  2. package/esm2022/src/authoring/input/input.mjs +37 -14
  3. package/esm2022/src/authoring/input/input_signal.mjs +1 -1
  4. package/esm2022/src/authoring/input/input_signal_node.mjs +1 -1
  5. package/esm2022/src/authoring/input/input_type_checking.mjs +1 -1
  6. package/esm2022/src/authoring/model/model.mjs +35 -15
  7. package/esm2022/src/authoring/output/output.mjs +32 -10
  8. package/esm2022/src/authoring/queries.mjs +11 -1
  9. package/esm2022/src/defer/instructions.mjs +21 -6
  10. package/esm2022/src/render3/component_ref.mjs +1 -1
  11. package/esm2022/src/render3/util/injector_discovery_utils.mjs +12 -8
  12. package/esm2022/src/version.mjs +1 -1
  13. package/esm2022/testing/src/fake_async.mjs +6 -1
  14. package/esm2022/testing/src/logger.mjs +3 -3
  15. package/esm2022/testing/src/test_hooks.mjs +3 -3
  16. package/esm2022/testing/src/testing.mjs +2 -2
  17. package/fesm2022/core.mjs +139 -47
  18. package/fesm2022/core.mjs.map +1 -1
  19. package/fesm2022/primitives/signals.mjs +1 -1
  20. package/fesm2022/rxjs-interop.mjs +2 -2
  21. package/fesm2022/rxjs-interop.mjs.map +1 -1
  22. package/fesm2022/testing.mjs +7 -2
  23. package/fesm2022/testing.mjs.map +1 -1
  24. package/index.d.ts +158 -109
  25. package/package.json +1 -1
  26. package/primitives/signals/index.d.ts +1 -1
  27. package/rxjs-interop/index.d.ts +2 -2
  28. package/schematics/migrations/block-template-entities/bundle.js +163 -162
  29. package/schematics/migrations/block-template-entities/bundle.js.map +2 -2
  30. package/schematics/migrations/compiler-options/bundle.js +13 -13
  31. package/schematics/migrations/invalid-two-way-bindings/bundle.js +164 -163
  32. package/schematics/migrations/invalid-two-way-bindings/bundle.js.map +2 -2
  33. package/schematics/migrations/transfer-state/bundle.js +13 -13
  34. package/schematics/ng-generate/control-flow-migration/bundle.js +199 -183
  35. package/schematics/ng-generate/control-flow-migration/bundle.js.map +3 -3
  36. package/schematics/ng-generate/standalone-migration/bundle.js +3281 -1660
  37. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  38. package/testing/index.d.ts +1 -1
package/fesm2022/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v17.3.1
2
+ * @license Angular v17.3.3
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -6664,25 +6664,47 @@ function getOutputDestroyRef(ref) {
6664
6664
  }
6665
6665
 
6666
6666
  /**
6667
- * The `output` function allows declaration of outputs in directives and
6668
- * components.
6667
+ * The `output` function allows declaration of Angular outputs in
6668
+ * directives and components.
6669
6669
  *
6670
- * Initializes an output that can emit values to consumers of your
6671
- * directive/component.
6670
+ * You can use outputs to emit values to parent directives and component.
6671
+ * Parents can subscribe to changes via:
6672
+ *
6673
+ * - template event bindings. For example, `(myOutput)="doSomething($event)"`
6674
+ * - programmatic subscription by using `OutputRef#subscribe`.
6672
6675
  *
6673
6676
  * @usageNotes
6674
- * Initialize an output in your directive by declaring a
6675
- * class field and initializing it with the `output()` function.
6677
+ *
6678
+ * To use `output()`, import the function from `@angular/core`.
6679
+ *
6680
+ * ```
6681
+ * import {output} from '@angular/core`;
6682
+ * ```
6683
+ *
6684
+ * Inside your component, introduce a new class member and initialize
6685
+ * it with a call to `output`.
6676
6686
  *
6677
6687
  * ```ts
6678
- * @Directive({..})
6688
+ * @Directive({
6689
+ * ...
6690
+ * })
6679
6691
  * export class MyDir {
6680
- * nameChange = output<string>(); // OutputEmitterRef<string>
6681
- * onClick = output(); // OutputEmitterRef<void>
6692
+ * nameChange = output<string>(); // OutputEmitterRef<string>
6693
+ * onClick = output(); // OutputEmitterRef<void>
6694
+ * }
6695
+ * ```
6696
+ *
6697
+ * You can emit values to consumers of your directive, by using
6698
+ * the `emit` method from `OutputEmitterRef`.
6699
+ *
6700
+ * ```ts
6701
+ * updateName(newName: string): void {
6702
+ * this.nameChange.emit(newName);
6682
6703
  * }
6683
6704
  * ```
6684
6705
  *
6685
6706
  * @developerPreview
6707
+ * @initializerApiFunction {"showTypesInSignaturePreview": true}
6686
6708
  */
6687
6709
  function output(opts) {
6688
6710
  ngDevMode && assertInInjectionContext(output);
@@ -6698,29 +6720,52 @@ function inputRequiredFunction(opts) {
6698
6720
  return createInputSignal(REQUIRED_UNSET_VALUE, opts);
6699
6721
  }
6700
6722
  /**
6701
- * The `input` function allows declaration of inputs in directives and
6702
- * components.
6723
+ * The `input` function allows declaration of Angular inputs in directives
6724
+ * and components.
6703
6725
  *
6704
- * Initializes an input with an initial value. If no explicit value
6705
- * is specified, Angular will use `undefined`.
6726
+ * There are two variants of inputs that can be declared:
6706
6727
  *
6707
- * Consider using `input.required` for inputs that don't need an
6708
- * initial value.
6728
+ * 1. **Optional inputs** with an initial value.
6729
+ * 2. **Required inputs** that consumers need to set.
6730
+ *
6731
+ * By default, the `input` function will declare optional inputs that
6732
+ * always have an initial value. Required inputs can be declared
6733
+ * using the `input.required()` function.
6734
+ *
6735
+ * Inputs are signals. The values of an input are exposed as a `Signal`.
6736
+ * The signal always holds the latest value of the input that is bound
6737
+ * from the parent.
6709
6738
  *
6710
6739
  * @usageNotes
6711
- * Initialize an input in your directive or component by declaring a
6712
- * class field and initializing it with the `input()` function.
6740
+ * To use signal-based inputs, import `input` from `@angular/core`.
6741
+ *
6742
+ * ```
6743
+ * import {input} from '@angular/core`;
6744
+ * ```
6745
+ *
6746
+ * Inside your component, introduce a new class member and initialize
6747
+ * it with a call to `input` or `input.required`.
6713
6748
  *
6714
6749
  * ```ts
6715
- * @Directive({..})
6716
- * export class MyDir {
6717
- * firstName = input<string>(); // string|undefined
6718
- * lastName = input.required<string>(); // string
6719
- * age = input(0); // number
6750
+ * @Component({
6751
+ * ...
6752
+ * })
6753
+ * export class UserProfileComponent {
6754
+ * firstName = input<string>(); // Signal<string|undefined>
6755
+ * lastName = input.required<string>(); // Signal<string>
6756
+ * age = input(0) // Signal<number>
6720
6757
  * }
6721
6758
  * ```
6722
6759
  *
6760
+ * Inside your component template, you can display values of the inputs
6761
+ * by calling the signal.
6762
+ *
6763
+ * ```html
6764
+ * <span>{{firstName()}}</span>
6765
+ * ```
6766
+ *
6723
6767
  * @developerPreview
6768
+ * @initializerApiFunction
6724
6769
  */
6725
6770
  const input = (() => {
6726
6771
  // Note: This may be considered a side-effect, but nothing will depend on
@@ -15977,7 +16022,7 @@ function createRootComponent(componentView, rootComponentDef, rootDirectives, ho
15977
16022
  function setRootNodeAttributes(hostRenderer, componentDef, hostRNode, rootSelectorOrNode) {
15978
16023
  if (rootSelectorOrNode) {
15979
16024
  // The placeholder will be replaced with the actual version at build time.
15980
- setUpAttributes(hostRenderer, hostRNode, ['ng-version', '17.3.1']);
16025
+ setUpAttributes(hostRenderer, hostRNode, ['ng-version', '17.3.3']);
15981
16026
  }
15982
16027
  else {
15983
16028
  // If host element is created as a part of this function call (i.e. `rootSelectorOrNode`
@@ -17030,6 +17075,7 @@ function viewChildRequiredFn(locator, opts) {
17030
17075
  * ```
17031
17076
  *
17032
17077
  * @developerPreview
17078
+ * @initializerApiFunction
17033
17079
  */
17034
17080
  const viewChild = (() => {
17035
17081
  // Note: This may be considered a side-effect, but nothing will depend on
@@ -17054,6 +17100,9 @@ const viewChild = (() => {
17054
17100
  * divEls = viewChildren<ElementRef>('el'); // Signal<ReadonlyArray<ElementRef>>
17055
17101
  * }
17056
17102
  * ```
17103
+ *
17104
+ * @initializerApiFunction
17105
+ * @developerPreview
17057
17106
  */
17058
17107
  function viewChildren(locator, opts) {
17059
17108
  ngDevMode && assertInInjectionContext(viewChildren);
@@ -17084,6 +17133,9 @@ function contentChildRequiredFn(locator, opts) {
17084
17133
  * headerRequired = contentChild.required(MyHeader); // Signal<MyHeader>
17085
17134
  * }
17086
17135
  * ```
17136
+ *
17137
+ * @initializerApiFunction
17138
+ * @developerPreview
17087
17139
  */
17088
17140
  const contentChild = (() => {
17089
17141
  // Note: This may be considered a side-effect, but nothing will depend on
@@ -17108,6 +17160,9 @@ const contentChild = (() => {
17108
17160
  * headerEl = contentChildren<ElementRef>('h'); // Signal<ReadonlyArray<ElementRef>>
17109
17161
  * }
17110
17162
  * ```
17163
+ *
17164
+ * @initializerApiFunction
17165
+ * @developerPreview
17111
17166
  */
17112
17167
  function contentChildren(locator, opts) {
17113
17168
  return createMultiResultQuerySignalFn();
@@ -17165,31 +17220,51 @@ function modelRequiredFunction() {
17165
17220
  return createModelSignal(REQUIRED_UNSET_VALUE);
17166
17221
  }
17167
17222
  /**
17168
- * `model` declares a writeable signal that is exposed as an input/output pair on the containing
17169
- * directive. The input name is taken either from the class member or from the `alias` option.
17223
+ * `model` declares a writeable signal that is exposed as an input/output
17224
+ * pair on the containing directive.
17225
+ *
17226
+ * The input name is taken either from the class member or from the `alias` option.
17170
17227
  * The output name is generated by taking the input name and appending `Change`.
17171
17228
  *
17172
- * Initializes a model with an initial value. If no explicit value
17173
- * is specified, Angular will use `undefined`.
17229
+ * @usageNotes
17174
17230
  *
17175
- * Consider using `model.required` for models that don't need an
17176
- * initial value.
17231
+ * To use `model()`, import the function from `@angular/core`.
17177
17232
  *
17178
- * @usageNotes
17179
- * Initialize a model in your directive or component by declaring a
17180
- * class field and initializing it with the `model()` or `model.required()`
17181
- * function.
17233
+ * ```
17234
+ * import {model} from '@angular/core`;
17235
+ * ```
17236
+ *
17237
+ * Inside your component, introduce a new class member and initialize
17238
+ * it with a call to `model` or `model.required`.
17182
17239
  *
17183
17240
  * ```ts
17184
- * @Directive({..})
17241
+ * @Directive({
17242
+ * ...
17243
+ * })
17185
17244
  * export class MyDir {
17186
- * firstName = model<string>(); // string|undefined
17187
- * lastName = model.required<string>(); // string
17188
- * age = model(0); // number
17245
+ * firstName = model<string>(); // ModelSignal<string|undefined>
17246
+ * lastName = model.required<string>(); // ModelSignal<string>
17247
+ * age = model(0); // ModelSignal<number>
17248
+ * }
17249
+ * ```
17250
+ *
17251
+ * Inside your component template, you can display the value of a `model`
17252
+ * by calling the signal.
17253
+ *
17254
+ * ```html
17255
+ * <span>{{firstName()}}</span>
17256
+ * ```
17257
+ *
17258
+ * Updating the `model` is equivalent to updating a writable signal.
17259
+ *
17260
+ * ```ts
17261
+ * updateName(newFirstName: string): void {
17262
+ * this.firstName.set(newFirstName);
17189
17263
  * }
17190
17264
  * ```
17191
17265
  *
17192
17266
  * @developerPreview
17267
+ * @initializerApiFunction
17193
17268
  */
17194
17269
  const model = (() => {
17195
17270
  // Note: This may be considered a side-effect, but nothing will depend on
@@ -19609,6 +19684,14 @@ function renderDeferBlockState(newState, tNode, lContainer, skipTimerScheduling
19609
19684
  }
19610
19685
  }
19611
19686
  }
19687
+ /**
19688
+ * Detects whether an injector is an instance of a `ChainedInjector`,
19689
+ * created based on the `OutletInjector`.
19690
+ */
19691
+ function isRouterOutletInjector(currentInjector) {
19692
+ return (currentInjector instanceof ChainedInjector) &&
19693
+ (currentInjector.injector.__ngOutletInjector);
19694
+ }
19612
19695
  /**
19613
19696
  * Applies changes to the DOM to reflect a given state.
19614
19697
  */
@@ -19635,14 +19718,20 @@ function applyDeferBlockState(newState, lDetails, lContainer, tNode, hostLView)
19635
19718
  const providers = tDetails.providers;
19636
19719
  if (providers && providers.length > 0) {
19637
19720
  const parentInjector = hostLView[INJECTOR];
19638
- const parentEnvInjector = parentInjector.get(EnvironmentInjector);
19639
- injector =
19640
- parentEnvInjector.get(CachedInjectorService)
19641
- .getOrCreateInjector(tDetails, parentEnvInjector, providers, ngDevMode ? 'DeferBlock Injector' : '');
19721
+ // Note: we have a special case for Router's `OutletInjector`,
19722
+ // since it's not an instance of the `EnvironmentInjector`, so
19723
+ // we can't inject it. Once the `OutletInjector` is replaced
19724
+ // with the `EnvironmentInjector` in Router's code, this special
19725
+ // handling can be removed.
19726
+ const parentEnvInjector = isRouterOutletInjector(parentInjector) ?
19727
+ parentInjector :
19728
+ parentInjector.get(EnvironmentInjector);
19729
+ injector = parentEnvInjector.get(CachedInjectorService)
19730
+ .getOrCreateInjector(tDetails, parentEnvInjector, providers, ngDevMode ? 'DeferBlock Injector' : '');
19642
19731
  }
19643
19732
  }
19644
19733
  const dehydratedView = findMatchingDehydratedView(lContainer, activeBlockTNode.tView.ssrId);
19645
- const embeddedLView = createAndRenderEmbeddedLView(hostLView, activeBlockTNode, null, { dehydratedView, embeddedViewInjector: injector });
19734
+ const embeddedLView = createAndRenderEmbeddedLView(hostLView, activeBlockTNode, null, { dehydratedView, injector });
19646
19735
  addLViewToLContainer(lContainer, embeddedLView, viewIndex, shouldAddViewToDom(activeBlockTNode, dehydratedView));
19647
19736
  markViewDirty(embeddedLView);
19648
19737
  }
@@ -29741,7 +29830,7 @@ class Version {
29741
29830
  /**
29742
29831
  * @publicApi
29743
29832
  */
29744
- const VERSION = new Version('17.3.1');
29833
+ const VERSION = new Version('17.3.3');
29745
29834
 
29746
29835
  class Console {
29747
29836
  log(message) {
@@ -30503,8 +30592,11 @@ function getInjectorParent(injector) {
30503
30592
  else if (injector instanceof NullInjector) {
30504
30593
  return null;
30505
30594
  }
30595
+ else if (injector instanceof ChainedInjector) {
30596
+ return injector.parentInjector;
30597
+ }
30506
30598
  else {
30507
- throwError('getInjectorParent only support injectors of type R3Injector, NodeInjector, NullInjector');
30599
+ throwError('getInjectorParent only support injectors of type R3Injector, NodeInjector, NullInjector, ChainedInjector');
30508
30600
  }
30509
30601
  const parentLocation = getParentInjectorLocation(tNode, lView);
30510
30602
  if (hasParentInjector(parentLocation)) {
@@ -30543,8 +30635,8 @@ function getModuleInjectorOfNodeInjector(injector) {
30543
30635
  else {
30544
30636
  throwError('getModuleInjectorOfNodeInjector must be called with a NodeInjector');
30545
30637
  }
30546
- const chainedInjector = lView[INJECTOR];
30547
- const moduleInjector = chainedInjector.parentInjector;
30638
+ const inj = lView[INJECTOR];
30639
+ const moduleInjector = (inj instanceof ChainedInjector) ? inj.parentInjector : inj.parent;
30548
30640
  if (!moduleInjector) {
30549
30641
  throwError('NodeInjector must have some connection to the module injector tree');
30550
30642
  }