@angular/upgrade 18.2.6 → 18.2.8

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.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license Angular v18.2.6
2
+ * @license Angular v18.2.8
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i0 from '@angular/core';
8
- import { ɵNG_MOD_DEF, Injector, ChangeDetectorRef, Testability, TestabilityRegistry, ApplicationRef, SimpleChange, NgZone, ComponentFactoryResolver, Version, ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, PlatformRef, EventEmitter, Directive, NgModule } from '@angular/core';
8
+ import { ɵNG_MOD_DEF, Injector, ChangeDetectorRef, Testability, TestabilityRegistry, ApplicationRef, SimpleChange, ɵSIGNAL, NgZone, ComponentFactoryResolver, Version, ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, PlatformRef, EventEmitter, Directive, NgModule } from '@angular/core';
9
9
  import { platformBrowser } from '@angular/platform-browser';
10
10
 
11
11
  function noNg() {
@@ -326,7 +326,7 @@ const INITIAL_VALUE$1 = {
326
326
  __UNINITIALIZED__: true,
327
327
  };
328
328
  class DowngradeComponentAdapter {
329
- constructor(element, attrs, scope, ngModel, parentInjector, $compile, $parse, componentFactory, wrapCallback) {
329
+ constructor(element, attrs, scope, ngModel, parentInjector, $compile, $parse, componentFactory, wrapCallback, unsafelyOverwriteSignalInputs) {
330
330
  this.element = element;
331
331
  this.attrs = attrs;
332
332
  this.scope = scope;
@@ -336,6 +336,7 @@ class DowngradeComponentAdapter {
336
336
  this.$parse = $parse;
337
337
  this.componentFactory = componentFactory;
338
338
  this.wrapCallback = wrapCallback;
339
+ this.unsafelyOverwriteSignalInputs = unsafelyOverwriteSignalInputs;
339
340
  this.implementsOnChanges = false;
340
341
  this.inputChangeCount = 0;
341
342
  this.inputChanges = {};
@@ -391,7 +392,7 @@ class DowngradeComponentAdapter {
391
392
  const inputBinding = new PropertyBinding(input.propName, input.templateName);
392
393
  let expr = null;
393
394
  if (attrs.hasOwnProperty(inputBinding.attr)) {
394
- const observeFn = ((prop) => {
395
+ const observeFn = ((prop, isSignal) => {
395
396
  let prevValue = INITIAL_VALUE$1;
396
397
  return (currValue) => {
397
398
  // Initially, both `$observe()` and `$watch()` will call this function.
@@ -399,11 +400,11 @@ class DowngradeComponentAdapter {
399
400
  if (prevValue === INITIAL_VALUE$1) {
400
401
  prevValue = currValue;
401
402
  }
402
- this.updateInput(componentRef, prop, prevValue, currValue);
403
+ this.updateInput(componentRef, prop, prevValue, currValue, isSignal);
403
404
  prevValue = currValue;
404
405
  }
405
406
  };
406
- })(inputBinding.prop);
407
+ })(inputBinding.prop, input.isSignal);
407
408
  attrs.$observe(inputBinding.attr, observeFn);
408
409
  // Use `$watch()` (in addition to `$observe()`) in order to initialize the input in time
409
410
  // for `ngOnChanges()`. This is necessary if we are already in a `$digest`, which means that
@@ -427,7 +428,7 @@ class DowngradeComponentAdapter {
427
428
  expr = attrs[inputBinding.bracketParenAttr];
428
429
  }
429
430
  if (expr != null) {
430
- const watchFn = ((prop) => (currValue, prevValue) => this.updateInput(componentRef, prop, prevValue, currValue))(inputBinding.prop);
431
+ const watchFn = ((prop, isSignal) => (currValue, prevValue) => this.updateInput(componentRef, prop, prevValue, currValue, isSignal))(inputBinding.prop, input.isSignal);
431
432
  this.componentScope.$watch(expr, watchFn);
432
433
  }
433
434
  }
@@ -538,12 +539,18 @@ class DowngradeComponentAdapter {
538
539
  }
539
540
  });
540
541
  }
541
- updateInput(componentRef, prop, prevValue, currValue) {
542
+ updateInput(componentRef, prop, prevValue, currValue, isSignal) {
542
543
  if (this.implementsOnChanges) {
543
544
  this.inputChanges[prop] = new SimpleChange(prevValue, currValue, prevValue === currValue);
544
545
  }
545
546
  this.inputChangeCount++;
546
- componentRef.instance[prop] = currValue;
547
+ if (isSignal && !this.unsafelyOverwriteSignalInputs) {
548
+ const node = componentRef.instance[prop][ɵSIGNAL];
549
+ node.applyValueToInputSignal(node, currValue);
550
+ }
551
+ else {
552
+ componentRef.instance[prop] = currValue;
553
+ }
547
554
  }
548
555
  groupProjectableNodes() {
549
556
  let ngContentSelectors = this.componentFactory.ngContentSelectors;
@@ -696,6 +703,7 @@ class SyncPromise {
696
703
  */
697
704
  function downgradeComponent(info) {
698
705
  const directiveFactory = function ($compile, $injector, $parse) {
706
+ const unsafelyOverwriteSignalInputs = info.unsafelyOverwriteSignalInputs ?? false;
699
707
  // When using `downgradeModule()`, we need to handle certain things specially. For example:
700
708
  // - We always need to attach the component view to the `ApplicationRef` for it to be
701
709
  // dirty-checked.
@@ -783,7 +791,7 @@ function downgradeComponent(info) {
783
791
  throw new Error(`Expecting ComponentFactory for: ${getTypeName(info.component)}`);
784
792
  }
785
793
  const injectorPromise = new ParentInjectorPromise(element);
786
- const facade = new DowngradeComponentAdapter(element, attrs, scope, ngModel, injector, $compile, $parse, componentFactory, wrapCallback);
794
+ const facade = new DowngradeComponentAdapter(element, attrs, scope, ngModel, injector, $compile, $parse, componentFactory, wrapCallback, unsafelyOverwriteSignalInputs);
787
795
  const projectableNodes = facade.compileContents();
788
796
  const componentRef = facade.createComponentAndSetup(projectableNodes, isNgUpgradeLite, info.propagateDigest);
789
797
  injectorPromise.resolve(componentRef.injector);
@@ -922,7 +930,7 @@ function downgradeInjectable(token, downgradedModule = '') {
922
930
  /**
923
931
  * @publicApi
924
932
  */
925
- const VERSION = new Version('18.2.6');
933
+ const VERSION = new Version('18.2.8');
926
934
 
927
935
  /**
928
936
  * The Trusted Types policy, or null if Trusted Types are not
@@ -1672,10 +1680,10 @@ class UpgradeComponent {
1672
1680
  bindingDestination.$onChanges(changes);
1673
1681
  }
1674
1682
  }
1675
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: UpgradeComponent, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
1676
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.6", type: UpgradeComponent, usesOnChanges: true, ngImport: i0 }); }
1683
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: UpgradeComponent, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
1684
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.8", type: UpgradeComponent, usesOnChanges: true, ngImport: i0 }); }
1677
1685
  }
1678
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: UpgradeComponent, decorators: [{
1686
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: UpgradeComponent, decorators: [{
1679
1687
  type: Directive
1680
1688
  }], ctorParameters: () => [{ type: undefined }, { type: i0.ElementRef }, { type: i0.Injector }] });
1681
1689
 
@@ -1951,11 +1959,11 @@ class UpgradeModule {
1951
1959
  }
1952
1960
  return returnValue;
1953
1961
  }
1954
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: UpgradeModule, deps: [{ token: i0.Injector }, { token: i0.NgZone }, { token: i0.PlatformRef }], target: i0.ɵɵFactoryTarget.NgModule }); }
1955
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.6", ngImport: i0, type: UpgradeModule }); }
1956
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: UpgradeModule, providers: [angular1Providers] }); }
1962
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: UpgradeModule, deps: [{ token: i0.Injector }, { token: i0.NgZone }, { token: i0.PlatformRef }], target: i0.ɵɵFactoryTarget.NgModule }); }
1963
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.8", ngImport: i0, type: UpgradeModule }); }
1964
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: UpgradeModule, providers: [angular1Providers] }); }
1957
1965
  }
1958
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.6", ngImport: i0, type: UpgradeModule, decorators: [{
1966
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: UpgradeModule, decorators: [{
1959
1967
  type: NgModule,
1960
1968
  args: [{ providers: [angular1Providers] }]
1961
1969
  }], ctorParameters: () => [{ type: i0.Injector }, { type: i0.NgZone }, { type: i0.PlatformRef }] });