@angular/upgrade 19.0.0-next.0 → 19.0.0-next.10

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 (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/fesm2022/static/testing.mjs +5 -5
  4. package/fesm2022/static/testing.mjs.map +1 -1
  5. package/fesm2022/static.mjs +70 -21
  6. package/fesm2022/static.mjs.map +1 -1
  7. package/fesm2022/upgrade.mjs +68 -18
  8. package/fesm2022/upgrade.mjs.map +1 -1
  9. package/index.d.ts +1 -1
  10. package/package.json +5 -11
  11. package/static/index.d.ts +28 -4
  12. package/static/testing/index.d.ts +1 -1
  13. package/esm2022/index.mjs +0 -13
  14. package/esm2022/public_api.mjs +0 -17
  15. package/esm2022/src/common/src/angular1.mjs +0 -73
  16. package/esm2022/src/common/src/component_info.mjs +0 -27
  17. package/esm2022/src/common/src/constants.mjs +0 -33
  18. package/esm2022/src/common/src/downgrade_component.mjs +0 -203
  19. package/esm2022/src/common/src/downgrade_component_adapter.mjs +0 -284
  20. package/esm2022/src/common/src/downgrade_injectable.mjs +0 -87
  21. package/esm2022/src/common/src/promise_util.mjs +0 -58
  22. package/esm2022/src/common/src/upgrade_helper.mjs +0 -244
  23. package/esm2022/src/common/src/util.mjs +0 -151
  24. package/esm2022/src/common/src/version.mjs +0 -18
  25. package/esm2022/src/dynamic/src/upgrade_adapter.mjs +0 -657
  26. package/esm2022/src/dynamic/src/upgrade_ng1_adapter.mjs +0 -229
  27. package/esm2022/static/common.mjs +0 -22
  28. package/esm2022/static/index.mjs +0 -13
  29. package/esm2022/static/public_api.mjs +0 -17
  30. package/esm2022/static/src/angular1_providers.mjs +0 -43
  31. package/esm2022/static/src/downgrade_module.mjs +0 -190
  32. package/esm2022/static/src/upgrade_component.mjs +0 -250
  33. package/esm2022/static/src/upgrade_module.mjs +0 -294
  34. package/esm2022/static/src/util.mjs +0 -24
  35. package/esm2022/static/static.mjs +0 -5
  36. package/esm2022/static/testing/index.mjs +0 -9
  37. package/esm2022/static/testing/public_api.mjs +0 -10
  38. package/esm2022/static/testing/src/create_angular_testing_module.mjs +0 -101
  39. package/esm2022/static/testing/src/create_angularjs_testing_module.mjs +0 -93
  40. package/esm2022/static/testing/testing.mjs +0 -5
  41. package/esm2022/upgrade.mjs +0 -5
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license Angular v19.0.0-next.0
2
+ * @license Angular v19.0.0-next.10
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.0');
20
+ const VERSION = new Version('19.0.0-next.10');
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);
@@ -864,6 +872,47 @@ function downgradeInjectable(token, downgradedModule = '') {
864
872
  return factory;
865
873
  }
866
874
 
875
+ /**
876
+ * The Trusted Types policy, or null if Trusted Types are not
877
+ * enabled/supported, or undefined if the policy has not been created yet.
878
+ */
879
+ let policy;
880
+ /**
881
+ * Returns the Trusted Types policy, or null if Trusted Types are not
882
+ * enabled/supported. The first call to this function will create the policy.
883
+ */
884
+ function getPolicy() {
885
+ if (policy === undefined) {
886
+ policy = null;
887
+ const windowWithTrustedTypes = window;
888
+ if (windowWithTrustedTypes.trustedTypes) {
889
+ try {
890
+ policy = windowWithTrustedTypes.trustedTypes.createPolicy('angular#unsafe-upgrade', {
891
+ createHTML: (s) => s,
892
+ });
893
+ }
894
+ catch {
895
+ // trustedTypes.createPolicy throws if called with a name that is
896
+ // already registered, even in report-only mode. Until the API changes,
897
+ // catch the error not to break the applications functionally. In such
898
+ // cases, the code will fall back to using strings.
899
+ }
900
+ }
901
+ }
902
+ return policy;
903
+ }
904
+ /**
905
+ * Unsafely promote a legacy AngularJS template to a TrustedHTML, falling back
906
+ * to strings when Trusted Types are not available.
907
+ * @security This is a security-sensitive function; any use of this function
908
+ * must go through security review. In particular, the template string should
909
+ * always be under full control of the application author, as untrusted input
910
+ * can cause an XSS vulnerability.
911
+ */
912
+ function trustedHTMLFromLegacyTemplate(html) {
913
+ return getPolicy()?.createHTML(html) || html;
914
+ }
915
+
867
916
  // Constants
868
917
  const REQUIRE_PREFIX_RE = /^(\^\^?)?(\?)?(\^\^?)?/;
869
918
  // Classes
@@ -895,14 +944,14 @@ class UpgradeHelper {
895
944
  }
896
945
  static getTemplate($injector, directive, fetchRemoteTemplate = false, $element) {
897
946
  if (directive.template !== undefined) {
898
- return getOrCall(directive.template, $element);
947
+ return trustedHTMLFromLegacyTemplate(getOrCall(directive.template, $element));
899
948
  }
900
949
  else if (directive.templateUrl) {
901
950
  const $templateCache = $injector.get($TEMPLATE_CACHE);
902
951
  const url = getOrCall(directive.templateUrl, $element);
903
952
  const template = $templateCache.get(url);
904
953
  if (template !== undefined) {
905
- return template;
954
+ return trustedHTMLFromLegacyTemplate(template);
906
955
  }
907
956
  else if (!fetchRemoteTemplate) {
908
957
  throw new Error('loading directive templates asynchronously is not supported');
@@ -911,7 +960,7 @@ class UpgradeHelper {
911
960
  const $httpBackend = $injector.get($HTTP_BACKEND);
912
961
  $httpBackend('GET', url, null, (status, response) => {
913
962
  if (status === 200) {
914
- resolve($templateCache.put(url, response));
963
+ resolve(trustedHTMLFromLegacyTemplate($templateCache.put(url, response)));
915
964
  }
916
965
  else {
917
966
  reject(`GET component template from '${url}' returned '${status}: ${response}'`);
@@ -1138,6 +1187,7 @@ class UpgradeNg1ComponentAdapterBuilder {
1138
1187
  selector: selector,
1139
1188
  inputs: this.inputsRename,
1140
1189
  outputs: this.outputsRename,
1190
+ standalone: false,
1141
1191
  }),
1142
1192
  __metadata("design:paramtypes", [Object, Injector, ElementRef])
1143
1193
  ], MyClass);
@@ -1241,7 +1291,7 @@ class UpgradeNg1ComponentAdapter {
1241
1291
  ngOnInit() {
1242
1292
  // Collect contents, insert and compile template
1243
1293
  const attachChildNodes = this.helper.prepareTransclusion();
1244
- const linkFn = this.helper.compileTemplate(this.template);
1294
+ const linkFn = this.helper.compileTemplate(trustedHTMLFromLegacyTemplate(this.template));
1245
1295
  // Instantiate controller (if not already done so)
1246
1296
  const controllerType = this.directive.controller;
1247
1297
  const bindToController = this.directive.bindToController;
@@ -1306,10 +1356,10 @@ class UpgradeNg1ComponentAdapter {
1306
1356
  setComponentProperty(name, value) {
1307
1357
  this.destinationObj[this.propertyMap[name]] = value;
1308
1358
  }
1309
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-next.0", ngImport: i0, type: UpgradeNg1ComponentAdapter, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
1310
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0-next.0", type: UpgradeNg1ComponentAdapter, usesOnChanges: true, ngImport: i0 }); }
1359
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-next.10", ngImport: i0, type: UpgradeNg1ComponentAdapter, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
1360
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0-next.10", type: UpgradeNg1ComponentAdapter, isStandalone: true, usesOnChanges: true, ngImport: i0 }); }
1311
1361
  }
1312
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-next.0", ngImport: i0, type: UpgradeNg1ComponentAdapter, decorators: [{
1362
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-next.10", ngImport: i0, type: UpgradeNg1ComponentAdapter, decorators: [{
1313
1363
  type: Directive
1314
1364
  }], ctorParameters: () => [{ type: UpgradeHelper }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }] });
1315
1365