@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
package/fesm2015/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
  */
@@ -4729,7 +4729,10 @@ function setCurrentInjector(injector) {
4729
4729
  }
4730
4730
  function injectInjectorOnly(token, flags = InjectFlags.Default) {
4731
4731
  if (_currentInjector === undefined) {
4732
- throw new Error(`inject() must be called from an injection context`);
4732
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
4733
+ `inject() must be called from an injection context` :
4734
+ '';
4735
+ throw new RuntimeError(203 /* MISSING_INJECTION_CONTEXT */, errorMessage);
4733
4736
  }
4734
4737
  else if (_currentInjector === null) {
4735
4738
  return injectRootLimpMode(token, undefined, flags);
@@ -4793,7 +4796,10 @@ function injectArgs(types) {
4793
4796
  const arg = resolveForwardRef(types[i]);
4794
4797
  if (Array.isArray(arg)) {
4795
4798
  if (arg.length === 0) {
4796
- throw new Error('Arguments array must have arguments.');
4799
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
4800
+ 'Arguments array must have arguments.' :
4801
+ '';
4802
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
4797
4803
  }
4798
4804
  let type = undefined;
4799
4805
  let flags = InjectFlags.Default;
@@ -5990,7 +5996,10 @@ function ɵɵsanitizeResourceUrl(unsafeResourceUrl) {
5990
5996
  if (allowSanitizationBypassAndThrow(unsafeResourceUrl, "ResourceURL" /* ResourceUrl */)) {
5991
5997
  return trustedScriptURLFromStringBypass(unwrapSafeValue(unsafeResourceUrl));
5992
5998
  }
5993
- throw new Error('unsafe value used in a resource URL context (see https://g.co/ng/security#xss)');
5999
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
6000
+ 'unsafe value used in a resource URL context (see https://g.co/ng/security#xss)' :
6001
+ '';
6002
+ throw new RuntimeError(904 /* UNSAFE_VALUE_IN_RESOURCE_URL */, errorMessage);
5994
6003
  }
5995
6004
  /**
5996
6005
  * A `script` sanitizer which only lets trusted javascript through.
@@ -6012,7 +6021,10 @@ function ɵɵsanitizeScript(unsafeScript) {
6012
6021
  if (allowSanitizationBypassAndThrow(unsafeScript, "Script" /* Script */)) {
6013
6022
  return trustedScriptFromStringBypass(unwrapSafeValue(unsafeScript));
6014
6023
  }
6015
- throw new Error('unsafe value used in a script context');
6024
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
6025
+ 'unsafe value used in a script context' :
6026
+ '';
6027
+ throw new RuntimeError(905 /* UNSAFE_VALUE_IN_SCRIPT */, errorMessage);
6016
6028
  }
6017
6029
  /**
6018
6030
  * A template tag function for promoting the associated constant literal to a
@@ -6100,18 +6112,18 @@ function ɵɵsanitizeUrlOrResourceUrl(unsafeUrl, tag, prop) {
6100
6112
  }
6101
6113
  function validateAgainstEventProperties(name) {
6102
6114
  if (name.toLowerCase().startsWith('on')) {
6103
- const msg = `Binding to event property '${name}' is disallowed for security reasons, ` +
6115
+ const errorMessage = `Binding to event property '${name}' is disallowed for security reasons, ` +
6104
6116
  `please use (${name.slice(2)})=...` +
6105
6117
  `\nIf '${name}' is a directive input, make sure the directive is imported by the` +
6106
6118
  ` current module.`;
6107
- throw new Error(msg);
6119
+ throw new RuntimeError(306 /* INVALID_EVENT_BINDING */, errorMessage);
6108
6120
  }
6109
6121
  }
6110
6122
  function validateAgainstEventAttributes(name) {
6111
6123
  if (name.toLowerCase().startsWith('on')) {
6112
- const msg = `Binding to event attribute '${name}' is disallowed for security reasons, ` +
6124
+ const errorMessage = `Binding to event attribute '${name}' is disallowed for security reasons, ` +
6113
6125
  `please use (${name.slice(2)})=...`;
6114
- throw new Error(msg);
6126
+ throw new RuntimeError(306 /* INVALID_EVENT_BINDING */, errorMessage);
6115
6127
  }
6116
6128
  }
6117
6129
  function getSanitizer() {
@@ -11283,7 +11295,10 @@ class R3Injector {
11283
11295
  }
11284
11296
  assertNotDestroyed() {
11285
11297
  if (this._destroyed) {
11286
- throw new Error('Injector has already been destroyed.');
11298
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11299
+ 'Injector has already been destroyed.' :
11300
+ '';
11301
+ throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, errorMessage);
11287
11302
  }
11288
11303
  }
11289
11304
  /**
@@ -11447,21 +11462,28 @@ function injectableDefOrInjectorDefFactory(token) {
11447
11462
  // InjectionTokens should have an injectable def (ɵprov) and thus should be handled above.
11448
11463
  // If it's missing that, it's an error.
11449
11464
  if (token instanceof InjectionToken) {
11450
- throw new Error(`Token ${stringify(token)} is missing a ɵprov definition.`);
11465
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11466
+ `Token ${stringify(token)} is missing a ɵprov definition.` :
11467
+ '';
11468
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11451
11469
  }
11452
11470
  // Undecorated types can sometimes be created if they have no constructor arguments.
11453
11471
  if (token instanceof Function) {
11454
11472
  return getUndecoratedInjectableFactory(token);
11455
11473
  }
11456
11474
  // There was no way to resolve a factory for this token.
11457
- throw new Error('unreachable');
11475
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ? 'unreachable' : '';
11476
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11458
11477
  }
11459
11478
  function getUndecoratedInjectableFactory(token) {
11460
11479
  // If the token has parameters then it has dependencies that we cannot resolve implicitly.
11461
11480
  const paramLength = token.length;
11462
11481
  if (paramLength > 0) {
11463
11482
  const args = newArray(paramLength, '?');
11464
- throw new Error(`Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).`);
11483
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11484
+ `Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).` :
11485
+ '';
11486
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11465
11487
  }
11466
11488
  // The constructor function appears to have no parameters.
11467
11489
  // This might be because it inherits from a super-class. In which case, use an injectable
@@ -12320,7 +12342,10 @@ function ɵɵInheritDefinitionFeature(definition) {
12320
12342
  }
12321
12343
  else {
12322
12344
  if (superType.ɵcmp) {
12323
- throw new Error('Directives cannot inherit Components');
12345
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
12346
+ 'Directives cannot inherit Components' :
12347
+ '';
12348
+ throw new RuntimeError(903 /* INVALID_INHERITANCE */, errorMessage);
12324
12349
  }
12325
12350
  // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
12326
12351
  superDef = superType.ɵdir;
@@ -19101,7 +19126,9 @@ function applyMutableOpCodes(tView, mutableOpCodes, lView, anchorRNode) {
19101
19126
  setElementAttribute(renderer, getNativeByIndex(elementNodeIndex, lView), null, null, attrName, attrValue, null);
19102
19127
  break;
19103
19128
  default:
19104
- throw new Error(`Unable to determine the type of mutate operation for "${opCode}"`);
19129
+ if (ngDevMode) {
19130
+ throw new RuntimeError(700 /* INVALID_I18N_STRUCTURE */, `Unable to determine the type of mutate operation for "${opCode}"`);
19131
+ }
19105
19132
  }
19106
19133
  }
19107
19134
  else {
@@ -20828,6 +20855,9 @@ class ComponentRef$1 {
20828
20855
  * @see [Dynamic Components](guide/dynamic-component-loader)
20829
20856
  *
20830
20857
  * @publicApi
20858
+ *
20859
+ * @deprecated Angular no longer requires Component factories. Please use other APIs where
20860
+ * Component class can be used directly.
20831
20861
  */
20832
20862
  class ComponentFactory$1 {
20833
20863
  }
@@ -20864,6 +20894,9 @@ class _NullComponentFactoryResolver {
20864
20894
  * does **not** require resolving component factory: component class can be used directly.
20865
20895
  *
20866
20896
  * @publicApi
20897
+ *
20898
+ * @deprecated Angular no longer requires Component factories. Please use other APIs where
20899
+ * Component class can be used directly.
20867
20900
  */
20868
20901
  class ComponentFactoryResolver$1 {
20869
20902
  }
@@ -21028,7 +21061,7 @@ class Version {
21028
21061
  /**
21029
21062
  * @publicApi
21030
21063
  */
21031
- const VERSION = new Version('13.2.0-next.2');
21064
+ const VERSION = new Version('13.2.0-rc.0');
21032
21065
 
21033
21066
  /**
21034
21067
  * @license
@@ -21056,6 +21089,37 @@ const VERSION = new Version('13.2.0-next.2');
21056
21089
  // - mod2.injector.get(token, default)
21057
21090
  const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
21058
21091
 
21092
+ /**
21093
+ * @license
21094
+ * Copyright Google LLC All Rights Reserved.
21095
+ *
21096
+ * Use of this source code is governed by an MIT-style license that can be
21097
+ * found in the LICENSE file at https://angular.io/license
21098
+ */
21099
+ /**
21100
+ * Injector that looks up a value using a specific injector, before falling back to the module
21101
+ * injector. Used primarily when creating components or embedded views dynamically.
21102
+ */
21103
+ class ChainedInjector {
21104
+ constructor(injector, parentInjector) {
21105
+ this.injector = injector;
21106
+ this.parentInjector = parentInjector;
21107
+ }
21108
+ get(token, notFoundValue, flags) {
21109
+ const value = this.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21110
+ if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21111
+ notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21112
+ // Return the value from the root element injector when
21113
+ // - it provides it
21114
+ // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21115
+ // - the module injector should not be checked
21116
+ // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21117
+ return value;
21118
+ }
21119
+ return this.parentInjector.get(token, notFoundValue, flags);
21120
+ }
21121
+ }
21122
+
21059
21123
  /**
21060
21124
  * @license
21061
21125
  * Copyright Google LLC All Rights Reserved.
@@ -21364,7 +21428,8 @@ class ViewRef$1 {
21364
21428
  }
21365
21429
  attachToViewContainerRef() {
21366
21430
  if (this._appRef) {
21367
- throw new Error('This view is already attached directly to the ApplicationRef!');
21431
+ const errorMessage = ngDevMode ? 'This view is already attached directly to the ApplicationRef!' : '';
21432
+ throw new RuntimeError(902 /* VIEW_ALREADY_ATTACHED */, errorMessage);
21368
21433
  }
21369
21434
  this._attachedToViewContainer = true;
21370
21435
  }
@@ -21374,7 +21439,8 @@ class ViewRef$1 {
21374
21439
  }
21375
21440
  attachToAppRef(appRef) {
21376
21441
  if (this._attachedToViewContainer) {
21377
- throw new Error('This view is already attached to a ViewContainer!');
21442
+ const errorMessage = ngDevMode ? 'This view is already attached to a ViewContainer!' : '';
21443
+ throw new RuntimeError(902 /* VIEW_ALREADY_ATTACHED */, errorMessage);
21378
21444
  }
21379
21445
  this._appRef = appRef;
21380
21446
  }
@@ -21439,23 +21505,6 @@ const SCHEDULER = new InjectionToken('SCHEDULER_TOKEN', {
21439
21505
  providedIn: 'root',
21440
21506
  factory: () => defaultScheduler,
21441
21507
  });
21442
- function createChainedInjector(rootViewInjector, moduleInjector) {
21443
- return {
21444
- get: (token, notFoundValue, flags) => {
21445
- const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21446
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21447
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21448
- // Return the value from the root element injector when
21449
- // - it provides it
21450
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21451
- // - the module injector should not be checked
21452
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21453
- return value;
21454
- }
21455
- return moduleInjector.get(token, notFoundValue, flags);
21456
- }
21457
- };
21458
- }
21459
21508
  /**
21460
21509
  * Render3 implementation of {@link viewEngine_ComponentFactory}.
21461
21510
  */
@@ -21482,7 +21531,7 @@ class ComponentFactory extends ComponentFactory$1 {
21482
21531
  }
21483
21532
  create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
21484
21533
  ngModule = ngModule || this.ngModule;
21485
- const rootViewInjector = ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
21534
+ const rootViewInjector = ngModule ? new ChainedInjector(injector, ngModule.injector) : injector;
21486
21535
  const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
21487
21536
  const sanitizer = rootViewInjector.get(Sanitizer, null);
21488
21537
  const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
@@ -22618,9 +22667,9 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22618
22667
  this._declarationTContainer = _declarationTContainer;
22619
22668
  this.elementRef = elementRef;
22620
22669
  }
22621
- createEmbeddedView(context) {
22670
+ createEmbeddedView(context, injector) {
22622
22671
  const embeddedTView = this._declarationTContainer.tViews;
22623
- const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null);
22672
+ const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, createEmbeddedViewInjector(injector, this._declarationLView[INJECTOR$1]));
22624
22673
  const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
22625
22674
  ngDevMode && assertLContainer(declarationLContainer);
22626
22675
  embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
@@ -22632,6 +22681,14 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22632
22681
  return new ViewRef$1(embeddedLView);
22633
22682
  }
22634
22683
  };
22684
+ function createEmbeddedViewInjector(embeddedViewInjector, declarationViewInjector) {
22685
+ if (!embeddedViewInjector) {
22686
+ return null;
22687
+ }
22688
+ return declarationViewInjector ?
22689
+ new ChainedInjector(embeddedViewInjector, declarationViewInjector) :
22690
+ embeddedViewInjector;
22691
+ }
22635
22692
  /**
22636
22693
  * Creates a TemplateRef given a node.
22637
22694
  *
@@ -22736,8 +22793,17 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
22736
22793
  get length() {
22737
22794
  return this._lContainer.length - CONTAINER_HEADER_OFFSET;
22738
22795
  }
22739
- createEmbeddedView(templateRef, context, index) {
22740
- const viewRef = templateRef.createEmbeddedView(context || {});
22796
+ createEmbeddedView(templateRef, context, indexOrOptions) {
22797
+ let index;
22798
+ let injector;
22799
+ if (typeof indexOrOptions === 'number') {
22800
+ index = indexOrOptions;
22801
+ }
22802
+ else if (indexOrOptions != null) {
22803
+ index = indexOrOptions.index;
22804
+ injector = indexOrOptions.injector;
22805
+ }
22806
+ const viewRef = templateRef.createEmbeddedView(context || {}, injector);
22741
22807
  this.insert(viewRef, index);
22742
22808
  return viewRef;
22743
22809
  }
@@ -27372,7 +27438,10 @@ class DefaultIterableDiffer {
27372
27438
  if (collection == null)
27373
27439
  collection = [];
27374
27440
  if (!isListLikeIterable(collection)) {
27375
- throw new Error(`Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed`);
27441
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
27442
+ `Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed` :
27443
+ '';
27444
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
27376
27445
  }
27377
27446
  if (this.check(collection)) {
27378
27447
  return this;
@@ -27973,7 +28042,10 @@ class DefaultKeyValueDiffer {
27973
28042
  map = new Map();
27974
28043
  }
27975
28044
  else if (!(map instanceof Map || isJsObject(map))) {
27976
- throw new Error(`Error trying to diff '${stringify(map)}'. Only maps and objects are allowed`);
28045
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28046
+ `Error trying to diff '${stringify(map)}'. Only maps and objects are allowed` :
28047
+ '';
28048
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
27977
28049
  }
27978
28050
  return this.check(map) ? this : null;
27979
28051
  }
@@ -28220,7 +28292,10 @@ class IterableDiffers {
28220
28292
  return factory;
28221
28293
  }
28222
28294
  else {
28223
- throw new Error(`Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'`);
28295
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28296
+ `Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'` :
28297
+ '';
28298
+ throw new RuntimeError(901 /* NO_SUPPORTING_DIFFER_FACTORY */, errorMessage);
28224
28299
  }
28225
28300
  }
28226
28301
  }
@@ -28294,7 +28369,10 @@ class KeyValueDiffers {
28294
28369
  if (factory) {
28295
28370
  return factory;
28296
28371
  }
28297
- throw new Error(`Cannot find a differ supporting object '${kv}'`);
28372
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28373
+ `Cannot find a differ supporting object '${kv}'` :
28374
+ '';
28375
+ throw new RuntimeError(901 /* NO_SUPPORTING_DIFFER_FACTORY */, errorMessage);
28298
28376
  }
28299
28377
  }
28300
28378
  /** @nocollapse */