@angular/core 13.2.0-rc.1 → 14.0.0-next.1

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 (39) hide show
  1. package/core.d.ts +32 -26
  2. package/esm2020/src/di/r3_injector.mjs +5 -15
  3. package/esm2020/src/di/reflective_injector.mjs +1 -1
  4. package/esm2020/src/errors.mjs +22 -5
  5. package/esm2020/src/linker/template_ref.mjs +4 -13
  6. package/esm2020/src/linker/view_container_ref.mjs +3 -12
  7. package/esm2020/src/metadata/directives.mjs +14 -5
  8. package/esm2020/src/render3/component_ref.mjs +20 -3
  9. package/esm2020/src/render3/instructions/shared.mjs +2 -2
  10. package/esm2020/src/render3/interfaces/injector.mjs +1 -1
  11. package/esm2020/src/version.mjs +1 -1
  12. package/esm2020/src/zone/ng_zone.mjs +3 -2
  13. package/esm2020/testing/src/logger.mjs +3 -3
  14. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  15. package/esm2020/testing/src/r3_test_bed.mjs +6 -1
  16. package/fesm2015/core.mjs +65 -79
  17. package/fesm2015/core.mjs.map +1 -1
  18. package/fesm2015/testing.mjs +6 -1
  19. package/fesm2015/testing.mjs.map +1 -1
  20. package/fesm2020/core.mjs +65 -79
  21. package/fesm2020/core.mjs.map +1 -1
  22. package/fesm2020/testing.mjs +6 -1
  23. package/fesm2020/testing.mjs.map +1 -1
  24. package/package.json +1 -1
  25. package/schematics/migrations/typed-forms/index.js +2 -2
  26. package/schematics/migrations/typed-forms/util.js +3 -8
  27. package/schematics/migrations.json +1 -16
  28. package/testing/testing.d.ts +1 -1
  29. package/esm2020/src/render3/chained_injector.mjs +0 -32
  30. package/schematics/migrations/router-link-empty-expression/analyze_template.d.ts +0 -11
  31. package/schematics/migrations/router-link-empty-expression/analyze_template.js +0 -34
  32. package/schematics/migrations/router-link-empty-expression/angular/html_routerlink_empty_expr_visitor.d.ts +0 -20
  33. package/schematics/migrations/router-link-empty-expression/angular/html_routerlink_empty_expr_visitor.js +0 -47
  34. package/schematics/migrations/router-link-empty-expression/index.d.ts +0 -11
  35. package/schematics/migrations/router-link-empty-expression/index.js +0 -170
  36. package/schematics/migrations/testbed-teardown/index.d.ts +0 -11
  37. package/schematics/migrations/testbed-teardown/index.js +0 -92
  38. package/schematics/migrations/testbed-teardown/util.d.ts +0 -35
  39. package/schematics/migrations/testbed-teardown/util.js +0 -188
package/fesm2015/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.2.0-rc.1
2
+ * @license Angular v14.0.0-next.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -152,20 +152,37 @@ const ERROR_DETAILS_PAGE_BASE_URL = 'https://angular.io/errors';
152
152
  * Use of this source code is governed by an MIT-style license that can be
153
153
  * found in the LICENSE file at https://angular.io/license
154
154
  */
155
+ /**
156
+ * Class that represents a runtime error.
157
+ * Formats and outputs the error message in a consistent way.
158
+ *
159
+ * Example:
160
+ * ```
161
+ * throw new RuntimeError(
162
+ * RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
163
+ * ngDevMode && 'Injector has already been destroyed.');
164
+ * ```
165
+ *
166
+ * Note: the `message` argument contains a descriptive error message as a string in development
167
+ * mode (when the `ngDevMode` is defined). In production mode (after tree-shaking pass), the
168
+ * `message` argument becomes `false`, thus we account for it in the typings and the runtime logic.
169
+ */
155
170
  class RuntimeError extends Error {
156
171
  constructor(code, message) {
157
172
  super(formatRuntimeError(code, message));
158
173
  this.code = code;
159
174
  }
160
175
  }
161
- /** Called to format a runtime error */
176
+ /**
177
+ * Called to format a runtime error.
178
+ * See additional info on the `message` argument type in the `RuntimeError` class description.
179
+ */
162
180
  function formatRuntimeError(code, message) {
163
- const codeAsNumber = code;
164
181
  // Error code might be a negative number, which is a special marker that instructs the logic to
165
182
  // generate a link to the error details page on angular.io.
166
- const fullCode = `NG0${Math.abs(codeAsNumber)}`;
183
+ const fullCode = `NG0${Math.abs(code)}`;
167
184
  let errorMessage = `${fullCode}${message ? ': ' + message : ''}`;
168
- if (ngDevMode && codeAsNumber < 0) {
185
+ if (ngDevMode && code < 0) {
169
186
  errorMessage = `${errorMessage}. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/${fullCode}`;
170
187
  }
171
188
  return errorMessage;
@@ -10377,7 +10394,7 @@ function cacheMatchingLocalNames(tNode, localRefs, exportsMap) {
10377
10394
  for (let i = 0; i < localRefs.length; i += 2) {
10378
10395
  const index = exportsMap[localRefs[i + 1]];
10379
10396
  if (index == null)
10380
- throw new RuntimeError(-301 /* EXPORT_NOT_FOUND */, `Export of name '${localRefs[i + 1]}' not found!`);
10397
+ throw new RuntimeError(-301 /* EXPORT_NOT_FOUND */, ngDevMode && `Export of name '${localRefs[i + 1]}' not found!`);
10381
10398
  localNames.push(localRefs[i], index);
10382
10399
  }
10383
10400
  }
@@ -11303,10 +11320,7 @@ class R3Injector {
11303
11320
  }
11304
11321
  assertNotDestroyed() {
11305
11322
  if (this._destroyed) {
11306
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11307
- 'Injector has already been destroyed.' :
11308
- '';
11309
- throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, errorMessage);
11323
+ throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && 'Injector has already been destroyed.');
11310
11324
  }
11311
11325
  }
11312
11326
  /**
@@ -11470,28 +11484,21 @@ function injectableDefOrInjectorDefFactory(token) {
11470
11484
  // InjectionTokens should have an injectable def (ɵprov) and thus should be handled above.
11471
11485
  // If it's missing that, it's an error.
11472
11486
  if (token instanceof InjectionToken) {
11473
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11474
- `Token ${stringify(token)} is missing a ɵprov definition.` :
11475
- '';
11476
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11487
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
11477
11488
  }
11478
11489
  // Undecorated types can sometimes be created if they have no constructor arguments.
11479
11490
  if (token instanceof Function) {
11480
11491
  return getUndecoratedInjectableFactory(token);
11481
11492
  }
11482
11493
  // There was no way to resolve a factory for this token.
11483
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ? 'unreachable' : '';
11484
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11494
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && 'unreachable');
11485
11495
  }
11486
11496
  function getUndecoratedInjectableFactory(token) {
11487
11497
  // If the token has parameters then it has dependencies that we cannot resolve implicitly.
11488
11498
  const paramLength = token.length;
11489
11499
  if (paramLength > 0) {
11490
11500
  const args = newArray(paramLength, '?');
11491
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11492
- `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).` :
11493
- '';
11494
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11501
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).`);
11495
11502
  }
11496
11503
  // The constructor function appears to have no parameters.
11497
11504
  // This might be because it inherits from a super-class. In which case, use an injectable
@@ -21069,7 +21076,7 @@ class Version {
21069
21076
  /**
21070
21077
  * @publicApi
21071
21078
  */
21072
- const VERSION = new Version('13.2.0-rc.1');
21079
+ const VERSION = new Version('14.0.0-next.1');
21073
21080
 
21074
21081
  /**
21075
21082
  * @license
@@ -21097,37 +21104,6 @@ const VERSION = new Version('13.2.0-rc.1');
21097
21104
  // - mod2.injector.get(token, default)
21098
21105
  const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
21099
21106
 
21100
- /**
21101
- * @license
21102
- * Copyright Google LLC All Rights Reserved.
21103
- *
21104
- * Use of this source code is governed by an MIT-style license that can be
21105
- * found in the LICENSE file at https://angular.io/license
21106
- */
21107
- /**
21108
- * Injector that looks up a value using a specific injector, before falling back to the module
21109
- * injector. Used primarily when creating components or embedded views dynamically.
21110
- */
21111
- class ChainedInjector {
21112
- constructor(injector, parentInjector) {
21113
- this.injector = injector;
21114
- this.parentInjector = parentInjector;
21115
- }
21116
- get(token, notFoundValue, flags) {
21117
- const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21118
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21119
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21120
- // Return the value from the root element injector when
21121
- // - it provides it
21122
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21123
- // - the module injector should not be checked
21124
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21125
- return value;
21126
- }
21127
- return this.parentInjector.get(token, notFoundValue, flags);
21128
- }
21129
- }
21130
-
21131
21107
  /**
21132
21108
  * @license
21133
21109
  * Copyright Google LLC All Rights Reserved.
@@ -21513,6 +21489,23 @@ const SCHEDULER = new InjectionToken('SCHEDULER_TOKEN', {
21513
21489
  providedIn: 'root',
21514
21490
  factory: () => defaultScheduler,
21515
21491
  });
21492
+ function createChainedInjector(rootViewInjector, moduleInjector) {
21493
+ return {
21494
+ get: (token, notFoundValue, flags) => {
21495
+ const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21496
+ if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21497
+ notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21498
+ // Return the value from the root element injector when
21499
+ // - it provides it
21500
+ // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21501
+ // - the module injector should not be checked
21502
+ // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21503
+ return value;
21504
+ }
21505
+ return moduleInjector.get(token, notFoundValue, flags);
21506
+ }
21507
+ };
21508
+ }
21516
21509
  /**
21517
21510
  * Render3 implementation of {@link viewEngine_ComponentFactory}.
21518
21511
  */
@@ -21539,7 +21532,7 @@ class ComponentFactory extends ComponentFactory$1 {
21539
21532
  }
21540
21533
  create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
21541
21534
  ngModule = ngModule || this.ngModule;
21542
- const rootViewInjector = ngModule ? new ChainedInjector(injector, ngModule.injector) : injector;
21535
+ const rootViewInjector = ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
21543
21536
  const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
21544
21537
  const sanitizer = rootViewInjector.get(Sanitizer, null);
21545
21538
  const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
@@ -22675,9 +22668,9 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22675
22668
  this._declarationTContainer = _declarationTContainer;
22676
22669
  this.elementRef = elementRef;
22677
22670
  }
22678
- createEmbeddedView(context, injector) {
22671
+ createEmbeddedView(context) {
22679
22672
  const embeddedTView = this._declarationTContainer.tViews;
22680
- const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, createEmbeddedViewInjector(injector, this._declarationLView[INJECTOR$1]));
22673
+ const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null);
22681
22674
  const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
22682
22675
  ngDevMode && assertLContainer(declarationLContainer);
22683
22676
  embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
@@ -22689,14 +22682,6 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22689
22682
  return new ViewRef$1(embeddedLView);
22690
22683
  }
22691
22684
  };
22692
- function createEmbeddedViewInjector(embeddedViewInjector, declarationViewInjector) {
22693
- if (!embeddedViewInjector) {
22694
- return null;
22695
- }
22696
- return declarationViewInjector ?
22697
- new ChainedInjector(embeddedViewInjector, declarationViewInjector) :
22698
- embeddedViewInjector;
22699
- }
22700
22685
  /**
22701
22686
  * Creates a TemplateRef given a node.
22702
22687
  *
@@ -22801,17 +22786,8 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
22801
22786
  get length() {
22802
22787
  return this._lContainer.length - CONTAINER_HEADER_OFFSET;
22803
22788
  }
22804
- createEmbeddedView(templateRef, context, indexOrOptions) {
22805
- let index;
22806
- let injector;
22807
- if (typeof indexOrOptions === 'number') {
22808
- index = indexOrOptions;
22809
- }
22810
- else if (indexOrOptions != null) {
22811
- index = indexOrOptions.index;
22812
- injector = indexOrOptions.injector;
22813
- }
22814
- const viewRef = templateRef.createEmbeddedView(context || {}, injector);
22789
+ createEmbeddedView(templateRef, context, index) {
22790
+ const viewRef = templateRef.createEmbeddedView(context || {});
22815
22791
  this.insert(viewRef, index);
22816
22792
  return viewRef;
22817
22793
  }
@@ -24579,19 +24555,20 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24579
24555
  *
24580
24556
  * ```
24581
24557
  *
24582
- * The following example registers another DOM event handler that listens for key-press events.
24558
+ * The following example registers another DOM event handler that listens for `Enter` key-press
24559
+ * events on the global `window`.
24583
24560
  * ``` ts
24584
24561
  * import { HostListener, Component } from "@angular/core";
24585
24562
  *
24586
24563
  * @Component({
24587
24564
  * selector: 'app',
24588
- * template: `<h1>Hello, you have pressed keys {{counter}} number of times!</h1> Press any key to
24589
- * increment the counter.
24565
+ * template: `<h1>Hello, you have pressed enter {{counter}} number of times!</h1> Press enter key
24566
+ * to increment the counter.
24590
24567
  * <button (click)="resetCounter()">Reset Counter</button>`
24591
24568
  * })
24592
24569
  * class AppComponent {
24593
24570
  * counter = 0;
24594
- * @HostListener('window:keydown', ['$event'])
24571
+ * @HostListener('window:keydown.enter', ['$event'])
24595
24572
  * handleKeyDown(event: KeyboardEvent) {
24596
24573
  * this.counter++;
24597
24574
  * }
@@ -24600,6 +24577,14 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24600
24577
  * }
24601
24578
  * }
24602
24579
  * ```
24580
+ * The list of valid key names for `keydown` and `keyup` events
24581
+ * can be found here:
24582
+ * https://www.w3.org/TR/DOM-Level-3-Events-key/#named-key-attribute-values
24583
+ *
24584
+ * Note that keys can also be combined, e.g. `@HostListener('keydown.shift.a')`.
24585
+ *
24586
+ * The global target names that can be used to prefix an event name are
24587
+ * `document:`, `window:` and `body:`.
24603
24588
  *
24604
24589
  * @Annotation
24605
24590
  * @publicApi
@@ -25328,7 +25313,8 @@ class NgZone {
25328
25313
  forkInnerZoneWithAngularBehavior(self);
25329
25314
  }
25330
25315
  static isInAngularZone() {
25331
- return Zone.current.get('isAngularZone') === true;
25316
+ // Zone needs to be checked, because this method might be called even when NoopNgZone is used.
25317
+ return typeof Zone !== 'undefined' && Zone.current.get('isAngularZone') === true;
25332
25318
  }
25333
25319
  static assertInAngularZone() {
25334
25320
  if (!NgZone.isInAngularZone()) {