@angular/core 10.2.0 → 10.2.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v10.2.0
2
+ * @license Angular v10.2.1
3
3
  * (c) 2010-2020 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -2381,6 +2381,182 @@
2381
2381
  assertNumber(lView[injectorIndex + 8 /* PARENT */], 'injectorIndex should point to parent injector');
2382
2382
  }
2383
2383
 
2384
+ /**
2385
+ * @license
2386
+ * Copyright Google LLC All Rights Reserved.
2387
+ *
2388
+ * Use of this source code is governed by an MIT-style license that can be
2389
+ * found in the LICENSE file at https://angular.io/license
2390
+ */
2391
+ /**
2392
+ * Used for stringify render output in Ivy.
2393
+ * Important! This function is very performance-sensitive and we should
2394
+ * be extra careful not to introduce megamorphic reads in it.
2395
+ */
2396
+ function renderStringify(value) {
2397
+ if (typeof value === 'string')
2398
+ return value;
2399
+ if (value == null)
2400
+ return '';
2401
+ return '' + value;
2402
+ }
2403
+ /**
2404
+ * Used to stringify a value so that it can be displayed in an error message.
2405
+ * Important! This function contains a megamorphic read and should only be
2406
+ * used for error messages.
2407
+ */
2408
+ function stringifyForError(value) {
2409
+ if (typeof value === 'function')
2410
+ return value.name || value.toString();
2411
+ if (typeof value === 'object' && value != null && typeof value.type === 'function') {
2412
+ return value.type.name || value.type.toString();
2413
+ }
2414
+ return renderStringify(value);
2415
+ }
2416
+ var ɵ0$2 = function () { return (typeof requestAnimationFrame !== 'undefined' &&
2417
+ requestAnimationFrame || // browser only
2418
+ setTimeout // everything else
2419
+ )
2420
+ .bind(_global); };
2421
+ var defaultScheduler = (ɵ0$2)();
2422
+ /**
2423
+ *
2424
+ * @codeGenApi
2425
+ */
2426
+ function ɵɵresolveWindow(element) {
2427
+ return { name: 'window', target: element.ownerDocument.defaultView };
2428
+ }
2429
+ /**
2430
+ *
2431
+ * @codeGenApi
2432
+ */
2433
+ function ɵɵresolveDocument(element) {
2434
+ return { name: 'document', target: element.ownerDocument };
2435
+ }
2436
+ /**
2437
+ *
2438
+ * @codeGenApi
2439
+ */
2440
+ function ɵɵresolveBody(element) {
2441
+ return { name: 'body', target: element.ownerDocument.body };
2442
+ }
2443
+ /**
2444
+ * The special delimiter we use to separate property names, prefixes, and suffixes
2445
+ * in property binding metadata. See storeBindingMetadata().
2446
+ *
2447
+ * We intentionally use the Unicode "REPLACEMENT CHARACTER" (U+FFFD) as a delimiter
2448
+ * because it is a very uncommon character that is unlikely to be part of a user's
2449
+ * property names or interpolation strings. If it is in fact used in a property
2450
+ * binding, DebugElement.properties will not return the correct value for that
2451
+ * binding. However, there should be no runtime effect for real applications.
2452
+ *
2453
+ * This character is typically rendered as a question mark inside of a diamond.
2454
+ * See https://en.wikipedia.org/wiki/Specials_(Unicode_block)
2455
+ *
2456
+ */
2457
+ var INTERPOLATION_DELIMITER = "\uFFFD";
2458
+ /**
2459
+ * Unwrap a value which might be behind a closure (for forward declaration reasons).
2460
+ */
2461
+ function maybeUnwrapFn(value) {
2462
+ if (value instanceof Function) {
2463
+ return value();
2464
+ }
2465
+ else {
2466
+ return value;
2467
+ }
2468
+ }
2469
+
2470
+ /** Called when directives inject each other (creating a circular dependency) */
2471
+ function throwCyclicDependencyError(token, path) {
2472
+ var depPath = path ? ". Dependency path: " + path.join(' > ') + " > " + token : '';
2473
+ throw new Error("Circular dependency in DI detected for " + token + depPath);
2474
+ }
2475
+ /** Called when there are multiple component selectors that match a given node */
2476
+ function throwMultipleComponentError(tNode) {
2477
+ throw new Error("Multiple components match node with tagname " + tNode.tagName);
2478
+ }
2479
+ function throwMixedMultiProviderError() {
2480
+ throw new Error("Cannot mix multi providers and regular providers");
2481
+ }
2482
+ function throwInvalidProviderError(ngModuleType, providers, provider) {
2483
+ var ngModuleDetail = '';
2484
+ if (ngModuleType && providers) {
2485
+ var providerDetail = providers.map(function (v) { return v == provider ? '?' + provider + '?' : '...'; });
2486
+ ngModuleDetail =
2487
+ " - only instances of Provider and Type are allowed, got: [" + providerDetail.join(', ') + "]";
2488
+ }
2489
+ throw new Error("Invalid provider for the NgModule '" + stringify(ngModuleType) + "'" + ngModuleDetail);
2490
+ }
2491
+ /** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */
2492
+ function throwErrorIfNoChangesMode(creationMode, oldValue, currValue, propName) {
2493
+ var field = propName ? " for '" + propName + "'" : '';
2494
+ var msg = "ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value" + field + ": '" + oldValue + "'. Current value: '" + currValue + "'.";
2495
+ if (creationMode) {
2496
+ msg +=
2497
+ " It seems like the view has been created after its parent and its children have been dirty checked." +
2498
+ " Has it been created in a change detection hook?";
2499
+ }
2500
+ // TODO: include debug context, see `viewDebugError` function in
2501
+ // `packages/core/src/view/errors.ts` for reference.
2502
+ throw new Error(msg);
2503
+ }
2504
+ function constructDetailsForInterpolation(lView, rootIndex, expressionIndex, meta, changedValue) {
2505
+ var _a = __read(meta.split(INTERPOLATION_DELIMITER)), propName = _a[0], prefix = _a[1], chunks = _a.slice(2);
2506
+ var oldValue = prefix, newValue = prefix;
2507
+ for (var i = 0; i < chunks.length; i++) {
2508
+ var slotIdx = rootIndex + i;
2509
+ oldValue += "" + lView[slotIdx] + chunks[i];
2510
+ newValue += "" + (slotIdx === expressionIndex ? changedValue : lView[slotIdx]) + chunks[i];
2511
+ }
2512
+ return { propName: propName, oldValue: oldValue, newValue: newValue };
2513
+ }
2514
+ /**
2515
+ * Constructs an object that contains details for the ExpressionChangedAfterItHasBeenCheckedError:
2516
+ * - property name (for property bindings or interpolations)
2517
+ * - old and new values, enriched using information from metadata
2518
+ *
2519
+ * More information on the metadata storage format can be found in `storePropertyBindingMetadata`
2520
+ * function description.
2521
+ */
2522
+ function getExpressionChangedErrorDetails(lView, bindingIndex, oldValue, newValue) {
2523
+ var tData = lView[TVIEW].data;
2524
+ var metadata = tData[bindingIndex];
2525
+ if (typeof metadata === 'string') {
2526
+ // metadata for property interpolation
2527
+ if (metadata.indexOf(INTERPOLATION_DELIMITER) > -1) {
2528
+ return constructDetailsForInterpolation(lView, bindingIndex, bindingIndex, metadata, newValue);
2529
+ }
2530
+ // metadata for property binding
2531
+ return { propName: metadata, oldValue: oldValue, newValue: newValue };
2532
+ }
2533
+ // metadata is not available for this expression, check if this expression is a part of the
2534
+ // property interpolation by going from the current binding index left and look for a string that
2535
+ // contains INTERPOLATION_DELIMITER, the layout in tView.data for this case will look like this:
2536
+ // [..., 'id�Prefix � and � suffix', null, null, null, ...]
2537
+ if (metadata === null) {
2538
+ var idx = bindingIndex - 1;
2539
+ while (typeof tData[idx] !== 'string' && tData[idx + 1] === null) {
2540
+ idx--;
2541
+ }
2542
+ var meta = tData[idx];
2543
+ if (typeof meta === 'string') {
2544
+ var matches = meta.match(new RegExp(INTERPOLATION_DELIMITER, 'g'));
2545
+ // first interpolation delimiter separates property name from interpolation parts (in case of
2546
+ // property interpolations), so we subtract one from total number of found delimiters
2547
+ if (matches && (matches.length - 1) > bindingIndex - idx) {
2548
+ return constructDetailsForInterpolation(lView, idx, bindingIndex, meta, newValue);
2549
+ }
2550
+ }
2551
+ }
2552
+ return { propName: undefined, oldValue: oldValue, newValue: newValue };
2553
+ }
2554
+ /** Throws an error when a token is not found in DI. */
2555
+ function throwProviderNotFoundError(token, injectorName) {
2556
+ var injectorDetails = injectorName ? " in " + injectorName : '';
2557
+ throw new Error("No provider for " + stringifyForError(token) + " found" + injectorDetails);
2558
+ }
2559
+
2384
2560
  /**
2385
2561
  * @license
2386
2562
  * Copyright Google LLC All Rights Reserved.
@@ -2596,11 +2772,11 @@
2596
2772
  function isProceduralRenderer(renderer) {
2597
2773
  return !!(renderer.listen);
2598
2774
  }
2599
- var ɵ0$2 = function (hostElement, rendererType) {
2775
+ var ɵ0$3 = function (hostElement, rendererType) {
2600
2776
  return getDocument();
2601
2777
  };
2602
2778
  var domRendererFactory3 = {
2603
- createRenderer: ɵ0$2
2779
+ createRenderer: ɵ0$3
2604
2780
  };
2605
2781
  // Note: This hack is necessary so we don't erroneously get a circular dependency
2606
2782
  // failure based on types.
@@ -3869,92 +4045,6 @@
3869
4045
  return parentView;
3870
4046
  }
3871
4047
 
3872
- /**
3873
- * @license
3874
- * Copyright Google LLC All Rights Reserved.
3875
- *
3876
- * Use of this source code is governed by an MIT-style license that can be
3877
- * found in the LICENSE file at https://angular.io/license
3878
- */
3879
- /**
3880
- * Used for stringify render output in Ivy.
3881
- * Important! This function is very performance-sensitive and we should
3882
- * be extra careful not to introduce megamorphic reads in it.
3883
- */
3884
- function renderStringify(value) {
3885
- if (typeof value === 'string')
3886
- return value;
3887
- if (value == null)
3888
- return '';
3889
- return '' + value;
3890
- }
3891
- /**
3892
- * Used to stringify a value so that it can be displayed in an error message.
3893
- * Important! This function contains a megamorphic read and should only be
3894
- * used for error messages.
3895
- */
3896
- function stringifyForError(value) {
3897
- if (typeof value === 'function')
3898
- return value.name || value.toString();
3899
- if (typeof value === 'object' && value != null && typeof value.type === 'function') {
3900
- return value.type.name || value.type.toString();
3901
- }
3902
- return renderStringify(value);
3903
- }
3904
- var ɵ0$3 = function () { return (typeof requestAnimationFrame !== 'undefined' &&
3905
- requestAnimationFrame || // browser only
3906
- setTimeout // everything else
3907
- )
3908
- .bind(_global); };
3909
- var defaultScheduler = (ɵ0$3)();
3910
- /**
3911
- *
3912
- * @codeGenApi
3913
- */
3914
- function ɵɵresolveWindow(element) {
3915
- return { name: 'window', target: element.ownerDocument.defaultView };
3916
- }
3917
- /**
3918
- *
3919
- * @codeGenApi
3920
- */
3921
- function ɵɵresolveDocument(element) {
3922
- return { name: 'document', target: element.ownerDocument };
3923
- }
3924
- /**
3925
- *
3926
- * @codeGenApi
3927
- */
3928
- function ɵɵresolveBody(element) {
3929
- return { name: 'body', target: element.ownerDocument.body };
3930
- }
3931
- /**
3932
- * The special delimiter we use to separate property names, prefixes, and suffixes
3933
- * in property binding metadata. See storeBindingMetadata().
3934
- *
3935
- * We intentionally use the Unicode "REPLACEMENT CHARACTER" (U+FFFD) as a delimiter
3936
- * because it is a very uncommon character that is unlikely to be part of a user's
3937
- * property names or interpolation strings. If it is in fact used in a property
3938
- * binding, DebugElement.properties will not return the correct value for that
3939
- * binding. However, there should be no runtime effect for real applications.
3940
- *
3941
- * This character is typically rendered as a question mark inside of a diamond.
3942
- * See https://en.wikipedia.org/wiki/Specials_(Unicode_block)
3943
- *
3944
- */
3945
- var INTERPOLATION_DELIMITER = "\uFFFD";
3946
- /**
3947
- * Unwrap a value which might be behind a closure (for forward declaration reasons).
3948
- */
3949
- function maybeUnwrapFn(value) {
3950
- if (value instanceof Function) {
3951
- return value();
3952
- }
3953
- else {
3954
- return value;
3955
- }
3956
- }
3957
-
3958
4048
  /**
3959
4049
  * @license
3960
4050
  * Copyright Google LLC All Rights Reserved.
@@ -4280,7 +4370,7 @@
4280
4370
  try {
4281
4371
  var value = bloomHash();
4282
4372
  if (value == null && !(flags & exports.InjectFlags.Optional)) {
4283
- throw new Error("No provider for " + stringifyForError(token) + "!");
4373
+ throwProviderNotFoundError(token);
4284
4374
  }
4285
4375
  else {
4286
4376
  return value;
@@ -4379,7 +4469,7 @@
4379
4469
  return notFoundValue;
4380
4470
  }
4381
4471
  else {
4382
- throw new Error("NodeInjector: NOT_FOUND [" + stringifyForError(token) + "]");
4472
+ throwProviderNotFoundError(token, 'NodeInjector');
4383
4473
  }
4384
4474
  }
4385
4475
  var NOT_FOUND = {};
@@ -4463,7 +4553,7 @@
4463
4553
  if (isFactory(value)) {
4464
4554
  var factory = value;
4465
4555
  if (factory.resolving) {
4466
- throw new Error("Circular dep for " + stringifyForError(tData[index]));
4556
+ throwCyclicDependencyError(stringifyForError(tData[index]));
4467
4557
  }
4468
4558
  var previousIncludeViewProviders = setIncludeViewProviders(factory.canSeeViewProviders);
4469
4559
  factory.resolving = true;
@@ -5926,90 +6016,6 @@
5926
6016
  return null;
5927
6017
  }
5928
6018
 
5929
- /** Called when directives inject each other (creating a circular dependency) */
5930
- function throwCyclicDependencyError(token) {
5931
- throw new Error("Cannot instantiate cyclic dependency! " + token);
5932
- }
5933
- /** Called when there are multiple component selectors that match a given node */
5934
- function throwMultipleComponentError(tNode) {
5935
- throw new Error("Multiple components match node with tagname " + tNode.tagName);
5936
- }
5937
- function throwMixedMultiProviderError() {
5938
- throw new Error("Cannot mix multi providers and regular providers");
5939
- }
5940
- function throwInvalidProviderError(ngModuleType, providers, provider) {
5941
- var ngModuleDetail = '';
5942
- if (ngModuleType && providers) {
5943
- var providerDetail = providers.map(function (v) { return v == provider ? '?' + provider + '?' : '...'; });
5944
- ngModuleDetail =
5945
- " - only instances of Provider and Type are allowed, got: [" + providerDetail.join(', ') + "]";
5946
- }
5947
- throw new Error("Invalid provider for the NgModule '" + stringify(ngModuleType) + "'" + ngModuleDetail);
5948
- }
5949
- /** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */
5950
- function throwErrorIfNoChangesMode(creationMode, oldValue, currValue, propName) {
5951
- var field = propName ? " for '" + propName + "'" : '';
5952
- var msg = "ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value" + field + ": '" + oldValue + "'. Current value: '" + currValue + "'.";
5953
- if (creationMode) {
5954
- msg +=
5955
- " It seems like the view has been created after its parent and its children have been dirty checked." +
5956
- " Has it been created in a change detection hook?";
5957
- }
5958
- // TODO: include debug context, see `viewDebugError` function in
5959
- // `packages/core/src/view/errors.ts` for reference.
5960
- throw new Error(msg);
5961
- }
5962
- function constructDetailsForInterpolation(lView, rootIndex, expressionIndex, meta, changedValue) {
5963
- var _a = __read(meta.split(INTERPOLATION_DELIMITER)), propName = _a[0], prefix = _a[1], chunks = _a.slice(2);
5964
- var oldValue = prefix, newValue = prefix;
5965
- for (var i = 0; i < chunks.length; i++) {
5966
- var slotIdx = rootIndex + i;
5967
- oldValue += "" + lView[slotIdx] + chunks[i];
5968
- newValue += "" + (slotIdx === expressionIndex ? changedValue : lView[slotIdx]) + chunks[i];
5969
- }
5970
- return { propName: propName, oldValue: oldValue, newValue: newValue };
5971
- }
5972
- /**
5973
- * Constructs an object that contains details for the ExpressionChangedAfterItHasBeenCheckedError:
5974
- * - property name (for property bindings or interpolations)
5975
- * - old and new values, enriched using information from metadata
5976
- *
5977
- * More information on the metadata storage format can be found in `storePropertyBindingMetadata`
5978
- * function description.
5979
- */
5980
- function getExpressionChangedErrorDetails(lView, bindingIndex, oldValue, newValue) {
5981
- var tData = lView[TVIEW].data;
5982
- var metadata = tData[bindingIndex];
5983
- if (typeof metadata === 'string') {
5984
- // metadata for property interpolation
5985
- if (metadata.indexOf(INTERPOLATION_DELIMITER) > -1) {
5986
- return constructDetailsForInterpolation(lView, bindingIndex, bindingIndex, metadata, newValue);
5987
- }
5988
- // metadata for property binding
5989
- return { propName: metadata, oldValue: oldValue, newValue: newValue };
5990
- }
5991
- // metadata is not available for this expression, check if this expression is a part of the
5992
- // property interpolation by going from the current binding index left and look for a string that
5993
- // contains INTERPOLATION_DELIMITER, the layout in tView.data for this case will look like this:
5994
- // [..., 'id�Prefix � and � suffix', null, null, null, ...]
5995
- if (metadata === null) {
5996
- var idx = bindingIndex - 1;
5997
- while (typeof tData[idx] !== 'string' && tData[idx + 1] === null) {
5998
- idx--;
5999
- }
6000
- var meta = tData[idx];
6001
- if (typeof meta === 'string') {
6002
- var matches = meta.match(new RegExp(INTERPOLATION_DELIMITER, 'g'));
6003
- // first interpolation delimiter separates property name from interpolation parts (in case of
6004
- // property interpolations), so we subtract one from total number of found delimiters
6005
- if (matches && (matches.length - 1) > bindingIndex - idx) {
6006
- return constructDetailsForInterpolation(lView, idx, bindingIndex, meta, newValue);
6007
- }
6008
- }
6009
- }
6010
- return { propName: undefined, oldValue: oldValue, newValue: newValue };
6011
- }
6012
-
6013
6019
  /**
6014
6020
  * @license
6015
6021
  * Copyright Google LLC All Rights Reserved.
@@ -8263,7 +8269,7 @@
8263
8269
  return propStore;
8264
8270
  }
8265
8271
  /**
8266
- * Initializes data structures required to work with directive outputs and outputs.
8272
+ * Initializes data structures required to work with directive inputs and outputs.
8267
8273
  * Initialization is done for all directives matched on a given TNode.
8268
8274
  */
8269
8275
  function initializeInputAndOutputAliases(tView, tNode) {
@@ -11739,7 +11745,8 @@
11739
11745
  // Check for circular dependencies.
11740
11746
  if (ngDevMode && parents.indexOf(defType) !== -1) {
11741
11747
  var defName = stringify(defType);
11742
- throw new Error("Circular dependency in DI detected for type " + defName + ". Dependency path: " + parents.map(function (defType) { return stringify(defType); }).join(' > ') + " > " + defName + ".");
11748
+ var path = parents.map(stringify);
11749
+ throwCyclicDependencyError(defName, path);
11743
11750
  }
11744
11751
  // Check for multiple imports of the same module
11745
11752
  var isDuplicate = dedupStack.indexOf(defType) !== -1;
@@ -13954,7 +13961,7 @@
13954
13961
  * found in the LICENSE file at https://angular.io/license
13955
13962
  */
13956
13963
  var ɵ0$b = function (token, notFoundValue) {
13957
- throw new Error('NullInjector: Not found: ' + stringifyForError(token));
13964
+ throwProviderNotFoundError(token, 'NullInjector');
13958
13965
  };
13959
13966
  // TODO: A hack to not pull in the NullInjector from @angular/core.
13960
13967
  var NULL_INJECTOR$1 = {
@@ -21677,7 +21684,7 @@
21677
21684
  /**
21678
21685
  * @publicApi
21679
21686
  */
21680
- var VERSION = new Version('10.2.0');
21687
+ var VERSION = new Version('10.2.1');
21681
21688
 
21682
21689
  /**
21683
21690
  * @license
@@ -26301,7 +26308,7 @@
26301
26308
  if (flags === void 0) { flags = exports.InjectFlags.Default; }
26302
26309
  var value = injectChangeDetectorRef(true);
26303
26310
  if (value == null && !(flags & exports.InjectFlags.Optional)) {
26304
- throw new Error("No provider for ChangeDetectorRef!");
26311
+ throwProviderNotFoundError('ChangeDetectorRef');
26305
26312
  }
26306
26313
  else {
26307
26314
  return value;
@@ -32647,7 +32654,7 @@
32647
32654
  * Use of this source code is governed by an MIT-style license that can be
32648
32655
  * found in the LICENSE file at https://angular.io/license
32649
32656
  */
32650
- if (ngDevMode) {
32657
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
32651
32658
  // This helper is to give a reasonable error message to people upgrading to v9 that have not yet
32652
32659
  // installed `@angular/localize` in their app.
32653
32660
  // tslint:disable-next-line: no-toplevel-property-access