![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/www/wp-content/plugins/wp-rocket/assets/js/ |
(()=>{var h=class{static getScreenWidth(){return window.innerWidth||document.documentElement.clientWidth}static getScreenHeight(){return window.innerHeight||document.documentElement.clientHeight}static isNotValidScreensize(e,i){const t=this.getScreenWidth(),r=this.getScreenHeight(),s=e&&(t>i.width||r>i.height),n=!e&&(t<i.width||r<i.height);return s||n}static isPageCached(){const e=document.documentElement.nextSibling&&document.documentElement.nextSibling.data?document.documentElement.nextSibling.data:"";return e&&e.includes("Debug: cached")}static isIntersecting(e){return e.bottom>=0&&e.right>=0&&e.top<=(window.innerHeight||document.documentElement.clientHeight)&&e.left<=(window.innerWidth||document.documentElement.clientWidth)}},c=h,u=class{constructor(e,i){this.config=e,this.performanceImages=[],this.logger=i}async run(){try{const e=this._generateLcpCandidates(1/0);e&&(this._initWithFirstElementWithInfo(e),this._fillATFWithoutDuplications(e))}catch(e){this.errorCode="script_error",this.logger.logMessage("Script Error: "+e)}}_generateLcpCandidates(e){const i=document.querySelectorAll(this.config.elements);return i.length<=0?[]:Array.from(i).map(s=>{if(s.nodeName.toLowerCase()==="img"&&s.parentElement.nodeName.toLowerCase()==="picture")return null;let n;if(s.nodeName.toLowerCase()==="picture"){const o=s.querySelector("img");if(o)n=o.getBoundingClientRect();else return null}else n=s.getBoundingClientRect();return{element:s,rect:n}}).filter(s=>s!==null).filter(s=>s.rect.width>0&&s.rect.height>0&&c.isIntersecting(s.rect)).map(s=>({item:s,area:this._getElementArea(s.rect),elementInfo:this._getElementInfo(s.element)})).sort((s,n)=>n.area-s.area).slice(0,e).map(s=>({element:s.item.element,elementInfo:s.elementInfo}))}_getElementArea(e){const i=Math.min(e.width,(window.innerWidth||document.documentElement.clientWidth)-e.left),t=Math.min(e.height,(window.innerHeight||document.documentElement.clientHeight)-e.top);return i*t}_getElementInfo(e){const i=e.nodeName.toLowerCase(),t={type:"",src:"",srcset:"",sizes:"",sources:[],bg_set:[],current_src:""},r=/url\(\s*?['"]?\s*?(.+?)\s*?["']?\s*?\)/ig;if(i==="img"&&e.srcset)t.type="img-srcset",t.src=e.src,t.srcset=e.srcset,t.sizes=e.sizes,t.current_src=e.currentSrc;else if(i==="img")t.type="img",t.src=e.src,t.current_src=e.currentSrc;else if(i==="video"){t.type="img";const s=e.querySelector("source");t.src=e.poster||(s?s.src:""),t.current_src=t.src}else if(i==="svg"){const s=e.querySelector("image");s&&(t.type="img",t.src=s.getAttribute("href")||"",t.current_src=t.src)}else if(i==="picture"){t.type="picture";const s=e.querySelector("img");t.src=s?s.src:"",t.sources=Array.from(e.querySelectorAll("source")).map(n=>({srcset:n.srcset||"",media:n.media||"",type:n.type||"",sizes:n.sizes||""}))}else{const n=[window.getComputedStyle(e,null).getPropertyValue("background-image"),getComputedStyle(e,":after").getPropertyValue("background-image"),getComputedStyle(e,":before").getPropertyValue("background-image")].filter(a=>a!=="none");if(n.length===0)return null;const o=n[0];if(t.type="bg-img",o.includes("image-set(")&&(t.type="bg-img-set"),!o||o===""||o.includes("data:image"))return null;const g=[...o.matchAll(r)];t.bg_set=g.map(a=>a[1]?{src:a[1].trim()+(a[2]?" "+a[2].trim():"")}:{}),t.bg_set.every(a=>a.src==="")&&(t.bg_set=g.map(a=>a[1]?{src:a[1].trim()}:{})),t.bg_set.length>0&&(t.src=t.bg_set[0].src,t.type==="bg-img-set"&&(t.src=t.bg_set))}return t}_initWithFirstElementWithInfo(e){const i=e.find(t=>t.elementInfo!==null);if(!i){this.logger.logMessage("No LCP candidate found."),this.performanceImages=[];return}this.performanceImages=[{...i.elementInfo,label:"lcp"}]}_fillATFWithoutDuplications(e){e.forEach(({element:i,elementInfo:t})=>{this._isDuplicateImage(i)||!t||this.performanceImages.push({...t,label:"above-the-fold"})})}_isDuplicateImage(e){const i=this._getElementInfo(e);if(i===null)return!1;const t=i.type==="img"||i.type==="img-srcset"||i.type==="video",r=i.type==="bg-img"||i.type==="bg-img-set"||i.type==="picture";return(t||r)&&this.performanceImages.some(s=>s.src===i.src)}getResults(){return this.performanceImages}},d=u,p=class{constructor(e,i){this.config=e,this.logger=i,this.lazyRenderElements=[]}async run(){try{const e=this._getLazyRenderElements();e&&this._processElements(e)}catch(e){this.errorCode="script_error",this.logger.logMessage("Script Error: "+e)}}_getLazyRenderElements(){const e=document.querySelectorAll("[data-rocket-location-hash]");return e.length<=0?[]:Array.from(e).filter(t=>!this._skipElement(t)).map(t=>({element:t,depth:this._getElementDepth(t),distance:this._getElementDistance(t),hash:this._getLocationHash(t)}))}_getElementDepth(e){let i=0,t=e.parentElement;for(;t;)i++,t=t.parentElement;return i}_getElementDistance(e){const i=e.getBoundingClientRect(),t=window.pageYOffset||document.documentElement.scrollTop;return Math.max(0,i.top+t-c.getScreenHeight())}_skipElement(e){const i=this.config.skipStrings||["memex"];return!e||!e.id?!1:i.some(t=>e.id.toLowerCase().includes(t.toLowerCase()))}_shouldSkipElement(e,i){if(!e)return!1;for(let t=0;t<i.length;t++){const[r,s]=i[t],n=e.getAttribute(r);if(n&&new RegExp(s,"i").test(n))return!0}return!1}_processElements(e){e.forEach(({element:i,depth:t,distance:r,hash:s})=>{if(this._shouldSkipElement(i,this.config.exclusions||[])||s==="No hash detected")return;const n=i.parentElement&&this._getElementDistance(i.parentElement)<this.config.lrc_threshold&&r>=this.config.lrc_threshold,o=n?"green":r===0?"red":"";this.logger.logColoredMessage(`${" ".repeat(t)}${i.tagName} (Depth: ${t}, Distance from viewport bottom: ${r}px)`,o),this.logger.logColoredMessage(`${" ".repeat(t)}Location hash: ${s}`,o),this.logger.logColoredMessage(`${" ".repeat(t)}Dimensions Client Height: ${i.clientHeight}`,o),n&&(this.lazyRenderElements.push(s),this.logger.logMessage(`Element pushed with hash: ${s}`))})}_getXPath(e){return e&&e.id!==""?`//*[@id="${e.id}"]`:this._getElementXPath(e)}_getElementXPath(e){if(e===document.body)return"/html/body";const i=this._getElementPosition(e);return`${this._getElementXPath(e.parentNode)}/${e.nodeName.toLowerCase()}[${i}]`}_getElementPosition(e){let i=1,t=e.previousElementSibling;for(;t;)t.nodeName===e.nodeName&&i++,t=t.previousElementSibling;return i}_getLocationHash(e){return e.hasAttribute("data-rocket-location-hash")?e.getAttribute("data-rocket-location-hash"):"No hash detected"}getResults(){return this.lazyRenderElements}},m=p,f=class{constructor(e){this.enabled=e}logMessage(e){this.enabled&&console.log(e)}logColoredMessage(e,i="green"){this.enabled&&console.log(`%c${e}`,`color: ${i};`)}},_=f,b=class{constructor(e){this.config=e,this.lcpBeacon=null,this.lrcBeacon=null,this.infiniteLoopId=null,this.errorCode="",this.logger=new _(this.config.debug)}async init(){if(this.scriptTimer=new Date,!await this._isValidPreconditions()){this._finalize();return}this.infiniteLoopId=setTimeout(()=>{this._handleInfiniteLoop()},1e4);const e=await this._getGeneratedBefore(),i=this.config.status.atf&&(e===!1||e.lcp===!1),t=this.config.status.lrc&&(e===!1||e.lrc===!1);i?(this.lcpBeacon=new d(this.config,this.logger),await this.lcpBeacon.run()):this.logger.logMessage("Not running BeaconLcp because data is already available or feature is disabled"),t?(this.lrcBeacon=new m(this.config,this.logger),await this.lrcBeacon.run()):this.logger.logMessage("Not running BeaconLrc because data is already available or feature is disabled"),i||t?this._saveFinalResultIntoDB():(this.logger.logMessage("Not saving results into DB as no beacon features ran."),this._finalize())}async _isValidPreconditions(){const e={width:this.config.width_threshold,height:this.config.height_threshold};return c.isNotValidScreensize(this.config.is_mobile,e)?(this.logger.logMessage("Bailing out because screen size is not acceptable"),!1):!0}async _getGeneratedBefore(){if(!c.isPageCached())return!1;let e=new FormData;return e.append("action","rocket_check_beacon"),e.append("rocket_beacon_nonce",this.config.nonce),e.append("url",this.config.url),e.append("is_mobile",this.config.is_mobile),(await fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:e}).then(t=>t.json())).data}_saveFinalResultIntoDB(){const e={lcp:this.lcpBeacon?this.lcpBeacon.getResults():null,lrc:this.lrcBeacon?this.lrcBeacon.getResults():null},i=new FormData;i.append("action","rocket_beacon"),i.append("rocket_beacon_nonce",this.config.nonce),i.append("url",this.config.url),i.append("is_mobile",this.config.is_mobile),i.append("status",this._getFinalStatus()),i.append("results",JSON.stringify(e)),fetch(this.config.ajax_url,{method:"POST",credentials:"same-origin",body:i,headers:{"wpr-saas-no-intercept":!0}}).then(t=>t.json()).then(t=>{this.logger.logMessage(t.data.lcp)}).catch(t=>{this.logger.logMessage(t)}).finally(()=>{this._finalize()})}_getFinalStatus(){return this.errorCode!==""?this.errorCode:10<=(new Date-this.scriptTimer)/1e3?"timeout":"success"}_handleInfiniteLoop(){this._saveFinalResultIntoDB()}_finalize(){document.querySelector('[data-name="wpr-wpr-beacon"]').setAttribute("beacon-completed","true"),clearTimeout(this.infiniteLoopId)}},l=b;(e=>{if(!e)return;const i=new l(e);if(document.readyState!=="loading"){setTimeout(()=>{i.init()},e.delay);return}document.addEventListener("DOMContentLoaded",()=>{setTimeout(()=>{i.init()},e.delay)})})(window.rocket_beacon_data);var y=l})(); //# sourceMappingURL=wpr-beacon.min.js.map