@angular/core 13.2.0-next.0 → 13.2.0-rc.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 (58) hide show
  1. package/core.d.ts +87 -29
  2. package/esm2020/src/application_ref.mjs +10 -10
  3. package/esm2020/src/change_detection/differs/default_iterable_differ.mjs +6 -2
  4. package/esm2020/src/change_detection/differs/default_keyvalue_differ.mjs +6 -2
  5. package/esm2020/src/change_detection/differs/iterable_differs.mjs +6 -2
  6. package/esm2020/src/change_detection/differs/keyvalue_differs.mjs +6 -2
  7. package/esm2020/src/core_private_export.mjs +2 -2
  8. package/esm2020/src/di/injector_compatibility.mjs +10 -3
  9. package/esm2020/src/di/r3_injector.mjs +16 -5
  10. package/esm2020/src/error_details_base_url.mjs +16 -0
  11. package/esm2020/src/error_handler.mjs +2 -2
  12. package/esm2020/src/errors.mjs +18 -12
  13. package/esm2020/src/linker/compiler.mjs +1 -1
  14. package/esm2020/src/linker/component_factory.mjs +4 -1
  15. package/esm2020/src/linker/component_factory_resolver.mjs +4 -1
  16. package/esm2020/src/linker/ng_module_factory.mjs +1 -1
  17. package/esm2020/src/linker/template_ref.mjs +13 -4
  18. package/esm2020/src/linker/view_container_ref.mjs +12 -3
  19. package/esm2020/src/metadata/directives.mjs +2 -2
  20. package/esm2020/src/reflection/reflection_capabilities.mjs +2 -2
  21. package/esm2020/src/render3/chained_injector.mjs +32 -0
  22. package/esm2020/src/render3/component_ref.mjs +3 -20
  23. package/esm2020/src/render3/errors.mjs +4 -6
  24. package/esm2020/src/render3/errors_di.mjs +11 -4
  25. package/esm2020/src/render3/features/inherit_definition_feature.mjs +6 -2
  26. package/esm2020/src/render3/i18n/i18n_apply.mjs +5 -2
  27. package/esm2020/src/render3/i18n/i18n_parse.mjs +2 -2
  28. package/esm2020/src/render3/instructions/element.mjs +3 -3
  29. package/esm2020/src/render3/instructions/shared.mjs +4 -4
  30. package/esm2020/src/render3/interfaces/injector.mjs +1 -1
  31. package/esm2020/src/render3/namespaces.mjs +10 -3
  32. package/esm2020/src/render3/ng_module_ref.mjs +2 -2
  33. package/esm2020/src/render3/node_manipulation.mjs +5 -3
  34. package/esm2020/src/render3/pipe.mjs +3 -3
  35. package/esm2020/src/render3/view_ref.mjs +6 -3
  36. package/esm2020/src/sanitization/sanitization.mjs +14 -7
  37. package/esm2020/src/util/errors.mjs +10 -2
  38. package/esm2020/src/version.mjs +1 -1
  39. package/esm2020/testing/src/logger.mjs +3 -3
  40. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  41. package/fesm2015/core.mjs +170 -106
  42. package/fesm2015/core.mjs.map +1 -1
  43. package/fesm2015/testing.mjs +2 -2
  44. package/fesm2020/core.mjs +170 -106
  45. package/fesm2020/core.mjs.map +1 -1
  46. package/fesm2020/testing.mjs +2 -2
  47. package/package.json +1 -1
  48. package/schematics/migrations/typed-forms/index.d.ts +14 -0
  49. package/schematics/migrations/typed-forms/index.js +90 -0
  50. package/schematics/migrations/typed-forms/util.d.ts +21 -0
  51. package/schematics/migrations/typed-forms/util.js +87 -0
  52. package/schematics/migrations.json +5 -0
  53. package/schematics/utils/import_manager.d.ts +0 -5
  54. package/schematics/utils/import_manager.js +3 -7
  55. package/schematics/utils/typescript/imports.js +2 -5
  56. package/testing/testing.d.ts +2 -2
  57. package/esm2020/src/render3/error_code.mjs +0 -42
  58. package/esm2020/src/render3/error_details_base_url.mjs +0 -16
package/fesm2015/core.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @license Angular v13.2.0-next.0
3
- * (c) 2010-2021 Google LLC. https://angular.io/
2
+ * @license Angular v13.2.0-rc.1
3
+ * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
@@ -141,7 +141,7 @@ function isForwardRef(fn) {
141
141
  *
142
142
  * Keep the files below in full sync:
143
143
  * - packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts
144
- * - packages/core/src/render3/error_details_base_url.ts
144
+ * - packages/core/src/error_details_base_url.ts
145
145
  */
146
146
  const ERROR_DETAILS_PAGE_BASE_URL = 'https://angular.io/errors';
147
147
 
@@ -158,30 +158,15 @@ class RuntimeError extends Error {
158
158
  this.code = code;
159
159
  }
160
160
  }
161
- // Contains a set of error messages that have details guides at angular.io.
162
- // Full list of available error guides can be found at https://angular.io/errors
163
- /* tslint:disable:no-toplevel-property-access */
164
- const RUNTIME_ERRORS_WITH_GUIDES = new Set([
165
- "100" /* EXPRESSION_CHANGED_AFTER_CHECKED */,
166
- "200" /* CYCLIC_DI_DEPENDENCY */,
167
- "201" /* PROVIDER_NOT_FOUND */,
168
- "300" /* MULTIPLE_COMPONENTS_MATCH */,
169
- "301" /* EXPORT_NOT_FOUND */,
170
- "302" /* PIPE_NOT_FOUND */,
171
- ]);
172
- /* tslint:enable:no-toplevel-property-access */
173
161
  /** Called to format a runtime error */
174
162
  function formatRuntimeError(code, message) {
175
- const fullCode = code ? `NG0${code}: ` : '';
176
- let errorMessage = `${fullCode}${message}`;
177
- // Some runtime errors are still thrown without `ngDevMode` (for example
178
- // `throwProviderNotFoundError`), so we add `ngDevMode` check here to avoid pulling
179
- // `RUNTIME_ERRORS_WITH_GUIDES` symbol into prod bundles.
180
- // TODO: revisit all instances where `RuntimeError` is thrown and see if `ngDevMode` can be added
181
- // there instead to tree-shake more devmode-only code (and eventually remove `ngDevMode` check
182
- // from this code).
183
- if (ngDevMode && RUNTIME_ERRORS_WITH_GUIDES.has(code)) {
184
- errorMessage = `${errorMessage}. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0${code}`;
163
+ const codeAsNumber = code;
164
+ // Error code might be a negative number, which is a special marker that instructs the logic to
165
+ // generate a link to the error details page on angular.io.
166
+ const fullCode = `NG0${Math.abs(codeAsNumber)}`;
167
+ let errorMessage = `${fullCode}${message ? ': ' + message : ''}`;
168
+ if (ngDevMode && codeAsNumber < 0) {
169
+ errorMessage = `${errorMessage}. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/${fullCode}`;
185
170
  }
186
171
  return errorMessage;
187
172
  }
@@ -222,10 +207,17 @@ function stringifyForError(value) {
222
207
  return renderStringify(value);
223
208
  }
224
209
 
210
+ /**
211
+ * @license
212
+ * Copyright Google LLC All Rights Reserved.
213
+ *
214
+ * Use of this source code is governed by an MIT-style license that can be
215
+ * found in the LICENSE file at https://angular.io/license
216
+ */
225
217
  /** Called when directives inject each other (creating a circular dependency) */
226
218
  function throwCyclicDependencyError(token, path) {
227
219
  const depPath = path ? `. Dependency path: ${path.join(' > ')} > ${token}` : '';
228
- throw new RuntimeError("200" /* CYCLIC_DI_DEPENDENCY */, `Circular dependency in DI detected for ${token}${depPath}`);
220
+ throw new RuntimeError(-200 /* CYCLIC_DI_DEPENDENCY */, `Circular dependency in DI detected for ${token}${depPath}`);
229
221
  }
230
222
  function throwMixedMultiProviderError() {
231
223
  throw new Error(`Cannot mix multi providers and regular providers`);
@@ -242,7 +234,7 @@ function throwInvalidProviderError(ngModuleType, providers, provider) {
242
234
  /** Throws an error when a token is not found in DI. */
243
235
  function throwProviderNotFoundError(token, injectorName) {
244
236
  const injectorDetails = injectorName ? ` in ${injectorName}` : '';
245
- throw new RuntimeError("201" /* PROVIDER_NOT_FOUND */, `No provider for ${stringifyForError(token)} found${injectorDetails}`);
237
+ throw new RuntimeError(-201 /* PROVIDER_NOT_FOUND */, `No provider for ${stringifyForError(token)} found${injectorDetails}`);
246
238
  }
247
239
 
248
240
  /**
@@ -1560,8 +1552,15 @@ const profiler = function (event, instance, hookOrListener) {
1560
1552
  * Use of this source code is governed by an MIT-style license that can be
1561
1553
  * found in the LICENSE file at https://angular.io/license
1562
1554
  */
1563
- const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1564
- const MATH_ML_NAMESPACE = 'http://www.w3.org/1998/MathML/';
1555
+ const SVG_NAMESPACE = 'svg';
1556
+ const SVG_NAMESPACE_URI = 'http://www.w3.org/2000/svg';
1557
+ const MATH_ML_NAMESPACE = 'math';
1558
+ const MATH_ML_NAMESPACE_URI = 'http://www.w3.org/1998/MathML/';
1559
+ function getNamespaceUri(namespace) {
1560
+ const name = namespace.toLowerCase();
1561
+ return name === SVG_NAMESPACE ? SVG_NAMESPACE_URI :
1562
+ (name === MATH_ML_NAMESPACE ? MATH_ML_NAMESPACE_URI : null);
1563
+ }
1565
1564
 
1566
1565
  /**
1567
1566
  * @license
@@ -4458,7 +4457,7 @@ const ES2015_INHERITED_CLASS_WITH_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{
4458
4457
  * Regular expression that detects ES2015 classes which extend from other classes
4459
4458
  * and inherit a constructor.
4460
4459
  */
4461
- const ES2015_INHERITED_CLASS_WITH_DELEGATE_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(\)\s*{\s*super\(\.\.\.arguments\)/;
4460
+ const ES2015_INHERITED_CLASS_WITH_DELEGATE_CTOR = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(\)\s*{[^}]*super\(\.\.\.arguments\)/;
4462
4461
  /**
4463
4462
  * Determine whether a stringified type is a class which delegates its constructor
4464
4463
  * to its parent.
@@ -4737,7 +4736,10 @@ function setCurrentInjector(injector) {
4737
4736
  }
4738
4737
  function injectInjectorOnly(token, flags = InjectFlags.Default) {
4739
4738
  if (_currentInjector === undefined) {
4740
- throw new Error(`inject() must be called from an injection context`);
4739
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
4740
+ `inject() must be called from an injection context` :
4741
+ '';
4742
+ throw new RuntimeError(203 /* MISSING_INJECTION_CONTEXT */, errorMessage);
4741
4743
  }
4742
4744
  else if (_currentInjector === null) {
4743
4745
  return injectRootLimpMode(token, undefined, flags);
@@ -4801,7 +4803,10 @@ function injectArgs(types) {
4801
4803
  const arg = resolveForwardRef(types[i]);
4802
4804
  if (Array.isArray(arg)) {
4803
4805
  if (arg.length === 0) {
4804
- throw new Error('Arguments array must have arguments.');
4806
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
4807
+ 'Arguments array must have arguments.' :
4808
+ '';
4809
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
4805
4810
  }
4806
4811
  let type = undefined;
4807
4812
  let flags = InjectFlags.Default;
@@ -5998,7 +6003,10 @@ function ɵɵsanitizeResourceUrl(unsafeResourceUrl) {
5998
6003
  if (allowSanitizationBypassAndThrow(unsafeResourceUrl, "ResourceURL" /* ResourceUrl */)) {
5999
6004
  return trustedScriptURLFromStringBypass(unwrapSafeValue(unsafeResourceUrl));
6000
6005
  }
6001
- throw new Error('unsafe value used in a resource URL context (see https://g.co/ng/security#xss)');
6006
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
6007
+ 'unsafe value used in a resource URL context (see https://g.co/ng/security#xss)' :
6008
+ '';
6009
+ throw new RuntimeError(904 /* UNSAFE_VALUE_IN_RESOURCE_URL */, errorMessage);
6002
6010
  }
6003
6011
  /**
6004
6012
  * A `script` sanitizer which only lets trusted javascript through.
@@ -6020,7 +6028,10 @@ function ɵɵsanitizeScript(unsafeScript) {
6020
6028
  if (allowSanitizationBypassAndThrow(unsafeScript, "Script" /* Script */)) {
6021
6029
  return trustedScriptFromStringBypass(unwrapSafeValue(unsafeScript));
6022
6030
  }
6023
- throw new Error('unsafe value used in a script context');
6031
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
6032
+ 'unsafe value used in a script context' :
6033
+ '';
6034
+ throw new RuntimeError(905 /* UNSAFE_VALUE_IN_SCRIPT */, errorMessage);
6024
6035
  }
6025
6036
  /**
6026
6037
  * A template tag function for promoting the associated constant literal to a
@@ -6108,18 +6119,18 @@ function ɵɵsanitizeUrlOrResourceUrl(unsafeUrl, tag, prop) {
6108
6119
  }
6109
6120
  function validateAgainstEventProperties(name) {
6110
6121
  if (name.toLowerCase().startsWith('on')) {
6111
- const msg = `Binding to event property '${name}' is disallowed for security reasons, ` +
6122
+ const errorMessage = `Binding to event property '${name}' is disallowed for security reasons, ` +
6112
6123
  `please use (${name.slice(2)})=...` +
6113
6124
  `\nIf '${name}' is a directive input, make sure the directive is imported by the` +
6114
6125
  ` current module.`;
6115
- throw new Error(msg);
6126
+ throw new RuntimeError(306 /* INVALID_EVENT_BINDING */, errorMessage);
6116
6127
  }
6117
6128
  }
6118
6129
  function validateAgainstEventAttributes(name) {
6119
6130
  if (name.toLowerCase().startsWith('on')) {
6120
- const msg = `Binding to event attribute '${name}' is disallowed for security reasons, ` +
6131
+ const errorMessage = `Binding to event attribute '${name}' is disallowed for security reasons, ` +
6121
6132
  `please use (${name.slice(2)})=...`;
6122
- throw new Error(msg);
6133
+ throw new RuntimeError(306 /* INVALID_EVENT_BINDING */, errorMessage);
6123
6134
  }
6124
6135
  }
6125
6136
  function getSanitizer() {
@@ -6439,7 +6450,6 @@ function discoverLocalRefs(lView, nodeIndex) {
6439
6450
  * Use of this source code is governed by an MIT-style license that can be
6440
6451
  * found in the LICENSE file at https://angular.io/license
6441
6452
  */
6442
- const ERROR_TYPE = 'ngType';
6443
6453
  const ERROR_ORIGINAL_ERROR = 'ngOriginalError';
6444
6454
  const ERROR_LOGGER = 'ngErrorLogger';
6445
6455
  function wrappedError(message, originalError) {
@@ -6448,17 +6458,6 @@ function wrappedError(message, originalError) {
6448
6458
  error[ERROR_ORIGINAL_ERROR] = originalError;
6449
6459
  return error;
6450
6460
  }
6451
-
6452
- /**
6453
- * @license
6454
- * Copyright Google LLC All Rights Reserved.
6455
- *
6456
- * Use of this source code is governed by an MIT-style license that can be
6457
- * found in the LICENSE file at https://angular.io/license
6458
- */
6459
- function getType(error) {
6460
- return error[ERROR_TYPE];
6461
- }
6462
6461
  function getOriginalError(error) {
6463
6462
  return error[ERROR_ORIGINAL_ERROR];
6464
6463
  }
@@ -6703,7 +6702,7 @@ function maybeUnwrapFn(value) {
6703
6702
  */
6704
6703
  /** Called when there are multiple component selectors that match a given node */
6705
6704
  function throwMultipleComponentError(tNode) {
6706
- throw new RuntimeError("300" /* MULTIPLE_COMPONENTS_MATCH */, `Multiple components match node with tagname ${tNode.value}`);
6705
+ throw new RuntimeError(-300 /* MULTIPLE_COMPONENTS_MATCH */, `Multiple components match node with tagname ${tNode.value}`);
6707
6706
  }
6708
6707
  /** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */
6709
6708
  function throwErrorIfNoChangesMode(creationMode, oldValue, currValue, propName) {
@@ -6714,9 +6713,7 @@ function throwErrorIfNoChangesMode(creationMode, oldValue, currValue, propName)
6714
6713
  ` It seems like the view has been created after its parent and its children have been dirty checked.` +
6715
6714
  ` Has it been created in a change detection hook?`;
6716
6715
  }
6717
- // TODO: include debug context, see `viewDebugError` function in
6718
- // `packages/core/src/view/errors.ts` for reference.
6719
- throw new RuntimeError("100" /* EXPRESSION_CHANGED_AFTER_CHECKED */, msg);
6716
+ throw new RuntimeError(-100 /* EXPRESSION_CHANGED_AFTER_CHECKED */, msg);
6720
6717
  }
6721
6718
  function constructDetailsForInterpolation(lView, rootIndex, expressionIndex, meta, changedValue) {
6722
6719
  const [propName, prefix, ...chunks] = meta.split(INTERPOLATION_DELIMITER);
@@ -6983,8 +6980,9 @@ function createElementNode(renderer, name, namespace) {
6983
6980
  return renderer.createElement(name, namespace);
6984
6981
  }
6985
6982
  else {
6986
- return namespace === null ? renderer.createElement(name) :
6987
- renderer.createElementNS(namespace, name);
6983
+ const namespaceUri = namespace !== null ? getNamespaceUri(namespace) : null;
6984
+ return namespaceUri === null ? renderer.createElement(name) :
6985
+ renderer.createElementNS(namespaceUri, name);
6988
6986
  }
6989
6987
  }
6990
6988
  /**
@@ -10126,7 +10124,7 @@ function matchingSchemas(tView, tagName) {
10126
10124
  */
10127
10125
  function logUnknownPropertyError(propName, tNode) {
10128
10126
  let message = `Can't bind to '${propName}' since it isn't a known property of '${tNode.value}'.`;
10129
- console.error(formatRuntimeError("303" /* UNKNOWN_BINDING */, message));
10127
+ console.error(formatRuntimeError(303 /* UNKNOWN_BINDING */, message));
10130
10128
  }
10131
10129
  /**
10132
10130
  * Instantiate a root component.
@@ -10379,7 +10377,7 @@ function cacheMatchingLocalNames(tNode, localRefs, exportsMap) {
10379
10377
  for (let i = 0; i < localRefs.length; i += 2) {
10380
10378
  const index = exportsMap[localRefs[i + 1]];
10381
10379
  if (index == null)
10382
- throw new RuntimeError("301" /* EXPORT_NOT_FOUND */, `Export of name '${localRefs[i + 1]}' not found!`);
10380
+ throw new RuntimeError(-301 /* EXPORT_NOT_FOUND */, `Export of name '${localRefs[i + 1]}' not found!`);
10383
10381
  localNames.push(localRefs[i], index);
10384
10382
  }
10385
10383
  }
@@ -11305,7 +11303,10 @@ class R3Injector {
11305
11303
  }
11306
11304
  assertNotDestroyed() {
11307
11305
  if (this._destroyed) {
11308
- throw new Error('Injector has already been destroyed.');
11306
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
11307
+ 'Injector has already been destroyed.' :
11308
+ '';
11309
+ throw new RuntimeError(205 /* INJECTOR_ALREADY_DESTROYED */, errorMessage);
11309
11310
  }
11310
11311
  }
11311
11312
  /**
@@ -11469,21 +11470,28 @@ function injectableDefOrInjectorDefFactory(token) {
11469
11470
  // InjectionTokens should have an injectable def (ɵprov) and thus should be handled above.
11470
11471
  // If it's missing that, it's an error.
11471
11472
  if (token instanceof InjectionToken) {
11472
- throw new Error(`Token ${stringify(token)} is missing a ɵprov definition.`);
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);
11473
11477
  }
11474
11478
  // Undecorated types can sometimes be created if they have no constructor arguments.
11475
11479
  if (token instanceof Function) {
11476
11480
  return getUndecoratedInjectableFactory(token);
11477
11481
  }
11478
11482
  // There was no way to resolve a factory for this token.
11479
- throw new Error('unreachable');
11483
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ? 'unreachable' : '';
11484
+ throw new RuntimeError(204 /* INVALID_INJECTION_TOKEN */, errorMessage);
11480
11485
  }
11481
11486
  function getUndecoratedInjectableFactory(token) {
11482
11487
  // If the token has parameters then it has dependencies that we cannot resolve implicitly.
11483
11488
  const paramLength = token.length;
11484
11489
  if (paramLength > 0) {
11485
11490
  const args = newArray(paramLength, '?');
11486
- throw new Error(`Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).`);
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);
11487
11495
  }
11488
11496
  // The constructor function appears to have no parameters.
11489
11497
  // This might be because it inherits from a super-class. In which case, use an injectable
@@ -12342,7 +12350,10 @@ function ɵɵInheritDefinitionFeature(definition) {
12342
12350
  }
12343
12351
  else {
12344
12352
  if (superType.ɵcmp) {
12345
- throw new Error('Directives cannot inherit Components');
12353
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
12354
+ 'Directives cannot inherit Components' :
12355
+ '';
12356
+ throw new RuntimeError(903 /* INVALID_INHERITANCE */, errorMessage);
12346
12357
  }
12347
12358
  // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance.
12348
12359
  superDef = superType.ɵdir;
@@ -14604,7 +14615,7 @@ function logUnknownElementError(tView, element, tNode, hasDirectives) {
14604
14615
  message +=
14605
14616
  `2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.`;
14606
14617
  }
14607
- console.error(formatRuntimeError("304" /* UNKNOWN_ELEMENT */, message));
14618
+ console.error(formatRuntimeError(304 /* UNKNOWN_ELEMENT */, message));
14608
14619
  }
14609
14620
  }
14610
14621
  }
@@ -19123,7 +19134,9 @@ function applyMutableOpCodes(tView, mutableOpCodes, lView, anchorRNode) {
19123
19134
  setElementAttribute(renderer, getNativeByIndex(elementNodeIndex, lView), null, null, attrName, attrValue, null);
19124
19135
  break;
19125
19136
  default:
19126
- throw new Error(`Unable to determine the type of mutate operation for "${opCode}"`);
19137
+ if (ngDevMode) {
19138
+ throw new RuntimeError(700 /* INVALID_I18N_STRUCTURE */, `Unable to determine the type of mutate operation for "${opCode}"`);
19139
+ }
19127
19140
  }
19128
19141
  }
19129
19142
  else {
@@ -19749,7 +19762,7 @@ function i18nStartFirstCreatePass(tView, parentTNodeIndex, lView, index, message
19749
19762
  };
19750
19763
  }
19751
19764
  /**
19752
- * Allocate space in i18n Range add create OpCode instruction to crete a text or comment node.
19765
+ * Allocate space in i18n Range add create OpCode instruction to create a text or comment node.
19753
19766
  *
19754
19767
  * @param tView Current `TView` needed to allocate space in i18n range.
19755
19768
  * @param rootTNode Root `TNode` of the i18n block. This node determines if the new TNode will be
@@ -20850,6 +20863,9 @@ class ComponentRef$1 {
20850
20863
  * @see [Dynamic Components](guide/dynamic-component-loader)
20851
20864
  *
20852
20865
  * @publicApi
20866
+ *
20867
+ * @deprecated Angular no longer requires Component factories. Please use other APIs where
20868
+ * Component class can be used directly.
20853
20869
  */
20854
20870
  class ComponentFactory$1 {
20855
20871
  }
@@ -20886,6 +20902,9 @@ class _NullComponentFactoryResolver {
20886
20902
  * does **not** require resolving component factory: component class can be used directly.
20887
20903
  *
20888
20904
  * @publicApi
20905
+ *
20906
+ * @deprecated Angular no longer requires Component factories. Please use other APIs where
20907
+ * Component class can be used directly.
20889
20908
  */
20890
20909
  class ComponentFactoryResolver$1 {
20891
20910
  }
@@ -21050,7 +21069,7 @@ class Version {
21050
21069
  /**
21051
21070
  * @publicApi
21052
21071
  */
21053
- const VERSION = new Version('13.2.0-next.0');
21072
+ const VERSION = new Version('13.2.0-rc.1');
21054
21073
 
21055
21074
  /**
21056
21075
  * @license
@@ -21078,6 +21097,37 @@ const VERSION = new Version('13.2.0-next.0');
21078
21097
  // - mod2.injector.get(token, default)
21079
21098
  const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
21080
21099
 
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
+
21081
21131
  /**
21082
21132
  * @license
21083
21133
  * Copyright Google LLC All Rights Reserved.
@@ -21386,7 +21436,8 @@ class ViewRef$1 {
21386
21436
  }
21387
21437
  attachToViewContainerRef() {
21388
21438
  if (this._appRef) {
21389
- throw new Error('This view is already attached directly to the ApplicationRef!');
21439
+ const errorMessage = ngDevMode ? 'This view is already attached directly to the ApplicationRef!' : '';
21440
+ throw new RuntimeError(902 /* VIEW_ALREADY_ATTACHED */, errorMessage);
21390
21441
  }
21391
21442
  this._attachedToViewContainer = true;
21392
21443
  }
@@ -21396,7 +21447,8 @@ class ViewRef$1 {
21396
21447
  }
21397
21448
  attachToAppRef(appRef) {
21398
21449
  if (this._attachedToViewContainer) {
21399
- throw new Error('This view is already attached to a ViewContainer!');
21450
+ const errorMessage = ngDevMode ? 'This view is already attached to a ViewContainer!' : '';
21451
+ throw new RuntimeError(902 /* VIEW_ALREADY_ATTACHED */, errorMessage);
21400
21452
  }
21401
21453
  this._appRef = appRef;
21402
21454
  }
@@ -21461,23 +21513,6 @@ const SCHEDULER = new InjectionToken('SCHEDULER_TOKEN', {
21461
21513
  providedIn: 'root',
21462
21514
  factory: () => defaultScheduler,
21463
21515
  });
21464
- function createChainedInjector(rootViewInjector, moduleInjector) {
21465
- return {
21466
- get: (token, notFoundValue, flags) => {
21467
- const value = rootViewInjector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, flags);
21468
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
21469
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
21470
- // Return the value from the root element injector when
21471
- // - it provides it
21472
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21473
- // - the module injector should not be checked
21474
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
21475
- return value;
21476
- }
21477
- return moduleInjector.get(token, notFoundValue, flags);
21478
- }
21479
- };
21480
- }
21481
21516
  /**
21482
21517
  * Render3 implementation of {@link viewEngine_ComponentFactory}.
21483
21518
  */
@@ -21504,7 +21539,7 @@ class ComponentFactory extends ComponentFactory$1 {
21504
21539
  }
21505
21540
  create(injector, projectableNodes, rootSelectorOrNode, ngModule) {
21506
21541
  ngModule = ngModule || this.ngModule;
21507
- const rootViewInjector = ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
21542
+ const rootViewInjector = ngModule ? new ChainedInjector(injector, ngModule.injector) : injector;
21508
21543
  const rendererFactory = rootViewInjector.get(RendererFactory2, domRendererFactory3);
21509
21544
  const sanitizer = rootViewInjector.get(Sanitizer, null);
21510
21545
  const hostRenderer = rendererFactory.createRenderer(null, this.componentDef);
@@ -21788,7 +21823,7 @@ class NgModuleRef extends NgModuleRef$1 {
21788
21823
  }
21789
21824
  ], stringify(ngModuleType));
21790
21825
  // We need to resolve the injector types separately from the injector creation, because
21791
- // the module might be trying to use this ref in its contructor for DI which will cause a
21826
+ // the module might be trying to use this ref in its constructor for DI which will cause a
21792
21827
  // circular error that will eventually error out, because the injector isn't created yet.
21793
21828
  this._r3Injector._resolveInjectorDefTypes();
21794
21829
  this.instance = this.get(ngModuleType);
@@ -22267,7 +22302,7 @@ function getPipeDef(name, registry) {
22267
22302
  const declarationLView = lView[DECLARATION_COMPONENT_VIEW];
22268
22303
  const context = declarationLView[CONTEXT];
22269
22304
  const component = context ? ` in the '${context.constructor.name}' component` : '';
22270
- throw new RuntimeError("302" /* PIPE_NOT_FOUND */, `The pipe '${name}' could not be found${component}!`);
22305
+ throw new RuntimeError(-302 /* PIPE_NOT_FOUND */, `The pipe '${name}' could not be found${component}!`);
22271
22306
  }
22272
22307
  }
22273
22308
  /**
@@ -22640,9 +22675,9 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22640
22675
  this._declarationTContainer = _declarationTContainer;
22641
22676
  this.elementRef = elementRef;
22642
22677
  }
22643
- createEmbeddedView(context) {
22678
+ createEmbeddedView(context, injector) {
22644
22679
  const embeddedTView = this._declarationTContainer.tViews;
22645
- const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, null);
22680
+ const embeddedLView = createLView(this._declarationLView, embeddedTView, context, 16 /* CheckAlways */, null, embeddedTView.declTNode, null, null, null, createEmbeddedViewInjector(injector, this._declarationLView[INJECTOR$1]));
22646
22681
  const declarationLContainer = this._declarationLView[this._declarationTContainer.index];
22647
22682
  ngDevMode && assertLContainer(declarationLContainer);
22648
22683
  embeddedLView[DECLARATION_LCONTAINER] = declarationLContainer;
@@ -22654,6 +22689,14 @@ const R3TemplateRef = class TemplateRef extends ViewEngineTemplateRef {
22654
22689
  return new ViewRef$1(embeddedLView);
22655
22690
  }
22656
22691
  };
22692
+ function createEmbeddedViewInjector(embeddedViewInjector, declarationViewInjector) {
22693
+ if (!embeddedViewInjector) {
22694
+ return null;
22695
+ }
22696
+ return declarationViewInjector ?
22697
+ new ChainedInjector(embeddedViewInjector, declarationViewInjector) :
22698
+ embeddedViewInjector;
22699
+ }
22657
22700
  /**
22658
22701
  * Creates a TemplateRef given a node.
22659
22702
  *
@@ -22758,8 +22801,17 @@ const R3ViewContainerRef = class ViewContainerRef extends VE_ViewContainerRef {
22758
22801
  get length() {
22759
22802
  return this._lContainer.length - CONTAINER_HEADER_OFFSET;
22760
22803
  }
22761
- createEmbeddedView(templateRef, context, index) {
22762
- const viewRef = templateRef.createEmbeddedView(context || {});
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);
22763
22815
  this.insert(viewRef, index);
22764
22816
  return viewRef;
22765
22817
  }
@@ -24516,7 +24568,7 @@ const HostBinding = makePropDecorator('HostBinding', (hostPropertyName) => ({ ho
24516
24568
  * @HostListener('click', ['$event.target'])
24517
24569
  * onClick(btn) {
24518
24570
  * console.log('button', btn, 'number of clicks:', this.numberOfClicks++);
24519
- * }
24571
+ * }
24520
24572
  * }
24521
24573
  *
24522
24574
  * @Component({
@@ -25860,7 +25912,7 @@ function createPlatform(injector) {
25860
25912
  const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
25861
25913
  'There can be only one platform. Destroy the previous one to create a new one.' :
25862
25914
  '';
25863
- throw new RuntimeError("400" /* MULTIPLE_PLATFORMS */, errorMessage);
25915
+ throw new RuntimeError(400 /* MULTIPLE_PLATFORMS */, errorMessage);
25864
25916
  }
25865
25917
  publishDefaultGlobalUtils();
25866
25918
  _platform = injector.get(PlatformRef);
@@ -25909,11 +25961,11 @@ function assertPlatform(requiredToken) {
25909
25961
  const platform = getPlatform();
25910
25962
  if (!platform) {
25911
25963
  const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ? 'No platform exists!' : '';
25912
- throw new RuntimeError("401" /* PLATFORM_NOT_FOUND */, errorMessage);
25964
+ throw new RuntimeError(401 /* PLATFORM_NOT_FOUND */, errorMessage);
25913
25965
  }
25914
25966
  if ((typeof ngDevMode === 'undefined' || ngDevMode) &&
25915
25967
  !platform.injector.get(requiredToken, null)) {
25916
- throw new RuntimeError("400" /* MULTIPLE_PLATFORMS */, 'A platform with a different configuration has been created. Please destroy it first.');
25968
+ throw new RuntimeError(400 /* MULTIPLE_PLATFORMS */, 'A platform with a different configuration has been created. Please destroy it first.');
25917
25969
  }
25918
25970
  return platform;
25919
25971
  }
@@ -26000,7 +26052,7 @@ class PlatformRef {
26000
26052
  const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
26001
26053
  'No ErrorHandler. Is platform module (BrowserModule) included?' :
26002
26054
  '';
26003
- throw new RuntimeError("402" /* ERROR_HANDLER_NOT_FOUND */, errorMessage);
26055
+ throw new RuntimeError(402 /* ERROR_HANDLER_NOT_FOUND */, errorMessage);
26004
26056
  }
26005
26057
  ngZone.runOutsideAngular(() => {
26006
26058
  const subscription = ngZone.onError.subscribe({
@@ -26061,7 +26113,7 @@ class PlatformRef {
26061
26113
  `but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. ` +
26062
26114
  `Please define one of these.` :
26063
26115
  '';
26064
- throw new RuntimeError("403" /* BOOTSTRAP_COMPONENTS_NOT_FOUND */, errorMessage);
26116
+ throw new RuntimeError(403 /* BOOTSTRAP_COMPONENTS_NOT_FOUND */, errorMessage);
26065
26117
  }
26066
26118
  this._modules.push(moduleRef);
26067
26119
  }
@@ -26087,7 +26139,7 @@ class PlatformRef {
26087
26139
  const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
26088
26140
  'The platform has already been destroyed!' :
26089
26141
  '';
26090
- throw new RuntimeError("404" /* ALREADY_DESTROYED_PLATFORM */, errorMessage);
26142
+ throw new RuntimeError(404 /* ALREADY_DESTROYED_PLATFORM */, errorMessage);
26091
26143
  }
26092
26144
  this._modules.slice().forEach(module => module.destroy());
26093
26145
  this._destroyListeners.forEach(listener => listener());
@@ -26353,7 +26405,7 @@ class ApplicationRef {
26353
26405
  'Cannot bootstrap as there are still asynchronous initializers running. ' +
26354
26406
  'Bootstrap components in the `ngDoBootstrap` method of the root module.' :
26355
26407
  '';
26356
- throw new RuntimeError("405" /* ASYNC_INITIALIZERS_STILL_RUNNING */, errorMessage);
26408
+ throw new RuntimeError(405 /* ASYNC_INITIALIZERS_STILL_RUNNING */, errorMessage);
26357
26409
  }
26358
26410
  let componentFactory;
26359
26411
  if (componentOrFactory instanceof ComponentFactory$1) {
@@ -26403,7 +26455,7 @@ class ApplicationRef {
26403
26455
  const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
26404
26456
  'ApplicationRef.tick is called recursively' :
26405
26457
  '';
26406
- throw new RuntimeError("101" /* RECURSIVE_APPLICATION_REF_TICK */, errorMessage);
26458
+ throw new RuntimeError(101 /* RECURSIVE_APPLICATION_REF_TICK */, errorMessage);
26407
26459
  }
26408
26460
  try {
26409
26461
  this._runningTick = true;
@@ -27394,7 +27446,10 @@ class DefaultIterableDiffer {
27394
27446
  if (collection == null)
27395
27447
  collection = [];
27396
27448
  if (!isListLikeIterable(collection)) {
27397
- throw new Error(`Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed`);
27449
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
27450
+ `Error trying to diff '${stringify(collection)}'. Only arrays and iterables are allowed` :
27451
+ '';
27452
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
27398
27453
  }
27399
27454
  if (this.check(collection)) {
27400
27455
  return this;
@@ -27995,7 +28050,10 @@ class DefaultKeyValueDiffer {
27995
28050
  map = new Map();
27996
28051
  }
27997
28052
  else if (!(map instanceof Map || isJsObject(map))) {
27998
- throw new Error(`Error trying to diff '${stringify(map)}'. Only maps and objects are allowed`);
28053
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28054
+ `Error trying to diff '${stringify(map)}'. Only maps and objects are allowed` :
28055
+ '';
28056
+ throw new RuntimeError(900 /* INVALID_DIFFER_INPUT */, errorMessage);
27999
28057
  }
28000
28058
  return this.check(map) ? this : null;
28001
28059
  }
@@ -28242,7 +28300,10 @@ class IterableDiffers {
28242
28300
  return factory;
28243
28301
  }
28244
28302
  else {
28245
- throw new Error(`Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'`);
28303
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28304
+ `Cannot find a differ supporting object '${iterable}' of type '${getTypeNameForDebugging(iterable)}'` :
28305
+ '';
28306
+ throw new RuntimeError(901 /* NO_SUPPORTING_DIFFER_FACTORY */, errorMessage);
28246
28307
  }
28247
28308
  }
28248
28309
  }
@@ -28316,7 +28377,10 @@ class KeyValueDiffers {
28316
28377
  if (factory) {
28317
28378
  return factory;
28318
28379
  }
28319
- throw new Error(`Cannot find a differ supporting object '${kv}'`);
28380
+ const errorMessage = (typeof ngDevMode === 'undefined' || ngDevMode) ?
28381
+ `Cannot find a differ supporting object '${kv}'` :
28382
+ '';
28383
+ throw new RuntimeError(901 /* NO_SUPPORTING_DIFFER_FACTORY */, errorMessage);
28320
28384
  }
28321
28385
  }
28322
28386
  /** @nocollapse */