@iframe-resizer/child 5.4.5-beta.3 → 5.4.5-beta.5
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/README.md +1 -1
- package/index.cjs.js +2 -2
- package/index.cjs.js.map +1 -1
- package/index.esm.js +2 -2
- package/index.esm.js.map +1 -1
- package/index.umd.js +2 -2
- package/index.umd.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
package/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/child 5.4.5-beta.
|
|
4
|
+
* @module iframe-resizer/child 5.4.5-beta.5 (cjs) - 2025-04-10
|
|
5
5
|
*
|
|
6
6
|
* @license GPL-3.0 for non-commercial use only.
|
|
7
7
|
* For commercial use, you must purchase a license from
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
"use strict";const e=require("auto-console-group"),t="5.4.5-beta.3",n=10,o="data-iframe-size",i="data-iframe-overflowed",r="data-iframe-ignore",a="bottom",s="right",l="resizeParent",c="setOffsetSize",d="resizeObserver",u="overflowObserver",m="mutationObserver",f=(e,t,n,o)=>e.addEventListener(t,n,o||!1),p=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const g=e=>(e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(p[e]),h=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},y=e=>e,b=e=>Math.round(1e3*e)/1e3,v=e=>e.charAt(0).toUpperCase()+e.slice(1),z=e=>""!=`${e}`&&void 0!==e;function w(e){switch(!0){case!z(e):return"";case z(e.id):return`${e.nodeName}#${e.id}`;case z(e.name):return`${e.nodeName} (${e.name}`;case z(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}const I=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${v(t)}`)};let $=!0;var O;const S=(O=e,O?.__esModule?O.default:O)({label:"iframeResizer(child)"});const H=(T="log",(...e)=>!$||S[T](...e));var T;const M=H,{assert:E,debug:j,endAutoGroup:k,error:A,errorBoundary:P,event:G,purge:L,warn:C}=S,x=e=>{return S.warn((t=y,e=>window.chrome?t(e.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):t(e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))(e));var t},N=x,R=(e=>(t,n="renamed to")=>(o,i,r="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${i}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(((e,t)=>x(t))),q=R("Method"),B=R("Method","replaced with"),F=R("Option"),D="--ifr-start",W="--ifr-end",U=[],V=new WeakSet,Z=e=>"object"==typeof e&&V.add(e);let J={},_=0;const Q=setInterval((()=>{if(U.length<10)return;if(J.hasTags&&J.len<25)return;U.sort();const e=Math.min(U.reduce(((e,t)=>e+t),0)/U.length,U[Math.floor(U.length/2)]),t=b(e);t>_&&(_=t,G("performanceObserver"),H("Mean time:",b(U[Math.floor(U.length/2)])),H("Median time:",b(U.reduce(((e,t)=>e+t),0)/U.length)),H("Average time:",t),H("Max time:",b(Math.max(...U)))),e<=4||(clearInterval(Q),x(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${b(e)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${J.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))}),5e3);function X(e){e.getEntries().forEach((e=>{if(e.name===W){const{duration:t}=performance.measure("--ifr-measure",D,W);J=e.detail,U.push(t),U.length>100&&U.shift()}}))}function Y(){new PerformanceObserver(X).observe({entryTypes:["mark"]}),Z(document.documentElement),Z(document.body)}"undefined"!=typeof document&&"undefined"!=typeof PerformanceObserver&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y()),"undefined"!=typeof window&&function(){const p={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},z={height:()=>(C("Custom height calculation function not defined"),ct.auto()),width:()=>(C("Custom width calculation function not defined"),dt.auto())},O={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,boundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},T={},A="checkVisibility"in window,L="auto",R="[iFrameSizer]",U={max:1,min:1,bodyScroll:1,documentElementScroll:1},V="scroll";let Z,J,_,Q,X,Y=!0,K="",ee=0,te="",ne="",oe=!0,ie=!1,re=!0,ae=!1,se=!1,le=!1,ce=1,de=L,ue="",me=!0,fe="",pe={},ge=!0,he=!1,ye=0,be=!1,ve="",ze=y,we=[],Ie="child",$e=null,Oe=!1,Se="",He=[],Te=window.parent,Me="*",Ee=0,je=!1,ke="",Ae=1,Pe=V,Ge=window,Le=()=>{C("onMessage function not defined")},Ce=()=>{},xe=null,Ne=null;function Re(){var l,d,u;!function(){const e=e=>"true"===e,t=fe.slice(13).split(":");ve=t[0],ee=void 0===t[1]?ee:Number(t[1]),ie=void 0===t[2]?ie:e(t[2]),he=void 0===t[3]?he:e(t[3]),Y=void 0===t[6]?Y:e(t[6]),te=t[7],de=void 0===t[8]?de:t[8],K=t[9],ne=t[10],Ee=void 0===t[11]?Ee:Number(t[11]),pe.enable=void 0!==t[12]&&e(t[12]),Ie=void 0===t[13]?Ie:t[13],Pe=void 0===t[14]?Pe:t[14],be=void 0===t[15]?be:e(t[15]),Z=void 0===t[16]?Z:Number(t[16]),J=void 0===t[17]?J:Number(t[17]),oe=void 0===t[18]?oe:e(t[18]),t[19],ke=t[20]||ke,ye=void 0===t[21]?ye:Number(t[21]),ge=void 0===t[23]?ge:e(t[23])}(),l={id:ve,enabled:he,expand:ge},S.label(`${l.id}`),S.expand(l.expand),$=l.enabled,H(`Initialising iframe v${t} ${window.location.href}`),function(){function t(e){H("Reading data from page:",e),Le=e?.onMessage||Le,Ce=e?.onReady||Ce,"number"==typeof e?.offset&&(F("offset","offsetSize"),oe&&(Z=e?.offset),ie&&(J=e?.offset)),"number"==typeof e?.offsetSize&&(oe&&(Z=e?.offsetSize),ie&&(J=e?.offsetSize)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(Se=e.sizeSelector),Object.prototype.hasOwnProperty.call(e,"ignoreSelector")&&(ue=e.ignoreSelector),Me=e?.targetOrigin||Me,de=e?.heightCalculationMethod||de,Pe=e?.widthCalculationMethod||Pe}function n(e,t){return"function"==typeof e&&(H(`Setup custom ${t}CalcMethod`),z[t]=e,e="custom"),e}if(1===ye)return;const o=window.iframeResizer||window.iFrameResizer;"object"==typeof o&&(t(o),de=n(de,"height"),Pe=n(Pe,"width"),M(`Set targetOrigin for parent: %c${Me}`,e.HIGHLIGHT))}(),Je(),function(){try{Oe=1===ye||"iframeParentListener"in window.parent}catch(e){H("Cross domain iframe detected")}}(),ye<0?N(`${g(ye+2)}${g(2)}`):ke.codePointAt(0)>4||ye<2&&N(g(3)),ke&&""!==ke&&"false"!==ke?ke!==t&&x(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${ke} - Child page: ${t}.\n`):x("<rb>Legacy version detected on parent page</>\n\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\n\nSee <u>https://iframe-resizer.com/setup/</> for more details.\n"),Xe(),Ye(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((n=>{e=!0,n.removeAttribute(t),n.toggleAttribute(o,!0)}));t("data-iframe-height"),t("data-iframe-width"),e&&x("<rb>Deprecated Attributes</>\n \nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),"BackCompat"===document.compatMode&&x("<rb>Quirks Mode Detected</>\n\nThis iframe is running in the browser's legacy <b>Quirks Mode</>, this may cause issues with the correct operation of <i>iframe-resizer</>. It is recommended that you switch to the modern <b>Standards Mode</>.\n\nFor more information see <u>https://iframe-resizer.com/quirks-mode</>.\n"),Fe(),1!==ye&&(Ge.parentIframe=Object.freeze({autoResize:e=>(I(e,"bool","parentIframe.autoResize(enable) enable"),!0===e&&!1===Y?(Y=!0,gt("autoResizeEnabled","Auto Resize enabled")):!1===e&&!0===Y&&(Y=!1),bt(0,0,"autoResize",JSON.stringify(Y)),Y),close(){bt(0,0,"close")},getId:()=>ve,getOrigin:()=>(q("getOrigin()","getParentOrigin()"),_),getParentOrigin:()=>_,getPageInfo(e){if("function"==typeof e)return xe=e,bt(0,0,"pageInfo"),void B("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");xe=null,bt(0,0,"pageInfoStop")},getParentProps:e=>(I(e,"function","parentIframe.getParentProps(callback) callback"),Ne=e,bt(0,0,"parentInfo"),()=>{Ne=null,bt(0,0,"parentInfoStop")}),getParentProperties(e){q("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){I(e,"string","parentIframe.moveToAnchor(anchor) anchor"),pe.findTarget(e)},reset(){yt("parentIframe.reset")},setOffsetSize(e){I(e,"number","parentIframe.setOffsetSize(offset) offset"),Z=e,J=e,gt(c,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){I(e,"number","parentIframe.scrollBy(x, y) x"),I(t,"number","parentIframe.scrollBy(x, y) y"),bt(t,e,"scrollBy")},scrollTo(e,t){I(e,"number","parentIframe.scrollTo(x, y) x"),I(t,"number","parentIframe.scrollTo(x, y) y"),bt(t,e,"scrollTo")},scrollToOffset(e,t){I(e,"number","parentIframe.scrollToOffset(x, y) x"),I(t,"number","parentIframe.scrollToOffset(x, y) y"),bt(t,e,"scrollToOffset")},sendMessage(e,t){t&&I(t,"string","parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),bt(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){de=e,Xe()},setWidthCalculationMethod(e){Pe=e,Ye()},setTargetOrigin(t){I(t,"string","parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),H(`Set targetOrigin: %c${t}`,e.HIGHLIGHT),Me=t},resize(e,t){e&&I(e,"number","parentIframe.resize(customHeight, customWidth) customHeight"),t&&I(t,"number","parentIframe.resize(customHeight, customWidth) customWidth"),gt("parentIframe.resize()",`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){q("size()","resize()"),this.resize(e,t)}}),Ge.parentIFrame=Ge.parentIframe),function(){function t(e){bt(0,0,e.type,`${e.screenY}:${e.screenX}`)}function n(n,o){H(`Add event listener: %c${o}`,e.HIGHLIGHT),f(window.document,n,t)}!0===be&&(n("mouseenter","Mouse Enter"),n("mouseleave","Mouse Leave"))}(),pe=function(){const t=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function o(e){const o=e.getBoundingClientRect(),i=t();return{x:parseInt(o.left,n)+parseInt(i.x,n),y:parseInt(o.top,n)+parseInt(i.y,n)}}function i(t){function n(t){const n=o(t);H(`Moving to in page link (%c#${i}%c) at x: %c${n.x}%c y: %c${n.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),bt(n.y,n.x,"scrollToOffset")}const i=t.split("#")[1]||t,r=decodeURIComponent(i),a=document.getElementById(r)||document.getElementsByName(r)[0];void 0===a?(H(`In page link (#${i}) not found in iFrame, so sending to parent`),bt(0,0,"inPageLink",`#${i}`)):n(a)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&f(e,"click",(t=>{t.preventDefault(),i(e.getAttribute("href"))}))}function s(){f(window,"hashchange",r)}function l(){setTimeout(r,128)}function c(){H("Setting up location.hash handlers"),a(),s(),l()}return pe.enable?1===ye?x("In page linking requires a Professional or Business license. Please see <u>https://iframe-resizer.com/pricing</> for more details."):c():H("In page linking not enabled"),{findTarget:i}}(),void 0===te&&(te=`${ee}px`),Ve("margin",(d="margin",(u=te).includes("-")&&(C(`Negative CSS value ignored for ${d}`),u=""),u)),Ve("background",K),Ve("padding",ne),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const t=e=>e.style.setProperty("height","auto","important");t(document.documentElement),t(document.body),H("Set HTML & body height: %cauto !important",e.HIGHLIGHT)}(),!0!==Y&&H("Auto Resize disabled"),function(e){_e({method:e,eventType:"After Print",eventName:"afterprint"}),_e({method:e,eventType:"Before Print",eventName:"beforeprint"}),_e({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}("add"),function(){const t=new Set,n=[];let o=!1,i=0;const r=e=>{H("Mutations observed:",e.length);for(const n of e){const{addedNodes:e,removedNodes:o}=n;for(const n of e)t.add(n);for(const e of o)t.delete(e)}},a=16,s=2,l=200;let c=1;function d(e){Je(),De(e),e.forEach(tt),e.clear()}function u(){G("mutationObserver");const f=performance.now(),p=f-i,g=a*c+++s;if(p>g&&p<l)return H(`MutationObserver delay: %c${p}ms > ${g}ms`,e.HIGHLIGHT),setTimeout(u,a*c),void(i=f);c=1,n.forEach(r),n.length=0,t.size>0&&d(t),Fe(),qe(),o=!1,gt(m,"Mutation Observed")}function f(e){n.push(e),o||(i=performance.now(),o=!0,requestAnimationFrame(u))}function p(){const e=new window.MutationObserver(f),t=document.querySelector("body"),n={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return H("Setup <body> MutationObserver"),e.observe(t,n),e}p()}(),H("Setup ResizeObserver"),$e=new ResizeObserver(Ke),$e.observe(document.body),et.add(document.body),tt(document.body),oe!==ie&&(H("Setup OverflowObserver"),ze=(e=>{const t=e.side||a,n=e.onChange||y,o={root:e.root,rootMargin:"0px",threshold:1},s=window?.requestAnimationFrame||y,l=(e=!1)=>n(e),c=(e,n)=>0===e||e>n[t],d=(e,t)=>e.toggleAttribute(i,t),u=new IntersectionObserver((function(e){G("observation");for(const o of e){const{boundingClientRect:e,rootBounds:i,target:r}=o,a=e[t],s=c(a,i)&&!((n=r).hidden||null===n.offsetParent||"none"===n.style.display);d(r,s),s&&H("Overflowed:",r)}var n;s(l)}),o),m=new WeakSet;return function(){const e=new window.MutationObserver((()=>{M("Detected changes in element attributes"),l(!0)})),t=document.querySelector("body"),n={attributes:!0,attributeFilter:[r],subtree:!0};H("Setup OverflowMutationObserver"),e.observe(t,n)}(),function(e){H("Attached overflowObservers");for(const t of e){const e=t.nodeType===Node.ELEMENT_NODE,n=m.has(t);!n&&e?(u.observe(t),m.add(t)):E(!n,"Node already observed",t)}}})({onChange:Be,root:document.documentElement,side:oe?a:s})),De(it(document)()),queueMicrotask(Ce),H("Initialization complete"),gt("init","Init message from host page",void 0,void 0,t),document.title&&""!==document.title&&bt(0,0,"title",document.title)}function qe(){we=document.querySelectorAll(`[${i}]:not([${r}]):not([${r}] *)`),se=we.length>0}function Be(e){qe(),(se||e)&&(H("Observed Elements:",we.length),gt(u,"Overflow updated"))}function Fe(){He=document.querySelectorAll(`[${o}]`),le=He.length>0,H(`Tagged elements found: %c${le}`,le?e.HIGHLIGHT:e.FOREGROUND)}function De(e){le||ze(e)}let We=0;function Ue(){const t=document.querySelectorAll(`*[${r}]`);ae=t.length>0,ae&&t.length!==We&&(function(t){const n=1===t.length?"":"s";C(`%c[${r}]%c found on %c${t.length}%c element${n}`,e.BOLD,e.NORMAL,e.BOLD,e.NORMAL)}(t),We=t.length)}function Ve(t,n){void 0!==n&&""!==n&&"null"!==n&&(document.body.style.setProperty(t,n),M(`Set body ${t}: %c${n}`,e.HIGHLIGHT))}function Ze(t,n,o){if(""!==o){H(`${t}: %c${o}`,e.HIGHLIGHT);for(const e of document.querySelectorAll(o))H(`Applying ${n} to:`,e),e.toggleAttribute(n,!0)}}function Je(){Ze("sizeSelector",o,Se),Ze("ignoreSelector",r,ue)}function _e(t){({add(e){function n(){gt(t.eventName,t.eventType)}T[e]=n,f(window,e,n,{passive:!0})},remove(e){const t=T[e];var n,o;delete T[e],n=e,o=t,window.removeEventListener(n,o,!1)}})[t.method](t.eventName),H(`${v(t.method)} event listener: %c${t.eventType}`,e.HIGHLIGHT)}function Qe(t,n,o,i){return n!==t&&(t in o||(C(`${t} is not a valid option for ${i}CalculationMethod.`),t=n),t in O&&x(`<rb>Deprecated ${i}CalculationMethod (${t})</>\n\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${i} calculation method. It is recommended that you remove this option.`),H(`Set ${i} calculation method: %c${t}`,e.HIGHLIGHT)),t}function Xe(){de=Qe(de,L,ct,"height")}function Ye(){Pe=Qe(Pe,V,dt,"width")}function Ke(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;gt(d,`Element resized <${w(t)}>`)}const et=new WeakSet;function tt(t){if(t.nodeType!==Node.ELEMENT_NODE)return;if(!et.has(t)){const n=getComputedStyle(t)?.position;""!==n&&"static"!==n&&($e.observe(t),et.add(t),H(`Attached resizeObserver: %c${w(t)}`,e.HIGHLIGHT))}const n=it(t)();for(const t of n){if(et.has(t)||t?.nodeType!==Node.ELEMENT_NODE)continue;const n=getComputedStyle(t)?.position;""!==n&&"static"!==n&&($e.observe(t),et.add(t),H(`Attached resizeObserver: %c${w(t)}`,e.HIGHLIGHT))}}function nt(e){performance.mark(D);const t=v(e);let n=0,o=document.documentElement,i=le?0:document.documentElement.getBoundingClientRect().bottom;const r=le?He:se?we:it(document)();let a=r.length;for(const t of r)le||!A||t.checkVisibility(p)?(n=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),n>i&&(i=n,o=t)):a-=1;return M(`${t} position calculated from:`,o),performance.mark(W,{detail:{Side:t,len:a,hasTags:le,logging:he}}),i}const ot=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],it=e=>()=>{Ue();const t=["* ","not(head)","not(meta)","not(base)","not(title)","not(script)","not(link)","not(style)","not(map)","not(area)","not(option)","not(optgroup)","not(template)","not(track)","not(wbr)","not(nobr)"];return ae&&t.push(`not([${r}])`,`not([${r}] *)`),e.querySelectorAll(t.join(":"))},rt={height:0,width:0},at={height:0,width:0},st=[e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT];function lt(t){function n(){return at[i]=r,rt[i]=l,r}const o=t===ct,i=o?"height":"width",r=t.boundingClientRect(),a=Math.ceil(r),s=Math.floor(r),l=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(t),c=`HTML: %c${r}px %cPage: %c${l}px`;let d=0;switch(!0){case!t.enabled():return l;case le:M("Found element with data-iframe-size attribute"),d=t.taggedElement();break;case!se&&0===at[i]&&0===rt[i]:M(`Initial page size values: ${c}`,...st),d=n();break;case je&&r===at[i]&&l===rt[i]:M(`Size unchanged: ${c}`,...st),d=Math.max(r,l);break;case 0===r:M(`Page is hidden: ${c}`,...st),d=l;break;case!se&&r!==at[i]&&l<=rt[i]:M(`New <html> size: ${c} `,...st),M(`Previous <html> size: %c${at[i]}px`,e.HIGHLIGHT),d=n();break;case!o:d=t.taggedElement();break;case!se&&r<at[i]:M(`<html> size decreased: ${c}`,...st),d=n();break;case l===s||l===a:M(`<html> size equals page size: ${c}`,...st),d=n();break;case r>l:M(`Page size < <html> size: ${c}`,...st),d=n();break;case se:M("Found element overflowing <html> "),d=t.taggedElement();break;default:M(`Using <html> size: ${c}`,...st),d=n()}return M(`Content ${i}: %c${d}px`,e.HIGHLIGHT),d+=function(t){const n=t.getOffset();return 0!==n&&M(`Page offsetSize: %c${n}px`,e.HIGHLIGHT),n}(t),d}const ct={enabled:()=>oe,getOffset:()=>Z,auto:()=>lt(ct),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,n)+parseInt(t.marginBottom,n)},bodyScroll:()=>document.body.scrollHeight,offset:()=>ct.bodyOffset(),custom:()=>z.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...ot(ct)),min:()=>Math.min(...ot(ct)),grow:()=>ct.max(),lowestElement:()=>nt(a),taggedElement:()=>nt(a)},dt={enabled:()=>ie,getOffset:()=>J,auto:()=>lt(dt),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>z.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...ot(dt)),min:()=>Math.min(...ot(dt)),rightMostElement:()=>nt(s),scroll:()=>Math.max(dt.bodyScroll(),dt.documentElementScroll()),taggedElement:()=>nt(s)},ut=(e,t)=>!(Math.abs(e-t)<=Ee);function mt(e,t,n,o,i){const r=void 0===n?ct[de]():n,a=void 0===o?dt[Pe]():o;switch(!0){case oe&&ut(ce,r)||ie&&ut(Ae,a)||"init"===e:ce=r,Ae=a;case e===c:bt(ce,Ae,e,i);break;case!e!==l&&(oe&&de in U||ie&&Pe in U):yt(t);break;case e===d:case e===u:case e===m:H("No change in content size detected");break;default:M("No change in content size detected")}Q=!1}let ft=!1;const pt=h((()=>N(g(4)))),gt=P(((t,n,o,i,r)=>{X=performance.now(),G(t),Y||t===l?document.hidden?H("Page hidden - Ignored resize request"):(ft||(H(`Resize event: %c${n}`,e.HIGHLIGHT),Q=!0,mt(t,n,o,i,r),requestAnimationFrame((()=>{ft=!1}))),ft=!0):M("Resizing disabled")}));function ht(e){ce=ct[de](),Ae=dt[Pe](),bt(ce,Ae,e)}function yt(t){const n=de;de=L,H(`Reset trigger event: %c${t}`,e.HIGHLIGHT),je?H("TriggerLock blocked calculation"):(je=!0,j("Trigger event lock on"),requestAnimationFrame((()=>{je=!1,j("Trigger event lock off")}))),ht("reset"),de=n}const bt=P((function(t,n,o,i,r){ye<-1||(G(o),void 0!==r?H(`Message targetOrigin: %c${r}`,e.HIGHLIGHT):r=Me,function(){const a=`${ve}:${t}:${n}:${o}${void 0===i?"":`:${i}`}`;if(Oe)try{window.parent.iframeParentListener(R+a)}catch(e){if(1!==ye)throw e;return void pt()}else Te.postMessage(R+a,r);Q&&M(function(){const e=b(performance.now()-X);return"init"===o?`Initialised iFrame in %c${e}ms`:`Size calculated in %c${e}ms`}(),e.HIGHLIGHT),M("Sending message to host page via "+(Oe?"sameOrigin":"postMessage")),M(`%c${a}`,e.ITALIC)}(),k())})),vt=P((function(e){const{freeze:t}=Object,{parse:n}=JSON,o=e=>bt(0,0,`${e}Stop`),i={init:function(){fe=e.data,Te=e.source,_=e.origin,Re(),re=!1,setTimeout((()=>{me=!1}),128)},reset(){me?H("Page reset ignored by init"):(H("Page size reset by host page"),ht("resetPage"))},resize(){gt(l,"Parent window requested size check")},moveToAnchor(){pe.findTarget(a())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=a();H(`PageInfo received from parent: ${e}`),xe?setTimeout((()=>xe(n(e)))):o("pageInfo")},parentInfo(){const e=a();H(`ParentInfo received from parent: ${e}`),Ne?setTimeout((()=>Ne(t(n(e))))):o("parentInfo")},message(){const e=a();H(`onMessage called from parent: ${e}`),setTimeout((()=>Le(n(e))))}},r=()=>e.data.split("]")[1].split(":")[0],a=()=>e.data.slice(e.data.indexOf(":")+1),s=()=>e.data.split(":")[2]in{true:1,false:1};function c(){const t=r();t in i?i[t]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||s()||C(`Unexpected message (${e.data})`)}R===`${e.data}`.slice(0,13)&&(G(r()),!1!==re?s()?i.init():H(`Ignored message of type "${r()}". Received before initialization.`):c())}));function zt(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"iframeChildListener"in window?C("Already setup"):(window.iframeChildListener=e=>setTimeout((()=>vt({data:e,sameOrigin:!0}))),f(window,"message",vt),f(window,"readystatechange",zt),zt())}();
|
|
20
|
+
"use strict";const e=require("auto-console-group"),t="5.4.5-beta.5",n=10,o="data-iframe-size",i="data-iframe-overflowed",r="data-iframe-ignore",a="bottom",s="right",l="resizeParent",c="setOffsetSize",d="resizeObserver",u="overflowObserver",m="mutationObserver",f=(e,t,n,o)=>e.addEventListener(t,n,o||!1),p=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const g=e=>(e=>e.replace(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(p[e]),h=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},y=e=>e,b=e=>Math.round(1e3*e)/1e3,v=e=>e.charAt(0).toUpperCase()+e.slice(1),z=e=>""!=`${e}`&&void 0!==e;function w(e){switch(!0){case!z(e):return"";case z(e.id):return`${e.nodeName}#${e.id}`;case z(e.name):return`${e.nodeName} (${e.name}`;case z(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}const I=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${v(t)}`)};let $=!0;var O;const S=(O=e,O?.__esModule?O.default:O)({label:"iframeResizer(child)"});const H=(T="log",(...e)=>!$||S[T](...e));var T;const M=H,{assert:E,debug:j,endAutoGroup:k,error:P,errorBoundary:A,event:G,purge:L,warn:C}=S,x=e=>{return S.warn((t=y,e=>window.chrome?t(e.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):t(e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))(e));var t},N=x,R=(e=>(t,n="renamed to")=>(o,i,r="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${i}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(((e,t)=>x(t))),q=R("Method"),B=R("Method","replaced with"),F=R("Option"),D="--ifr-start",W="--ifr-end",U=[],V=new WeakSet,Z=e=>"object"==typeof e&&V.add(e);let J={},_=0;const Q=setInterval((()=>{if(U.length<10)return;if(J.hasTags&&J.len<25)return;U.sort();const e=Math.min(U.reduce(((e,t)=>e+t),0)/U.length,U[Math.floor(U.length/2)]),t=b(e);t>_&&(_=t,G("performanceObserver"),H("Mean time:",b(U[Math.floor(U.length/2)])),H("Median time:",b(U.reduce(((e,t)=>e+t),0)/U.length)),H("Average time:",t),H("Max time:",b(Math.max(...U)))),e<=4||(clearInterval(Q),x(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${b(e)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${J.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))}),5e3);function X(e){e.getEntries().forEach((e=>{if(e.name===W){const{duration:t}=performance.measure("--ifr-measure",D,W);J=e.detail,U.push(t),U.length>100&&U.shift()}}))}function Y(){new PerformanceObserver(X).observe({entryTypes:["mark"]}),Z(document.documentElement),Z(document.body)}"undefined"!=typeof document&&"undefined"!=typeof PerformanceObserver&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",Y):Y()),"undefined"!=typeof window&&function(){const p={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},z={height:()=>(C("Custom height calculation function not defined"),ct.auto()),width:()=>(C("Custom width calculation function not defined"),dt.auto())},O={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,boundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},T={},P="checkVisibility"in window,L="auto",R="[iFrameSizer]",U={max:1,min:1,bodyScroll:1,documentElementScroll:1},V="scroll";let Z,J,_,Q,X,Y=!0,K="",ee=0,te="",ne="",oe=!0,ie=!1,re=!0,ae=!1,se=!1,le=!1,ce=1,de=L,ue="",me=!0,fe="",pe={},ge=!0,he=!1,ye=0,be=!1,ve="",ze=y,we=[],Ie="child",$e=null,Oe=!1,Se="",He=[],Te=window.parent,Me="*",Ee=0,je=!1,ke="",Pe=1,Ae=V,Ge=window,Le=()=>{C("onMessage function not defined")},Ce=()=>{},xe=null,Ne=null;function Re(){var l,d,u;!function(){const e=e=>"true"===e,t=fe.slice(13).split(":");ve=t[0],ee=void 0===t[1]?ee:Number(t[1]),ie=void 0===t[2]?ie:e(t[2]),he=void 0===t[3]?he:e(t[3]),Y=void 0===t[6]?Y:e(t[6]),te=t[7],de=void 0===t[8]?de:t[8],K=t[9],ne=t[10],Ee=void 0===t[11]?Ee:Number(t[11]),pe.enable=void 0!==t[12]&&e(t[12]),Ie=void 0===t[13]?Ie:t[13],Ae=void 0===t[14]?Ae:t[14],be=void 0===t[15]?be:e(t[15]),Z=void 0===t[16]?Z:Number(t[16]),J=void 0===t[17]?J:Number(t[17]),oe=void 0===t[18]?oe:e(t[18]),t[19],ke=t[20]||ke,ye=void 0===t[21]?ye:Number(t[21]),ge=void 0===t[23]?ge:e(t[23])}(),l={id:ve,enabled:he,expand:ge},S.label(`${l.id}`),S.expand(l.expand),$=l.enabled,H(`Initialising iframe v${t} ${window.location.href}`),function(){function t(e){H("Reading data from page:",e),Le=e?.onMessage||Le,Ce=e?.onReady||Ce,"number"==typeof e?.offset&&(F("offset","offsetSize"),oe&&(Z=e?.offset),ie&&(J=e?.offset)),"number"==typeof e?.offsetSize&&(oe&&(Z=e?.offsetSize),ie&&(J=e?.offsetSize)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(Se=e.sizeSelector),Object.prototype.hasOwnProperty.call(e,"ignoreSelector")&&(ue=e.ignoreSelector),Me=e?.targetOrigin||Me,de=e?.heightCalculationMethod||de,Ae=e?.widthCalculationMethod||Ae}function n(e,t){return"function"==typeof e&&(H(`Setup custom ${t}CalcMethod`),z[t]=e,e="custom"),e}if(1===ye)return;const o=window.iframeResizer||window.iFrameResizer;"object"==typeof o&&(t(o),de=n(de,"height"),Ae=n(Ae,"width"),M(`Set targetOrigin for parent: %c${Me}`,e.HIGHLIGHT))}(),Je(),function(){try{Oe=1===ye||"iframeParentListener"in window.parent}catch(e){H("Cross domain iframe detected")}}(),ye<0?N(`${g(ye+2)}${g(2)}`):ke.codePointAt(0)>4||ye<2&&N(g(3)),ke&&""!==ke&&"false"!==ke?ke!==t&&x(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${ke} - Child page: ${t}.\n`):x("<rb>Legacy version detected on parent page</>\n\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\n\nSee <u>https://iframe-resizer.com/setup/</> for more details.\n"),Xe(),Ye(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((n=>{e=!0,n.removeAttribute(t),n.toggleAttribute(o,!0)}));t("data-iframe-height"),t("data-iframe-width"),e&&x("<rb>Deprecated Attributes</>\n \nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),"BackCompat"===document.compatMode&&x("<rb>Quirks Mode Detected</>\n\nThis iframe is running in the browser's legacy <b>Quirks Mode</>, this may cause issues with the correct operation of <i>iframe-resizer</>. It is recommended that you switch to the modern <b>Standards Mode</>.\n\nFor more information see <u>https://iframe-resizer.com/quirks-mode</>.\n"),Fe(),1!==ye&&(Ge.parentIframe=Object.freeze({autoResize:e=>(I(e,"bool","parentIframe.autoResize(enable) enable"),!0===e&&!1===Y?(Y=!0,gt("autoResizeEnabled","Auto Resize enabled")):!1===e&&!0===Y&&(Y=!1),bt(0,0,"autoResize",JSON.stringify(Y)),Y),close(){bt(0,0,"close")},getId:()=>ve,getOrigin:()=>(q("getOrigin()","getParentOrigin()"),_),getParentOrigin:()=>_,getPageInfo(e){if("function"==typeof e)return xe=e,bt(0,0,"pageInfo"),void B("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");xe=null,bt(0,0,"pageInfoStop")},getParentProps:e=>(I(e,"function","parentIframe.getParentProps(callback) callback"),Ne=e,bt(0,0,"parentInfo"),()=>{Ne=null,bt(0,0,"parentInfoStop")}),getParentProperties(e){q("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){I(e,"string","parentIframe.moveToAnchor(anchor) anchor"),pe.findTarget(e)},reset(){yt("parentIframe.reset")},setOffsetSize(e){I(e,"number","parentIframe.setOffsetSize(offset) offset"),Z=e,J=e,gt(c,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){I(e,"number","parentIframe.scrollBy(x, y) x"),I(t,"number","parentIframe.scrollBy(x, y) y"),bt(t,e,"scrollBy")},scrollTo(e,t){I(e,"number","parentIframe.scrollTo(x, y) x"),I(t,"number","parentIframe.scrollTo(x, y) y"),bt(t,e,"scrollTo")},scrollToOffset(e,t){I(e,"number","parentIframe.scrollToOffset(x, y) x"),I(t,"number","parentIframe.scrollToOffset(x, y) y"),bt(t,e,"scrollToOffset")},sendMessage(e,t){t&&I(t,"string","parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),bt(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){de=e,Xe()},setWidthCalculationMethod(e){Ae=e,Ye()},setTargetOrigin(t){I(t,"string","parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),H(`Set targetOrigin: %c${t}`,e.HIGHLIGHT),Me=t},resize(e,t){e&&I(e,"number","parentIframe.resize(customHeight, customWidth) customHeight"),t&&I(t,"number","parentIframe.resize(customHeight, customWidth) customWidth"),gt("parentIframe.resize()",`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){q("size()","resize()"),this.resize(e,t)}}),Ge.parentIFrame=Ge.parentIframe),function(){function t(e){bt(0,0,e.type,`${e.screenY}:${e.screenX}`)}function n(n,o){H(`Add event listener: %c${o}`,e.HIGHLIGHT),f(window.document,n,t)}!0===be&&(n("mouseenter","Mouse Enter"),n("mouseleave","Mouse Leave"))}(),pe=function(){const t=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function o(e){const o=e.getBoundingClientRect(),i=t();return{x:parseInt(o.left,n)+parseInt(i.x,n),y:parseInt(o.top,n)+parseInt(i.y,n)}}function i(t){function n(t){const n=o(t);H(`Moving to in page link (%c#${i}%c) at x: %c${n.x}%c y: %c${n.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),bt(n.y,n.x,"scrollToOffset")}const i=t.split("#")[1]||t,r=decodeURIComponent(i),a=document.getElementById(r)||document.getElementsByName(r)[0];void 0===a?(H(`In page link (#${i}) not found in iFrame, so sending to parent`),bt(0,0,"inPageLink",`#${i}`)):n(a)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&f(e,"click",(t=>{t.preventDefault(),i(e.getAttribute("href"))}))}function s(){f(window,"hashchange",r)}function l(){setTimeout(r,128)}function c(){H("Setting up location.hash handlers"),a(),s(),l()}return pe.enable?1===ye?x("In page linking requires a Professional or Business license. Please see <u>https://iframe-resizer.com/pricing</> for more details."):c():H("In page linking not enabled"),{findTarget:i}}(),void 0===te&&(te=`${ee}px`),Ve("margin",(d="margin",(u=te).includes("-")&&(C(`Negative CSS value ignored for ${d}`),u=""),u)),Ve("background",K),Ve("padding",ne),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const t=e=>e.style.setProperty("height","auto","important");t(document.documentElement),t(document.body),H("Set HTML & body height: %cauto !important",e.HIGHLIGHT)}(),!0!==Y&&H("Auto Resize disabled"),function(e){_e({method:e,eventType:"After Print",eventName:"afterprint"}),_e({method:e,eventType:"Before Print",eventName:"beforeprint"}),_e({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}("add"),function(){const t=new Set,n=[];let o=!1,i=0;const r=e=>{H("Mutations observed:",e.length);for(const n of e){const{addedNodes:e,removedNodes:o}=n;for(const n of e)t.add(n);for(const e of o)t.delete(e)}},a=16,s=2,l=200;let c=1;function d(e){Je(),De(e),e.forEach(tt),e.clear()}function u(){G("mutationObserver");const f=performance.now(),p=f-i,g=a*c+++s;if(p>g&&p<l)return H(`MutationObserver delay: %c${p}ms > ${g}ms`,e.HIGHLIGHT),setTimeout(u,a*c),void(i=f);c=1,n.forEach(r),n.length=0,t.size>0&&d(t),Fe(),qe(),o=!1,gt(m,"Mutation Observed")}function f(e){n.push(e),o||(i=performance.now(),o=!0,requestAnimationFrame(u))}function p(){const e=new window.MutationObserver(f),t=document.querySelector("body"),n={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return H("Setup <body> MutationObserver"),e.observe(t,n),e}p()}(),H("Setup ResizeObserver"),$e=new ResizeObserver(Ke),$e.observe(document.body),et.add(document.body),tt(document.body),oe!==ie&&(H("Setup OverflowObserver"),ze=(e=>{const t=e.side||a,n=e.onChange||y,o={root:e.root,rootMargin:"0px",threshold:1},s=window?.requestAnimationFrame||y,l=(e=!1)=>n(e),c=(e,n)=>0===e||e>n[t],d=(e,t)=>e.toggleAttribute(i,t),u=new IntersectionObserver((function(e){G("observation");for(const o of e){const{boundingClientRect:e,rootBounds:i,target:r}=o,a=e[t],s=c(a,i)&&!((n=r).hidden||null===n.offsetParent||"none"===n.style.display);d(r,s),s&&H("Overflowed:",r)}var n;s(l)}),o),m=new WeakSet;return function(){const e=new window.MutationObserver((()=>{M("Detected changes in element attributes"),l(!0)})),t=document.querySelector("body"),n={attributes:!0,attributeFilter:[r],subtree:!0};H("Setup OverflowMutationObserver"),e.observe(t,n)}(),function(e){H("Attached overflowObservers");for(const t of e){const e=t.nodeType===Node.ELEMENT_NODE,n=m.has(t);!n&&e?(u.observe(t),m.add(t)):E(!n,"Node already observed",t)}}})({onChange:Be,root:document.documentElement,side:oe?a:s})),De(it(document)()),queueMicrotask(Ce),H("Initialization complete"),gt("init","Init message from host page",void 0,void 0,t),document.title&&""!==document.title&&bt(0,0,"title",document.title)}function qe(){we=document.querySelectorAll(`[${i}]:not([${r}]):not([${r}] *)`),se=we.length>0}function Be(e){qe(),(se||e)&&(H("Observed Elements:",we.length),gt(u,"Overflow updated"))}function Fe(){He=document.querySelectorAll(`[${o}]`),le=He.length>0,H(`Tagged elements found: %c${le}`,le?e.HIGHLIGHT:e.FOREGROUND)}function De(e){le||ze(e)}let We=0;function Ue(){const t=document.querySelectorAll(`*[${r}]`);ae=t.length>0,ae&&t.length!==We&&(function(t){const n=1===t.length?"":"s";C(`%c[${r}]%c found on %c${t.length}%c element${n}`,e.BOLD,e.NORMAL,e.BOLD,e.NORMAL)}(t),We=t.length)}function Ve(t,n){void 0!==n&&""!==n&&"null"!==n&&(document.body.style.setProperty(t,n),M(`Set body ${t}: %c${n}`,e.HIGHLIGHT))}function Ze(t,n,o){if(""!==o){H(`${t}: %c${o}`,e.HIGHLIGHT);for(const e of document.querySelectorAll(o))H(`Applying ${n} to:`,e),e.toggleAttribute(n,!0)}}function Je(){Ze("sizeSelector",o,Se),Ze("ignoreSelector",r,ue)}function _e(t){({add(e){function n(){gt(t.eventName,t.eventType)}T[e]=n,f(window,e,n,{passive:!0})},remove(e){const t=T[e];var n,o;delete T[e],n=e,o=t,window.removeEventListener(n,o,!1)}})[t.method](t.eventName),H(`${v(t.method)} event listener: %c${t.eventType}`,e.HIGHLIGHT)}function Qe(t,n,o,i){return n!==t&&(t in o||(C(`${t} is not a valid option for ${i}CalculationMethod.`),t=n),t in O&&x(`<rb>Deprecated ${i}CalculationMethod (${t})</>\n\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${i} calculation method. It is recommended that you remove this option.`),H(`Set ${i} calculation method: %c${t}`,e.HIGHLIGHT)),t}function Xe(){de=Qe(de,L,ct,"height")}function Ye(){Ae=Qe(Ae,V,dt,"width")}function Ke(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;gt(d,`Element resized <${w(t)}>`)}const et=new WeakSet;function tt(t){if(t.nodeType!==Node.ELEMENT_NODE)return;if(!et.has(t)){const n=getComputedStyle(t)?.position;""!==n&&"static"!==n&&($e.observe(t),et.add(t),H(`Attached resizeObserver: %c${w(t)}`,e.HIGHLIGHT))}const n=it(t)();for(const t of n){if(et.has(t)||t?.nodeType!==Node.ELEMENT_NODE)continue;const n=getComputedStyle(t)?.position;""!==n&&"static"!==n&&($e.observe(t),et.add(t),H(`Attached resizeObserver: %c${w(t)}`,e.HIGHLIGHT))}}function nt(e){performance.mark(D);const t=v(e);let n=0,o=document.documentElement,i=le?0:document.documentElement.getBoundingClientRect().bottom;const r=le?He:se?we:it(document)();let a=r.length;for(const t of r)le||!P||t.checkVisibility(p)?(n=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),n>i&&(i=n,o=t)):a-=1;return M(`${t} position calculated from:`,o),performance.mark(W,{detail:{Side:t,len:a,hasTags:le,logging:he}}),i}const ot=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],it=e=>()=>{Ue();const t=["* ","not(head)","not(meta)","not(base)","not(title)","not(script)","not(link)","not(style)","not(map)","not(area)","not(option)","not(optgroup)","not(template)","not(track)","not(wbr)","not(nobr)"];return ae&&t.push(`not([${r}])`,`not([${r}] *)`),e.querySelectorAll(t.join(":"))},rt={height:0,width:0},at={height:0,width:0},st=[e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT];function lt(t){function n(){return at[i]=r,rt[i]=l,r}const o=t===ct,i=o?"height":"width",r=t.boundingClientRect(),a=Math.ceil(r),s=Math.floor(r),l=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(t),c=`HTML: %c${r}px %cPage: %c${l}px`;let d=0;switch(!0){case!t.enabled():return l;case le:M("Found element with data-iframe-size attribute"),d=t.taggedElement();break;case!se&&0===at[i]&&0===rt[i]:M(`Initial page size values: ${c}`,...st),d=n();break;case je&&r===at[i]&&l===rt[i]:M(`Size unchanged: ${c}`,...st),d=Math.max(r,l);break;case 0===r:M(`Page is hidden: ${c}`,...st),d=l;break;case!se&&r!==at[i]&&l<=rt[i]:M(`New <html> size: ${c} `,...st),M(`Previous <html> size: %c${at[i]}px`,e.HIGHLIGHT),d=n();break;case!o:d=t.taggedElement();break;case!se&&r<at[i]:M(`<html> size decreased: ${c}`,...st),d=n();break;case l===s||l===a:M(`<html> size equals page size: ${c}`,...st),d=n();break;case r>l:M(`Page size < <html> size: ${c}`,...st),d=n();break;case se:M("Found element overflowing <html> "),d=t.taggedElement();break;default:M(`Using <html> size: ${c}`,...st),d=n()}return M(`Content ${i}: %c${d}px`,e.HIGHLIGHT),d+=function(t){const n=t.getOffset();return 0!==n&&M(`Page offsetSize: %c${n}px`,e.HIGHLIGHT),n}(t),d}const ct={enabled:()=>oe,getOffset:()=>Z,auto:()=>lt(ct),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,n)+parseInt(t.marginBottom,n)},bodyScroll:()=>document.body.scrollHeight,offset:()=>ct.bodyOffset(),custom:()=>z.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...ot(ct)),min:()=>Math.min(...ot(ct)),grow:()=>ct.max(),lowestElement:()=>nt(a),taggedElement:()=>nt(a)},dt={enabled:()=>ie,getOffset:()=>J,auto:()=>lt(dt),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>z.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...ot(dt)),min:()=>Math.min(...ot(dt)),rightMostElement:()=>nt(s),scroll:()=>Math.max(dt.bodyScroll(),dt.documentElementScroll()),taggedElement:()=>nt(s)},ut=(e,t)=>!(Math.abs(e-t)<=Ee);function mt(e,t,n,o,i){const r=void 0===n?ct[de]():n,a=void 0===o?dt[Ae]():o;switch(!0){case oe&&ut(ce,r)||ie&&ut(Pe,a)||"init"===e:ce=r,Pe=a;case e===c:bt(ce,Pe,e,i);break;case!e!==l&&(oe&&de in U||ie&&Ae in U):yt(t);break;case e===d:case e===u:case e===m:H("No change in content size detected");break;default:M("No change in content size detected")}Q=!1}let ft=!1;const pt=h((()=>N(g(4)))),gt=A(((t,n,o,i,r)=>{X=performance.now(),G(t),Y||t===l?document.hidden?H("Page hidden - Ignored resize request"):(ft||(H(`Resize event: %c${n}`,e.HIGHLIGHT),Q=!0,mt(t,n,o,i,r),requestAnimationFrame((()=>{ft=!1}))),ft=!0):M("Resizing disabled")}));function ht(e){ce=ct[de](),Pe=dt[Ae](),bt(ce,Pe,e)}function yt(t){const n=de;de=L,H(`Reset trigger event: %c${t}`,e.HIGHLIGHT),je?H("TriggerLock blocked calculation"):(je=!0,j("Trigger event lock on"),requestAnimationFrame((()=>{je=!1,j("Trigger event lock off")}))),ht("reset"),de=n}const bt=A((function(t,n,o,i,r){ye<-1||(G(o),void 0!==r?H(`Message targetOrigin: %c${r}`,e.HIGHLIGHT):r=Me,function(){const a=`${ve}:${t}:${n}:${o}${void 0===i?"":`:${i}`}`;if(Oe)try{window.parent.iframeParentListener(R+a)}catch(e){if(1!==ye)throw e;return void pt()}else Te.postMessage(R+a,r);Q&&M(function(){const e=b(performance.now()-X);return"init"===o?`Initialised iFrame in %c${e}ms`:`Size calculated in %c${e}ms`}(),e.HIGHLIGHT),M("Sending message to host page via "+(Oe?"sameOrigin":"postMessage")),M(`%c${a}`,e.ITALIC)}(),k())})),vt=A((function(e){const{freeze:t}=Object,{parse:n}=JSON,o=e=>bt(0,0,`${e}Stop`),i={init:function(){fe=e.data,Te=e.source,_=e.origin,Re(),re=!1,setTimeout((()=>{me=!1}),128)},reset(){me?H("Page reset ignored by init"):(H("Page size reset by host page"),ht("resetPage"))},resize(){gt(l,"Parent window requested size check")},moveToAnchor(){pe.findTarget(a())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=a();H(`PageInfo received from parent: ${e}`),xe?setTimeout((()=>xe(n(e)))):o("pageInfo")},parentInfo(){const e=a();H(`ParentInfo received from parent: ${e}`),Ne?setTimeout((()=>Ne(t(n(e))))):o("parentInfo")},message(){const e=a();H(`onMessage called from parent: ${e}`),setTimeout((()=>Le(n(e))))}},r=()=>e.data.split("]")[1].split(":")[0],a=()=>e.data.slice(e.data.indexOf(":")+1),s=()=>e.data.split(":")[2]in{true:1,false:1};function c(){const t=r();t in i?i[t]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||s()||C(`Unexpected message (${e.data})`)}R===`${e.data}`.slice(0,13)&&(G(r()),!1!==re?s()?i.init():H(`Ignored message of type "${r()}". Received before initialization.`):c())}));function zt(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"iframeChildListener"in window?C("Already setup"):(window.iframeChildListener=e=>setTimeout((()=>vt({data:e,sameOrigin:!0}))),f(window,"message",vt),f(window,"readystatechange",zt),zt())}();
|
|
21
21
|
//# sourceMappingURL=index.cjs.js.map
|