@angular/upgrade 19.0.0-next.6 → 19.0.0-next.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 v19.0.0-next.6
2
+ * @license Angular v19.0.0-next.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 { Version, ɵNG_MOD_DEF, Injector, ChangeDetectorRef, Testability, TestabilityRegistry, ApplicationRef, SimpleChange, NgZone, ComponentFactoryResolver, Inject, ElementRef, Directive, EventEmitter, Compiler, NgModule, resolveForwardRef } from '@angular/core';
8
+ import { Version, ɵNG_MOD_DEF, Injector, ChangeDetectorRef, Testability, TestabilityRegistry, ApplicationRef, SimpleChange, ɵSIGNAL, NgZone, ComponentFactoryResolver, Inject, ElementRef, Directive, EventEmitter, Compiler, NgModule, resolveForwardRef } from '@angular/core';
9
9
  import { __decorate, __metadata } from 'tslib';
10
10
  import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
11
11
 
@@ -17,7 +17,7 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
17
17
  /**
18
18
  * @publicApi
19
19
  */
20
- const VERSION = new Version('19.0.0-next.6');
20
+ const VERSION = new Version('19.0.0-next.8');
21
21
 
22
22
  function noNg() {
23
23
  throw new Error('AngularJS v1.x is not loaded!');
@@ -276,7 +276,7 @@ const INITIAL_VALUE$1 = {
276
276
  __UNINITIALIZED__: true,
277
277
  };
278
278
  class DowngradeComponentAdapter {
279
- constructor(element, attrs, scope, ngModel, parentInjector, $compile, $parse, componentFactory, wrapCallback) {
279
+ constructor(element, attrs, scope, ngModel, parentInjector, $compile, $parse, componentFactory, wrapCallback, unsafelyOverwriteSignalInputs) {
280
280
  this.element = element;
281
281
  this.attrs = attrs;
282
282
  this.scope = scope;
@@ -286,6 +286,7 @@ class DowngradeComponentAdapter {
286
286
  this.$parse = $parse;
287
287
  this.componentFactory = componentFactory;
288
288
  this.wrapCallback = wrapCallback;
289
+ this.unsafelyOverwriteSignalInputs = unsafelyOverwriteSignalInputs;
289
290
  this.implementsOnChanges = false;
290
291
  this.inputChangeCount = 0;
291
292
  this.inputChanges = {};
@@ -341,7 +342,7 @@ class DowngradeComponentAdapter {
341
342
  const inputBinding = new PropertyBinding(input.propName, input.templateName);
342
343
  let expr = null;
343
344
  if (attrs.hasOwnProperty(inputBinding.attr)) {
344
- const observeFn = ((prop) => {
345
+ const observeFn = ((prop, isSignal) => {
345
346
  let prevValue = INITIAL_VALUE$1;
346
347
  return (currValue) => {
347
348
  // Initially, both `$observe()` and `$watch()` will call this function.
@@ -349,11 +350,11 @@ class DowngradeComponentAdapter {
349
350
  if (prevValue === INITIAL_VALUE$1) {
350
351
  prevValue = currValue;
351
352
  }
352
- this.updateInput(componentRef, prop, prevValue, currValue);
353
+ this.updateInput(componentRef, prop, prevValue, currValue, isSignal);
353
354
  prevValue = currValue;
354
355
  }
355
356
  };
356
- })(inputBinding.prop);
357
+ })(inputBinding.prop, input.isSignal);
357
358
  attrs.$observe(inputBinding.attr, observeFn);
358
359
  // Use `$watch()` (in addition to `$observe()`) in order to initialize the input in time
359
360
  // for `ngOnChanges()`. This is necessary if we are already in a `$digest`, which means that
@@ -377,7 +378,7 @@ class DowngradeComponentAdapter {
377
378
  expr = attrs[inputBinding.bracketParenAttr];
378
379
  }
379
380
  if (expr != null) {
380
- const watchFn = ((prop) => (currValue, prevValue) => this.updateInput(componentRef, prop, prevValue, currValue))(inputBinding.prop);
381
+ const watchFn = ((prop, isSignal) => (currValue, prevValue) => this.updateInput(componentRef, prop, prevValue, currValue, isSignal))(inputBinding.prop, input.isSignal);
381
382
  this.componentScope.$watch(expr, watchFn);
382
383
  }
383
384
  }
@@ -488,12 +489,18 @@ class DowngradeComponentAdapter {
488
489
  }
489
490
  });
490
491
  }
491
- updateInput(componentRef, prop, prevValue, currValue) {
492
+ updateInput(componentRef, prop, prevValue, currValue, isSignal) {
492
493
  if (this.implementsOnChanges) {
493
494
  this.inputChanges[prop] = new SimpleChange(prevValue, currValue, prevValue === currValue);
494
495
  }
495
496
  this.inputChangeCount++;
496
- componentRef.instance[prop] = currValue;
497
+ if (isSignal && !this.unsafelyOverwriteSignalInputs) {
498
+ const node = componentRef.instance[prop][ɵSIGNAL];
499
+ node.applyValueToInputSignal(node, currValue);
500
+ }
501
+ else {
502
+ componentRef.instance[prop] = currValue;
503
+ }
497
504
  }
498
505
  groupProjectableNodes() {
499
506
  let ngContentSelectors = this.componentFactory.ngContentSelectors;
@@ -646,6 +653,7 @@ class SyncPromise {
646
653
  */
647
654
  function downgradeComponent(info) {
648
655
  const directiveFactory = function ($compile, $injector, $parse) {
656
+ const unsafelyOverwriteSignalInputs = info.unsafelyOverwriteSignalInputs ?? false;
649
657
  // When using `downgradeModule()`, we need to handle certain things specially. For example:
650
658
  // - We always need to attach the component view to the `ApplicationRef` for it to be
651
659
  // dirty-checked.
@@ -733,7 +741,7 @@ function downgradeComponent(info) {
733
741
  throw new Error(`Expecting ComponentFactory for: ${getTypeName(info.component)}`);
734
742
  }
735
743
  const injectorPromise = new ParentInjectorPromise(element);
736
- const facade = new DowngradeComponentAdapter(element, attrs, scope, ngModel, injector, $compile, $parse, componentFactory, wrapCallback);
744
+ const facade = new DowngradeComponentAdapter(element, attrs, scope, ngModel, injector, $compile, $parse, componentFactory, wrapCallback, unsafelyOverwriteSignalInputs);
737
745
  const projectableNodes = facade.compileContents();
738
746
  const componentRef = facade.createComponentAndSetup(projectableNodes, isNgUpgradeLite, info.propagateDigest);
739
747
  injectorPromise.resolve(componentRef.injector);
@@ -1347,10 +1355,10 @@ class UpgradeNg1ComponentAdapter {
1347
1355
  setComponentProperty(name, value) {
1348
1356
  this.destinationObj[this.propertyMap[name]] = value;
1349
1357
  }
1350
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-next.6", ngImport: i0, type: UpgradeNg1ComponentAdapter, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
1351
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0-next.6", type: UpgradeNg1ComponentAdapter, usesOnChanges: true, ngImport: i0 }); }
1358
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-next.8", ngImport: i0, type: UpgradeNg1ComponentAdapter, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
1359
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0-next.8", type: UpgradeNg1ComponentAdapter, usesOnChanges: true, ngImport: i0 }); }
1352
1360
  }
1353
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-next.6", ngImport: i0, type: UpgradeNg1ComponentAdapter, decorators: [{
1361
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-next.8", ngImport: i0, type: UpgradeNg1ComponentAdapter, decorators: [{
1354
1362
  type: Directive
1355
1363
  }], ctorParameters: () => [{ type: UpgradeHelper }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }] });
1356
1364