@angular/core 11.2.5 → 11.2.9

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.
package/fesm2015/core.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v11.2.5
2
+ * @license Angular v11.2.9
3
3
  * (c) 2010-2021 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -811,6 +811,28 @@ if ((typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode()) {
811
811
  Object.freeze(EMPTY_ARRAY);
812
812
  }
813
813
 
814
+ /**
815
+ * @license
816
+ * Copyright Google LLC All Rights Reserved.
817
+ *
818
+ * Use of this source code is governed by an MIT-style license that can be
819
+ * found in the LICENSE file at https://angular.io/license
820
+ */
821
+ /**
822
+ * This file contains reuseable "empty" symbols that can be used as default return values
823
+ * in different parts of the rendering code. Because the same symbols are returned, this
824
+ * allows for identity checks against these values to be consistently used by the framework
825
+ * code.
826
+ */
827
+ const EMPTY_ARRAY$1 = [];
828
+ // freezing the values prevents any code from accidentally inserting new values in
829
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode()) {
830
+ // These property accesses can be ignored because ngDevMode will be set to false
831
+ // when optimizing code and the whole if statement will be dropped.
832
+ // tslint:disable-next-line:no-toplevel-property-access
833
+ Object.freeze(EMPTY_ARRAY$1);
834
+ }
835
+
814
836
  /**
815
837
  * @license
816
838
  * Copyright Google LLC All Rights Reserved.
@@ -883,7 +905,7 @@ function ɵɵdefineComponent(componentDefinition) {
883
905
  onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush,
884
906
  directiveDefs: null,
885
907
  pipeDefs: null,
886
- selectors: componentDefinition.selectors || EMPTY_ARRAY,
908
+ selectors: componentDefinition.selectors || EMPTY_ARRAY$1,
887
909
  viewQuery: componentDefinition.viewQuery || null,
888
910
  features: componentDefinition.features || null,
889
911
  data: componentDefinition.data || {},
@@ -891,7 +913,7 @@ function ɵɵdefineComponent(componentDefinition) {
891
913
  // directly in the next line. Also `None` should be 0 not 2.
892
914
  encapsulation: componentDefinition.encapsulation || ViewEncapsulation.Emulated,
893
915
  id: 'c',
894
- styles: componentDefinition.styles || EMPTY_ARRAY,
916
+ styles: componentDefinition.styles || EMPTY_ARRAY$1,
895
917
  _: null,
896
918
  setInput: null,
897
919
  schemas: componentDefinition.schemas || null,
@@ -949,10 +971,10 @@ const autoRegisterModuleById = {};
949
971
  function ɵɵdefineNgModule(def) {
950
972
  const res = {
951
973
  type: def.type,
952
- bootstrap: def.bootstrap || EMPTY_ARRAY,
953
- declarations: def.declarations || EMPTY_ARRAY,
954
- imports: def.imports || EMPTY_ARRAY,
955
- exports: def.exports || EMPTY_ARRAY,
974
+ bootstrap: def.bootstrap || EMPTY_ARRAY$1,
975
+ declarations: def.declarations || EMPTY_ARRAY$1,
976
+ imports: def.imports || EMPTY_ARRAY$1,
977
+ exports: def.exports || EMPTY_ARRAY$1,
956
978
  transitiveCompileScopes: null,
957
979
  schemas: def.schemas || null,
958
980
  id: def.id || null,
@@ -977,9 +999,9 @@ function ɵɵdefineNgModule(def) {
977
999
  function ɵɵsetNgModuleScope(type, scope) {
978
1000
  return noSideEffects(() => {
979
1001
  const ngModuleDef = getNgModuleDef(type, true);
980
- ngModuleDef.declarations = scope.declarations || EMPTY_ARRAY;
981
- ngModuleDef.imports = scope.imports || EMPTY_ARRAY;
982
- ngModuleDef.exports = scope.exports || EMPTY_ARRAY;
1002
+ ngModuleDef.declarations = scope.declarations || EMPTY_ARRAY$1;
1003
+ ngModuleDef.imports = scope.imports || EMPTY_ARRAY$1;
1004
+ ngModuleDef.exports = scope.exports || EMPTY_ARRAY$1;
983
1005
  });
984
1006
  }
985
1007
  /**
@@ -1516,6 +1538,42 @@ function setSimpleChangesStore(instance, store) {
1516
1538
  return instance[SIMPLE_CHANGES_STORE] = store;
1517
1539
  }
1518
1540
 
1541
+ /**
1542
+ * @license
1543
+ * Copyright Google LLC All Rights Reserved.
1544
+ *
1545
+ * Use of this source code is governed by an MIT-style license that can be
1546
+ * found in the LICENSE file at https://angular.io/license
1547
+ */
1548
+ let profilerCallback = null;
1549
+ /**
1550
+ * Sets the callback function which will be invoked before and after performing certain actions at
1551
+ * runtime (for example, before and after running change detection).
1552
+ *
1553
+ * Warning: this function is *INTERNAL* and should not be relied upon in application's code.
1554
+ * The contract of the function might be changed in any release and/or the function can be removed
1555
+ * completely.
1556
+ *
1557
+ * @param profiler function provided by the caller or null value to disable profiling.
1558
+ */
1559
+ const setProfiler = (profiler) => {
1560
+ profilerCallback = profiler;
1561
+ };
1562
+ /**
1563
+ * Profiler function which wraps user code executed by the runtime.
1564
+ *
1565
+ * @param event ProfilerEvent corresponding to the execution context
1566
+ * @param instance component instance
1567
+ * @param hookOrListener lifecycle hook function or output listener. The value depends on the
1568
+ * execution context
1569
+ * @returns
1570
+ */
1571
+ const profiler = function (event, instance, hookOrListener) {
1572
+ if (profilerCallback != null /* both `null` and `undefined` */) {
1573
+ profilerCallback(event, instance, hookOrListener);
1574
+ }
1575
+ };
1576
+
1519
1577
  /**
1520
1578
  * @license
1521
1579
  * Copyright Google LLC All Rights Reserved.
@@ -2510,11 +2568,23 @@ function callHook(currentView, initPhase, arr, i) {
2510
2568
  (currentView[PREORDER_HOOK_FLAGS] >> 16 /* NumberOfInitHooksCalledShift */) &&
2511
2569
  (currentView[FLAGS] & 3 /* InitPhaseStateMask */) === initPhase) {
2512
2570
  currentView[FLAGS] += 2048 /* IndexWithinInitPhaseIncrementer */;
2513
- hook.call(directive);
2571
+ profiler(4 /* LifecycleHookStart */, directive, hook);
2572
+ try {
2573
+ hook.call(directive);
2574
+ }
2575
+ finally {
2576
+ profiler(5 /* LifecycleHookEnd */, directive, hook);
2577
+ }
2514
2578
  }
2515
2579
  }
2516
2580
  else {
2517
- hook.call(directive);
2581
+ profiler(4 /* LifecycleHookStart */, directive, hook);
2582
+ try {
2583
+ hook.call(directive);
2584
+ }
2585
+ finally {
2586
+ profiler(5 /* LifecycleHookEnd */, directive, hook);
2587
+ }
2518
2588
  }
2519
2589
  }
2520
2590
 
@@ -6607,7 +6677,7 @@ function getDirectivesAtNodeIndex(nodeIndex, lView, includeComponents) {
6607
6677
  const tNode = lView[TVIEW].data[nodeIndex];
6608
6678
  let directiveStartIndex = tNode.directiveStart;
6609
6679
  if (directiveStartIndex == 0)
6610
- return EMPTY_ARRAY;
6680
+ return EMPTY_ARRAY$1;
6611
6681
  const directiveEndIndex = tNode.directiveEnd;
6612
6682
  if (!includeComponents && tNode.flags & 2 /* isComponentHost */)
6613
6683
  directiveStartIndex++;
@@ -9517,17 +9587,22 @@ function renderComponentOrTemplate(tView, lView, templateFn, context) {
9517
9587
  }
9518
9588
  function executeTemplate(tView, lView, templateFn, rf, context) {
9519
9589
  const prevSelectedIndex = getSelectedIndex();
9590
+ const isUpdatePhase = rf & 2 /* Update */;
9520
9591
  try {
9521
9592
  setSelectedIndex(-1);
9522
- if (rf & 2 /* Update */ && lView.length > HEADER_OFFSET) {
9593
+ if (isUpdatePhase && lView.length > HEADER_OFFSET) {
9523
9594
  // When we're updating, inherently select 0 so we don't
9524
9595
  // have to generate that instruction for most update blocks.
9525
9596
  selectIndexInternal(tView, lView, HEADER_OFFSET, isInCheckNoChangesMode());
9526
9597
  }
9598
+ const preHookType = isUpdatePhase ? 2 /* TemplateUpdateStart */ : 0 /* TemplateCreateStart */;
9599
+ profiler(preHookType, context);
9527
9600
  templateFn(rf, context);
9528
9601
  }
9529
9602
  finally {
9530
9603
  setSelectedIndex(prevSelectedIndex);
9604
+ const postHookType = isUpdatePhase ? 3 /* TemplateUpdateEnd */ : 1 /* TemplateCreateEnd */;
9605
+ profiler(postHookType, context);
9531
9606
  }
9532
9607
  }
9533
9608
  //////////////////////////
@@ -11065,7 +11140,7 @@ const NOT_YET = {};
11065
11140
  * a circular dependency among the providers.
11066
11141
  */
11067
11142
  const CIRCULAR = {};
11068
- const EMPTY_ARRAY$1 = [];
11143
+ const EMPTY_ARRAY$2 = [];
11069
11144
  /**
11070
11145
  * A lazily initialized NullInjector.
11071
11146
  */
@@ -11300,7 +11375,7 @@ class R3Injector {
11300
11375
  if (importTypesWithProviders !== undefined) {
11301
11376
  for (let i = 0; i < importTypesWithProviders.length; i++) {
11302
11377
  const { ngModule, providers } = importTypesWithProviders[i];
11303
- deepForEach(providers, provider => this.processProvider(provider, ngModule, providers || EMPTY_ARRAY$1));
11378
+ deepForEach(providers, provider => this.processProvider(provider, ngModule, providers || EMPTY_ARRAY$2));
11304
11379
  }
11305
11380
  }
11306
11381
  }
@@ -12221,6 +12296,12 @@ let _published = false;
12221
12296
  function publishDefaultGlobalUtils() {
12222
12297
  if (!_published) {
12223
12298
  _published = true;
12299
+ /**
12300
+ * Warning: this function is *INTERNAL* and should not be relied upon in application's code.
12301
+ * The contract of the function might be changed in any release and/or the function can be
12302
+ * removed completely.
12303
+ */
12304
+ publishGlobalUtil('ɵsetProfiler', setProfiler);
12224
12305
  publishGlobalUtil('getComponent', getComponent);
12225
12306
  publishGlobalUtil('getContext', getContext);
12226
12307
  publishGlobalUtil('getListeners', getListeners);
@@ -12554,7 +12635,7 @@ function maybeUnwrapEmpty(value) {
12554
12635
  if (value === EMPTY_OBJ) {
12555
12636
  return {};
12556
12637
  }
12557
- else if (value === EMPTY_ARRAY) {
12638
+ else if (value === EMPTY_ARRAY$1) {
12558
12639
  return [];
12559
12640
  }
12560
12641
  else {
@@ -13648,7 +13729,7 @@ function getInjectableMetadata(type, srcMeta) {
13648
13729
  */
13649
13730
  const ɵ0$9 = getClosureSafeProperty;
13650
13731
  const USE_VALUE$2 = getClosureSafeProperty({ provide: String, useValue: ɵ0$9 });
13651
- const EMPTY_ARRAY$2 = [];
13732
+ const EMPTY_ARRAY$3 = [];
13652
13733
  function convertInjectableProviderToFactory(type, provider) {
13653
13734
  if (!provider) {
13654
13735
  const reflectionCapabilities = new ReflectionCapabilities();
@@ -13666,7 +13747,7 @@ function convertInjectableProviderToFactory(type, provider) {
13666
13747
  }
13667
13748
  else if (provider.useFactory) {
13668
13749
  const factoryProvider = provider;
13669
- return () => factoryProvider.useFactory(...injectArgs(factoryProvider.deps || EMPTY_ARRAY$2));
13750
+ return () => factoryProvider.useFactory(...injectArgs(factoryProvider.deps || EMPTY_ARRAY$3));
13670
13751
  }
13671
13752
  else if (provider.useClass) {
13672
13753
  const classProvider = provider;
@@ -15081,6 +15162,7 @@ function listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn,
15081
15162
  const isTNodeDirectiveHost = isDirectiveHost(tNode);
15082
15163
  const firstCreatePass = tView.firstCreatePass;
15083
15164
  const tCleanup = firstCreatePass && getOrCreateTViewCleanup(tView);
15165
+ const context = lView[CONTEXT];
15084
15166
  // When the ɵɵlistener instruction was generated and is executed we know that there is either a
15085
15167
  // native listener or a directive output on this element. As such we we know that we will have to
15086
15168
  // register a listener and store its cleanup function on LView.
@@ -15133,7 +15215,7 @@ function listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn,
15133
15215
  // The first argument of `listen` function in Procedural Renderer is:
15134
15216
  // - either a target name (as a string) in case of global target (window, document, body)
15135
15217
  // - or element reference (in all other cases)
15136
- listenerFn = wrapListener(tNode, lView, listenerFn, false /** preventDefault */);
15218
+ listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
15137
15219
  const cleanupFn = renderer.listen(resolved.name || target, eventName, listenerFn);
15138
15220
  ngDevMode && ngDevMode.rendererAddEventListener++;
15139
15221
  lCleanup.push(listenerFn, cleanupFn);
@@ -15141,7 +15223,7 @@ function listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn,
15141
15223
  }
15142
15224
  }
15143
15225
  else {
15144
- listenerFn = wrapListener(tNode, lView, listenerFn, true /** preventDefault */);
15226
+ listenerFn = wrapListener(tNode, lView, context, listenerFn, true /** preventDefault */);
15145
15227
  target.addEventListener(eventName, listenerFn, useCapture);
15146
15228
  ngDevMode && ngDevMode.rendererAddEventListener++;
15147
15229
  lCleanup.push(listenerFn);
@@ -15151,7 +15233,7 @@ function listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn,
15151
15233
  else {
15152
15234
  // Even if there is no native listener to add, we still need to wrap the listener so that OnPush
15153
15235
  // ancestors are marked dirty when an event occurs.
15154
- listenerFn = wrapListener(tNode, lView, listenerFn, false /** preventDefault */);
15236
+ listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
15155
15237
  }
15156
15238
  // subscribe to directive outputs
15157
15239
  const outputs = tNode.outputs;
@@ -15176,8 +15258,9 @@ function listenerInternal(tView, lView, renderer, tNode, eventName, listenerFn,
15176
15258
  }
15177
15259
  }
15178
15260
  }
15179
- function executeListenerWithErrorHandling(lView, listenerFn, e) {
15261
+ function executeListenerWithErrorHandling(lView, context, listenerFn, e) {
15180
15262
  try {
15263
+ profiler(6 /* OutputStart */, context, listenerFn);
15181
15264
  // Only explicitly returning false from a listener should preventDefault
15182
15265
  return listenerFn(e) !== false;
15183
15266
  }
@@ -15185,6 +15268,9 @@ function executeListenerWithErrorHandling(lView, listenerFn, e) {
15185
15268
  handleError(lView, error);
15186
15269
  return false;
15187
15270
  }
15271
+ finally {
15272
+ profiler(7 /* OutputEnd */, context, listenerFn);
15273
+ }
15188
15274
  }
15189
15275
  /**
15190
15276
  * Wraps an event listener with a function that marks ancestors dirty and prevents default behavior,
@@ -15196,7 +15282,7 @@ function executeListenerWithErrorHandling(lView, listenerFn, e) {
15196
15282
  * @param wrapWithPreventDefault Whether or not to prevent default behavior
15197
15283
  * (the procedural renderer does this already, so in those cases, we should skip)
15198
15284
  */
15199
- function wrapListener(tNode, lView, listenerFn, wrapWithPreventDefault) {
15285
+ function wrapListener(tNode, lView, context, listenerFn, wrapWithPreventDefault) {
15200
15286
  // Note: we are performing most of the work in the listener function itself
15201
15287
  // to optimize listener registration.
15202
15288
  return function wrapListenerIn_markDirtyAndPreventDefault(e) {
@@ -15214,13 +15300,13 @@ function wrapListener(tNode, lView, listenerFn, wrapWithPreventDefault) {
15214
15300
  if ((lView[FLAGS] & 32 /* ManualOnPush */) === 0) {
15215
15301
  markViewDirty(startView);
15216
15302
  }
15217
- let result = executeListenerWithErrorHandling(lView, listenerFn, e);
15303
+ let result = executeListenerWithErrorHandling(lView, context, listenerFn, e);
15218
15304
  // A just-invoked listener function might have coalesced listeners so we need to check for
15219
15305
  // their presence and invoke as needed.
15220
15306
  let nextListenerFn = wrapListenerIn_markDirtyAndPreventDefault.__ngNextListenerFn__;
15221
15307
  while (nextListenerFn) {
15222
15308
  // We should prevent default if any of the listeners explicitly return false
15223
- result = executeListenerWithErrorHandling(lView, nextListenerFn, e) && result;
15309
+ result = executeListenerWithErrorHandling(lView, context, nextListenerFn, e) && result;
15224
15310
  nextListenerFn = nextListenerFn.__ngNextListenerFn__;
15225
15311
  }
15226
15312
  if (wrapWithPreventDefault && result === false) {
@@ -15838,31 +15924,6 @@ function ɵɵpropertyInterpolateV(propName, values, sanitizer) {
15838
15924
  return ɵɵpropertyInterpolateV;
15839
15925
  }
15840
15926
 
15841
- /**
15842
- * @license
15843
- * Copyright Google LLC All Rights Reserved.
15844
- *
15845
- * Use of this source code is governed by an MIT-style license that can be
15846
- * found in the LICENSE file at https://angular.io/license
15847
- */
15848
- /**
15849
- * This file contains reuseable "empty" symbols that can be used as default return values
15850
- * in different parts of the rendering code. Because the same symbols are returned, this
15851
- * allows for identity checks against these values to be consistently used by the framework
15852
- * code.
15853
- */
15854
- const EMPTY_OBJ$1 = {};
15855
- const EMPTY_ARRAY$3 = [];
15856
- // freezing the values prevents any code from accidentally inserting new values in
15857
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode()) {
15858
- // These property accesses can be ignored because ngDevMode will be set to false
15859
- // when optimizing code and the whole if statement will be dropped.
15860
- // tslint:disable-next-line:no-toplevel-property-access
15861
- Object.freeze(EMPTY_OBJ$1);
15862
- // tslint:disable-next-line:no-toplevel-property-access
15863
- Object.freeze(EMPTY_ARRAY$3);
15864
- }
15865
-
15866
15927
  /**
15867
15928
  * @license
15868
15929
  * Copyright Google LLC All Rights Reserved.
@@ -17045,7 +17106,7 @@ function collectStylingFromTAttrs(stylingKey, attrs, isClassBased) {
17045
17106
  */
17046
17107
  function toStylingKeyValueArray(keyValueArraySet, stringParser, value) {
17047
17108
  if (value == null /*|| value === undefined */ || value === '')
17048
- return EMPTY_ARRAY$3;
17109
+ return EMPTY_ARRAY;
17049
17110
  const styleKeyValueArray = [];
17050
17111
  const unwrappedValue = unwrapSafeValue(value);
17051
17112
  if (Array.isArray(unwrappedValue)) {
@@ -17102,7 +17163,7 @@ function styleKeyValueArraySet(keyValueArray, key, value) {
17102
17163
  function updateStylingMap(tView, tNode, lView, renderer, oldKeyValueArray, newKeyValueArray, isClassBased, bindingIndex) {
17103
17164
  if (oldKeyValueArray === NO_CHANGE) {
17104
17165
  // On first execution the oldKeyValueArray is NO_CHANGE => treat it as empty KeyValueArray.
17105
- oldKeyValueArray = EMPTY_ARRAY$3;
17166
+ oldKeyValueArray = EMPTY_ARRAY;
17106
17167
  }
17107
17168
  let oldIndex = 0;
17108
17169
  let newIndex = 0;
@@ -17240,7 +17301,7 @@ function findStylingValue(tData, tNode, lView, prop, index, isClassBased) {
17240
17301
  // we have `undefined` (or empty array in case of styling-map instruction) instead. This
17241
17302
  // allows the resolution to apply the value (which may later be overwritten when the
17242
17303
  // binding actually executes.)
17243
- valueAtLViewIndex = isStylingMap ? EMPTY_ARRAY$3 : undefined;
17304
+ valueAtLViewIndex = isStylingMap ? EMPTY_ARRAY : undefined;
17244
17305
  }
17245
17306
  let currentValue = isStylingMap ? keyValueArrayGet(valueAtLViewIndex, prop) :
17246
17307
  key === prop ? valueAtLViewIndex : undefined;
@@ -19679,7 +19740,7 @@ function loadIcuContainerVisitor() {
19679
19740
  _removes = tIcu.remove[currentCase];
19680
19741
  }
19681
19742
  else {
19682
- _removes = EMPTY_ARRAY;
19743
+ _removes = EMPTY_ARRAY$1;
19683
19744
  }
19684
19745
  }
19685
19746
  function icuContainerIteratorNext() {
@@ -21358,7 +21419,7 @@ class Version {
21358
21419
  /**
21359
21420
  * @publicApi
21360
21421
  */
21361
- const VERSION = new Version('11.2.5');
21422
+ const VERSION = new Version('11.2.9');
21362
21423
 
21363
21424
  /**
21364
21425
  * @license
@@ -27320,7 +27381,7 @@ function compileComponent(type, metadata) {
27320
27381
  }
27321
27382
  }
27322
27383
  const templateUrl = metadata.templateUrl || `ng:///${type.name}/template.html`;
27323
- const meta = Object.assign(Object.assign({}, directiveMetadata(type, metadata)), { typeSourceSpan: compiler.createParseSourceSpan('Component', type.name, templateUrl), template: metadata.template || '', preserveWhitespaces, styles: metadata.styles || EMPTY_ARRAY, animations: metadata.animations, directives: [], changeDetection: metadata.changeDetection, pipes: new Map(), encapsulation, interpolation: metadata.interpolation, viewProviders: metadata.viewProviders || null });
27384
+ const meta = Object.assign(Object.assign({}, directiveMetadata(type, metadata)), { typeSourceSpan: compiler.createParseSourceSpan('Component', type.name, templateUrl), template: metadata.template || '', preserveWhitespaces, styles: metadata.styles || EMPTY_ARRAY$1, animations: metadata.animations, directives: [], changeDetection: metadata.changeDetection, pipes: new Map(), encapsulation, interpolation: metadata.interpolation, viewProviders: metadata.viewProviders || null });
27324
27385
  compilationDepth++;
27325
27386
  try {
27326
27387
  if (meta.usesInheritance) {
@@ -27429,8 +27490,8 @@ function directiveMetadata(type, metadata) {
27429
27490
  deps: reflectDependencies(type),
27430
27491
  host: metadata.host || EMPTY_OBJ,
27431
27492
  propMetadata: propMetadata,
27432
- inputs: metadata.inputs || EMPTY_ARRAY,
27433
- outputs: metadata.outputs || EMPTY_ARRAY,
27493
+ inputs: metadata.inputs || EMPTY_ARRAY$1,
27494
+ outputs: metadata.outputs || EMPTY_ARRAY$1,
27434
27495
  queries: extractQueriesMetadata(type, propMetadata, isContentQuery),
27435
27496
  lifecycle: { usesOnChanges: reflect.hasLifecycleHook(type, 'ngOnChanges') },
27436
27497
  typeSourceSpan: null,