@angular/core 13.2.0-next.2 → 13.2.0-rc.0

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 (32) hide show
  1. package/core.d.ts +52 -4
  2. package/esm2020/src/change_detection/differs/default_iterable_differ.mjs +6 -2
  3. package/esm2020/src/change_detection/differs/default_keyvalue_differ.mjs +6 -2
  4. package/esm2020/src/change_detection/differs/iterable_differs.mjs +6 -2
  5. package/esm2020/src/change_detection/differs/keyvalue_differs.mjs +6 -2
  6. package/esm2020/src/di/injector_compatibility.mjs +10 -3
  7. package/esm2020/src/di/r3_injector.mjs +16 -5
  8. package/esm2020/src/errors.mjs +1 -1
  9. package/esm2020/src/linker/compiler.mjs +1 -1
  10. package/esm2020/src/linker/component_factory.mjs +4 -1
  11. package/esm2020/src/linker/component_factory_resolver.mjs +4 -1
  12. package/esm2020/src/linker/ng_module_factory.mjs +1 -1
  13. package/esm2020/src/linker/template_ref.mjs +13 -4
  14. package/esm2020/src/linker/view_container_ref.mjs +12 -3
  15. package/esm2020/src/render3/chained_injector.mjs +32 -0
  16. package/esm2020/src/render3/component_ref.mjs +3 -20
  17. package/esm2020/src/render3/features/inherit_definition_feature.mjs +6 -2
  18. package/esm2020/src/render3/i18n/i18n_apply.mjs +5 -2
  19. package/esm2020/src/render3/interfaces/injector.mjs +1 -1
  20. package/esm2020/src/render3/view_ref.mjs +6 -3
  21. package/esm2020/src/sanitization/sanitization.mjs +14 -7
  22. package/esm2020/src/version.mjs +1 -1
  23. package/esm2020/testing/src/logger.mjs +3 -3
  24. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  25. package/fesm2015/core.mjs +122 -44
  26. package/fesm2015/core.mjs.map +1 -1
  27. package/fesm2015/testing.mjs +1 -1
  28. package/fesm2020/core.mjs +122 -44
  29. package/fesm2020/core.mjs.map +1 -1
  30. package/fesm2020/testing.mjs +1 -1
  31. package/package.json +1 -1
  32. package/testing/testing.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.2.0-next.2
2
+ * @license Angular v13.2.0-rc.0
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
package/fesm2020/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v13.2.0-next.2
2
+ * @license Angular v13.2.0-rc.0
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -4750,7 +4750,10 @@ function setCurrentInjector(injector) {
4750
4750
  }
4751
4751
  function injectInjectorOnly(token, flags = InjectFlags.Default) {
4752
4752
  if (_currentInjector === undefined) {
4753
- throw new Error(`inject() must be called from an injection context`);
4753
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
4754
+ `inject() must be called from an injection context` :
4755
+ '';
4756
+ throw new RuntimeError(203 /* MISSING_INJECTION_CONTEXT */, errorMessage);
4754
4757
  }
4755
4758
  else if (_currentInjector === null) {
4756
4759
  return injectRootLimpMode(token, undefined, flags);
@@ -4814,7 +4817,10 @@ function injectArgs(types) {
4814
4817
  const arg = resolveForwardRef(types[i]);
4815
4818
  if (Array.isArray(arg)) {
4816
4819
  if (arg.length === 0) {
4817
- throw new Error('Arguments array must have arguments.');
4820
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
4821
+ 'Arguments array must have arguments.' :
4822
+ '';
4823
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
4818
4824
  }
4819
4825
  let type = undefined;
4820
4826
  let flags = InjectFlags.Default;
@@ -6005,7 +6011,10 @@ function ɵɵsanitizeResourceUrl(unsafeResourceUrl) {
6005
6011
  if (allowSanitizationBypassAndThrow(unsafeResourceUrl, "ResourceURL" /* ResourceUrl */)) {
6006
6012
  return trustedScriptURLFromStringBypass(unwrapSafeValue(unsafeResourceUrl));
6007
6013
  }
6008
- throw new Error('unsafe value used in a resource URL context (see https://g.co/ng/security#xss)');
6014
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
6015
+ 'unsafe value used in a resource URL context (see https://g.co/ng/security#xss)' :
6016
+ '';
6017
+ throw new RuntimeError(904 /* UNSAFE_VALUE_IN_RESOURCE_URL */, errorMessage);
6009
6018
  }
6010
6019
  /**
6011
6020
  * A `script` sanitizer which only lets trusted javascript through.
@@ -6027,7 +6036,10 @@ function ɵɵsanitizeScript(unsafeScript) {
6027
6036
  if (allowSanitizationBypassAndThrow(unsafeScript, "Script" /* Script */)) {
6028
6037
  return trustedScriptFromStringBypass(unwrapSafeValue(unsafeScript));
6029
6038
  }
6030
- throw new Error('unsafe value used in a script context');
6039
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
6040
+ 'unsafe value used in a script context' :
6041
+ '';
6042
+ throw new RuntimeError(905 /* UNSAFE_VALUE_IN_SCRIPT */, errorMessage);
6031
6043
  }
6032
6044
  /**
6033
6045
  * A template tag function for promoting the associated constant literal to a
@@ -6115,18 +6127,18 @@ function ɵɵsanitizeUrlOrResourceUrl(unsafeUrl, tag, prop) {
6115
6127
  }
6116
6128
  function validateAgainstEventProperties(name) {
6117
6129
  if (name.toLowerCase().startsWith('on')) {
6118
- const msg = `Binding to event property '${name}' is disallowed for security reasons, ` +
6130
+ const errorMessage = `Binding to event property '${name}' is disallowed for security reasons, ` +
6119
6131
  `please use (${name.slice(2)})=...` +
6120
6132
  `\nIf '${name}' is a directive input, make sure the directive is imported by the` +
6121
6133
  ` current module.`;
6122
- throw new Error(msg);
6134
+ throw new RuntimeError(306 /* INVALID_EVENT_BINDING */, errorMessage);
6123
6135
  }
6124
6136
  }
6125
6137
  function validateAgainstEventAttributes(name) {
6126
6138
  if (name.toLowerCase().startsWith('on')) {
6127
- const msg = `Binding to event attribute '${name}' is disallowed for security reasons, ` +
6139
+ const errorMessage = `Binding to event attribute '${name}' is disallowed for security reasons, ` +
6128
6140
  `please use (${name.slice(2)})=...`;
6129
- throw new Error(msg);
6141
+ throw new RuntimeError(306 /* INVALID_EVENT_BINDING */, errorMessage);
6130
6142
  }
6131
6143
  }
6132
6144
  function getSanitizer() {
@@ -11298,7 +11310,10 @@ class R3Injector {
11298
11310
  }
11299
11311
  assertNotDestroyed() {
11300
11312
  if (this._destroyed) {
11301
- throw new Error('Injector has already been destroyed.');
11313
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11314
+ 'Injector has already been destroyed.' :
11315
+ '';
11316
+ throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, errorMessage);
11302
11317
  }
11303
11318
  }
11304
11319
  /**
@@ -11462,21 +11477,28 @@ function injectableDefOrInjectorDefFactory(token) {
11462
11477
  // InjectionTokens should have an injectable def (ɵprov) and thus should be handled above.
11463
11478
  // If it's missing that, it's an error.
11464
11479
  if (token instanceof InjectionToken) {
11465
- throw new Error(`Token ${stringify(token)} is missing a ɵprov definition.`);
11480
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11481
+ `Token ${stringify(token)} is missing a ɵprov definition.` :
11482
+ '';
11483
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11466
11484
  }
11467
11485
  // Undecorated types can sometimes be created if they have no constructor arguments.
11468
11486
  if (token instanceof Function) {
11469
11487
  return getUndecoratedInjectableFactory(token);
11470
11488
  }
11471
11489
  // There was no way to resolve a factory for this token.
11472
- throw new Error('unreachable');
11490
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ? 'unreachable' : '';
11491
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11473
11492
  }
11474
11493
  function getUndecoratedInjectableFactory(token) {
11475
11494
  // If the token has parameters then it has dependencies that we cannot resolve implicitly.
11476
11495
  const paramLength = token.length;
11477
11496
  if (paramLength > 0) {
11478
11497
  const args = newArray(paramLength, '?');
11479
- throw new Error(`Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).`);
11498
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11499
+ `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).` :
11500
+ '';
11501
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11480
11502
  }
11481
11503
  // The constructor function appears to have no parameters.
11482
11504
  // This might be because it inherits from a super-class. In which case, use an injectable
@@ -12334,7 +12356,10 @@ function ɵɵInheritDefinitionFeature(definition) {
12334
12356
  }
12335
12357
  else {
12336
12358
  if (superType.ɵcmp) {
12337
- throw new Error('Directives cannot inherit Components');
12359
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
12360
+ 'Directives cannot inherit Components' :
12361
+ '';
12362
+ throw new RuntimeError(903 /* INVALID_INHERITANCE */, errorMessage);
12338
12363
  }
12339
12364
  // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
12340
12365
  superDef = superType.ɵdir;
@@ -19115,7 +19140,9 @@ function applyMutableOpCodes(tView, mutableOpCodes, lView, anchorRNode) {
19115
19140
  setElementAttribute(renderer, getNativeByIndex(elementNodeIndex, lView), null, null, attrName, attrValue, null);
19116
19141
  break;
19117
19142
  default:
19118
- throw new Error(`Unable to determine the type of mutate operation for "${opCode}"`);
19143
+ if (ngDevMode) {
19144
+ throw new RuntimeError(700 /* INVALID_I18N_STRUCTURE */, `Unable to determine the type of mutate operation for "${opCode}"`);
19145
+ }
19119
19146
  }
19120
19147
  }
19121
19148
  else {
@@ -20842,6 +20869,9 @@ class ComponentRef$1 {
20842
20869
  * @see [Dynamic Components](guide/dynamic-component-loader)
20843
20870
  *
20844
20871
  * @publicApi
20872
+ *
20873
+ * @deprecated Angular no longer requires Component factories. Please use other APIs where
20874
+ * Component class can be used directly.
20845
20875
  */
20846
20876
  class ComponentFactory$1 {
20847
20877
  }
@@ -20878,6 +20908,9 @@ class _NullComponentFactoryResolver {
20878
20908
  * does **not** require resolving component factory: component class can be used directly.
20879
20909
  *
20880
20910
  * @publicApi
20911
+ *
20912
+ * @deprecated Angular no longer requires Component factories. Please use other APIs where
20913
+ * Component class can be used directly.
20881
20914
  */
20882
20915
  class ComponentFactoryResolver$1 {
20883
20916
  }
@@ -21042,7 +21075,7 @@ class Version {
21042
21075
  /**
21043
21076
  * @publicApi
21044
21077
  */
21045
- const VERSION = new Version('13.2.0-next.2');
21078
+ const VERSION = new Version('13.2.0-rc.0');
21046
21079
 
21047
21080
  /**
21048
21081
  * @license
@@ -21070,6 +21103,37 @@ const VERSION = new Version('13.2.0-next.2');
21070
21103
  // - mod2.injector.get(token, default)
21071
21104
  const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
21072
21105
 
21106
+ /**
21107
+ * @license
21108
+ * Copyright Google LLC All Rights Reserved.
21109
+ *
21110
+ * Use of this source code is governed by an MIT-style license that can be
21111
+ * found in the LICENSE file at https://angular.io/license
21112
+ */
21113
+ /**
21114
+ * Injector that looks up a value using a specific injector, before falling back to the module
21115
+ * injector. Used primarily when creating components or embedded views dynamically.
21116
+ */
21117
+ class ChainedInjector {
21118
+ constructor(injector, parentInjector) {
21119
+ this.injector = injector;
21120
+ this.parentInjector = parentInjector;
21121
+ }
21122
+ get(token, notFoundValue, flags) {
21123
+ const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21124
+ if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21125
+ notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21126
+ // Return the value from the root element injector when
21127
+ // - it provides it
21128
+ // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21129
+ // - the module injector should not be checked
21130
+ // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21131
+ return value;
21132
+ }
21133
+ return this.parentInjector.get(token, notFoundValue, flags);
21134
+ }
21135
+ }
21136
+
21073
21137
  /**
21074
21138
  * @license
21075
21139
  * Copyright Google LLC All Rights Reserved.
@@ -21378,7 +21442,8 @@ class ViewRef$1 {
21378
21442
  }
21379
21443
  attachToViewContainerRef() {
21380
21444
  if (this._appRef) {
21381
- throw new Error('This view is already attached directly to the ApplicationRef!');
21445
+ const errorMessage = ngDevMode ? 'This view is already attached directly to the ApplicationRef!' : '';
21446
+ throw new RuntimeError(902 /* VIEW_ALREADY_ATTACHED */, errorMessage);
21382
21447
  }
21383
21448
  this._attachedToViewContainer = true;
21384
21449
  }
@@ -21388,7 +21453,8 @@ class ViewRef$1 {
21388
21453
  }
21389
21454
  attachToAppRef(appRef) {
21390
21455
  if (this._attachedToViewContainer) {
21391
- throw new Error('This view is already attached to a ViewContainer!');
21456
+ const errorMessage = ngDevMode ? 'This view is already attached to a ViewContainer!' : '';
21457
+ throw new RuntimeError(902 /* VIEW_ALREADY_ATTACHED */, errorMessage);
21392
21458
  }
21393
21459
  this._appRef = appRef;
21394
21460
  }
@@ -21453,23 +21519,6 @@ const SCHEDULER = new InjectionToken('SCHEDULER_TOKEN', {
21453
21519
  providedIn: 'root',
21454
21520
  factory: () => defaultScheduler,
21455
21521
  });
21456
- function createChainedInjector(rootViewInjector, moduleInjector) {
21457
- return {
21458
- get: (token, notFoundValue, flags) => {
21459
- const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21460
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21461
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21462
- // Return the value from the root element injector when
21463
- // - it provides it
21464
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21465
- // - the module injector should not be checked
21466
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21467
- return value;
21468
- }
21469
- return moduleInjector.get(token, notFoundValue, flags);
21470
- }
21471
- };
21472
- }
21473
21522
  /**
21474
21523
  * Render3 implementation of {@link viewEngine_ComponentFactory}.
21475
21524
  */
@@ -21496,7 +21545,7 @@ class ComponentFactory extends ComponentFactory$1 {
21496
21545
  }
21497
21546
  create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
21498
21547
  ngModule = ngModule || this.ngModule;
21499
- const rootViewInjector = ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
21548
+ const rootViewInjector = ngModule ? new ChainedInjector(injector, ngModule.injector) : injector;
21500
21549
  const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
21501
21550
  const sanitizer = rootViewInjector.get(Sanitizer, null);
21502
21551
  const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
@@ -22631,9 +22680,9 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22631
22680
  this._declarationTContainer = _declarationTContainer;
22632
22681
  this.elementRef = elementRef;
22633
22682
  }
22634
- createEmbeddedView(context) {
22683
+ createEmbeddedView(context, injector) {
22635
22684
  const embeddedTView = this._declarationTContainer.tViews;
22636
- const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null);
22685
+ const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, createEmbeddedViewInjector(injector, this._declarationLView[INJECTOR$1]));
22637
22686
  const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
22638
22687
  ngDevMode && assertLContainer(declarationLContainer);
22639
22688
  embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
@@ -22645,6 +22694,14 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22645
22694
  return new ViewRef$1(embeddedLView);
22646
22695
  }
22647
22696
  };
22697
+ function createEmbeddedViewInjector(embeddedViewInjector, declarationViewInjector) {
22698
+ if (!embeddedViewInjector) {
22699
+ return null;
22700
+ }
22701
+ return declarationViewInjector ?
22702
+ new ChainedInjector(embeddedViewInjector, declarationViewInjector) :
22703
+ embeddedViewInjector;
22704
+ }
22648
22705
  /**
22649
22706
  * Creates a TemplateRef given a node.
22650
22707
  *
@@ -22749,8 +22806,17 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
22749
22806
  get length() {
22750
22807
  return this._lContainer.length - CONTAINER_HEADER_OFFSET;
22751
22808
  }
22752
- createEmbeddedView(templateRef, context, index) {
22753
- const viewRef = templateRef.createEmbeddedView(context || {});
22809
+ createEmbeddedView(templateRef, context, indexOrOptions) {
22810
+ let index;
22811
+ let injector;
22812
+ if (typeof indexOrOptions === 'number') {
22813
+ index = indexOrOptions;
22814
+ }
22815
+ else if (indexOrOptions != null) {
22816
+ index = indexOrOptions.index;
22817
+ injector = indexOrOptions.injector;
22818
+ }
22819
+ const viewRef = templateRef.createEmbeddedView(context || {}, injector);
22754
22820
  this.insert(viewRef, index);
22755
22821
  return viewRef;
22756
22822
  }
@@ -27390,7 +27456,10 @@ class DefaultIterableDiffer {
27390
27456
  if (collection == null)
27391
27457
  collection = [];
27392
27458
  if (!isListLikeIterable(collection)) {
27393
- throw new Error(`Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed`);
27459
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
27460
+ `Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed` :
27461
+ '';
27462
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
27394
27463
  }
27395
27464
  if (this.check(collection)) {
27396
27465
  return this;
@@ -27991,7 +28060,10 @@ class DefaultKeyValueDiffer {
27991
28060
  map = new Map();
27992
28061
  }
27993
28062
  else if (!(map instanceof Map || isJsObject(map))) {
27994
- throw new Error(`Error trying to diff '${stringify(map)}'. Only maps and objects are allowed`);
28063
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28064
+ `Error trying to diff '${stringify(map)}'. Only maps and objects are allowed` :
28065
+ '';
28066
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
27995
28067
  }
27996
28068
  return this.check(map) ? this : null;
27997
28069
  }
@@ -28238,7 +28310,10 @@ class IterableDiffers {
28238
28310
  return factory;
28239
28311
  }
28240
28312
  else {
28241
- throw new Error(`Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'`);
28313
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28314
+ `Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'` :
28315
+ '';
28316
+ throw new RuntimeError(901 /* NO_SUPPORTING_DIFFER_FACTORY */, errorMessage);
28242
28317
  }
28243
28318
  }
28244
28319
  }
@@ -28312,7 +28387,10 @@ class KeyValueDiffers {
28312
28387
  if (factory) {
28313
28388
  return factory;
28314
28389
  }
28315
- throw new Error(`Cannot find a differ supporting object '${kv}'`);
28390
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28391
+ `Cannot find a differ supporting object '${kv}'` :
28392
+ '';
28393
+ throw new RuntimeError(901 /* NO_SUPPORTING_DIFFER_FACTORY */, errorMessage);
28316
28394
  }
28317
28395
  }
28318
28396
  /** @nocollapse */