@iframe-resizer/child 5.5.0-beta.2 → 5.5.0-beta.4
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/iframe-resizer.child.d.ts +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 +1 -1
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ declare module '@iframe-resizer/child' {
|
|
|
31
31
|
onBeforeResize?(newSize: number): number
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Receive message posted from the parent page with the iframe.
|
|
34
|
+
* Receive message posted from the parent page with the iframe.iframeResizer.sendMessage() method.
|
|
35
35
|
*/
|
|
36
36
|
onMessage?(message: any): void
|
|
37
37
|
|
package/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/child 5.5.0-beta.
|
|
4
|
+
* @module iframe-resizer/child 5.5.0-beta.4 (cjs) - 2025-07-29
|
|
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.5.0-beta.2",n=10,o="data-iframe-size",r="data-iframe-overflowed",i="data-iframe-ignore",a="bottom",s="right",l="autoResizeEnabled",c=Symbol("sizeChanged"),u="manualResize",d="parentResize",m={[u]:1,[d]:1},f="setOffsetSize",p="resizeObserver",h="overflowObserver",g="mutationObserver",y="visibilityObserver",b="none",v="No change in content size detected",z="init",w=(e,t,n,o)=>e.addEventListener(t,n,o||!1),I=["<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 $=e=>(e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)))(I[e]),S=(e,...t)=>setTimeout(()=>e(...t),0),H=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},T=e=>e,O=e=>Math.round(1e3*e)/1e3,E=e=>e.charAt(0).toUpperCase()+e.slice(1),M=e=>""!=`${e}`&&void 0!==e;function k(e){switch(!0){case!M(e):return"";case M(e.id):return`${e.nodeName}#${e.id}`;case M(e.name):return`${e.nodeName} (${e.name}`;case M(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}const j=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${E(t)}`)};let G=!0;var L;const A=(L=e,L?.__esModule?L.default:L)({label:"iframeResizer(child)"});const R=(C="log",(...e)=>!G||A[C](...e));var C;const x=R,{assert:P,debug:N,endAutoGroup:B,error:q,errorBoundary:D,event:F,label:W,purge:U,warn:V}=A,Z=e=>{return A.warn((t=T,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},J=Z,_=(e=>(t,n="renamed to")=>(o,r,i="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${r}</>. ${i}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))((e,t)=>Z(t)),Q=_("Method"),Y=_("Method","replaced with"),X=_("Option"),K=["min-height","min-width","max-height","max-width"],ee=new Set,te=e=>e.tagName?e.tagName.toLowerCase():"unknown",ne=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),oe=(e,t)=>{return(n=ne(e,t))&&"0px"!==n&&"auto"!==n&&"none"!==n;var n};function re({href:e}){ee.has(e)||(R("Unable to access stylesheet:",e),ee.add(e))}const ie=(e,t)=>function(e,t){const n=e.style[t];return n?{source:"an inline style attribute",value:n}:null}(e,t)||function(e,t){for(const n of document.styleSheets)try{for(const o of n.cssRules||[])if(o.selectorText&&e.matches(o.selectorText)){const e=o.style[t];if(e)return{source:"STYLE"===n.ownerNode.tagName?"an inline <style> block":`stylesheet (${n.href})`,value:e}}}catch(e){re(n)}return{source:"cross-origin stylesheet",value:ne(e,t)}}(e,t),ae=(e,t)=>{const{source:n,value:o}=ie(e,t),r=te(e);Z(`The <b>${t}</> CSS property is set to <b>${o}</> on the <b><${r}></> element via ${n}. This may cause issues with the correct operation of <i>iframe-resizer</>.\n\nIf you wish to restrict the size of the iframe, then you should set this property on the iframe element itself, not the content inside it.`)};function se(){for(const e of[document.documentElement,document.body])for(const t of K)R(`Checking <${te(e)}> for blocking CSS: ${t}`),oe(e,t)&&ae(e,t)}const le=e=>t=>void 0===t?void 0:e(t),ce=le(e=>"true"===e),ue=le(Number),de=e=>e.hidden||null===e.offsetParent||"none"===e.style.display,me=e=>{const t=e.side,n=e.onChange||T,o={root:e.root,rootMargin:"0px",threshold:1},i=window?.requestAnimationFrame||T,a=(e=!1)=>n(e),s=(e,n)=>0===e||e>n[t],l=(e,t)=>e.toggleAttribute(r,t);const c=new IntersectionObserver(function(e){for(const n of e){const{boundingClientRect:e,rootBounds:o,target:r}=n,i=e[t],a=s(i,o)&&!de(r);l(r,a)}i(a)},o),u=new WeakSet;return function(e){R("Attached overflowObservers");for(const t of e){const e=t.nodeType===Node.ELEMENT_NODE,n=u.has(t);!n&&e?(c.observe(t),u.add(t)):P(!n,"Node already observed",t)}}},fe="--ifr-start",pe="--ifr-end",he=[],ge=new WeakSet,ye=e=>"object"==typeof e&&ge.add(e);let be={},ve=0;const ze=setInterval(()=>{if(he.length<10)return;if(be.hasTags&&be.len<25)return;he.sort();const e=Math.min(he.reduce((e,t)=>e+t,0)/he.length,he[Math.floor(he.length/2)]),t=O(e);t>ve&&(ve=t,F("performanceObserver"),R("Mean time:",O(he[Math.floor(he.length/2)])),R("Median time:",O(he.reduce((e,t)=>e+t,0)/he.length)),R("Average time:",t),R("Max time:",O(Math.max(...he)))),e<=4||(clearInterval(ze),Z(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${O(e)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${be.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},5e3);function we(e){e.getEntries().forEach(e=>{if(e.name===pe){const{duration:t}=performance.measure("--ifr-measure",fe,pe);be=e.detail,he.push(t),he.length>100&&he.shift()}})}function Ie(){new PerformanceObserver(we).observe({entryTypes:["mark"]}),ye(document.documentElement),ye(document.body)}"undefined"!=typeof document&&"undefined"!=typeof PerformanceObserver&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",Ie):Ie());const $e=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},Se=$e("function"),He=$e("number"),Te=$e("string");"undefined"!=typeof window&&function(){const I={height:()=>(V("Custom height calculation function not defined"),Ot.auto()),width:()=>(V("Custom width calculation function not defined"),Et.auto())},M={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,boundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},L={},C="auto",P="[iFrameSizer]",q="scroll";let U,_,K,ee,te,ne,oe,re=!0,ie="",ae=0,le="",de="",he=!1,ge=!0,ye=!1,be=!0,ve=!1,ze=!1,we=!1,Ie=1,$e=C,Oe="",Ee=!0,Me={},ke=!1,je=!0,Ge=!1,Le="",Ae=0,Re=!1,Ce="",xe=T,Pe=[],Ne="child",Be=null,qe=!1,De="",Fe=[],We=window.parent,Ue="*",Ve=0,Ze=!1,Je=1,_e=q,Qe=window,Ye=()=>{V("onMessage function not defined")},Xe=()=>{},Ke=null,et=null;function tt(r){var c,d,m;!function(e){Ce=e[0]??Ce,ae=ue(e[1])??ae,ye=ce(e[2])??ye,Ge=ce(e[3])??Ge,re=ce(e[6])??re,le=e[7]??le,$e=e[8]??$e,ie=e[9]??ie,de=e[10]??de,Ve=ue(e[11])??Ve,Me.enable=ce(e[12])??!1,Ne=e[13]??Ne,_e=e[14]??_e,Re=ce(e[15])??Re,U=ue(e[16])??U,_=ue(e[17])??_,ge=ce(e[18])??ge,Le=e[19]??Le,ne=e[20]??ne,Ae=ue(e[21])??Ae,je=ce(e[23])??je}(r),c={id:Ce,enabled:Ge,expand:je},A.label(`${c.id}`),A.expand(c.expand),G=c.enabled,R(`Initialising iframe v${t} ${window.location.href}`),function(){function t(e){R("Reading data from page:",e),oe=Se(e,"onBeforeResize")??oe,Ye=Se(e,"onMessage")??Ye,Xe=Se(e,"onReady")??Xe,"number"==typeof e?.offset&&(X("offset","offsetSize"),ge&&(U=He(e,"offset")??U),ye&&(_=He(e,"offset")??_)),"number"==typeof e?.offsetSize&&(ge&&(U=He(e,"offsetSize")??U),ye&&(_=He(e,"offsetSize")??_)),Oe=Te(e,"ignoreSelector")??Oe,De=Te(e,"sizeSelector")??De,Ue=Te(e,"targetOrigin")??Ue,$e=e?.heightCalculationMethod||$e,_e=e?.widthCalculationMethod||_e}function n(e,t){return"function"==typeof e&&(Z(`<rb>Deprecated Option(${t}CalculationMethod)</>\n\nThe use of <b>${t}CalculationMethod</> as a function is deprecated and will be removed in a future version of <i>iframe-resizer</>. Please use the new <b>onBeforeResize</> event handler instead.\n\nSee <u>https://iframe-resizer.com/api/child</> for more details.`),I[t]=e,e="custom"),e}if(1===Ae)return;const o=window.iframeResizer||window.iFrameResizer;"object"==typeof o&&(t(o),$e=n($e,"height"),_e=n(_e,"width"),x(`Set targetOrigin for parent: %c${Ue}`,e.HIGHLIGHT))}(),dt(),function(){try{qe=1===Ae||"iframeParentListener"in window.parent}catch(e){R("Cross domain iframe detected")}}(),ye===ge&&(he=!0),Ae<0?J(`${$(Ae+2)}${$(2)}`):ne?.codePointAt(0)>4||Ae<2&&J($(3)),ne&&""!==ne&&"false"!==ne?ne!==t&&Z(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${ne} - Child page: ${t}.\n`):Z("<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"),pt(),ht(),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&&Z("<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&&Z("<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"),it(),he||se(),1!==Ae&&(Qe.parentIframe=Object.freeze({autoResize:e=>(j(e,"boolean","parentIframe.autoResize(enable) enable"),!1===ye&&!1===ge?(F(l),Z(`Auto Resize can not be changed when <b>direction</> is set to '${b}'.`),!1):(!0===e&&!1===re?(re=!0,queueMicrotask(()=>At(l,"Auto Resize enabled"))):!1===e&&!0===re&&(re=!1),Ct(0,0,"autoResize",JSON.stringify(re)),re)),close(){Ct(0,0,"close")},getId:()=>Ce,getOrigin:()=>(Q("getOrigin()","getParentOrigin()"),K),getParentOrigin:()=>K,getPageInfo(e){if("function"==typeof e)return Ke=e,Ct(0,0,"pageInfo"),void Y("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");Ke=null,Ct(0,0,"pageInfoStop")},getParentProps:e=>(j(e,"function","parentIframe.getParentProps(callback) callback"),et=e,Ct(0,0,"parentInfo"),()=>{et=null,Ct(0,0,"parentInfoStop")}),getParentProperties(e){Q("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){j(e,"string","parentIframe.moveToAnchor(anchor) anchor"),Me.findTarget(e)},reset(){!function(){const t=$e;$e=C,R("Reset trigger event: %cparentIframe.reset",e.HIGHLIGHT),Ze?R("TriggerLock blocked calculation"):(Ze=!0,N("Trigger event lock on"),requestAnimationFrame(()=>{Ze=!1,N("Trigger event lock off")})),Rt("reset"),$e=t}()},setOffsetSize(e){j(e,"number","parentIframe.setOffsetSize(offset) offset"),U=e,_=e,At(f,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){j(e,"number","parentIframe.scrollBy(x, y) x"),j(t,"number","parentIframe.scrollBy(x, y) y"),Ct(t,e,"scrollBy")},scrollTo(e,t){j(e,"number","parentIframe.scrollTo(x, y) x"),j(t,"number","parentIframe.scrollTo(x, y) y"),Ct(t,e,"scrollTo")},scrollToOffset(e,t){j(e,"number","parentIframe.scrollToOffset(x, y) x"),j(t,"number","parentIframe.scrollToOffset(x, y) y"),Ct(t,e,"scrollToOffset")},sendMessage(e,t){t&&j(t,"string","parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),Ct(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){$e=e,pt()},setWidthCalculationMethod(e){_e=e,ht()},setTargetOrigin(t){j(t,"string","parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),R(`Set targetOrigin: %c${t}`,e.HIGHLIGHT),Ue=t},resize(e,t){e&&j(e,"number","parentIframe.resize(customHeight, customWidth) customHeight"),t&&j(t,"number","parentIframe.resize(customHeight, customWidth) customWidth"),At(u,`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){Q("size()","resize()"),this.resize(e,t)}}),Qe.parentIFrame=Qe.parentIframe),function(){function t(e){Ct(0,0,e.type,`${e.screenY}:${e.screenX}`)}function n(n,o){R(`Add event listener: %c${o}`,e.HIGHLIGHT),w(window.document,n,t)}!0===Re&&(n("mouseenter","Mouse Enter"),n("mouseleave","Mouse Leave"))}(),Me=function(){const t=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function o(e){const o=e.getBoundingClientRect(),r=t();return{x:parseInt(o.left,n)+parseInt(r.x,n),y:parseInt(o.top,n)+parseInt(r.y,n)}}function r(t){function n(t){const n=o(t);R(`Moving to in page link (%c#${r}%c) at x: %c${n.x}%c y: %c${n.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),Ct(n.y,n.x,"scrollToOffset")}const r=t.split("#")[1]||t,i=decodeURIComponent(r),a=document.getElementById(i)||document.getElementsByName(i)[0];void 0===a?(R(`In page link (#${r}) not found in iFrame, so sending to parent`),Ct(0,0,"inPageLink",`#${r}`)):n(a)}function i(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&r(t)}function a(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&w(e,"click",t=>{t.preventDefault(),r(e.getAttribute("href"))})}function s(){w(window,"hashchange",i)}function l(){setTimeout(i,128)}function c(){R("Setting up location.hash handlers"),a(),s(),l()}return Me.enable?1===Ae?Z("In page linking requires a Professional or Business license. Please see <u>https://iframe-resizer.com/pricing</> for more details."):c():R("In page linking not enabled"),{findTarget:r}}(),void 0===le&&(le=`${ae}px`),ct("margin",(d="margin",(m=le).includes("-")&&(V(`Negative CSS value ignored for ${d}`),m=""),m)),ct("background",ie),ct("padding",de),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),he||function(){const t=e=>e.style.setProperty("height","auto","important");t(document.documentElement),t(document.body),R("Set HTML & body height: %cauto !important",e.HIGHLIGHT)}(),!0!==re&&R("Auto Resize disabled"),function(e){mt({method:e,eventType:"After Print",eventName:"afterprint"}),mt({method:e,eventType:"Before Print",eventName:"beforeprint"}),mt({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}("add"),function(){const t=new Set,n=[];let r=!1,a=0;const s=e=>{x("Mutations observed:",e);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)}},l=16,c=2,u=200;let d=1;function m(e){dt(),at(e),e.forEach(bt),e.clear()}function f(){const o=performance.now(),i=o-a,p=l*d+++c;if(i>p&&i<u)return x("Backed off due to heavy workload on callStack"),R(`Delay: %c${O(i)}ms %c> Delay limit: %c${p}ms`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),setTimeout(f,l*d),void(a=o);d=1,n.forEach(s),n.length=0,t.size>0&&m(t),it(),ot(),r=!1,At(g,"Mutation Observed")}function p(e){n.push(e),r||(a=performance.now(),r=!0,requestAnimationFrame(f))}function h(){const e=new window.MutationObserver(p),t=document.querySelector("body"),n={attributes:!0,attributeFilter:[i,o],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return R("Setup <body> MutationObserver"),e.observe(t,n),e}h()}(),ge!==ye&&(R("Setup OverflowObserver"),xe=me({onChange:rt,root:document.documentElement,side:ge?a:s})),at(It(document)()),R("Setup ResizeObserver"),Be=new ResizeObserver(gt),Be.observe(document.body),yt.add(document.body),bt(document.body),R("Setup VisibilityObserver"),function(e){const t=new IntersectionObserver(t=>e(t[0].isIntersecting),{threshold:0}),n=document.documentElement;t.observe(n)}(vt),nt(H(Xe)),R("Initialization complete"),At(z,"Init message from host page",void 0,void 0,t),document.title&&""!==document.title&&Ct(0,0,"title",document.title)}function nt(e){"complete"===document.readyState?S(e):w(document,"readystatechange",()=>nt(e))}function ot(){const e=document.querySelectorAll(`[${r}]`);Pe=Array.from(e).filter(e=>!e.closest(`[${i}]`)),ze=Pe.length>0}function rt(e){ot(),(ze||e)&&(ze?x("Overflowed Elements:",...Pe):x("Overflow removed"),At(h,"Overflow updated"))}function it(){Fe=document.querySelectorAll(`[${o}]`),we=Fe.length>0,R(`Tagged elements found: %c${we}`,e.HIGHLIGHT)}function at(e){we||xe(e)}let st=0;function lt(){const t=document.querySelectorAll(`*[${i}]`);ve=t.length>0,ve&&t.length!==st&&(function(t){const n=1===t.length?"":"s";V(`%c[${i}]%c found on %c${t.length}%c element${n}`,e.BOLD,e.NORMAL,e.BOLD,e.NORMAL)}(t),st=t.length)}function ct(t,n){void 0!==n&&""!==n&&"null"!==n&&(document.body.style.setProperty(t,n),x(`Set body ${t}: %c${n}`,e.HIGHLIGHT))}function ut(t,n,o){if(""!==o){R(`${t}: %c${o}`,e.HIGHLIGHT);for(const e of document.querySelectorAll(o))R(`Applying ${n} to:`,e),e.toggleAttribute(n,!0)}}function dt(){ut("sizeSelector",o,De),ut("ignoreSelector",i,Oe)}function mt(t){({add(e){function n(){At(t.eventName,t.eventType)}L[e]=n,w(window,e,n,{passive:!0})},remove(e){const t=L[e];var n,o;delete L[e],n=e,o=t,window.removeEventListener(n,o,!1)}})[t.method](t.eventName),R(`${E(t.method)} event listener: %c${t.eventType}`,e.HIGHLIGHT)}function ft(t,n,o,r){return n!==t&&(t in o||(V(`${t} is not a valid option for ${r}CalculationMethod.`),t=n),t in M)&&Z(`<rb>Deprecated ${r}CalculationMethod (${t})</>\n\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${r} calculation method. It is recommended that you ${ne?"remove this option.":"set this option to <b>'auto'</> when using an older version of <i>iframe-resizer</> on the parent page."}`),R(`Set ${r} calculation method: %c${t}`,e.HIGHLIGHT),t}function pt(){$e=ft($e,C,Ot,"height")}function ht(){_e=ft(_e,q,Et,"width")}function gt(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;At(p,`Element resized <${k(t)}>`)}const yt=new WeakSet;function bt(t){if(t.nodeType!==Node.ELEMENT_NODE)return;if(!yt.has(t)){const n=getComputedStyle(t)?.position;""!==n&&"static"!==n&&(Be.observe(t),yt.add(t),R(`Attached resizeObserver: %c${k(t)}`,e.HIGHLIGHT))}const n=It(t)();for(const t of n){if(yt.has(t)||t?.nodeType!==Node.ELEMENT_NODE)continue;const n=getComputedStyle(t)?.position;""!==n&&"static"!==n&&(Be.observe(t),yt.add(t),R(`Attached resizeObserver: %c${k(t)}`,e.HIGHLIGHT))}}function vt(t){R(`Visible: %c${t}`,e.HIGHLIGHT),ke=!t,At(y,"Visibility changed")}function zt(e){performance.mark(fe);const t=E(e);let n=0,o=document.documentElement,r=we?0:document.documentElement.getBoundingClientRect().bottom;const i=we?Fe:ze?Pe:It(document)();for(const t of i)n=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),n>r&&(r=n,o=t);return x(`${t} position calculated from:`,o),performance.mark(pe,{detail:{hasTags:we,len:i.length,logging:Ge,Side:t}}),r}const wt=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],It=e=>()=>{lt();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 ve&&t.push(`not([${i}])`,`not([${i}] *)`),e.querySelectorAll(t.join(":"))},$t={height:0,width:0},St={height:0,width:0},Ht=[e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT];function Tt(t){function n(){return St[r]=i,$t[r]=l,i}const o=t===Ot,r=o?"height":"width",i=t.boundingClientRect(),a=Math.ceil(i),s=Math.floor(i),l=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(t),c=`HTML: %c${i}px %cPage: %c${l}px`;let u=0;switch(!0){case!t.enabled():return l;case we:x("Found element with data-iframe-size attribute"),u=t.taggedElement();break;case!ze&&0===St[r]&&0===$t[r]:x(`Initial page size values: ${c}`,...Ht),u=n();break;case Ze&&i===St[r]&&l===$t[r]:x(`Size unchanged: ${c}`,...Ht),u=Math.max(i,l);break;case 0===i:x(`Page is hidden: ${c}`,...Ht),u=l;break;case!ze&&i!==St[r]&&l<=$t[r]:x(`New <html> size: ${c} `,...Ht),x(`Previous <html> size: %c${St[r]}px`,e.HIGHLIGHT),u=n();break;case!o:u=t.taggedElement();break;case!ze&&i<St[r]:x(`<html> size decreased: ${c}`,...Ht),u=n();break;case l===s||l===a:x(`<html> size equals page size: ${c}`,...Ht),u=n();break;case i>l:x(`Page size < <html> size: ${c}`,...Ht),u=n();break;case ze:x("Found element overflowing <html> "),u=t.taggedElement();break;default:x(`Using <html> size: ${c}`,...Ht),u=n()}return x(`Content ${r}: %c${u}px`,e.HIGHLIGHT),u+=function(t){const n=t.getOffset();return 0!==n&&x(`Page offsetSize: %c${n}px`,e.HIGHLIGHT),n}(t),u}const Ot={enabled:()=>ge,getOffset:()=>U,auto:()=>Tt(Ot),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,n)+parseInt(t.marginBottom,n)},bodyScroll:()=>document.body.scrollHeight,offset:()=>Ot.bodyOffset(),custom:()=>I.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...wt(Ot)),min:()=>Math.min(...wt(Ot)),grow:()=>Ot.max(),lowestElement:()=>zt(a),taggedElement:()=>zt(a)},Et={enabled:()=>ye,getOffset:()=>_,auto:()=>Tt(Et),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>I.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...wt(Et)),min:()=>Math.min(...wt(Et)),rightMostElement:()=>zt(s),scroll:()=>Math.max(Et.bodyScroll(),Et.documentElementScroll()),taggedElement:()=>zt(s)},Mt=(e,t)=>!(Math.abs(e-t)<=Ve);function kt(e,t){const n=e[t]();return e.enabled()&&void 0!==oe?function(e){const t=oe(e);if(void 0===t)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(t))throw new TypeError(`Invalid value returned from onBeforeResize(): ${t}, expected Number`);return t}(n):n}let jt=!1;const Gt=H(()=>J($(4)));let Lt=!1;const At=D((t,n,o,r,i)=>{if(te=performance.now(),ee=!0,F(t),!0!==jt){if(!re&&!(t in m))return x("Resizing disabled"),void B();if(ke){if(!0===Lt)return;return R("Iframe hidden - Ignored resize request"),void(Lt=!0)}Lt=!1,jt=!0,requestAnimationFrame(()=>{jt=!1}),function(t,n,o,r,i){const a=o??kt(Ot,$e),s=r??kt(Et,_e),u=ge&&Mt(Ie,a)||ye&&Mt(Je,s)?c:t;switch(R(`Resize event: %c${n}`,e.HIGHLIGHT),u){case z:case l:case c:Ie=a,Je=s;case f:Ct(Ie,Je,t,i);break;case h:case g:case p:case y:R(v);break;default:x(v)}ee=!1}(t,n,o,r,i)}});function Rt(e){Ie=Ot[$e](),Je=Et[_e](),Ct(Ie,Je,e)}const Ct=D(function(t,n,o,r,i){Ae<-1||(F(o),void 0!==i?R(`Message targetOrigin: %c${i}`,e.HIGHLIGHT):i=Ue,function(){const a=`${Ce}:${t}:${n}:${o}${void 0===r?"":`:${r}`}`;if(qe)try{window.parent.iframeParentListener(P+a)}catch(e){if(1!==Ae)throw e;return void Gt()}else We.postMessage(P+a,i);ee&&R(function(){const e=O(performance.now()-te);return o===z?`Initialised iFrame in %c${e}ms`:`Size calculated in %c${e}ms`}(),e.HIGHLIGHT),x(`Sending message to parent page via ${qe?"sameOrigin":"postMessage"}: %c%c${a}`,e.ITALIC,e.HIGHLIGHT)}(),B())}),xt=D(function(t){F("onMessage");const{freeze:n}=Object,{parse:o}=JSON,r=e=>n(o(e)),i=e=>Ct(0,0,`${e}Stop`),a={init:function(){if("loading"===document.readyState)return void R("Page not ready, ignoring init message");const e=t.data.slice(13).split(":");We=t.source,K=t.origin,tt(e),be=!1,setTimeout(()=>{Ee=!1},128)},reset(){Ee?R("Page reset ignored by init"):(R("Page size reset by host page"),Rt("resetPage"))},resize(){R("Resize requested by host page"),At(d,"Parent window requested size check")},moveToAnchor(){Me.findTarget(l())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=l();R("PageInfo received from parent:",r(e)),Ke?S(Ke,o(e)):i("pageInfo")},parentInfo(){const e=r(l());R("ParentInfo received from parent:",e),et?S(et,e):i("parentInfo")},message(){const t=l();R("onMessage called from parent:%c",e.HIGHLIGHT,r(t)),S(Ye,o(t))}},s=()=>t.data.split("]")[1].split(":")[0],l=()=>t.data.slice(t.data.indexOf(":")+1),c=()=>t.data.split(":")[2]in{true:1,false:1};function u(){const e=s();F(e),e in a?a[e]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||c()||V(`Unexpected message (${t.data})`)}P===`${t.data}`.slice(0,13)&&function(){if(!1!==be)return c()?(W(s()),F(z),void a.init()):void R(`Ignored message of type "${s()}". Received before initialization.`);u()}()});function Pt(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"iframeChildListener"in window?V("Already setup"):(window.iframeChildListener=e=>setTimeout(()=>xt({data:e,sameOrigin:!0})),w(window,"message",xt),w(window,"readystatechange",Pt),Pt())}();
|
|
20
|
+
"use strict";const e=require("auto-console-group"),t="5.5.0-beta.4",n="iframeResizer",o=10,r="data-iframe-size",i="data-iframe-overflowed",a="data-iframe-ignore",s="bottom",l="right",c="autoResizeEnabled",u=Symbol("sizeChanged"),d="manualResize",f={},m="setOffsetSize",p="resizeObserver",h="overflowObserver",g="mutationObserver",y="visibilityObserver",b="none",v="No change in content size detected",z="init",w=(e,t,n,o)=>e.addEventListener(t,n,o||!1),$=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let o,r=0;r<e.length;r++)o=e.codePointAt(r),t=Math.imul(t^o,2246822519),n=Math.imul(n^o,3266489917);return t^=Math.imul(t^n>>>15,1935289751),n^=Math.imul(n^t>>>15,3405138345),t^=n>>>16,n^=t>>>16,(2097152*(n>>>0)+(t>>>11)).toString(36)},I=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),O=["spjluzl","rlf","clyzpvu"],S=["<yi>Puchspk Spjluzl Rlf</><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."],T=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],H=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),M=e=>I(S[e]),k=e=>{const t=e[I(O[0])]||e[I(O[1])]||e[I(O[2])];if(!t)return-1;const n=t.split("-");let o=function(e=""){let t=-2;const n=$(I(e));return n in H&&(t=H[n]),t}(n[0]);return 0===o||(e=>e[2]===$(e[0]+e[1]))(n)||(o=-2),o},j=(e,...t)=>setTimeout(()=>e(...t),0),E=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},A=e=>e,R=e=>Math.round(1e3*e)/1e3,L=e=>e.charAt(0).toUpperCase()+e.slice(1),N=e=>""!=`${e}`&&void 0!==e;const x=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${L(t)}`)};let G=!0,P=n;var C;const q=(C=e,C?.__esModule?C.default:C)({label:`${n}(child)`});const B=(F="log",(...e)=>!G||q[F](...e));var F;const W=B;const{assert:D,debug:U,endAutoGroup:V,error:Z,errorBoundary:J,event:Q,label:_,purge:Y,warn:X}=q,K=e=>{return q.warn((t=A,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},ee=K,te=(e=>(t,n="renamed to")=>(o,r,i="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${r}</>. ${i}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))((e,t)=>K(t)),ne=te("Method"),oe=te("Method","replaced with"),re=te("Option"),ie=["min-height","min-width","max-height","max-width"],ae=new Set,se=e=>e.tagName?e.tagName.toLowerCase():"unknown",le=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),ce=(e,t)=>{return(n=le(e,t))&&"0px"!==n&&"auto"!==n&&"none"!==n;var n};function ue({href:e}){ae.has(e)||(B("Unable to access stylesheet:",e),ae.add(e))}const de=(e,t)=>function(e,t){const n=e.style[t];return n?{source:"an inline style attribute",value:n}:null}(e,t)||function(e,t){for(const n of document.styleSheets)try{for(const o of n.cssRules||[])if(o.selectorText&&e.matches(o.selectorText)){const e=o.style[t];if(e)return{source:"STYLE"===n.ownerNode.tagName?"an inline <style> block":`stylesheet (${n.href})`,value:e}}}catch(e){ue(n)}return{source:"cross-origin stylesheet",value:le(e,t)}}(e,t),fe=(e,t)=>{const{source:n,value:o}=de(e,t),r=se(e);K(`The <b>${t}</> CSS property is set to <b>${o}</> on the <b><${r}></> element via ${n}. This may cause issues with the correct operation of <i>iframe-resizer</>.\n\nIf you wish to restrict the size of the iframe, then you should set this property on the iframe element itself, not the content inside it.`)};function me(){for(const e of[document.documentElement,document.body])for(const t of ie)B(`Checking <${se(e)}> for blocking CSS: ${t}`),ce(e,t)&&fe(e,t)}const pe=e=>t=>void 0===t?void 0:e(t),he=pe(e=>"true"===e),ge=pe(Number),ye=new Set,be=new Set,ve=[];let ze,we=1,$e=!1,Ie=0;const Oe=e=>{B("Mutations:",e);for(const t of e){const{addedNodes:e,removedNodes:n}=t;for(const t of e)ye.add(t);for(const e of n)ye.has(e)?ye.delete(e):be.add(e)}};function Se(e){ve.push(e),$e||(Ie=performance.now(),$e=!0,requestAnimationFrame(ze))}function Te(e){const t=new window.MutationObserver(Se),n=document.querySelector("body"),o={attributes:!0,attributeFilter:[a,r],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return ze=(e=>()=>{const t=performance.now(),n=t-Ie,o=16*we+++2;if(n>o&&n<200)return Q("MutationObserver"),K(`<rb>Update Delayed</> \n<i>iframe-resizer</> has delayed updating the page due heavy workload on callStack\n \nEventLoop busy time: ${R(n)}ms > limit: ${o}ms`),setTimeout(ze,16*we),void(Ie=t);we=1,ve.forEach(Oe),ve.length=0,e({addedMutations:ye,removedMutations:be}),$e=!1,ye.clear(),be.clear()})(e),t.observe(n,o),W("Attached MutationObserver to body"),t}const He=(t,n=!0)=>o=>{o>0&&W(`${n?"At":"De"}tached ${t}Observer ${n?"to":"from"} %c${o}%c element${1===o?"":"s"}`,e.HIGHLIGHT,e.NORMAL)},Me=(e,t,n)=>e=>{let o=0;for(const r of e)n.has(r)&&(t.unobserve(r),n.delete(r),o+=1);return o},ke=e=>e.hidden||null===e.offsetParent||"none"===e.style.display,je=(e,t)=>{const n=t.side,o={root:t.root,rootMargin:"0px",threshold:1},r=window?.requestAnimationFrame||A,a=(t=!1)=>e(t),s=(e,t)=>0===e||e>t[n],l=(e,t)=>e.toggleAttribute(i,t);const c=new IntersectionObserver(function(e){for(const t of e){const{boundingClientRect:e,rootBounds:o,target:r}=t,i=e[n],a=s(i,o)&&!ke(r);l(r,a)}r(a)},o),u=new WeakSet;return{attachObservers:function(e){let t=0;for(const n of e){const e=n.nodeType===Node.ELEMENT_NODE,o=u.has(n);e&&(D(!o,"Node already observed for overflow",n),o||(c.observe(n),u.add(n),t+=1))}return t},detachObservers:Me(0,c,u)}},Ee="--ifr-start",Ae="--ifr-end",Re=[],Le=new WeakSet,Ne=e=>"object"==typeof e&&Le.add(e);let xe={},Ge=0;function Pe(e){e.getEntries().forEach(e=>{if(e.name===Ae){const{duration:t}=performance.measure("--ifr-measure",Ee,Ae);xe=e.detail,Re.push(t),Re.length>100&&Re.shift()}})}function Ce(){W("Attached PerformanceObserver to page");new PerformanceObserver(Pe).observe({entryTypes:["mark"]}),Ne(document.documentElement),Ne(document.body),function(){const e=setInterval(()=>{if(Re.length<10)return;if(xe.hasTags&&xe.len<25)return;Re.sort();const t=Math.min(Re.reduce((e,t)=>e+t,0)/Re.length,Re[Math.floor(Re.length/2)]),n=R(t);n>Ge&&(Ge=n,Q("performanceObserver"),B("Mean time:",R(Re[Math.floor(Re.length/2)])),B("Median time:",R(Re.reduce((e,t)=>e+t,0)/Re.length)),B("Average time:",n),B("Max time:",R(Math.max(...Re)))),t<=4||(clearInterval(e),K(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${R(t)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${xe.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},5e3)}()}const qe=He("Resize"),Be=new WeakSet;let Fe;function We(e){let t=0;for(const n of e){const e=n.nodeType===Node.ELEMENT_NODE,o=Be.has(n);if(!e)continue;const r=getComputedStyle(n)?.position;""!==r&&"static"!==r&&(D(!o,"Node already observed for resize",n),o||(Fe.observe(n),Be.add(n),t+=1))}qe(t)}const De=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},Ue=De("function"),Ve=De("number"),Ze=De("string");"undefined"!=typeof window&&function(){const $={height:()=>(X("Custom height calculation function not defined"),qt.auto()),width:()=>(X("Custom width calculation function not defined"),Bt.auto())},S={},H={},A="auto",C="[iFrameSizer]",F="scroll";let D,Z,Y,te,ie,ae,se,le,ce,ue,de,fe=!0,pe="",ye=0,be="",ve="",ze=!1,we=!0,$e=!1,Ie=!0,Oe=!1,Se=!1,ke=!1,Re=1,Le=A,Ne="",xe=!0,Ge={},Pe=!1,qe=!0,De=!1,Je=0,Qe=!1,_e=[],Ye="",Xe="child",Ke=!1,et="",tt=[],nt=window.parent,ot="*",rt=0,it=!1,at=1,st=F,lt=window,ct=()=>{X("onMessage function not defined")},ut=()=>{},dt=null,ft=null;function mt(i){var a,u,f;!function(e){Ye=e[0]??Ye,ye=ge(e[1])??ye,$e=he(e[2])??$e,De=he(e[3])??De,fe=he(e[6])??fe,be=e[7]??be,Le=e[8]??Le,pe=e[9]??pe,ve=e[10]??ve,rt=ge(e[11])??rt,Ge.enable=he(e[12])??!1,Xe=e[13]??Xe,st=e[14]??st,Qe=he(e[15])??Qe,Y=ge(e[16])??Y,te=ge(e[17])??te,we=he(e[18])??we,D=e[19]??D,ue=e[20]??ue,Je=ge(e[21])??Je,qe=he(e[23])??qe}(i),P=(a={id:Ye,enabled:De,expand:qe}).id||n,q.label(`${P}`),q.expand(a.expand),G=a.enabled,B(`Initialising iframe v${t} ${window.location.href}`),function(){function t(e){B("Reading data from page:",Object.keys(e)),de=Ue(e,"onBeforeResize")??de,ct=Ue(e,"onMessage")??ct,ut=Ue(e,"onReady")??ut,"number"==typeof e?.offset&&(re("offset","offsetSize"),we&&(Y=Ve(e,"offset")??Y),$e&&(te=Ve(e,"offset")??te)),"number"==typeof e?.offsetSize&&(we&&(Y=Ve(e,"offsetSize")??Y),$e&&(te=Ve(e,"offsetSize")??te)),Z=Ze(e,I(O[0]))??Z,Ne=Ze(e,"ignoreSelector")??Ne,et=Ze(e,"sizeSelector")??et,ot=Ze(e,"targetOrigin")??ot,Le=e?.heightCalculationMethod||Le,st=e?.widthCalculationMethod||st}function n(e,t){return"function"==typeof e&&(K(`<rb>Deprecated Option(${t}CalculationMethod)</>\n\nThe use of <b>${t}CalculationMethod</> as a function is deprecated and will be removed in a future version of <i>iframe-resizer</>. Please use the new <b>onBeforeResize</> event handler instead.\n\nSee <u>https://iframe-resizer.com/api/child</> for more details.`),$[t]=e,e="custom"),e}if(1===Je)return;const o=window.iframeResizer||window.iFrameResizer;"object"==typeof o&&(t(o),Le=n(Le,"height"),st=n(st,"width"),W(`Set targetOrigin for parent: %c${ot}`,e.HIGHLIGHT))}(),zt(),function(){try{Ke=1===Je||"iframeParentListener"in window.parent}catch(e){B("Cross domain iframe detected")}}(),$e===we&&(ze=!0),function(){const n=Je,o=k({key:D}),r=k({key:Z});if(Je=Math.max(o,r),Je<0){if(Je=Math.min(o,r),K(`${M(Je+2)}${M(2)}`),N(ue))throw M(Je+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"")}else(!N(ue)||n>-1&&Je>n)&&(sessionStorage.getItem("ifr")!==t&&function(t,n){console.info(`${P} %ciframe-resizer ${t}`,G||n<1?"font-weight: bold;":e.NORMAL)}(`v${t} (${(e=>I(T[e]))(Je)})`,Je),Je<2&&ee(M(3)),sessionStorage.setItem("ifr",t))}(),ue&&""!==ue&&"false"!==ue?ue!==t&&K(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${ue} - Child page: ${t}.\n`):K("<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"),It(),Ot(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach(n=>{e=!0,n.removeAttribute(t),n.toggleAttribute(r,!0)});t("data-iframe-height"),t("data-iframe-width"),e&&K("<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&&K("<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"),ht(),ze||me(),1!==Je&&(lt.parentIframe=Object.freeze({autoResize:e=>(x(e,"boolean","parentIframe.autoResize(enable) enable"),!1===$e&&!1===we?(Q(c),K(`Auto Resize can not be changed when <b>direction</> is set to '${b}'.`),!1):(!0===e&&!1===fe?(fe=!0,queueMicrotask(()=>Zt(c,"Auto Resize enabled"))):!1===e&&!0===fe&&(fe=!1),Qt(0,0,"autoResize",JSON.stringify(fe)),fe)),close(){Qt(0,0,"close")},getId:()=>Ye,getOrigin:()=>(ne("getOrigin()","getParentOrigin()"),ie),getParentOrigin:()=>ie,getPageInfo(e){if("function"==typeof e)return dt=e,Qt(0,0,"pageInfo"),void oe("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");dt=null,Qt(0,0,"pageInfoStop")},getParentProps:e=>(x(e,"function","parentIframe.getParentProps(callback) callback"),ft=e,Qt(0,0,"parentInfo"),()=>{ft=null,Qt(0,0,"parentInfoStop")}),getParentProperties(e){ne("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){x(e,"string","parentIframe.moveToAnchor(anchor) anchor"),Ge.findTarget(e)},reset(){!function(){const t=Le;Le=A,B("Reset trigger event: %cparentIframe.reset",e.HIGHLIGHT),it?B("TriggerLock blocked calculation"):(it=!0,U("Trigger event lock on"),requestAnimationFrame(()=>{it=!1,U("Trigger event lock off")})),Jt("reset"),Le=t}()},setOffsetSize(e){x(e,"number","parentIframe.setOffsetSize(offset) offset"),Y=e,te=e,Zt(m,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){x(e,"number","parentIframe.scrollBy(x, y) x"),x(t,"number","parentIframe.scrollBy(x, y) y"),Qt(t,e,"scrollBy")},scrollTo(e,t){x(e,"number","parentIframe.scrollTo(x, y) x"),x(t,"number","parentIframe.scrollTo(x, y) y"),Qt(t,e,"scrollTo")},scrollToOffset(e,t){x(e,"number","parentIframe.scrollToOffset(x, y) x"),x(t,"number","parentIframe.scrollToOffset(x, y) y"),Qt(t,e,"scrollToOffset")},sendMessage(e,t){t&&x(t,"string","parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),Qt(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){Le=e,It()},setWidthCalculationMethod(e){st=e,Ot()},setTargetOrigin(t){x(t,"string","parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),B(`Set targetOrigin: %c${t}`,e.HIGHLIGHT),ot=t},resize(e,t){e&&x(e,"number","parentIframe.resize(customHeight, customWidth) customHeight"),t&&x(t,"number","parentIframe.resize(customHeight, customWidth) customWidth"),Zt(d,`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){ne("size()","resize()"),this.resize(e,t)}}),lt.parentIFrame=lt.parentIframe),function(){function t(e){Qt(0,0,e.type,`${e.screenY}:${e.screenX}`)}function n(n,o){B(`Add event listener: %c${o}`,e.HIGHLIGHT),w(window.document,n,t)}!0===Qe&&(n("mouseenter","Mouse Enter"),n("mouseleave","Mouse Leave"))}(),Ge=function(){const t=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(e){const n=e.getBoundingClientRect(),r=t();return{x:parseInt(n.left,o)+parseInt(r.x,o),y:parseInt(n.top,o)+parseInt(r.y,o)}}function r(t){function o(t){const o=n(t);B(`Moving to in page link (%c#${r}%c) at x: %c${o.x}%c y: %c${o.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),Qt(o.y,o.x,"scrollToOffset")}const r=t.split("#")[1]||t,i=decodeURIComponent(r),a=document.getElementById(i)||document.getElementsByName(i)[0];void 0===a?(B(`In page link (#${r}) not found in iFrame, so sending to parent`),Qt(0,0,"inPageLink",`#${r}`)):o(a)}function i(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&r(t)}function a(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&w(e,"click",t=>{t.preventDefault(),r(e.getAttribute("href"))})}function s(){w(window,"hashchange",i)}function l(){setTimeout(i,128)}function c(){B("Setting up location.hash handlers"),a(),s(),l()}return Ge.enable?1===Je?K("In page linking requires a Professional or Business license. Please see <u>https://iframe-resizer.com/pricing</> for more details."):c():B("In page linking not enabled"),{findTarget:r}}(),void 0===be&&(be=`${ye}px`),bt("margin",(u="margin",(f=be).includes("-")&&(X(`Negative CSS value ignored for ${u}`),f=""),f)),bt("background",pe),bt("padding",ve),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),ze||function(){const t=e=>e.style.setProperty("height","auto","important");t(document.documentElement),t(document.body),B("Set HTML & body height: %cauto !important",e.HIGHLIGHT)}(),!0!==fe&&B("Auto Resize disabled"),function(e){wt({method:e,eventType:"After Print",eventName:"afterprint"}),wt({method:e,eventType:"Before Print",eventName:"beforeprint"}),wt({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}("add"),function(){const e=Nt(document)();B("Attaching Observers"),Te(At),function(e){const t={root:document.documentElement,side:we?s:l};ae=je(St,t),ae.attachObservers(e)}(e),Ce(),function(e){Fe=new ResizeObserver(Tt),Fe.observe(document.body),Be.add(document.body),W("Attached ResizeObserver to body"),se={attachObserverToNonStaticElements:We,detachObservers:Me(0,Fe,Be)},se.attachObserverToNonStaticElements(e)}(e),function(e){const t=new IntersectionObserver(t=>e(t[0].isIntersecting),{threshold:0}),n=document.documentElement;t.observe(n),W("Attached VisibilityObserver to page")}(Ht)}(),pt(E(ut)),B("Initialization complete"),Zt(z,"Init message from host page",void 0,void 0,`${t}:${Je}`),document.title&&""!==document.title&&Qt(0,0,"title",document.title)}function pt(e){"complete"===document.readyState?j(e):w(document,"readystatechange",()=>pt(e))}function ht(){tt=document.querySelectorAll(`[${r}]`),ke=tt.length>0,B(`Tagged elements found: %c${ke}`,e.HIGHLIGHT)}let gt=0;function yt(){const t=document.querySelectorAll(`*[${a}]`);Oe=t.length>0,Oe&&t.length!==gt&&(function(t){const n=1===t.length?"":"s";X(`%c[${a}]%c found on %c${t.length}%c element${n}`,e.BOLD,e.NORMAL,e.BOLD,e.NORMAL)}(t),gt=t.length)}function bt(t,n){void 0!==n&&""!==n&&"null"!==n&&(document.body.style.setProperty(t,n),W(`Set body ${t}: %c${n}`,e.HIGHLIGHT))}function vt(t,n,o){if(""!==o){B(`${t}: %c${o}`,e.HIGHLIGHT);for(const e of document.querySelectorAll(o))B(`Applying ${n} to:`,e),e.toggleAttribute(n,!0)}}function zt(){vt("sizeSelector",r,et),vt("ignoreSelector",a,Ne)}function wt(t){({add(e){function n(){Zt(t.eventName,t.eventType)}H[e]=n,w(window,e,n,{passive:!0})},remove(e){const t=H[e];var n,o;delete H[e],n=e,o=t,window.removeEventListener(n,o,!1)}})[t.method](t.eventName),B(`${L(t.method)} event listener: %c${t.eventType}`,e.HIGHLIGHT)}function $t(t,n,o,r){return n!==t&&(t in o||(X(`${t} is not a valid option for ${r}CalculationMethod.`),t=n),t in S)&&K(`<rb>Deprecated ${r}CalculationMethod (${t})</>\n\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${r} calculation method. It is recommended that you ${ue?"remove this option.":"set this option to <b>'auto'</> when using an older version of <i>iframe-resizer</> on the parent page."}`),B(`Set ${r} calculation method: %c${t}`,e.HIGHLIGHT),t}function It(){Le=$t(Le,A,qt,"height")}function Ot(){st=$t(st,F,Bt,"width")}function St(e){!function(){const e=document.querySelectorAll(`[${i}]`);_e=Array.from(e).filter(e=>!e.closest(`[${a}]`)),Se=_e.length>0}(),(Se||e)&&(_e.length>1?W("Overflowed Elements:",..._e):Se||W("Overflow removed"),Zt(h,"Overflow updated"))}function Tt(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;Zt(p,`Element resized <${function(e){switch(!0){case!N(e):return"";case N(e.id):return`${e.nodeName}#${e.id}`;case N(e.name):return`${e.nodeName} (${e.name}`;case N(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}(t)}>`)}function Ht(t){B(`Visible: %c${t}`,e.HIGHLIGHT),Pe=!t,Zt(y,"Visibility changed")}const Mt=He("Overflow"),kt=He("Overflow",!1),jt=He("Resize"),Et=He("Resize",!1);function At(e){!function({addedMutations:e,removedMutations:t}){Q("contentMutated"),zt(),ht();let n=0,o=0,r=0,i=0;for(const e of t){const t=Nt(e)();o+=ae.detachObservers(t),i+=se.detachObservers(t)}for(const t of e){const e=Nt(t)();n+=ae.attachObservers(e),r+=se.attachObserverToNonStaticElements(e)}kt(o),Et(i),Mt(n),jt(r),V()}(e),Zt(g,"Mutation Observed")}function Rt(e){performance.mark(Ee);const t=L(e);let n=0,o=document.documentElement,r=ke?0:document.documentElement.getBoundingClientRect().bottom;const i=ke?tt:Se?_e:Nt(document)();for(const t of i)n=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),n>r&&(r=n,o=t);return W(`${t} position calculated from:`,o),performance.mark(Ae,{detail:{hasTags:ke,len:i.length,logging:De,Side:t}}),r}const Lt=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],Nt=e=>()=>{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 yt(),Oe&&t.push(`not([${a}])`,`not([${a}] *)`),[e,...e.querySelectorAll(t.join(":"))]},xt={height:0,width:0},Gt={height:0,width:0},Pt=[e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT];function Ct(t){function n(){return Gt[r]=i,xt[r]=l,i}const o=t===qt,r=o?"height":"width",i=t.boundingClientRect(),a=Math.ceil(i),s=Math.floor(i),l=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(t),c=`HTML: %c${i}px %cPage: %c${l}px`;let u=0;switch(!0){case!t.enabled():return l;case ke:W("Found element with data-iframe-size attribute"),u=t.taggedElement();break;case!Se&&0===Gt[r]&&0===xt[r]:W(`Initial page size values: ${c}`,...Pt),u=n();break;case it&&i===Gt[r]&&l===xt[r]:W(`Size unchanged: ${c}`,...Pt),u=Math.max(i,l);break;case 0===i:W(`Page is hidden: ${c}`,...Pt),u=l;break;case!Se&&i!==Gt[r]&&l<=xt[r]:W(`New <html> size: ${c} `,...Pt),W(`Previous <html> size: %c${Gt[r]}px`,e.HIGHLIGHT),u=n();break;case!o:u=t.taggedElement();break;case!Se&&i<Gt[r]:W(`<html> size decreased: ${c}`,...Pt),u=n();break;case l===s||l===a:W(`<html> size equals page size: ${c}`,...Pt),u=n();break;case i>l:W(`Page size < <html> size: ${c}`,...Pt),u=n();break;case Se:W("Found element overflowing <html> "),u=t.taggedElement();break;default:W(`Using <html> size: ${c}`,...Pt),u=n()}return W(`Content ${r}: %c${u}px`,e.HIGHLIGHT),u+=function(t){const n=t.getOffset();return 0!==n&&W(`Page offsetSize: %c${n}px`,e.HIGHLIGHT),n}(t),u}const qt={enabled:()=>we,getOffset:()=>Y,auto:()=>Ct(qt),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,o)+parseInt(t.marginBottom,o)},bodyScroll:()=>document.body.scrollHeight,offset:()=>qt.bodyOffset(),custom:()=>$.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...Lt(qt)),min:()=>Math.min(...Lt(qt)),grow:()=>qt.max(),lowestElement:()=>Rt(s),taggedElement:()=>Rt(s)},Bt={enabled:()=>$e,getOffset:()=>te,auto:()=>Ct(Bt),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>$.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...Lt(Bt)),min:()=>Math.min(...Lt(Bt)),rightMostElement:()=>Rt(l),scroll:()=>Math.max(Bt.bodyScroll(),Bt.documentElementScroll()),taggedElement:()=>Rt(l)},Ft=(e,t)=>!(Math.abs(e-t)<=rt);function Wt(e,t){const n=e[t]();return e.enabled()&&void 0!==de?function(e){const t=de(e);if(void 0===t)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(t))throw new TypeError(`Invalid value returned from onBeforeResize(): ${t}, expected Number`);return t}(n):n}let Dt=!1;const Ut=E(()=>ee(M(4)));let Vt=!1;const Zt=J((t,n,o,r,i)=>{if(ce=performance.now(),le=!0,Q(t),!0!==Dt){if(!fe&&!(t in f))return W("Resizing disabled"),void V();if(Pe){if(!0===Vt)return;return B("Iframe hidden - Ignored resize request"),void(Vt=!0)}Vt=!1,Dt=!0,requestAnimationFrame(()=>{Dt=!1}),function(t,n,o,r,i){const a=o??Wt(qt,Le),s=r??Wt(Bt,st),l=we&&Ft(Re,a)||$e&&Ft(at,s)?u:t;switch(B(`Resize event: %c${n}`,e.HIGHLIGHT),l){case z:case c:case u:Re=a,at=s;case m:Qt(Re,at,t,i);break;case h:case g:case p:case y:B(v);break;default:W(v)}le=!1}(t,n,o,r,i)}});function Jt(e){Re=qt[Le](),at=Bt[st](),Qt(Re,at,e)}const Qt=J(function(t,n,o,r,i){Je<-1||(Q(o),void 0!==i?B(`Message targetOrigin: %c${i}`,e.HIGHLIGHT):i=ot,function(){const a=`${Ye}:${t}:${n}:${o}${void 0===r?"":`:${r}`}`;if(Ke)try{window.parent.iframeParentListener(C+a)}catch(e){if(1!==Je)throw e;return void Ut()}else nt.postMessage(C+a,i);le&&B(function(){const e=R(performance.now()-ce);return o===z?`Initialised iFrame in %c${e}ms`:`Size calculated in %c${e}ms`}(),e.HIGHLIGHT),W(`Sending message to parent page via ${Ke?"sameOrigin":"postMessage"}: %c%c${a}`,e.ITALIC,e.HIGHLIGHT)}(),V())}),_t=J(function(t){Q("onMessage");const{freeze:n}=Object,{parse:o}=JSON,r=e=>n(o(e)),i=e=>Qt(0,0,`${e}Stop`),a={init:function(){if("loading"===document.readyState)return void B("Page not ready, ignoring init message");const e=t.data.slice(13).split(":");nt=t.source,ie=t.origin,mt(e),Ie=!1,setTimeout(()=>{xe=!1},128)},reset(){xe?B("Page reset ignored by init"):(B("Page size reset by host page"),Jt("resetPage"))},resize(){B("Resize requested by host page"),Zt("parentResize","Parent window requested size check")},moveToAnchor(){Ge.findTarget(l())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=l();B("PageInfo received from parent:",r(e)),dt?j(dt,o(e)):i("pageInfo")},parentInfo(){const e=r(l());B("ParentInfo received from parent:",e),ft?j(ft,e):i("parentInfo")},message(){const t=l();B("onMessage called from parent:%c",e.HIGHLIGHT,r(t)),j(ct,o(t))}},s=()=>t.data.split("]")[1].split(":")[0],l=()=>t.data.slice(t.data.indexOf(":")+1),c=()=>t.data.split(":")[2]in{true:1,false:1};function u(){const e=s();Q(e),e in a?a[e]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||c()||X(`Unexpected message (${t.data})`)}C===`${t.data}`.slice(0,13)&&function(){if(!1!==Ie)return c()?(_(s()),Q(z),void a.init()):void B(`Ignored message of type "${s()}". Received before initialization.`);u()}()});function Yt(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"iframeChildListener"in window?X("Already setup"):(window.iframeChildListener=e=>setTimeout(()=>_t({data:e,sameOrigin:!0})),w(window,"message",_t),w(window,"readystatechange",Yt),Yt())}();
|
|
21
21
|
//# sourceMappingURL=index.cjs.js.map
|