long-stack-trace-zone.min.js 1.68 KB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(this,function(){"use strict";function t(){return new Error("STACKTRACE TRACKING")}function e(){try{throw t()}catch(e){return e}}function n(t){return t.stack?t.stack.split(i):[]}function r(t,e){for(var r=n(e),a=0;a<r.length;a++){var c=r[a];a<s.length&&s[a]===c||t.push(r[a])}}function a(t,e){var n=[e];if(t)for(var a=(new Date).getTime(),c=0;c<t.length;c++){var o=t[c],s=o.timestamp;n.push(u+" Elapsed: "+(a-s.getTime())+" ms; At: "+s+" "+u),r(n,o.error),a=s.getTime()}return n.join(i)}function c(t,e){e>0&&(t.push(n((new l).error)),c(t,e-1))}function o(){var t=[];c(t,2);for(var e=t[0],n=t[1],r=0;r<e.length;r++){var a=e[r],o=n[r];if(a!==o)break;s.push(a)}}var i="\n",u="  -------------  ",s=[],f="__creationTrace__",l=function(){function t(){this.error=k(),this.timestamp=new Date}return t}(),h=t(),d=e(),k=h.stack?t:d.stack?e:t;Zone.longStackTraceZoneSpec={name:"long-stack-trace",longStackTraceLimit:10,onScheduleTask:function(t,e,n,r){var a=Zone.currentTask,c=a&&a.data&&a.data[f]||[];return c=[new l].concat(c),c.length>this.longStackTraceLimit&&(c.length=this.longStackTraceLimit),r.data||(r.data={}),r.data[f]=c,t.scheduleTask(n,r)},onHandleError:function(t,e,n,r){var c=Zone.currentTask||r.task;if(r instanceof Error&&c){var o=null;try{var i=Object.getOwnPropertyDescriptor(r,"stack");if(i&&i.configurable){var u=i.get,s=i.value;i={get:function(){return a(c.data&&c.data[f],u?u.apply(this):s)}},Object.defineProperty(r,"stack",i),o=!0}}catch(l){}var h=o?null:a(c.data&&c.data[f],r.stack);if(!o)try{o=r.stack=h}catch(l){}if(!o)try{o=r.longStack=h}catch(l){}}return t.handleError(n,r)}},o()});