web-vitals
Advanced tools
Comparing version 3.5.0-soft-navs-12 to 3.5.0-soft-navs-13
@@ -56,4 +56,4 @@ /* | ||
: 0); | ||
const lcpResponseEnd = Math.max(lcpRequestStart - softNavStart, lcpResourceEntry ? lcpResourceEntry.responseEnd - activationStart : 0); | ||
const lcpRenderTime = Math.max(lcpResponseEnd - softNavStart, lcpEntry ? lcpEntry.startTime - activationStart : 0); | ||
const lcpResponseEnd = Math.max(lcpRequestStart - softNavStart, lcpResourceEntry ? lcpResourceEntry.responseEnd - activationStart : 0, 0); | ||
const lcpRenderTime = Math.max(lcpResponseEnd - softNavStart, lcpEntry ? lcpEntry.startTime - activationStart : 0, 0); | ||
const attribution = { | ||
@@ -60,0 +60,0 @@ element: getSelector(lcpEntry.element), |
@@ -1,1 +0,1 @@ | ||
var webVitals=function(t){"use strict";var n,e,i,a,r,o,u=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},c=(null===(n=u())||void 0===n?void 0:n.navigationId)||"1",s=function(t){if("loading"===document.readyState)return"loading";var n=u();if(n){if(t<n.domInteractive)return"loading";if(0===n.domContentLoadedEventStart||t<n.domContentLoadedEventStart)return"dom-interactive";if(0===n.domComplete||t<n.domComplete)return"dom-content-loaded"}return"complete"},v=function(t){var n=t.nodeName;return 1===t.nodeType?n.toLowerCase():n.toUpperCase().replace(/^#/,"")},d=function(t,n){var e="";try{for(;t&&9!==t.nodeType;){var i=t,a=i.id?"#"+i.id:v(i)+(i.classList&&i.classList.value&&i.classList.value.trim()&&i.classList.value.trim().length?"."+i.classList.value.trim().replace(/\s+/g,"."):"");if(e.length+a.length>(n||100)-1)return e||a;if(e=e?a+">"+e:a,i.id)break;t=i.parentNode}}catch(t){}return e},f=function(t,n,e,i){var a,r;return function(o){n.value>=0&&(o||i)&&((r=n.value-(a||0))||void 0===a)&&(a=n.value,n.delta=r,n.rating=function(t,n){return t>n[1]?"poor":t>n[0]?"needs-improvement":"good"}(n.value,e),t(n))}},l=-1,g=function(){return l},m=function(t){addEventListener("pageshow",(function(n){n.persisted&&(l=n.timeStamp,t(n))}),!0)},p=function(t){requestAnimationFrame((function(){return requestAnimationFrame((function(){return t()}))}))},h=function(){var t=u();return t&&t.activationStart||0},T=function(t,n,e,i){var a=u(),r="navigate";e?r=e:g()>=0?r="back-forward-cache":a&&(document.prerendering||h()>0?r="prerender":document.wasDiscarded?r="restore":a.type&&(r=a.type.replace(/_/g,"-")));return{name:t,value:void 0===n?-1:n,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r,navigationId:i||c}},I=function(t){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&t&&t.reportSoftNavs},y=function(t){if(t){var n=window.performance.getEntriesByType("soft-navigation").filter((function(n){return n.navigationId===t}));return n?n[0]:void 0}},E=function(t,n,e){var i=I(e);try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var a=new PerformanceObserver((function(t){Promise.resolve().then((function(){n(t.getEntries())}))}));return a.observe(Object.assign({type:t,buffered:!0,includeSoftNavigationObservations:i},e||{})),a}}catch(t){}},S=function(t){var n=function(n){"pagehide"!==n.type&&"hidden"!==document.visibilityState||t(n)};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},b=-1,C=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},L=function(t){"hidden"===document.visibilityState&&b>-1&&(b="visibilitychange"===t.type?t.timeStamp:0,F())},w=function(){addEventListener("visibilitychange",L,!0),addEventListener("prerenderingchange",L,!0)},F=function(){removeEventListener("visibilitychange",L,!0),removeEventListener("prerenderingchange",L,!0)},M=function(){return b<0&&(b=C(),w(),m((function(){setTimeout((function(){b=C(),w()}),0)}))),{get firstHiddenTime(){return b}}},P=function(t){document.prerendering?addEventListener("prerenderingchange",(function(){return t()}),!0):t()},A=[1800,3e3],k=function(t,n){var e=I(n=n||{}),i=0;P((function(){var a,r=M(),o=T("FCP"),u=E("paint",(function(s){s.forEach((function(s){if("first-contentful-paint"===s.name){e?s.navigationId&&s.navigationId!==o.navigationId&&function(e,r){if(o=T("FCP",0,e,r),a=f(t,o,A,n.reportAllChanges),"soft-navigation"===e){var u=r?y(r):null;i=u&&u.startTime||0}}("soft-navigation",s.navigationId):u.disconnect();var v=0;if(s.navigationId&&s.navigationId!==c){var d=y(s.navigationId),l=d&&d.startTime?d.startTime:0;v=Math.max(s.startTime-l,0)}else v=Math.max(s.startTime-h(),0);var g=e&&s.navigationId?y(s.navigationId):null,m=g&&g.startTime?g.startTime:0;(s.startTime<r.firstHiddenTime||e&&s.navigationId&&s.navigationId!==o.navigationId&&s.navigationId!==c&&m>i)&&(o.value=v,o.entries.push(s),o.navigationId=s.navigationId||"1",a(!0))}}))}),n);u&&(a=f(t,o,A,n.reportAllChanges),m((function(e){o=T("FCP",0,"back-forward-cache",o.navigationId),a=f(t,o,A,n.reportAllChanges),p((function(){o.value=performance.now()-e.timeStamp,a(!0)}))})))}))},x=[.1,.25],B={passive:!0,capture:!0},D=new Date,N=function(t,n){e||(e=n,i=t,a=new Date,q(removeEventListener),O())},O=function(){if(i>=0&&i<a-D){var t={entryType:"first-input",name:e.type,target:e.target,cancelable:e.cancelable,startTime:e.timeStamp,processingStart:e.timeStamp+i};r.forEach((function(n){n([t])})),r=[]}},R=function(t){if(t.cancelable){var n=(t.timeStamp>1e12?new Date:performance.now())-t.timeStamp;"pointerdown"==t.type?function(t,n){var e=function(){N(t,n),a()},i=function(){a()},a=function(){removeEventListener("pointerup",e,B),removeEventListener("pointercancel",i,B)};addEventListener("pointerup",e,B),addEventListener("pointercancel",i,B)}(n,t):N(n,t)}},q=function(t){["mousedown","keydown","touchstart","pointerdown"].forEach((function(n){return t(n,R,B)}))},H=[100,300],_=function(t,n){var a=I(n=n||{});P((function(){var o,u=M(),s=T("FID"),v=function(e){e.forEach((function(e){var i,r;a?e.navigationId&&e.navigationId!==s.navigationId&&(i="soft-navigation",r=e.navigationId,s=T("FID",0,i,r),o=f(t,s,H,n.reportAllChanges)):d.disconnect(),e.startTime<u.firstHiddenTime&&(s.value=e.processingStart-e.startTime,s.entries.push(e),s.navigationId=e.navigationId||c,o(!0))}))},d=E("first-input",v,n);o=f(t,s,H,n.reportAllChanges),d&&S((function(){v(d.takeRecords()),a||d.disconnect()})),d&&m((function(){var a;s=T("FID",0,"back-forward-cache",s.navigationId),o=f(t,s,H,n.reportAllChanges),r=[],i=-1,e=null,q(addEventListener),a=v,r.push(a),O()}))}))},j=0,V=1/0,U=0,z=c,G=!1,J=function(t){t.forEach((function(t){t.interactionId&&(G&&t.navigationId&&t.navigationId!==z&&(z=t.navigationId,j=0,V=1/0,U=0),V=Math.min(V,t.interactionId),U=Math.max(U,t.interactionId),j=U?(U-V)/7+1:0)}))},K=function(){return o?j:performance.interactionCount||0},Q=function(t){"interactionCount"in performance||o||(o=E("event",J,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:G=t||!1}))},W=[200,500],X=0,Y=function(){return K()-X},Z=[],$={},tt=function(t){var n=Z[Z.length-1],e=$[t.interactionId];if(e||Z.length<10||t.duration>n.latency){if(e)e.entries.push(t),e.latency=Math.max(e.latency,t.duration);else{var i={id:t.interactionId,latency:t.duration,entries:[t]};$[i.id]=i,Z.push(i)}Z.sort((function(t,n){return n.latency-t.latency})),Z.splice(10).forEach((function(t){delete $[t.id]}))}},nt=function(t,n){var e=I(n=n||{}),i=!1,a=0;P((function(){var r;Q(e);var o,u=T("INP"),c=function(e,r){if(Z=[],X="soft-navigation"===e?0:K(),u=T("INP",0,e,r),o=f(t,u,W,n.reportAllChanges),i=!1,"soft-navigation"===e){var c=y(r);a=c&&c.startTime?c.startTime:0}},s=function(){var t,e=(t=Math.min(Z.length-1,Math.floor(Y()/50)),Z[t]);e&&(e.latency!==u.value||n&&n.reportAllChanges)&&(u.value=e.latency,u.entries=e.entries)},v=function(t){t.forEach((function(t){(e&&t.navigationId&&t.navigationId!==u.navigationId&&(i||(s(),u.value>0&&o(!0)),c("soft-navigation",t.navigationId)),t.interactionId&&tt(t),"first-input"===t.entryType)&&(!Z.some((function(n){return n.entries.some((function(n){return t.duration===n.duration&&t.startTime===n.startTime}))}))&&tt(t))})),s(),o()},d=E("event",v,{durationThreshold:null!==(r=n.durationThreshold)&&void 0!==r?r:40,opts:n});if(o=f(t,u,W,n.reportAllChanges),d){"interactionId"in PerformanceEventTiming.prototype&&d.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:e}),S((function(){v(d.takeRecords()),u.value<0&&Y()>0&&(u.value=0,u.entries=[]),o(!0)})),m((function(){c("back-forward-cache",u.navigationId),p((function(){return o()}))}));e&&E("soft-navigation",(function(e){e.forEach((function(e){var r=y(e.navigationId),s=r&&r.startTime?r.startTime:0;e.navigationId&&e.navigationId!==u.navigationId&&s>a&&(!i&&u.value>0&&o(!0),c("soft-navigation",e.navigationId),o=f(t,u,W,n.reportAllChanges))}))}),n)}}))},et=[2500,4e3],it=[800,1800],at=u(),rt=function t(n){document.prerendering?P((function(){return t(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return t(n)}),!0):setTimeout(n,0)},ot=function(t,n){var e=I(n=n||{}),i=T("TTFB"),a=f(t,i,it,n.reportAllChanges);rt((function(){if(at){var r=at.responseStart;if(r<=0||r>performance.now())return;i.value=Math.max(r-h(),0),i.entries=[at],a(!0),m((function(){i=T("TTFB",0,"back-forward-cache",i.navigationId),(a=f(t,i,it,n.reportAllChanges))(!0)}));e&&E("soft-navigation",(function(e){e.forEach((function(e){e.navigationId&&((i=T("TTFB",0,"soft-navigation",e.navigationId)).entries=[e],(a=f(t,i,it,n.reportAllChanges))(!0))}))}),n)}}))};return t.CLSThresholds=x,t.FCPThresholds=A,t.FIDThresholds=H,t.INPThresholds=W,t.LCPThresholds=et,t.TTFBThresholds=it,t.onCLS=function(t,n){!function(t,n){var e,i,a=I(n=n||{}),r=!1,o=0;k((e=function(){var e,i=T("CLS",0),u=0,c=[],s=function(a,c){if(i=T("CLS",0,a,c),e=f(t,i,x,n.reportAllChanges),u=0,r=!1,"soft-navigation"===a){var s=y(c);o=s&&s.startTime||0}},v=function(t){t.forEach((function(t){if(a&&t.navigationId&&t.navigationId!==i.navigationId&&(u>i.value&&(i.value=u,i.entries=c),e(!0),s("soft-navigation",t.navigationId)),!t.hadRecentInput){var n=c[0],r=c[c.length-1];u&&t.startTime-r.startTime<1e3&&t.startTime-n.startTime<5e3?(u+=t.value,c.push(t)):(u=t.value,c=[t])}})),u>i.value&&(i.value=u,i.entries=c,e())},d=E("layout-shift",v,n);d&&(e=f(t,i,x,n.reportAllChanges),S((function(){v(d.takeRecords()),e(!0),r=!0})),m((function(){s("back-forward-cache",i.navigationId),p((function(){return e()}))})),a&&E("soft-navigation",(function(a){a.forEach((function(a){var u=a.navigationId,c=u?y(u):null;u&&u!==i.navigationId&&c&&(c.startTime||0)>o&&(r||e(!0),s("soft-navigation",a.navigationId),e=f(t,i,x,n.reportAllChanges))}))}),n),setTimeout(e,0))},i=!1,function(t){i||(e(t),i=!0)}))}((function(n){!function(t){if(t.entries.length){var n=t.entries.reduce((function(t,n){return t&&t.value>n.value?t:n}));if(n&&n.sources&&n.sources.length){var e=(i=n.sources).find((function(t){return t.node&&1===t.node.nodeType}))||i[0];if(e)return void(t.attribution={largestShiftTarget:d(e.node),largestShiftTime:n.startTime,largestShiftValue:n.value,largestShiftSource:e,largestShiftEntry:n,loadState:s(n.startTime)})}}var i;t.attribution={}}(n),t(n)}),n)},t.onFCP=function(t,n){k((function(n){!function(t){if(t.entries.length){var n,e=t.entries[t.entries.length-1],i=0;if(t.navigationId&&t.navigationId!==c)i=(n=y(t.navigationId))?n.startTime:0;else if(n=u()){var a=n.activationStart||0;i=Math.max(0,n.responseStart-a)}if(n)return void(t.attribution={timeToFirstByte:i,firstByteToFCP:t.value-i,loadState:s(t.entries[0].startTime),navigationEntry:n,fcpEntry:e})}t.attribution={timeToFirstByte:0,firstByteToFCP:t.value,loadState:s(g())}}(n),t(n)}),n)},t.onFID=function(t,n){_((function(n){!function(t){var n=t.entries[0];t.attribution={eventTarget:d(n.target),eventType:n.name,eventTime:n.startTime,eventEntry:n,loadState:s(n.startTime)}}(n),t(n)}),n)},t.onINP=function(t,n){nt((function(n){!function(t){if(t.entries.length){var n=t.entries.sort((function(t,n){return n.duration-t.duration||n.processingEnd-n.processingStart-(t.processingEnd-t.processingStart)}))[0];t.attribution={eventTarget:d(n.target),eventType:n.name,eventTime:n.startTime,eventEntry:n,loadState:s(n.startTime)}}else t.attribution={}}(n),t(n)}),n)},t.onLCP=function(t,n){!function(t,n){var e=!1,i=I(n=n||{}),a=0;P((function(){var r,o=M(),u=T("LCP"),s=function(i,o){if(u=T("LCP",0,i,o),r=f(t,u,et,n.reportAllChanges),e=!1,"soft-navigation"===i){var c=y(o);a=c&&c.startTime?c.startTime:0}},v=function(t){t.forEach((function(t){if(t){i&&t.navigationId&&t.navigationId!==u.navigationId&&(e||r(!0),s("soft-navigation",t.navigationId));var n=0;if(t.navigationId&&t.navigationId!==c){var a=y(t.navigationId),v=a&&a.startTime?a.startTime:0;n=Math.max(t.startTime-v,0)}else n=Math.max(t.startTime-h(),0);t.startTime<o.firstHiddenTime&&(u.value=n,u.entries=[t],u.navigationId=t.navigationId||c,r())}}))},d=function(){e||(v(l.takeRecords()),i||l.disconnect(),e=!0,r(!0))},l=E("largest-contentful-paint",v,n);l&&(r=f(t,u,et,n.reportAllChanges),["keydown","click"].forEach((function(t){addEventListener(t,(function(){return setTimeout(d,0)}),!0)})),S(d),m((function(t){s("back-forward-cache",u.navigationId),p((function(){u.value=performance.now()-t.timeStamp,e=!0,r(!0)}))})),i&&E("soft-navigation",(function(t){t.forEach((function(t){var n=t.navigationId?y(t.navigationId):null;t.navigationId&&t.navigationId!==u.navigationId&&n&&(n.startTime||0)>a&&(e||r(!0),s("soft-navigation",t.navigationId))}))}),n))}))}((function(n){!function(t){if(t.entries.length){var n,e=0,i=0,a=0;if(t.navigationId&&t.navigationId!==c?e=a=(n=y(t.navigationId))?n.startTime:0:(e=(n=u())&&n.activationStart?n.activationStart:0,i=n&&n.responseStart?n.responseStart:0),n){var r=t.entries[t.entries.length-1],o=r.url&&performance.getEntriesByType("resource").filter((function(t){return t.name===r.url}))[0],s=Math.max(0,i-e),v=Math.max(s,o?(o.requestStart||o.startTime)-e:0),f=Math.max(v-a,o?o.responseEnd-e:0),l=Math.max(f-a,r?r.startTime-e:0),g={element:d(r.element),timeToFirstByte:s,resourceLoadDelay:v-s,resourceLoadTime:f-v,elementRenderDelay:l-f,navigationEntry:n,lcpEntry:r};return r.url&&(g.url=r.url),o&&(g.lcpResourceEntry=o),void(t.attribution=g)}}t.attribution={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadTime:0,elementRenderDelay:t.value}}(n),t(n)}),n)},t.onTTFB=function(t,n){ot((function(n){!function(t){if(t.entries.length){var n=t.entries[0],e=n.activationStart||0,i=Math.max(n.domainLookupStart-e||0,0),a=Math.max(n.connectStart-e||0,0),r=Math.max(n.requestStart-e||0,0);t.attribution={waitingTime:i,dnsTime:a-i,connectionTime:r-a,requestTime:t.value-r,navigationEntry:n}}else t.attribution={waitingTime:0,dnsTime:0,connectionTime:0,requestTime:0}}(n),t(n)}),n)},Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
var webVitals=function(t){"use strict";var n,e,i,a,r,o,u=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},c=(null===(n=u())||void 0===n?void 0:n.navigationId)||"1",s=function(t){if("loading"===document.readyState)return"loading";var n=u();if(n){if(t<n.domInteractive)return"loading";if(0===n.domContentLoadedEventStart||t<n.domContentLoadedEventStart)return"dom-interactive";if(0===n.domComplete||t<n.domComplete)return"dom-content-loaded"}return"complete"},v=function(t){var n=t.nodeName;return 1===t.nodeType?n.toLowerCase():n.toUpperCase().replace(/^#/,"")},d=function(t,n){var e="";try{for(;t&&9!==t.nodeType;){var i=t,a=i.id?"#"+i.id:v(i)+(i.classList&&i.classList.value&&i.classList.value.trim()&&i.classList.value.trim().length?"."+i.classList.value.trim().replace(/\s+/g,"."):"");if(e.length+a.length>(n||100)-1)return e||a;if(e=e?a+">"+e:a,i.id)break;t=i.parentNode}}catch(t){}return e},f=function(t,n,e,i){var a,r;return function(o){n.value>=0&&(o||i)&&((r=n.value-(a||0))||void 0===a)&&(a=n.value,n.delta=r,n.rating=function(t,n){return t>n[1]?"poor":t>n[0]?"needs-improvement":"good"}(n.value,e),t(n))}},l=-1,g=function(){return l},m=function(t){addEventListener("pageshow",(function(n){n.persisted&&(l=n.timeStamp,t(n))}),!0)},p=function(t){requestAnimationFrame((function(){return requestAnimationFrame((function(){return t()}))}))},h=function(){var t=u();return t&&t.activationStart||0},T=function(t,n,e,i){var a=u(),r="navigate";e?r=e:g()>=0?r="back-forward-cache":a&&(document.prerendering||h()>0?r="prerender":document.wasDiscarded?r="restore":a.type&&(r=a.type.replace(/_/g,"-")));return{name:t,value:void 0===n?-1:n,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r,navigationId:i||c}},I=function(t){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&t&&t.reportSoftNavs},y=function(t){if(t){var n=window.performance.getEntriesByType("soft-navigation").filter((function(n){return n.navigationId===t}));return n?n[0]:void 0}},E=function(t,n,e){var i=I(e);try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var a=new PerformanceObserver((function(t){Promise.resolve().then((function(){n(t.getEntries())}))}));return a.observe(Object.assign({type:t,buffered:!0,includeSoftNavigationObservations:i},e||{})),a}}catch(t){}},S=function(t){var n=function(n){"pagehide"!==n.type&&"hidden"!==document.visibilityState||t(n)};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},b=-1,C=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},L=function(t){"hidden"===document.visibilityState&&b>-1&&(b="visibilitychange"===t.type?t.timeStamp:0,F())},w=function(){addEventListener("visibilitychange",L,!0),addEventListener("prerenderingchange",L,!0)},F=function(){removeEventListener("visibilitychange",L,!0),removeEventListener("prerenderingchange",L,!0)},M=function(){return b<0&&(b=C(),w(),m((function(){setTimeout((function(){b=C(),w()}),0)}))),{get firstHiddenTime(){return b}}},P=function(t){document.prerendering?addEventListener("prerenderingchange",(function(){return t()}),!0):t()},A=[1800,3e3],k=function(t,n){var e=I(n=n||{}),i=0;P((function(){var a,r=M(),o=T("FCP"),u=E("paint",(function(s){s.forEach((function(s){if("first-contentful-paint"===s.name){e?s.navigationId&&s.navigationId!==o.navigationId&&function(e,r){if(o=T("FCP",0,e,r),a=f(t,o,A,n.reportAllChanges),"soft-navigation"===e){var u=r?y(r):null;i=u&&u.startTime||0}}("soft-navigation",s.navigationId):u.disconnect();var v=0;if(s.navigationId&&s.navigationId!==c){var d=y(s.navigationId),l=d&&d.startTime?d.startTime:0;v=Math.max(s.startTime-l,0)}else v=Math.max(s.startTime-h(),0);var g=e&&s.navigationId?y(s.navigationId):null,m=g&&g.startTime?g.startTime:0;(s.startTime<r.firstHiddenTime||e&&s.navigationId&&s.navigationId!==o.navigationId&&s.navigationId!==c&&m>i)&&(o.value=v,o.entries.push(s),o.navigationId=s.navigationId||"1",a(!0))}}))}),n);u&&(a=f(t,o,A,n.reportAllChanges),m((function(e){o=T("FCP",0,"back-forward-cache",o.navigationId),a=f(t,o,A,n.reportAllChanges),p((function(){o.value=performance.now()-e.timeStamp,a(!0)}))})))}))},x=[.1,.25],B={passive:!0,capture:!0},D=new Date,N=function(t,n){e||(e=n,i=t,a=new Date,q(removeEventListener),O())},O=function(){if(i>=0&&i<a-D){var t={entryType:"first-input",name:e.type,target:e.target,cancelable:e.cancelable,startTime:e.timeStamp,processingStart:e.timeStamp+i};r.forEach((function(n){n([t])})),r=[]}},R=function(t){if(t.cancelable){var n=(t.timeStamp>1e12?new Date:performance.now())-t.timeStamp;"pointerdown"==t.type?function(t,n){var e=function(){N(t,n),a()},i=function(){a()},a=function(){removeEventListener("pointerup",e,B),removeEventListener("pointercancel",i,B)};addEventListener("pointerup",e,B),addEventListener("pointercancel",i,B)}(n,t):N(n,t)}},q=function(t){["mousedown","keydown","touchstart","pointerdown"].forEach((function(n){return t(n,R,B)}))},H=[100,300],_=function(t,n){var a=I(n=n||{});P((function(){var o,u=M(),s=T("FID"),v=function(e){e.forEach((function(e){var i,r;a?e.navigationId&&e.navigationId!==s.navigationId&&(i="soft-navigation",r=e.navigationId,s=T("FID",0,i,r),o=f(t,s,H,n.reportAllChanges)):d.disconnect(),e.startTime<u.firstHiddenTime&&(s.value=e.processingStart-e.startTime,s.entries.push(e),s.navigationId=e.navigationId||c,o(!0))}))},d=E("first-input",v,n);o=f(t,s,H,n.reportAllChanges),d&&S((function(){v(d.takeRecords()),a||d.disconnect()})),d&&m((function(){var a;s=T("FID",0,"back-forward-cache",s.navigationId),o=f(t,s,H,n.reportAllChanges),r=[],i=-1,e=null,q(addEventListener),a=v,r.push(a),O()}))}))},j=0,V=1/0,U=0,z=c,G=!1,J=function(t){t.forEach((function(t){t.interactionId&&(G&&t.navigationId&&t.navigationId!==z&&(z=t.navigationId,j=0,V=1/0,U=0),V=Math.min(V,t.interactionId),U=Math.max(U,t.interactionId),j=U?(U-V)/7+1:0)}))},K=function(){return o?j:performance.interactionCount||0},Q=function(t){"interactionCount"in performance||o||(o=E("event",J,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:G=t||!1}))},W=[200,500],X=0,Y=function(){return K()-X},Z=[],$={},tt=function(t){var n=Z[Z.length-1],e=$[t.interactionId];if(e||Z.length<10||t.duration>n.latency){if(e)e.entries.push(t),e.latency=Math.max(e.latency,t.duration);else{var i={id:t.interactionId,latency:t.duration,entries:[t]};$[i.id]=i,Z.push(i)}Z.sort((function(t,n){return n.latency-t.latency})),Z.splice(10).forEach((function(t){delete $[t.id]}))}},nt=function(t,n){var e=I(n=n||{}),i=!1,a=0;P((function(){var r;Q(e);var o,u=T("INP"),c=function(e,r){if(Z=[],X="soft-navigation"===e?0:K(),u=T("INP",0,e,r),o=f(t,u,W,n.reportAllChanges),i=!1,"soft-navigation"===e){var c=y(r);a=c&&c.startTime?c.startTime:0}},s=function(){var t,e=(t=Math.min(Z.length-1,Math.floor(Y()/50)),Z[t]);e&&(e.latency!==u.value||n&&n.reportAllChanges)&&(u.value=e.latency,u.entries=e.entries)},v=function(t){t.forEach((function(t){(e&&t.navigationId&&t.navigationId!==u.navigationId&&(i||(s(),u.value>0&&o(!0)),c("soft-navigation",t.navigationId)),t.interactionId&&tt(t),"first-input"===t.entryType)&&(!Z.some((function(n){return n.entries.some((function(n){return t.duration===n.duration&&t.startTime===n.startTime}))}))&&tt(t))})),s(),o()},d=E("event",v,{durationThreshold:null!==(r=n.durationThreshold)&&void 0!==r?r:40,opts:n});if(o=f(t,u,W,n.reportAllChanges),d){"interactionId"in PerformanceEventTiming.prototype&&d.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:e}),S((function(){v(d.takeRecords()),u.value<0&&Y()>0&&(u.value=0,u.entries=[]),o(!0)})),m((function(){c("back-forward-cache",u.navigationId),p((function(){return o()}))}));e&&E("soft-navigation",(function(e){e.forEach((function(e){var r=y(e.navigationId),s=r&&r.startTime?r.startTime:0;e.navigationId&&e.navigationId!==u.navigationId&&s>a&&(!i&&u.value>0&&o(!0),c("soft-navigation",e.navigationId),o=f(t,u,W,n.reportAllChanges))}))}),n)}}))},et=[2500,4e3],it=[800,1800],at=u(),rt=function t(n){document.prerendering?P((function(){return t(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return t(n)}),!0):setTimeout(n,0)},ot=function(t,n){var e=I(n=n||{}),i=T("TTFB"),a=f(t,i,it,n.reportAllChanges);rt((function(){if(at){var r=at.responseStart;if(r<=0||r>performance.now())return;i.value=Math.max(r-h(),0),i.entries=[at],a(!0),m((function(){i=T("TTFB",0,"back-forward-cache",i.navigationId),(a=f(t,i,it,n.reportAllChanges))(!0)}));e&&E("soft-navigation",(function(e){e.forEach((function(e){e.navigationId&&((i=T("TTFB",0,"soft-navigation",e.navigationId)).entries=[e],(a=f(t,i,it,n.reportAllChanges))(!0))}))}),n)}}))};return t.CLSThresholds=x,t.FCPThresholds=A,t.FIDThresholds=H,t.INPThresholds=W,t.LCPThresholds=et,t.TTFBThresholds=it,t.onCLS=function(t,n){!function(t,n){var e,i,a=I(n=n||{}),r=!1,o=0;k((e=function(){var e,i=T("CLS",0),u=0,c=[],s=function(a,c){if(i=T("CLS",0,a,c),e=f(t,i,x,n.reportAllChanges),u=0,r=!1,"soft-navigation"===a){var s=y(c);o=s&&s.startTime||0}},v=function(t){t.forEach((function(t){if(a&&t.navigationId&&t.navigationId!==i.navigationId&&(u>i.value&&(i.value=u,i.entries=c),e(!0),s("soft-navigation",t.navigationId)),!t.hadRecentInput){var n=c[0],r=c[c.length-1];u&&t.startTime-r.startTime<1e3&&t.startTime-n.startTime<5e3?(u+=t.value,c.push(t)):(u=t.value,c=[t])}})),u>i.value&&(i.value=u,i.entries=c,e())},d=E("layout-shift",v,n);d&&(e=f(t,i,x,n.reportAllChanges),S((function(){v(d.takeRecords()),e(!0),r=!0})),m((function(){s("back-forward-cache",i.navigationId),p((function(){return e()}))})),a&&E("soft-navigation",(function(a){a.forEach((function(a){var u=a.navigationId,c=u?y(u):null;u&&u!==i.navigationId&&c&&(c.startTime||0)>o&&(r||e(!0),s("soft-navigation",a.navigationId),e=f(t,i,x,n.reportAllChanges))}))}),n),setTimeout(e,0))},i=!1,function(t){i||(e(t),i=!0)}))}((function(n){!function(t){if(t.entries.length){var n=t.entries.reduce((function(t,n){return t&&t.value>n.value?t:n}));if(n&&n.sources&&n.sources.length){var e=(i=n.sources).find((function(t){return t.node&&1===t.node.nodeType}))||i[0];if(e)return void(t.attribution={largestShiftTarget:d(e.node),largestShiftTime:n.startTime,largestShiftValue:n.value,largestShiftSource:e,largestShiftEntry:n,loadState:s(n.startTime)})}}var i;t.attribution={}}(n),t(n)}),n)},t.onFCP=function(t,n){k((function(n){!function(t){if(t.entries.length){var n,e=t.entries[t.entries.length-1],i=0;if(t.navigationId&&t.navigationId!==c)i=(n=y(t.navigationId))?n.startTime:0;else if(n=u()){var a=n.activationStart||0;i=Math.max(0,n.responseStart-a)}if(n)return void(t.attribution={timeToFirstByte:i,firstByteToFCP:t.value-i,loadState:s(t.entries[0].startTime),navigationEntry:n,fcpEntry:e})}t.attribution={timeToFirstByte:0,firstByteToFCP:t.value,loadState:s(g())}}(n),t(n)}),n)},t.onFID=function(t,n){_((function(n){!function(t){var n=t.entries[0];t.attribution={eventTarget:d(n.target),eventType:n.name,eventTime:n.startTime,eventEntry:n,loadState:s(n.startTime)}}(n),t(n)}),n)},t.onINP=function(t,n){nt((function(n){!function(t){if(t.entries.length){var n=t.entries.sort((function(t,n){return n.duration-t.duration||n.processingEnd-n.processingStart-(t.processingEnd-t.processingStart)}))[0];t.attribution={eventTarget:d(n.target),eventType:n.name,eventTime:n.startTime,eventEntry:n,loadState:s(n.startTime)}}else t.attribution={}}(n),t(n)}),n)},t.onLCP=function(t,n){!function(t,n){var e=!1,i=I(n=n||{}),a=0;P((function(){var r,o=M(),u=T("LCP"),s=function(i,o){if(u=T("LCP",0,i,o),r=f(t,u,et,n.reportAllChanges),e=!1,"soft-navigation"===i){var c=y(o);a=c&&c.startTime?c.startTime:0}},v=function(t){t.forEach((function(t){if(t){i&&t.navigationId&&t.navigationId!==u.navigationId&&(e||r(!0),s("soft-navigation",t.navigationId));var n=0;if(t.navigationId&&t.navigationId!==c){var a=y(t.navigationId),v=a&&a.startTime?a.startTime:0;n=Math.max(t.startTime-v,0)}else n=Math.max(t.startTime-h(),0);t.startTime<o.firstHiddenTime&&(u.value=n,u.entries=[t],u.navigationId=t.navigationId||c,r())}}))},d=function(){e||(v(l.takeRecords()),i||l.disconnect(),e=!0,r(!0))},l=E("largest-contentful-paint",v,n);l&&(r=f(t,u,et,n.reportAllChanges),["keydown","click"].forEach((function(t){addEventListener(t,(function(){return setTimeout(d,0)}),!0)})),S(d),m((function(t){s("back-forward-cache",u.navigationId),p((function(){u.value=performance.now()-t.timeStamp,e=!0,r(!0)}))})),i&&E("soft-navigation",(function(t){t.forEach((function(t){var n=t.navigationId?y(t.navigationId):null;t.navigationId&&t.navigationId!==u.navigationId&&n&&(n.startTime||0)>a&&(e||r(!0),s("soft-navigation",t.navigationId))}))}),n))}))}((function(n){!function(t){if(t.entries.length){var n,e=0,i=0,a=0;if(t.navigationId&&t.navigationId!==c?e=a=(n=y(t.navigationId))?n.startTime:0:(e=(n=u())&&n.activationStart?n.activationStart:0,i=n&&n.responseStart?n.responseStart:0),n){var r=t.entries[t.entries.length-1],o=r.url&&performance.getEntriesByType("resource").filter((function(t){return t.name===r.url}))[0],s=Math.max(0,i-e),v=Math.max(s,o?(o.requestStart||o.startTime)-e:0),f=Math.max(v-a,o?o.responseEnd-e:0,0),l=Math.max(f-a,r?r.startTime-e:0,0),g={element:d(r.element),timeToFirstByte:s,resourceLoadDelay:v-s,resourceLoadTime:f-v,elementRenderDelay:l-f,navigationEntry:n,lcpEntry:r};return r.url&&(g.url=r.url),o&&(g.lcpResourceEntry=o),void(t.attribution=g)}}t.attribution={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadTime:0,elementRenderDelay:t.value}}(n),t(n)}),n)},t.onTTFB=function(t,n){ot((function(n){!function(t){if(t.entries.length){var n=t.entries[0],e=n.activationStart||0,i=Math.max(n.domainLookupStart-e||0,0),a=Math.max(n.connectStart-e||0,0),r=Math.max(n.requestStart-e||0,0);t.attribution={waitingTime:i,dnsTime:a-i,connectionTime:r-a,requestTime:t.value-r,navigationEntry:n}}else t.attribution={waitingTime:0,dnsTime:0,connectionTime:0,requestTime:0}}(n),t(n)}),n)},Object.defineProperty(t,"__esModule",{value:!0}),t}({}); |
@@ -1,1 +0,1 @@ | ||
var t,n,e,i,a,r,o=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},u=(null===(t=o())||void 0===t?void 0:t.navigationId)||"1",c=function(t){if("loading"===document.readyState)return"loading";var n=o();if(n){if(t<n.domInteractive)return"loading";if(0===n.domContentLoadedEventStart||t<n.domContentLoadedEventStart)return"dom-interactive";if(0===n.domComplete||t<n.domComplete)return"dom-content-loaded"}return"complete"},s=function(t){var n=t.nodeName;return 1===t.nodeType?n.toLowerCase():n.toUpperCase().replace(/^#/,"")},v=function(t,n){var e="";try{for(;t&&9!==t.nodeType;){var i=t,a=i.id?"#"+i.id:s(i)+(i.classList&&i.classList.value&&i.classList.value.trim()&&i.classList.value.trim().length?"."+i.classList.value.trim().replace(/\s+/g,"."):"");if(e.length+a.length>(n||100)-1)return e||a;if(e=e?a+">"+e:a,i.id)break;t=i.parentNode}}catch(t){}return e},f=function(t,n,e,i){var a,r;return function(o){n.value>=0&&(o||i)&&((r=n.value-(a||0))||void 0===a)&&(a=n.value,n.delta=r,n.rating=function(t,n){return t>n[1]?"poor":t>n[0]?"needs-improvement":"good"}(n.value,e),t(n))}},d=-1,l=function(){return d},g=function(t){addEventListener("pageshow",(function(n){n.persisted&&(d=n.timeStamp,t(n))}),!0)},m=function(t){requestAnimationFrame((function(){return requestAnimationFrame((function(){return t()}))}))},p=function(){var t=o();return t&&t.activationStart||0},h=function(t,n,e,i){var a=o(),r="navigate";e?r=e:l()>=0?r="back-forward-cache":a&&(document.prerendering||p()>0?r="prerender":document.wasDiscarded?r="restore":a.type&&(r=a.type.replace(/_/g,"-")));return{name:t,value:void 0===n?-1:n,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r,navigationId:i||u}},T=function(t){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&t&&t.reportSoftNavs},I=function(t){if(t){var n=window.performance.getEntriesByType("soft-navigation").filter((function(n){return n.navigationId===t}));return n?n[0]:void 0}},y=function(t,n,e){var i=T(e);try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var a=new PerformanceObserver((function(t){Promise.resolve().then((function(){n(t.getEntries())}))}));return a.observe(Object.assign({type:t,buffered:!0,includeSoftNavigationObservations:i},e||{})),a}}catch(t){}},E=function(t){var n=function(n){"pagehide"!==n.type&&"hidden"!==document.visibilityState||t(n)};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},S=-1,b=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},C=function(t){"hidden"===document.visibilityState&&S>-1&&(S="visibilitychange"===t.type?t.timeStamp:0,w())},L=function(){addEventListener("visibilitychange",C,!0),addEventListener("prerenderingchange",C,!0)},w=function(){removeEventListener("visibilitychange",C,!0),removeEventListener("prerenderingchange",C,!0)},A=function(){return S<0&&(S=b(),L(),g((function(){setTimeout((function(){S=b(),L()}),0)}))),{get firstHiddenTime(){return S}}},M=function(t){document.prerendering?addEventListener("prerenderingchange",(function(){return t()}),!0):t()},F=[1800,3e3],k=function(t,n){var e=T(n=n||{}),i=0;M((function(){var a,r=A(),o=h("FCP"),c=y("paint",(function(s){s.forEach((function(s){if("first-contentful-paint"===s.name){e?s.navigationId&&s.navigationId!==o.navigationId&&function(e,r){if(o=h("FCP",0,e,r),a=f(t,o,F,n.reportAllChanges),"soft-navigation"===e){var u=r?I(r):null;i=u&&u.startTime||0}}("soft-navigation",s.navigationId):c.disconnect();var v=0;if(s.navigationId&&s.navigationId!==u){var d=I(s.navigationId),l=d&&d.startTime?d.startTime:0;v=Math.max(s.startTime-l,0)}else v=Math.max(s.startTime-p(),0);var g=e&&s.navigationId?I(s.navigationId):null,m=g&&g.startTime?g.startTime:0;(s.startTime<r.firstHiddenTime||e&&s.navigationId&&s.navigationId!==o.navigationId&&s.navigationId!==u&&m>i)&&(o.value=v,o.entries.push(s),o.navigationId=s.navigationId||"1",a(!0))}}))}),n);c&&(a=f(t,o,F,n.reportAllChanges),g((function(e){o=h("FCP",0,"back-forward-cache",o.navigationId),a=f(t,o,F,n.reportAllChanges),m((function(){o.value=performance.now()-e.timeStamp,a(!0)}))})))}))},x=[.1,.25],P=function(t,n){!function(t,n){var e,i,a=T(n=n||{}),r=!1,o=0;k((e=function(){var e,i=h("CLS",0),u=0,c=[],s=function(a,c){if(i=h("CLS",0,a,c),e=f(t,i,x,n.reportAllChanges),u=0,r=!1,"soft-navigation"===a){var s=I(c);o=s&&s.startTime||0}},v=function(t){t.forEach((function(t){if(a&&t.navigationId&&t.navigationId!==i.navigationId&&(u>i.value&&(i.value=u,i.entries=c),e(!0),s("soft-navigation",t.navigationId)),!t.hadRecentInput){var n=c[0],r=c[c.length-1];u&&t.startTime-r.startTime<1e3&&t.startTime-n.startTime<5e3?(u+=t.value,c.push(t)):(u=t.value,c=[t])}})),u>i.value&&(i.value=u,i.entries=c,e())},d=y("layout-shift",v,n);d&&(e=f(t,i,x,n.reportAllChanges),E((function(){v(d.takeRecords()),e(!0),r=!0})),g((function(){s("back-forward-cache",i.navigationId),m((function(){return e()}))})),a&&y("soft-navigation",(function(a){a.forEach((function(a){var u=a.navigationId,c=u?I(u):null;u&&u!==i.navigationId&&c&&(c.startTime||0)>o&&(r||e(!0),s("soft-navigation",a.navigationId),e=f(t,i,x,n.reportAllChanges))}))}),n),setTimeout(e,0))},i=!1,function(t){i||(e(t),i=!0)}))}((function(n){!function(t){if(t.entries.length){var n=t.entries.reduce((function(t,n){return t&&t.value>n.value?t:n}));if(n&&n.sources&&n.sources.length){var e=(i=n.sources).find((function(t){return t.node&&1===t.node.nodeType}))||i[0];if(e)return void(t.attribution={largestShiftTarget:v(e.node),largestShiftTime:n.startTime,largestShiftValue:n.value,largestShiftSource:e,largestShiftEntry:n,loadState:c(n.startTime)})}}var i;t.attribution={}}(n),t(n)}),n)},B=function(t,n){k((function(n){!function(t){if(t.entries.length){var n,e=t.entries[t.entries.length-1],i=0;if(t.navigationId&&t.navigationId!==u)i=(n=I(t.navigationId))?n.startTime:0;else if(n=o()){var a=n.activationStart||0;i=Math.max(0,n.responseStart-a)}if(n)return void(t.attribution={timeToFirstByte:i,firstByteToFCP:t.value-i,loadState:c(t.entries[0].startTime),navigationEntry:n,fcpEntry:e})}t.attribution={timeToFirstByte:0,firstByteToFCP:t.value,loadState:c(l())}}(n),t(n)}),n)},D={passive:!0,capture:!0},N=new Date,R=function(t,a){n||(n=a,e=t,i=new Date,H(removeEventListener),O())},O=function(){if(e>=0&&e<i-N){var t={entryType:"first-input",name:n.type,target:n.target,cancelable:n.cancelable,startTime:n.timeStamp,processingStart:n.timeStamp+e};a.forEach((function(n){n([t])})),a=[]}},q=function(t){if(t.cancelable){var n=(t.timeStamp>1e12?new Date:performance.now())-t.timeStamp;"pointerdown"==t.type?function(t,n){var e=function(){R(t,n),a()},i=function(){a()},a=function(){removeEventListener("pointerup",e,D),removeEventListener("pointercancel",i,D)};addEventListener("pointerup",e,D),addEventListener("pointercancel",i,D)}(n,t):R(n,t)}},H=function(t){["mousedown","keydown","touchstart","pointerdown"].forEach((function(n){return t(n,q,D)}))},j=[100,300],U=function(t,i){var r=T(i=i||{});M((function(){var o,c=A(),s=h("FID"),v=function(n){n.forEach((function(n){var e,a;r?n.navigationId&&n.navigationId!==s.navigationId&&(e="soft-navigation",a=n.navigationId,s=h("FID",0,e,a),o=f(t,s,j,i.reportAllChanges)):d.disconnect(),n.startTime<c.firstHiddenTime&&(s.value=n.processingStart-n.startTime,s.entries.push(n),s.navigationId=n.navigationId||u,o(!0))}))},d=y("first-input",v,i);o=f(t,s,j,i.reportAllChanges),d&&E((function(){v(d.takeRecords()),r||d.disconnect()})),d&&g((function(){var r;s=h("FID",0,"back-forward-cache",s.navigationId),o=f(t,s,j,i.reportAllChanges),a=[],e=-1,n=null,H(addEventListener),r=v,a.push(r),O()}))}))},V=function(t,n){U((function(n){!function(t){var n=t.entries[0];t.attribution={eventTarget:v(n.target),eventType:n.name,eventTime:n.startTime,eventEntry:n,loadState:c(n.startTime)}}(n),t(n)}),n)},_=0,z=1/0,G=0,J=u,K=!1,Q=function(t){t.forEach((function(t){t.interactionId&&(K&&t.navigationId&&t.navigationId!==J&&(J=t.navigationId,_=0,z=1/0,G=0),z=Math.min(z,t.interactionId),G=Math.max(G,t.interactionId),_=G?(G-z)/7+1:0)}))},W=function(){return r?_:performance.interactionCount||0},X=function(t){"interactionCount"in performance||r||(r=y("event",Q,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:K=t||!1}))},Y=[200,500],Z=0,$=function(){return W()-Z},tt=[],nt={},et=function(t){var n=tt[tt.length-1],e=nt[t.interactionId];if(e||tt.length<10||t.duration>n.latency){if(e)e.entries.push(t),e.latency=Math.max(e.latency,t.duration);else{var i={id:t.interactionId,latency:t.duration,entries:[t]};nt[i.id]=i,tt.push(i)}tt.sort((function(t,n){return n.latency-t.latency})),tt.splice(10).forEach((function(t){delete nt[t.id]}))}},it=function(t,n){var e=T(n=n||{}),i=!1,a=0;M((function(){var r;X(e);var o,u=h("INP"),c=function(e,r){if(tt=[],Z="soft-navigation"===e?0:W(),u=h("INP",0,e,r),o=f(t,u,Y,n.reportAllChanges),i=!1,"soft-navigation"===e){var c=I(r);a=c&&c.startTime?c.startTime:0}},s=function(){var t,e=(t=Math.min(tt.length-1,Math.floor($()/50)),tt[t]);e&&(e.latency!==u.value||n&&n.reportAllChanges)&&(u.value=e.latency,u.entries=e.entries)},v=function(t){t.forEach((function(t){(e&&t.navigationId&&t.navigationId!==u.navigationId&&(i||(s(),u.value>0&&o(!0)),c("soft-navigation",t.navigationId)),t.interactionId&&et(t),"first-input"===t.entryType)&&(!tt.some((function(n){return n.entries.some((function(n){return t.duration===n.duration&&t.startTime===n.startTime}))}))&&et(t))})),s(),o()},d=y("event",v,{durationThreshold:null!==(r=n.durationThreshold)&&void 0!==r?r:40,opts:n});if(o=f(t,u,Y,n.reportAllChanges),d){"interactionId"in PerformanceEventTiming.prototype&&d.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:e}),E((function(){v(d.takeRecords()),u.value<0&&$()>0&&(u.value=0,u.entries=[]),o(!0)})),g((function(){c("back-forward-cache",u.navigationId),m((function(){return o()}))}));e&&y("soft-navigation",(function(e){e.forEach((function(e){var r=I(e.navigationId),s=r&&r.startTime?r.startTime:0;e.navigationId&&e.navigationId!==u.navigationId&&s>a&&(!i&&u.value>0&&o(!0),c("soft-navigation",e.navigationId),o=f(t,u,Y,n.reportAllChanges))}))}),n)}}))},at=function(t,n){it((function(n){!function(t){if(t.entries.length){var n=t.entries.sort((function(t,n){return n.duration-t.duration||n.processingEnd-n.processingStart-(t.processingEnd-t.processingStart)}))[0];t.attribution={eventTarget:v(n.target),eventType:n.name,eventTime:n.startTime,eventEntry:n,loadState:c(n.startTime)}}else t.attribution={}}(n),t(n)}),n)},rt=[2500,4e3],ot=function(t,n){!function(t,n){var e=!1,i=T(n=n||{}),a=0;M((function(){var r,o=A(),c=h("LCP"),s=function(i,o){if(c=h("LCP",0,i,o),r=f(t,c,rt,n.reportAllChanges),e=!1,"soft-navigation"===i){var u=I(o);a=u&&u.startTime?u.startTime:0}},v=function(t){t.forEach((function(t){if(t){i&&t.navigationId&&t.navigationId!==c.navigationId&&(e||r(!0),s("soft-navigation",t.navigationId));var n=0;if(t.navigationId&&t.navigationId!==u){var a=I(t.navigationId),v=a&&a.startTime?a.startTime:0;n=Math.max(t.startTime-v,0)}else n=Math.max(t.startTime-p(),0);t.startTime<o.firstHiddenTime&&(c.value=n,c.entries=[t],c.navigationId=t.navigationId||u,r())}}))},d=function(){e||(v(l.takeRecords()),i||l.disconnect(),e=!0,r(!0))},l=y("largest-contentful-paint",v,n);l&&(r=f(t,c,rt,n.reportAllChanges),["keydown","click"].forEach((function(t){addEventListener(t,(function(){return setTimeout(d,0)}),!0)})),E(d),g((function(t){s("back-forward-cache",c.navigationId),m((function(){c.value=performance.now()-t.timeStamp,e=!0,r(!0)}))})),i&&y("soft-navigation",(function(t){t.forEach((function(t){var n=t.navigationId?I(t.navigationId):null;t.navigationId&&t.navigationId!==c.navigationId&&n&&(n.startTime||0)>a&&(e||r(!0),s("soft-navigation",t.navigationId))}))}),n))}))}((function(n){!function(t){if(t.entries.length){var n,e=0,i=0,a=0;if(t.navigationId&&t.navigationId!==u?e=a=(n=I(t.navigationId))?n.startTime:0:(e=(n=o())&&n.activationStart?n.activationStart:0,i=n&&n.responseStart?n.responseStart:0),n){var r=t.entries[t.entries.length-1],c=r.url&&performance.getEntriesByType("resource").filter((function(t){return t.name===r.url}))[0],s=Math.max(0,i-e),f=Math.max(s,c?(c.requestStart||c.startTime)-e:0),d=Math.max(f-a,c?c.responseEnd-e:0),l=Math.max(d-a,r?r.startTime-e:0),g={element:v(r.element),timeToFirstByte:s,resourceLoadDelay:f-s,resourceLoadTime:d-f,elementRenderDelay:l-d,navigationEntry:n,lcpEntry:r};return r.url&&(g.url=r.url),c&&(g.lcpResourceEntry=c),void(t.attribution=g)}}t.attribution={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadTime:0,elementRenderDelay:t.value}}(n),t(n)}),n)},ut=[800,1800],ct=o(),st=function t(n){document.prerendering?M((function(){return t(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return t(n)}),!0):setTimeout(n,0)},vt=function(t,n){var e=T(n=n||{}),i=h("TTFB"),a=f(t,i,ut,n.reportAllChanges);st((function(){if(ct){var r=ct.responseStart;if(r<=0||r>performance.now())return;i.value=Math.max(r-p(),0),i.entries=[ct],a(!0),g((function(){i=h("TTFB",0,"back-forward-cache",i.navigationId),(a=f(t,i,ut,n.reportAllChanges))(!0)}));e&&y("soft-navigation",(function(e){e.forEach((function(e){e.navigationId&&((i=h("TTFB",0,"soft-navigation",e.navigationId)).entries=[e],(a=f(t,i,ut,n.reportAllChanges))(!0))}))}),n)}}))},ft=function(t,n){vt((function(n){!function(t){if(t.entries.length){var n=t.entries[0],e=n.activationStart||0,i=Math.max(n.domainLookupStart-e||0,0),a=Math.max(n.connectStart-e||0,0),r=Math.max(n.requestStart-e||0,0);t.attribution={waitingTime:i,dnsTime:a-i,connectionTime:r-a,requestTime:t.value-r,navigationEntry:n}}else t.attribution={waitingTime:0,dnsTime:0,connectionTime:0,requestTime:0}}(n),t(n)}),n)};export{x as CLSThresholds,F as FCPThresholds,j as FIDThresholds,Y as INPThresholds,rt as LCPThresholds,ut as TTFBThresholds,P as onCLS,B as onFCP,V as onFID,at as onINP,ot as onLCP,ft as onTTFB}; | ||
var t,n,e,i,a,r,o=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},u=(null===(t=o())||void 0===t?void 0:t.navigationId)||"1",c=function(t){if("loading"===document.readyState)return"loading";var n=o();if(n){if(t<n.domInteractive)return"loading";if(0===n.domContentLoadedEventStart||t<n.domContentLoadedEventStart)return"dom-interactive";if(0===n.domComplete||t<n.domComplete)return"dom-content-loaded"}return"complete"},s=function(t){var n=t.nodeName;return 1===t.nodeType?n.toLowerCase():n.toUpperCase().replace(/^#/,"")},v=function(t,n){var e="";try{for(;t&&9!==t.nodeType;){var i=t,a=i.id?"#"+i.id:s(i)+(i.classList&&i.classList.value&&i.classList.value.trim()&&i.classList.value.trim().length?"."+i.classList.value.trim().replace(/\s+/g,"."):"");if(e.length+a.length>(n||100)-1)return e||a;if(e=e?a+">"+e:a,i.id)break;t=i.parentNode}}catch(t){}return e},f=function(t,n,e,i){var a,r;return function(o){n.value>=0&&(o||i)&&((r=n.value-(a||0))||void 0===a)&&(a=n.value,n.delta=r,n.rating=function(t,n){return t>n[1]?"poor":t>n[0]?"needs-improvement":"good"}(n.value,e),t(n))}},d=-1,l=function(){return d},g=function(t){addEventListener("pageshow",(function(n){n.persisted&&(d=n.timeStamp,t(n))}),!0)},m=function(t){requestAnimationFrame((function(){return requestAnimationFrame((function(){return t()}))}))},p=function(){var t=o();return t&&t.activationStart||0},h=function(t,n,e,i){var a=o(),r="navigate";e?r=e:l()>=0?r="back-forward-cache":a&&(document.prerendering||p()>0?r="prerender":document.wasDiscarded?r="restore":a.type&&(r=a.type.replace(/_/g,"-")));return{name:t,value:void 0===n?-1:n,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r,navigationId:i||u}},T=function(t){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&t&&t.reportSoftNavs},I=function(t){if(t){var n=window.performance.getEntriesByType("soft-navigation").filter((function(n){return n.navigationId===t}));return n?n[0]:void 0}},y=function(t,n,e){var i=T(e);try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var a=new PerformanceObserver((function(t){Promise.resolve().then((function(){n(t.getEntries())}))}));return a.observe(Object.assign({type:t,buffered:!0,includeSoftNavigationObservations:i},e||{})),a}}catch(t){}},E=function(t){var n=function(n){"pagehide"!==n.type&&"hidden"!==document.visibilityState||t(n)};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},S=-1,b=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},C=function(t){"hidden"===document.visibilityState&&S>-1&&(S="visibilitychange"===t.type?t.timeStamp:0,w())},L=function(){addEventListener("visibilitychange",C,!0),addEventListener("prerenderingchange",C,!0)},w=function(){removeEventListener("visibilitychange",C,!0),removeEventListener("prerenderingchange",C,!0)},A=function(){return S<0&&(S=b(),L(),g((function(){setTimeout((function(){S=b(),L()}),0)}))),{get firstHiddenTime(){return S}}},M=function(t){document.prerendering?addEventListener("prerenderingchange",(function(){return t()}),!0):t()},F=[1800,3e3],k=function(t,n){var e=T(n=n||{}),i=0;M((function(){var a,r=A(),o=h("FCP"),c=y("paint",(function(s){s.forEach((function(s){if("first-contentful-paint"===s.name){e?s.navigationId&&s.navigationId!==o.navigationId&&function(e,r){if(o=h("FCP",0,e,r),a=f(t,o,F,n.reportAllChanges),"soft-navigation"===e){var u=r?I(r):null;i=u&&u.startTime||0}}("soft-navigation",s.navigationId):c.disconnect();var v=0;if(s.navigationId&&s.navigationId!==u){var d=I(s.navigationId),l=d&&d.startTime?d.startTime:0;v=Math.max(s.startTime-l,0)}else v=Math.max(s.startTime-p(),0);var g=e&&s.navigationId?I(s.navigationId):null,m=g&&g.startTime?g.startTime:0;(s.startTime<r.firstHiddenTime||e&&s.navigationId&&s.navigationId!==o.navigationId&&s.navigationId!==u&&m>i)&&(o.value=v,o.entries.push(s),o.navigationId=s.navigationId||"1",a(!0))}}))}),n);c&&(a=f(t,o,F,n.reportAllChanges),g((function(e){o=h("FCP",0,"back-forward-cache",o.navigationId),a=f(t,o,F,n.reportAllChanges),m((function(){o.value=performance.now()-e.timeStamp,a(!0)}))})))}))},x=[.1,.25],P=function(t,n){!function(t,n){var e,i,a=T(n=n||{}),r=!1,o=0;k((e=function(){var e,i=h("CLS",0),u=0,c=[],s=function(a,c){if(i=h("CLS",0,a,c),e=f(t,i,x,n.reportAllChanges),u=0,r=!1,"soft-navigation"===a){var s=I(c);o=s&&s.startTime||0}},v=function(t){t.forEach((function(t){if(a&&t.navigationId&&t.navigationId!==i.navigationId&&(u>i.value&&(i.value=u,i.entries=c),e(!0),s("soft-navigation",t.navigationId)),!t.hadRecentInput){var n=c[0],r=c[c.length-1];u&&t.startTime-r.startTime<1e3&&t.startTime-n.startTime<5e3?(u+=t.value,c.push(t)):(u=t.value,c=[t])}})),u>i.value&&(i.value=u,i.entries=c,e())},d=y("layout-shift",v,n);d&&(e=f(t,i,x,n.reportAllChanges),E((function(){v(d.takeRecords()),e(!0),r=!0})),g((function(){s("back-forward-cache",i.navigationId),m((function(){return e()}))})),a&&y("soft-navigation",(function(a){a.forEach((function(a){var u=a.navigationId,c=u?I(u):null;u&&u!==i.navigationId&&c&&(c.startTime||0)>o&&(r||e(!0),s("soft-navigation",a.navigationId),e=f(t,i,x,n.reportAllChanges))}))}),n),setTimeout(e,0))},i=!1,function(t){i||(e(t),i=!0)}))}((function(n){!function(t){if(t.entries.length){var n=t.entries.reduce((function(t,n){return t&&t.value>n.value?t:n}));if(n&&n.sources&&n.sources.length){var e=(i=n.sources).find((function(t){return t.node&&1===t.node.nodeType}))||i[0];if(e)return void(t.attribution={largestShiftTarget:v(e.node),largestShiftTime:n.startTime,largestShiftValue:n.value,largestShiftSource:e,largestShiftEntry:n,loadState:c(n.startTime)})}}var i;t.attribution={}}(n),t(n)}),n)},B=function(t,n){k((function(n){!function(t){if(t.entries.length){var n,e=t.entries[t.entries.length-1],i=0;if(t.navigationId&&t.navigationId!==u)i=(n=I(t.navigationId))?n.startTime:0;else if(n=o()){var a=n.activationStart||0;i=Math.max(0,n.responseStart-a)}if(n)return void(t.attribution={timeToFirstByte:i,firstByteToFCP:t.value-i,loadState:c(t.entries[0].startTime),navigationEntry:n,fcpEntry:e})}t.attribution={timeToFirstByte:0,firstByteToFCP:t.value,loadState:c(l())}}(n),t(n)}),n)},D={passive:!0,capture:!0},N=new Date,R=function(t,a){n||(n=a,e=t,i=new Date,H(removeEventListener),O())},O=function(){if(e>=0&&e<i-N){var t={entryType:"first-input",name:n.type,target:n.target,cancelable:n.cancelable,startTime:n.timeStamp,processingStart:n.timeStamp+e};a.forEach((function(n){n([t])})),a=[]}},q=function(t){if(t.cancelable){var n=(t.timeStamp>1e12?new Date:performance.now())-t.timeStamp;"pointerdown"==t.type?function(t,n){var e=function(){R(t,n),a()},i=function(){a()},a=function(){removeEventListener("pointerup",e,D),removeEventListener("pointercancel",i,D)};addEventListener("pointerup",e,D),addEventListener("pointercancel",i,D)}(n,t):R(n,t)}},H=function(t){["mousedown","keydown","touchstart","pointerdown"].forEach((function(n){return t(n,q,D)}))},j=[100,300],U=function(t,i){var r=T(i=i||{});M((function(){var o,c=A(),s=h("FID"),v=function(n){n.forEach((function(n){var e,a;r?n.navigationId&&n.navigationId!==s.navigationId&&(e="soft-navigation",a=n.navigationId,s=h("FID",0,e,a),o=f(t,s,j,i.reportAllChanges)):d.disconnect(),n.startTime<c.firstHiddenTime&&(s.value=n.processingStart-n.startTime,s.entries.push(n),s.navigationId=n.navigationId||u,o(!0))}))},d=y("first-input",v,i);o=f(t,s,j,i.reportAllChanges),d&&E((function(){v(d.takeRecords()),r||d.disconnect()})),d&&g((function(){var r;s=h("FID",0,"back-forward-cache",s.navigationId),o=f(t,s,j,i.reportAllChanges),a=[],e=-1,n=null,H(addEventListener),r=v,a.push(r),O()}))}))},V=function(t,n){U((function(n){!function(t){var n=t.entries[0];t.attribution={eventTarget:v(n.target),eventType:n.name,eventTime:n.startTime,eventEntry:n,loadState:c(n.startTime)}}(n),t(n)}),n)},_=0,z=1/0,G=0,J=u,K=!1,Q=function(t){t.forEach((function(t){t.interactionId&&(K&&t.navigationId&&t.navigationId!==J&&(J=t.navigationId,_=0,z=1/0,G=0),z=Math.min(z,t.interactionId),G=Math.max(G,t.interactionId),_=G?(G-z)/7+1:0)}))},W=function(){return r?_:performance.interactionCount||0},X=function(t){"interactionCount"in performance||r||(r=y("event",Q,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:K=t||!1}))},Y=[200,500],Z=0,$=function(){return W()-Z},tt=[],nt={},et=function(t){var n=tt[tt.length-1],e=nt[t.interactionId];if(e||tt.length<10||t.duration>n.latency){if(e)e.entries.push(t),e.latency=Math.max(e.latency,t.duration);else{var i={id:t.interactionId,latency:t.duration,entries:[t]};nt[i.id]=i,tt.push(i)}tt.sort((function(t,n){return n.latency-t.latency})),tt.splice(10).forEach((function(t){delete nt[t.id]}))}},it=function(t,n){var e=T(n=n||{}),i=!1,a=0;M((function(){var r;X(e);var o,u=h("INP"),c=function(e,r){if(tt=[],Z="soft-navigation"===e?0:W(),u=h("INP",0,e,r),o=f(t,u,Y,n.reportAllChanges),i=!1,"soft-navigation"===e){var c=I(r);a=c&&c.startTime?c.startTime:0}},s=function(){var t,e=(t=Math.min(tt.length-1,Math.floor($()/50)),tt[t]);e&&(e.latency!==u.value||n&&n.reportAllChanges)&&(u.value=e.latency,u.entries=e.entries)},v=function(t){t.forEach((function(t){(e&&t.navigationId&&t.navigationId!==u.navigationId&&(i||(s(),u.value>0&&o(!0)),c("soft-navigation",t.navigationId)),t.interactionId&&et(t),"first-input"===t.entryType)&&(!tt.some((function(n){return n.entries.some((function(n){return t.duration===n.duration&&t.startTime===n.startTime}))}))&&et(t))})),s(),o()},d=y("event",v,{durationThreshold:null!==(r=n.durationThreshold)&&void 0!==r?r:40,opts:n});if(o=f(t,u,Y,n.reportAllChanges),d){"interactionId"in PerformanceEventTiming.prototype&&d.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:e}),E((function(){v(d.takeRecords()),u.value<0&&$()>0&&(u.value=0,u.entries=[]),o(!0)})),g((function(){c("back-forward-cache",u.navigationId),m((function(){return o()}))}));e&&y("soft-navigation",(function(e){e.forEach((function(e){var r=I(e.navigationId),s=r&&r.startTime?r.startTime:0;e.navigationId&&e.navigationId!==u.navigationId&&s>a&&(!i&&u.value>0&&o(!0),c("soft-navigation",e.navigationId),o=f(t,u,Y,n.reportAllChanges))}))}),n)}}))},at=function(t,n){it((function(n){!function(t){if(t.entries.length){var n=t.entries.sort((function(t,n){return n.duration-t.duration||n.processingEnd-n.processingStart-(t.processingEnd-t.processingStart)}))[0];t.attribution={eventTarget:v(n.target),eventType:n.name,eventTime:n.startTime,eventEntry:n,loadState:c(n.startTime)}}else t.attribution={}}(n),t(n)}),n)},rt=[2500,4e3],ot=function(t,n){!function(t,n){var e=!1,i=T(n=n||{}),a=0;M((function(){var r,o=A(),c=h("LCP"),s=function(i,o){if(c=h("LCP",0,i,o),r=f(t,c,rt,n.reportAllChanges),e=!1,"soft-navigation"===i){var u=I(o);a=u&&u.startTime?u.startTime:0}},v=function(t){t.forEach((function(t){if(t){i&&t.navigationId&&t.navigationId!==c.navigationId&&(e||r(!0),s("soft-navigation",t.navigationId));var n=0;if(t.navigationId&&t.navigationId!==u){var a=I(t.navigationId),v=a&&a.startTime?a.startTime:0;n=Math.max(t.startTime-v,0)}else n=Math.max(t.startTime-p(),0);t.startTime<o.firstHiddenTime&&(c.value=n,c.entries=[t],c.navigationId=t.navigationId||u,r())}}))},d=function(){e||(v(l.takeRecords()),i||l.disconnect(),e=!0,r(!0))},l=y("largest-contentful-paint",v,n);l&&(r=f(t,c,rt,n.reportAllChanges),["keydown","click"].forEach((function(t){addEventListener(t,(function(){return setTimeout(d,0)}),!0)})),E(d),g((function(t){s("back-forward-cache",c.navigationId),m((function(){c.value=performance.now()-t.timeStamp,e=!0,r(!0)}))})),i&&y("soft-navigation",(function(t){t.forEach((function(t){var n=t.navigationId?I(t.navigationId):null;t.navigationId&&t.navigationId!==c.navigationId&&n&&(n.startTime||0)>a&&(e||r(!0),s("soft-navigation",t.navigationId))}))}),n))}))}((function(n){!function(t){if(t.entries.length){var n,e=0,i=0,a=0;if(t.navigationId&&t.navigationId!==u?e=a=(n=I(t.navigationId))?n.startTime:0:(e=(n=o())&&n.activationStart?n.activationStart:0,i=n&&n.responseStart?n.responseStart:0),n){var r=t.entries[t.entries.length-1],c=r.url&&performance.getEntriesByType("resource").filter((function(t){return t.name===r.url}))[0],s=Math.max(0,i-e),f=Math.max(s,c?(c.requestStart||c.startTime)-e:0),d=Math.max(f-a,c?c.responseEnd-e:0,0),l=Math.max(d-a,r?r.startTime-e:0,0),g={element:v(r.element),timeToFirstByte:s,resourceLoadDelay:f-s,resourceLoadTime:d-f,elementRenderDelay:l-d,navigationEntry:n,lcpEntry:r};return r.url&&(g.url=r.url),c&&(g.lcpResourceEntry=c),void(t.attribution=g)}}t.attribution={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadTime:0,elementRenderDelay:t.value}}(n),t(n)}),n)},ut=[800,1800],ct=o(),st=function t(n){document.prerendering?M((function(){return t(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return t(n)}),!0):setTimeout(n,0)},vt=function(t,n){var e=T(n=n||{}),i=h("TTFB"),a=f(t,i,ut,n.reportAllChanges);st((function(){if(ct){var r=ct.responseStart;if(r<=0||r>performance.now())return;i.value=Math.max(r-p(),0),i.entries=[ct],a(!0),g((function(){i=h("TTFB",0,"back-forward-cache",i.navigationId),(a=f(t,i,ut,n.reportAllChanges))(!0)}));e&&y("soft-navigation",(function(e){e.forEach((function(e){e.navigationId&&((i=h("TTFB",0,"soft-navigation",e.navigationId)).entries=[e],(a=f(t,i,ut,n.reportAllChanges))(!0))}))}),n)}}))},ft=function(t,n){vt((function(n){!function(t){if(t.entries.length){var n=t.entries[0],e=n.activationStart||0,i=Math.max(n.domainLookupStart-e||0,0),a=Math.max(n.connectStart-e||0,0),r=Math.max(n.requestStart-e||0,0);t.attribution={waitingTime:i,dnsTime:a-i,connectionTime:r-a,requestTime:t.value-r,navigationEntry:n}}else t.attribution={waitingTime:0,dnsTime:0,connectionTime:0,requestTime:0}}(n),t(n)}),n)};export{x as CLSThresholds,F as FCPThresholds,j as FIDThresholds,Y as INPThresholds,rt as LCPThresholds,ut as TTFBThresholds,P as onCLS,B as onFCP,V as onFID,at as onINP,ot as onLCP,ft as onTTFB}; |
{ | ||
"name": "web-vitals", | ||
"version": "3.5.0-soft-navs-12", | ||
"version": "3.5.0-soft-navs-13", | ||
"description": "Easily measure performance metrics in JavaScript", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -74,7 +74,9 @@ /* | ||
lcpRequestStart - softNavStart, | ||
lcpResourceEntry ? lcpResourceEntry.responseEnd - activationStart : 0 | ||
lcpResourceEntry ? lcpResourceEntry.responseEnd - activationStart : 0, | ||
0 | ||
); | ||
const lcpRenderTime = Math.max( | ||
lcpResponseEnd - softNavStart, | ||
lcpEntry ? lcpEntry.startTime - activationStart : 0 | ||
lcpEntry ? lcpEntry.startTime - activationStart : 0, | ||
0 | ||
); | ||
@@ -81,0 +83,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
457656
7366