@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/fesm2020/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;
@@ -10392,7 +10409,7 @@ function cacheMatchingLocalNames(tNode, localRefs, exportsMap) {
10392
10409
  for (let i = 0; i < localRefs.length; i += 2) {
10393
10410
  const index = exportsMap[localRefs[i + 1]];
10394
10411
  if (index == null)
10395
- throw new RuntimeError(-301 /* EXPORT_NOT_FOUND */, `Export of name '${localRefs[i + 1]}' not found!`);
10412
+ throw new RuntimeError(-301 /* EXPORT_NOT_FOUND */, ngDevMode && `Export of name '${localRefs[i + 1]}' not found!`);
10396
10413
  localNames.push(localRefs[i], index);
10397
10414
  }
10398
10415
  }
@@ -11318,10 +11335,7 @@ class R3Injector {
11318
11335
  }
11319
11336
  assertNotDestroyed() {
11320
11337
  if (this._destroyed) {
11321
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11322
- 'Injector has already been destroyed.' :
11323
- '';
11324
- throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, errorMessage);
11338
+ throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, ngDevMode && 'Injector has already been destroyed.');
11325
11339
  }
11326
11340
  }
11327
11341
  /**
@@ -11485,28 +11499,21 @@ function injectableDefOrInjectorDefFactory(token) {
11485
11499
  // InjectionTokens should have an injectable def (ɵprov) and thus should be handled above.
11486
11500
  // If it's missing that, it's an error.
11487
11501
  if (token instanceof InjectionToken) {
11488
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11489
- `Token ${stringify(token)} is missing a ɵprov definition.` :
11490
- '';
11491
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11502
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`);
11492
11503
  }
11493
11504
  // Undecorated types can sometimes be created if they have no constructor arguments.
11494
11505
  if (token instanceof Function) {
11495
11506
  return getUndecoratedInjectableFactory(token);
11496
11507
  }
11497
11508
  // There was no way to resolve a factory for this token.
11498
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ? 'unreachable' : '';
11499
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11509
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && 'unreachable');
11500
11510
  }
11501
11511
  function getUndecoratedInjectableFactory(token) {
11502
11512
  // If the token has parameters then it has dependencies that we cannot resolve implicitly.
11503
11513
  const paramLength = token.length;
11504
11514
  if (paramLength > 0) {
11505
11515
  const args = newArray(paramLength, '?');
11506
- const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11507
- `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).` :
11508
- '';
11509
- throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11516
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, ngDevMode && `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).`);
11510
11517
  }
11511
11518
  // The constructor function appears to have no parameters.
11512
11519
  // This might be because it inherits from a super-class. In which case, use an injectable
@@ -21083,7 +21090,7 @@ class Version {
21083
21090
  /**
21084
21091
  * @publicApi
21085
21092
  */
21086
- const VERSION = new Version('13.2.0-rc.1');
21093
+ const VERSION = new Version('14.0.0-next.1');
21087
21094
 
21088
21095
  /**
21089
21096
  * @license
@@ -21111,37 +21118,6 @@ const VERSION = new Version('13.2.0-rc.1');
21111
21118
  // - mod2.injector.get(token, default)
21112
21119
  const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
21113
21120
 
21114
- /**
21115
- * @license
21116
- * Copyright Google LLC All Rights Reserved.
21117
- *
21118
- * Use of this source code is governed by an MIT-style license that can be
21119
- * found in the LICENSE file at https://angular.io/license
21120
- */
21121
- /**
21122
- * Injector that looks up a value using a specific injector, before falling back to the module
21123
- * injector. Used primarily when creating components or embedded views dynamically.
21124
- */
21125
- class ChainedInjector {
21126
- constructor(injector, parentInjector) {
21127
- this.injector = injector;
21128
- this.parentInjector = parentInjector;
21129
- }
21130
- get(token, notFoundValue, flags) {
21131
- const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21132
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21133
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21134
- // Return the value from the root element injector when
21135
- // - it provides it
21136
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21137
- // - the module injector should not be checked
21138
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21139
- return value;
21140
- }
21141
- return this.parentInjector.get(token, notFoundValue, flags);
21142
- }
21143
- }
21144
-
21145
21121
  /**
21146
21122
  * @license
21147
21123
  * Copyright Google LLC All Rights Reserved.
@@ -21527,6 +21503,23 @@ const SCHEDULER = new InjectionToken('SCHEDULER_TOKEN', {
21527
21503
  providedIn: 'root',
21528
21504
  factory: () => defaultScheduler,
21529
21505
  });
21506
+ function createChainedInjector(rootViewInjector, moduleInjector) {
21507
+ return {
21508
+ get: (token, notFoundValue, flags) => {
21509
+ const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21510
+ if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21511
+ notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21512
+ // Return the value from the root element injector when
21513
+ // - it provides it
21514
+ // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21515
+ // - the module injector should not be checked
21516
+ // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21517
+ return value;
21518
+ }
21519
+ return moduleInjector.get(token, notFoundValue, flags);
21520
+ }
21521
+ };
21522
+ }
21530
21523
  /**
21531
21524
  * Render3 implementation of {@link viewEngine_ComponentFactory}.
21532
21525
  */
@@ -21553,7 +21546,7 @@ class ComponentFactory extends ComponentFactory$1 {
21553
21546
  }
21554
21547
  create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
21555
21548
  ngModule = ngModule || this.ngModule;
21556
- const rootViewInjector = ngModule ? new ChainedInjector(injector, ngModule.injector) : injector;
21549
+ const rootViewInjector = ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
21557
21550
  const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
21558
21551
  const sanitizer = rootViewInjector.get(Sanitizer, null);
21559
21552
  const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
@@ -22688,9 +22681,9 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22688
22681
  this._declarationTContainer = _declarationTContainer;
22689
22682
  this.elementRef = elementRef;
22690
22683
  }
22691
- createEmbeddedView(context, injector) {
22684
+ createEmbeddedView(context) {
22692
22685
  const embeddedTView = this._declarationTContainer.tViews;
22693
- const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, createEmbeddedViewInjector(injector, this._declarationLView[INJECTOR$1]));
22686
+ const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null);
22694
22687
  const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
22695
22688
  ngDevMode && assertLContainer(declarationLContainer);
22696
22689
  embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
@@ -22702,14 +22695,6 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22702
22695
  return new ViewRef$1(embeddedLView);
22703
22696
  }
22704
22697
  };
22705
- function createEmbeddedViewInjector(embeddedViewInjector, declarationViewInjector) {
22706
- if (!embeddedViewInjector) {
22707
- return null;
22708
- }
22709
- return declarationViewInjector ?
22710
- new ChainedInjector(embeddedViewInjector, declarationViewInjector) :
22711
- embeddedViewInjector;
22712
- }
22713
22698
  /**
22714
22699
  * Creates a TemplateRef given a node.
22715
22700
  *
@@ -22814,17 +22799,8 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
22814
22799
  get length() {
22815
22800
  return this._lContainer.length - CONTAINER_HEADER_OFFSET;
22816
22801
  }
22817
- createEmbeddedView(templateRef, context, indexOrOptions) {
22818
- let index;
22819
- let injector;
22820
- if (typeof indexOrOptions === 'number') {
22821
- index = indexOrOptions;
22822
- }
22823
- else if (indexOrOptions != null) {
22824
- index = indexOrOptions.index;
22825
- injector = indexOrOptions.injector;
22826
- }
22827
- const viewRef = templateRef.createEmbeddedView(context || {}, injector);
22802
+ createEmbeddedView(templateRef, context, index) {
22803
+ const viewRef = templateRef.createEmbeddedView(context || {});
22828
22804
  this.insert(viewRef, index);
22829
22805
  return viewRef;
22830
22806
  }
@@ -24605,19 +24581,20 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24605
24581
  *
24606
24582
  * ```
24607
24583
  *
24608
- * The following example registers another DOM event handler that listens for key-press events.
24584
+ * The following example registers another DOM event handler that listens for `Enter` key-press
24585
+ * events on the global `window`.
24609
24586
  * ``` ts
24610
24587
  * import { HostListener, Component } from "@angular/core";
24611
24588
  *
24612
24589
  * @Component({
24613
24590
  * selector: 'app',
24614
- * template: `<h1>Hello, you have pressed keys {{counter}} number of times!</h1> Press any key to
24615
- * increment the counter.
24591
+ * template: `<h1>Hello, you have pressed enter {{counter}} number of times!</h1> Press enter key
24592
+ * to increment the counter.
24616
24593
  * <button (click)="resetCounter()">Reset Counter</button>`
24617
24594
  * })
24618
24595
  * class AppComponent {
24619
24596
  * counter = 0;
24620
- * @HostListener('window:keydown', ['$event'])
24597
+ * @HostListener('window:keydown.enter', ['$event'])
24621
24598
  * handleKeyDown(event: KeyboardEvent) {
24622
24599
  * this.counter++;
24623
24600
  * }
@@ -24626,6 +24603,14 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24626
24603
  * }
24627
24604
  * }
24628
24605
  * ```
24606
+ * The list of valid key names for `keydown` and `keyup` events
24607
+ * can be found here:
24608
+ * https://www.w3.org/TR/DOM-Level-3-Events-key/#named-key-attribute-values
24609
+ *
24610
+ * Note that keys can also be combined, e.g. `@HostListener('keydown.shift.a')`.
24611
+ *
24612
+ * The global target names that can be used to prefix an event name are
24613
+ * `document:`, `window:` and `body:`.
24629
24614
  *
24630
24615
  * @Annotation
24631
24616
  * @publicApi
@@ -25354,7 +25339,8 @@ class NgZone {
25354
25339
  forkInnerZoneWithAngularBehavior(self);
25355
25340
  }
25356
25341
  static isInAngularZone() {
25357
- return Zone.current.get('isAngularZone') === true;
25342
+ // Zone needs to be checked, because this method might be called even when NoopNgZone is used.
25343
+ return typeof Zone !== 'undefined' && Zone.current.get('isAngularZone') === true;
25358
25344
  }
25359
25345
  static assertInAngularZone() {
25360
25346
  if (!NgZone.isInAngularZone()) {