@angular/core 11.2.8 → 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v11.2.8
2
+ * @license Angular v11.2.9
3
3
  * (c) 2010-2021 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1812,6 +1812,42 @@
1812
1812
  return instance[SIMPLE_CHANGES_STORE] = store;
1813
1813
  }
1814
1814
 
1815
+ /**
1816
+ * @license
1817
+ * Copyright Google LLC All Rights Reserved.
1818
+ *
1819
+ * Use of this source code is governed by an MIT-style license that can be
1820
+ * found in the LICENSE file at https://angular.io/license
1821
+ */
1822
+ var profilerCallback = null;
1823
+ /**
1824
+ * Sets the callback function which will be invoked before and after performing certain actions at
1825
+ * runtime (for example, before and after running change detection).
1826
+ *
1827
+ * Warning: this function is *INTERNAL* and should not be relied upon in application's code.
1828
+ * The contract of the function might be changed in any release and/or the function can be removed
1829
+ * completely.
1830
+ *
1831
+ * @param profiler function provided by the caller or null value to disable profiling.
1832
+ */
1833
+ var setProfiler = function (profiler) {
1834
+ profilerCallback = profiler;
1835
+ };
1836
+ /**
1837
+ * Profiler function which wraps user code executed by the runtime.
1838
+ *
1839
+ * @param event ProfilerEvent corresponding to the execution context
1840
+ * @param instance component instance
1841
+ * @param hookOrListener lifecycle hook function or output listener. The value depends on the
1842
+ * execution context
1843
+ * @returns
1844
+ */
1845
+ var profiler = function (event, instance, hookOrListener) {
1846
+ if (profilerCallback != null /* both `null` and `undefined` */) {
1847
+ profilerCallback(event, instance, hookOrListener);
1848
+ }
1849
+ };
1850
+
1815
1851
  /**
1816
1852
  * @license
1817
1853
  * Copyright Google LLC All Rights Reserved.
@@ -2806,11 +2842,23 @@
2806
2842
  (currentView[PREORDER_HOOK_FLAGS] >> 16 /* NumberOfInitHooksCalledShift */) &&
2807
2843
  (currentView[FLAGS] & 3 /* InitPhaseStateMask */) === initPhase) {
2808
2844
  currentView[FLAGS] += 2048 /* IndexWithinInitPhaseIncrementer */;
2809
- hook.call(directive);
2845
+ profiler(4 /* LifecycleHookStart */, directive, hook);
2846
+ try {
2847
+ hook.call(directive);
2848
+ }
2849
+ finally {
2850
+ profiler(5 /* LifecycleHookEnd */, directive, hook);
2851
+ }
2810
2852
  }
2811
2853
  }
2812
2854
  else {
2813
- hook.call(directive);
2855
+ profiler(4 /* LifecycleHookStart */, directive, hook);
2856
+ try {
2857
+ hook.call(directive);
2858
+ }
2859
+ finally {
2860
+ profiler(5 /* LifecycleHookEnd */, directive, hook);
2861
+ }
2814
2862
  }
2815
2863
  }
2816
2864
 
@@ -10025,17 +10073,22 @@
10025
10073
  }
10026
10074
  function executeTemplate(tView, lView, templateFn, rf, context) {
10027
10075
  var prevSelectedIndex = getSelectedIndex();
10076
+ var isUpdatePhase = rf & 2 /* Update */;
10028
10077
  try {
10029
10078
  setSelectedIndex(-1);
10030
- if (rf & 2 /* Update */ && lView.length > HEADER_OFFSET) {
10079
+ if (isUpdatePhase && lView.length > HEADER_OFFSET) {
10031
10080
  // When we're updating, inherently select 0 so we don't
10032
10081
  // have to generate that instruction for most update blocks.
10033
10082
  selectIndexInternal(tView, lView, HEADER_OFFSET, isInCheckNoChangesMode());
10034
10083
  }
10084
+ var preHookType = isUpdatePhase ? 2 /* TemplateUpdateStart */ : 0 /* TemplateCreateStart */;
10085
+ profiler(preHookType, context);
10035
10086
  templateFn(rf, context);
10036
10087
  }
10037
10088
  finally {
10038
10089
  setSelectedIndex(prevSelectedIndex);
10090
+ var postHookType = isUpdatePhase ? 3 /* TemplateUpdateEnd */ : 1 /* TemplateCreateEnd */;
10091
+ profiler(postHookType, context);
10039
10092
  }
10040
10093
  }
10041
10094
  //////////////////////////
@@ -12745,6 +12798,12 @@
12745
12798
  function publishDefaultGlobalUtils() {
12746
12799
  if (!_published) {
12747
12800
  _published = true;
12801
+ /**
12802
+ * Warning: this function is *INTERNAL* and should not be relied upon in application's code.
12803
+ * The contract of the function might be changed in any release and/or the function can be
12804
+ * removed completely.
12805
+ */
12806
+ publishGlobalUtil('ɵsetProfiler', setProfiler);
12748
12807
  publishGlobalUtil('getComponent', getComponent);
12749
12808
  publishGlobalUtil('getContext', getContext);
12750
12809
  publishGlobalUtil('getListeners', getListeners);
@@ -15638,6 +15697,7 @@
15638
15697
  var isTNodeDirectiveHost = isDirectiveHost(tNode);
15639
15698
  var firstCreatePass = tView.firstCreatePass;
15640
15699
  var tCleanup = firstCreatePass && getOrCreateTViewCleanup(tView);
15700
+ var context = lView[CONTEXT];
15641
15701
  // When the ɵɵlistener instruction was generated and is executed we know that there is either a
15642
15702
  // native listener or a directive output on this element. As such we we know that we will have to
15643
15703
  // register a listener and store its cleanup function on LView.
@@ -15690,7 +15750,7 @@
15690
15750
  // The first argument of `listen` function in Procedural Renderer is:
15691
15751
  // - either a target name (as a string) in case of global target (window, document, body)
15692
15752
  // - or element reference (in all other cases)
15693
- listenerFn = wrapListener(tNode, lView, listenerFn, false /** preventDefault */);
15753
+ listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
15694
15754
  var cleanupFn = renderer.listen(resolved.name || target, eventName, listenerFn);
15695
15755
  ngDevMode && ngDevMode.rendererAddEventListener++;
15696
15756
  lCleanup.push(listenerFn, cleanupFn);
@@ -15698,7 +15758,7 @@
15698
15758
  }
15699
15759
  }
15700
15760
  else {
15701
- listenerFn = wrapListener(tNode, lView, listenerFn, true /** preventDefault */);
15761
+ listenerFn = wrapListener(tNode, lView, context, listenerFn, true /** preventDefault */);
15702
15762
  target.addEventListener(eventName, listenerFn, useCapture);
15703
15763
  ngDevMode && ngDevMode.rendererAddEventListener++;
15704
15764
  lCleanup.push(listenerFn);
@@ -15708,7 +15768,7 @@
15708
15768
  else {
15709
15769
  // Even if there is no native listener to add, we still need to wrap the listener so that OnPush
15710
15770
  // ancestors are marked dirty when an event occurs.
15711
- listenerFn = wrapListener(tNode, lView, listenerFn, false /** preventDefault */);
15771
+ listenerFn = wrapListener(tNode, lView, context, listenerFn, false /** preventDefault */);
15712
15772
  }
15713
15773
  // subscribe to directive outputs
15714
15774
  var outputs = tNode.outputs;
@@ -15733,8 +15793,9 @@
15733
15793
  }
15734
15794
  }
15735
15795
  }
15736
- function executeListenerWithErrorHandling(lView, listenerFn, e) {
15796
+ function executeListenerWithErrorHandling(lView, context, listenerFn, e) {
15737
15797
  try {
15798
+ profiler(6 /* OutputStart */, context, listenerFn);
15738
15799
  // Only explicitly returning false from a listener should preventDefault
15739
15800
  return listenerFn(e) !== false;
15740
15801
  }
@@ -15742,6 +15803,9 @@
15742
15803
  handleError(lView, error);
15743
15804
  return false;
15744
15805
  }
15806
+ finally {
15807
+ profiler(7 /* OutputEnd */, context, listenerFn);
15808
+ }
15745
15809
  }
15746
15810
  /**
15747
15811
  * Wraps an event listener with a function that marks ancestors dirty and prevents default behavior,
@@ -15753,7 +15817,7 @@
15753
15817
  * @param wrapWithPreventDefault Whether or not to prevent default behavior
15754
15818
  * (the procedural renderer does this already, so in those cases, we should skip)
15755
15819
  */
15756
- function wrapListener(tNode, lView, listenerFn, wrapWithPreventDefault) {
15820
+ function wrapListener(tNode, lView, context, listenerFn, wrapWithPreventDefault) {
15757
15821
  // Note: we are performing most of the work in the listener function itself
15758
15822
  // to optimize listener registration.
15759
15823
  return function wrapListenerIn_markDirtyAndPreventDefault(e) {
@@ -15771,13 +15835,13 @@
15771
15835
  if ((lView[FLAGS] & 32 /* ManualOnPush */) === 0) {
15772
15836
  markViewDirty(startView);
15773
15837
  }
15774
- var result = executeListenerWithErrorHandling(lView, listenerFn, e);
15838
+ var result = executeListenerWithErrorHandling(lView, context, listenerFn, e);
15775
15839
  // A just-invoked listener function might have coalesced listeners so we need to check for
15776
15840
  // their presence and invoke as needed.
15777
15841
  var nextListenerFn = wrapListenerIn_markDirtyAndPreventDefault.__ngNextListenerFn__;
15778
15842
  while (nextListenerFn) {
15779
15843
  // We should prevent default if any of the listeners explicitly return false
15780
- result = executeListenerWithErrorHandling(lView, nextListenerFn, e) && result;
15844
+ result = executeListenerWithErrorHandling(lView, context, nextListenerFn, e) && result;
15781
15845
  nextListenerFn = nextListenerFn.__ngNextListenerFn__;
15782
15846
  }
15783
15847
  if (wrapWithPreventDefault && result === false) {
@@ -21919,7 +21983,7 @@
21919
21983
  /**
21920
21984
  * @publicApi
21921
21985
  */
21922
- var VERSION = new Version('11.2.8');
21986
+ var VERSION = new Version('11.2.9');
21923
21987
 
21924
21988
  /**
21925
21989
  * @license