iframe-resizer 5.5.6-beta.2 → 5.5.7-beta.1
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/index.cjs.js +1 -1
- package/index.esm.js +1 -1
- package/js/iframeResizer.contentWindow.js +2 -2
- package/js/iframeResizer.contentWindow.js.map +1 -1
- package/js/iframeResizer.contentWindow.min.js +2 -2
- package/js/iframeResizer.contentWindow.min.js.map +1 -1
- package/js/iframeResizer.js +2 -2
- package/js/iframeResizer.js.map +1 -1
- package/js/iframeResizer.min.js +2 -2
- package/js/iframeResizer.min.js.map +1 -1
- package/package.json +4 -4
package/js/iframeResizer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/legacy (parent) 5.5.
|
|
4
|
+
* @module iframe-resizer/legacy (parent) 5.5.7-beta.1 (umd) - 2025-09-21
|
|
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
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).iframeResize=t()}(this,function(){"use strict";console.info("IFRAME-RESIZER 5\n\nThis package has been split into separate packages for Parent and Child pages. Along with new packages for jQuery, React and Vue.\n\nGoing forward you are advised to use the new separate packages for Parent and Child pages, rather than this combined package.\n\nPlease see https://iframe-resizer.com/upgrade for more details.\n");const e="font-weight: normal;",t=e+"font-style: italic;",n="default",i=Object.freeze({assert:!0,error:!0,warn:!0}),o={expand:!1,defaultEvent:void 0,event:void 0,label:"AutoConsoleGroup",showTime:!0},r={profile:0,profileEnd:0,timeStamp:0,trace:0},s=Object.assign(console);const{fromEntries:a,keys:l}=Object,c=e=>[e,s[e]],d=e=>t=>[t,function(n){e[t]=n}],u=(e,t)=>a(l(e).map(t));const f=!(typeof window>"u"||"function"!=typeof window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches,p=f?"color: #A9C7FB;":"color: #135CD2;",m=f?"color: #E3E3E3;":"color: #1F1F1F;",h="5.5.6-beta.2",g="iframeResizer",y="autoResize",b="init",w="iframeReady",v="load",z="message",$="onload",j="pageInfo",k="parentInfo",T="reset",x="resize",M="scroll",E="none",R="vertical",S="horizontal",O="[iFrameSizer]",I=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),C=Object.freeze({[$]:1,[b]:1,[w]:1}),A="expanded",W="collapsed",L=Object.freeze({[A]:1,[W]:1}),N=e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(t)),F=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),B=e=>e,P={},H=(q=function(a={}){const l={},f={},p=[],m={...o,expand:!a.collapsed||o.expanded,...a};let h="";function g(){p.length=0,h=""}function y(){delete m.event,g()}const b=()=>!!p.some(([e])=>e in i)||!!m.expand;function w(){if(0!==p.length){s[b()?"group":"groupCollapsed"](`%c${m.label}%c ${(e=>{const t=e.event||e.defaultEvent;return t?`${t}`:""})(m)} %c${m.showTime?h:""}`,e,"font-weight: bold;",t);for(const[e,...t]of p)s.assert(e in s,`Unknown console method: ${e}`),e in s&&s[e](...t);s.groupEnd(),y()}else y()}function v(){""===h&&(h=function(){const e=new Date,t=(t,n)=>e[t]().toString().padStart(n,"0");return`@ ${t("getHours",2)}:${t("getMinutes",2)}:${t("getSeconds",2)}.${t("getMilliseconds",3)}`}())}function z(e,...t){0===p.length&&(v(),queueMicrotask(()=>queueMicrotask(w))),p.push([e,...t])}function $(e=n,...t){l[e]?z("log",`${e}: ${performance.now()-l[e]} ms`,...t):z("timeLog",e,...t)}return{...u(m,d(m)),...u(console,e=>[e,(...t)=>z(e,...t)]),...u(r,c),assert:function(e,...t){!0!==e&&z("assert",e,...t)},count:function(e=n){f[e]?f[e]+=1:f[e]=1,z("log",`${e}: ${f[e]}`)},countReset:function(e=n){delete f[e]},endAutoGroup:w,errorBoundary:e=>(...t)=>{let n;try{n=e(...t)}catch(e){if(!Error.prototype.isPrototypeOf(e))throw e;z("error",e),w()}return n},event:function(e){v(),m.event=e},purge:g,time:function(e=n){v(),l[e]=performance.now()},timeEnd:function(e=n){$(e),delete l[e]},timeLog:$,touch:v}},q?.__esModule?q.default:q);var q;let D=!0;const U=H({expand:!1,label:"parent"}),V=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const J=e=>(t,...n)=>P[t]?P[t].console[e](...n):U[e](...n),Z=e=>(t,...n)=>!0===(e=>P[e]?P[e].log:D)(t)?J(e)(t,...n):null,G=Z("log"),X=G,Y=Z("debug"),_=J("warn"),Q=J("error"),K=J("event"),ee=J("purge"),te=J("errorBoundary");const ne=(e,...t)=>P[e]?P[e].console.warn(N(B)(...t)):queueMicrotask(()=>console?.warn(N((e=>(...t)=>[`${g}(${e})`,...t].join(" "))(e))(...t))),ie=(e=>(t,n="renamed to")=>(i,o,r="",s="")=>e(s,`<rb>Deprecated ${t}(${i.replace("()","")})</>\n\nThe <b>${i}</> ${t.toLowerCase()} has been ${n} <b>${o}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(ne),oe=ie("Function"),re=ie("Option"),se=(e,t,n,i)=>e.addEventListener(t,n,i||!1),ae=(e,t,n)=>e.removeEventListener(t,n,!1),le=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let i,o=0;o<e.length;o++)i=e.codePointAt(o),t=Math.imul(t^i,2246822519),n=Math.imul(n^i,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)},ce=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),de=["spjluzl","rlf","clyzpvu"],ue=["<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."],fe=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],pe=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),me=e=>ce(ue[e]),he=e=>{const t=e[ce(de[0])]||e[ce(de[1])]||e[ce(de[2])];if(!t)return-1;const n=t.split("-");let i=function(e=""){let t=-2;const n=le(ce(e));return n in pe&&(t=pe[n]),t}(n[0]);return 0===i||(e=>e[2]===le(e[0]+e[1]))(n)||(i=-2),i};function ge(e,t){const{msgTimeout:n,warningTimeout:i}=t[e];i&&(n&&clearTimeout(n),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{initialised:n,loadErrorShown:i}=t[e];t[e].msgTimeout=void 0,n||i||(t[e].loadErrorShown=!0,function(e,t){const{iframe:n,waitForLoad:i}=t[e],{sandbox:o}=n,r="object"==typeof o&&o.length>0&&!(o.contains("allow-scripts")&&o.contains("allow-same-origin"));K(e,"noResponse"),ne(e,`<rb>No response from iframe</>\n \nThe iframe (<i>${e}</>) has not responded within ${t[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${i?"\nThe <b>waitForLoad</> option is currently set to <b>'true'</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'allow-scripts'</> values.\n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`)}(e,t))},i))}const ye=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:R,firstRun:!0,inPageLinks:!1,heightCalculationMethod:"auto",id:"iFrameResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof P[e.id].onInit&&(re("init()","onReady()","",e.id),P[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),be={position:null,version:h};function we(e){function t(){Me(N),Te(H),I("onResized",N)}function n(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function i(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const o=e=>L.slice(L.indexOf(":")+7+e);const r=(e,t)=>(n,i)=>{const o={};var r,s;r=function(){Re(`${n} (${e})`,`${e}:${t()}`,i)},o[s=i]||(r(),o[s]=requestAnimationFrame(()=>{o[s]=null}))},s=(e,t)=>()=>{let n=!1;const i=t=>()=>{P[l]?n&&n!==t||(e(t,l),n=t,requestAnimationFrame(()=>{n=!1})):a()},o=i(M),r=i("resize window");function s(e,n){G(l,`${e}listeners for send${t}`),n(window,M,o),n(window,x,r)}function a(){K(l,`stop${t}`),s("Remove ",ae),c.disconnect(),d.disconnect(),ae(P[l].iframe,v,a)}const l=H,c=new ResizeObserver(i("pageObserver")),d=new ResizeObserver(i("iframeObserver"));P[l]&&(P[l][`stop${t}`]=a,se(P[l].iframe,v,a),s("Add ",se),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(P[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},a=e=>()=>{e in P[H]&&(P[H][e](),delete P[H][e])},l=r(j,function(){const e=document.body.getBoundingClientRect(),t=N.iframe.getBoundingClientRect(),{scrollY:n,scrollX:i,innerHeight:o,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(s,o||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:n,scrollLeft:i,documentHeight:s,documentWidth:a,windowHeight:o,windowWidth:r})}),c=r(k,function(){const{iframe:e}=N,{scrollWidth:t,scrollHeight:n}=document.documentElement,{width:i,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:n},viewport:{width:i,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),d=s(l,"PageInfo"),u=s(c,"ParentInfo"),f=a("stopPageInfo"),g=a("stopParentInfo");function $(e){const t=e.getBoundingClientRect();return je(H),{x:Number(t.left)+Number(be.position.x),y:Number(t.top)+Number(be.position.y)}}function E(e){const t=e?$(N.iframe):{x:0,y:0};X(H,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,p,m,p);const n=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(N,t),i=window.parentIframe||window.parentIFrame;i?function(t,n){setTimeout(()=>t["scrollTo"+(e?"Offset":"")](n.x,n.y))}(i,n):function(e){be.position=e,R(H)}(n)}function R(e){const{x:t,y:n}=be.position,i=P[e]?.iframe;!1!==I("onScroll",{iframe:i,top:n,left:t,x:t,y:n})?Te(e):ke()}function S(e){let t={};if(0===N.width&&0===N.height){const e=o(9).split(":");t={x:e[1],y:e[0]}}else t={x:N.width,y:N.height};I(e,{iframe:N.iframe,screenX:Number(t.x),screenY:Number(t.y),type:N.type})}const I=(e,t)=>ve(H,e,t);function C(){const{height:e,iframe:n,msg:i,type:r,width:s}=N;switch(P[H]?.firstRun&&function(){if(!P[H])return;G(H,`First run for ${H}`),Ae(H,N.mode),P[H].firstRun=!1}(),r){case"close":$e(n);break;case z:l=o(6),G(H,`onMessage passed: {iframe: %c${N.iframe.id}%c, message: %c${l}%c}`,p,m,p,m),I("onMessage",{iframe:N.iframe,message:JSON.parse(l)});break;case"mouseenter":S("onMouseEnter");break;case"mouseleave":S("onMouseLeave");break;case"beforeUnload":X(H,"Ready state reset"),P[H].initialised=!1;break;case y:P[H].autoResize=JSON.parse(o(9));break;case"scrollBy":!function(){const e=N.width,t=N.height,n=window.parentIframe||window.parentIFrame||window;X(H,`scrollBy: x: %c${e}%c y: %c${t}`,p,m,p),n.scrollBy(e,t)}();break;case"scrollTo":E(!1);break;case"scrollToOffset":E(!0);break;case j:d();break;case k:u();break;case"pageInfoStop":f();break;case"parentInfoStop":g();break;case"inPageLink":!function(e){const t=e.split("#")[1]||"",n=decodeURIComponent(t);let i=document.getElementById(n)||document.getElementsByName(n)[0];i?function(){const e=$(i);X(H,`Moving to in page link: %c#${t}`,p),be.position={x:e.x,y:e.y},R(H),window.location.hash=t}():window.top!==window.self?function(){const e=window.parentIframe||window.parentIFrame;e?e.moveToAnchor(t):G(H,`In page link #${t} not found`)}():G(H,`In page link #${t} not found`)}(o(9));break;case"title":!function(e,t){P[t]?.syncTitle&&(P[t].iframe.title=e,X(t,`Set iframe title attribute: %c${e}`,p))}(i,H);break;case T:xe(N);break;case b:t(),function(e){try{P[e].sameOrigin=!!P[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){P[e].sameOrigin=!1}G(e,`sameOrigin: %c${P[e].sameOrigin}`,p)}(H),(a=i)!==h&&(void 0!==a?G(H,`Version mismatch (Child: %c${a}%c !== Parent: %c${h})`,p,m,p):ne(H,"<rb>Legacy version detected in iframe</>\n\nDetected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.\n\nSee <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.\n")),P[H].initialised=!0,I("onReady",n);break;default:if(0===s&&0===e)return void _(H,`Unsupported message received (${r}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===s||0===e)return void G(H,"Ignoring message with 0 height or width");if(document.hidden)return void G(H,"Page hidden - ignored resize request");t()}var a,l}function A(e){if(!P[e])throw new Error(`${N.type} No settings for ${e}. Message was: ${L}`)}const W=e=>Object.keys(P).forEach((e=>t=>{const{initialised:n,postMessageTarget:i}=P[t];n||e!==i||(G(t,"iframe requested init"),Re(w,Se(t),t),ge(t,P))})(e));let L=e.data;if("[iFrameResizerChild]Ready"===L)return void W(e.source);if(!(e=>O===`${e}`.slice(0,13)&&e.slice(13).split(":")[0]in P)(L)){if("string"!=typeof L)return;return K("parent","ignoredMessage"),void Y("parent",L)}const N=function(e){const t=e.slice(13).split(":"),o=t[1]?Number(t[1]):0,r=P[t[0]]?.iframe,s=getComputedStyle(r),a={iframe:r,id:t[0],height:o+n(s)+i(s),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(a.mode=t[5]),a}(L),{id:F,type:B}=N,H=F;H?(K(H,B),te(H,function(t){A(H),function(){const e=N.type in{true:1,false:1,undefined:1};return e&&G(H,"Ignoring init message from meta parent page"),e}()||(G(H,`Received: %c${t}`,p),(null!==N.iframe||(_(H,`The iframe (${N.id}) was not found.`),0))&&function(){const{origin:t,sameOrigin:n}=e;if(n)return!0;let i=P[H]?.checkOrigin;if(i&&"null"!=`${t}`&&!(i.constructor===Array?function(){let e=0,n=!1;for(G(H,`Checking connection is from allowed list of origins: %c${i}`,p);e<i.length;e++)if(i[e]===t){n=!0;break}return n}():function(){const e=P[H]?.remoteHost;return G(H,`Checking connection is from: %c${e}`,p),t===e}()))throw new Error(`Unexpected message received from: ${t} for ${N.iframe.id}. Message was: ${e.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&C())})(L)):_("","iframeResizer received messageData without id, message was: ",L)}function ve(e,t,n){let i=null,o=null;if(P[e]){if(i=P[e][t],"function"!=typeof i)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{o=i(n)}catch(n){console.error(n),_(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(i,n)}return o}function ze(e){const{id:t}=e;G(t,"Disconnected from iframe"),delete P[t],delete e.iframeResizer}function $e(e){const{id:t}=e;if(!1!==ve(t,"onBeforeClose",t)){G(t,`Removing iFrame: %c${t}`,p);try{e.parentNode&&e.remove()}catch(e){_(t,e)}ve(t,"onAfterClose",t),ze(e)}else G(t,"Close iframe cancelled by onBeforeClose")}function je(e){null===be.position&&(be.position={x:window.scrollX,y:window.scrollY},G(e,`Get page position: %c${be.position.x}%c, %c${be.position.y}`,p,m,p))}function ke(){be.position=null}function Te(e){null!==be.position&&(window.scrollTo(be.position.x,be.position.y),X(e,`Set page position: %c${be.position.x}%c, %c${be.position.y}`,p,m,p),ke())}function xe(e){G(e.id,"Size reset requested by "+(e.type===b?"parent page":"child page")),je(e.id),Me(e),Re(T,T,e.id)}function Me(e){function t(t){const i=`${e[t]}px`;e.iframe.style[t]=i,X(n,`Set ${t}: %c${i}`,p)}const{id:n}=e,{sizeHeight:i,sizeWidth:o}=P[n];i&&t("height"),o&&t("width")}const Ee=e=>e.split(":").filter((e,t)=>19!==t).join(":");function Re(e,t,n){function i(i){const o=e in C?Ee(t):t;X(n,i,p,m,p),X(n,`Message data: %c${o}`,p)}K(n,e),P[n]&&(P[n]?.postMessageTarget?function(){const{iframe:o,postMessageTarget:r,sameOrigin:s,targetOrigin:a}=P[n];if(s)try{return o.contentWindow.iframeChildListener(O+t),void i(`Sending message to iframe %c${n}%c via same origin%c`)}catch(t){e in C?(P[n].sameOrigin=!1,G(n,"New iframe does not support same origin")):_(n,"Same origin messaging failed, falling back to postMessage")}i(`Sending message to iframe: %c${n}%c targetOrigin: %c${a}`),r.postMessage(O+t,a)}():_(n,`Iframe(${n}) not found`))}function Se(e){const t=P[e];return[e,"8",t.sizeWidth,t.log,"32",!0,t.autoResize,t.bodyMargin,t.heightCalculationMethod,t.bodyBackground,t.bodyPadding,t.tolerance,t.inPageLinks,"child",t.widthCalculationMethod,t.mouseEvents,t.offsetHeight,t.offsetWidth,t.sizeHeight,t.license,be.version,t.mode,"",t.logExpand].join(":")}let Oe=0,Ie=!1,Ce=!1;function Ae(t,n=-3){if(Ie)return;const i=Math.max(P[t].mode,n);if(i>P[t].mode&&(P[t].mode=i),i<0)throw ee(t),P[t].vAdvised||ne(t||"Parent",`${me(i+2)}${me(2)}`),P[t].vAdvised=!0,me(i+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");i>0&&Ce||function(t,n){queueMicrotask(()=>console.info(`%ciframe-resizer ${t}`,D||n<1?"font-weight: bold;":e))}(`v${h} (${(e=>ce(fe[e]))(i)})`,i),i<1&&ne("Parent",me(3)),Ie=!0}const We=e=>t=>{function n(){if(P[d]){const{iframe:e}=P[d],t={close:$e.bind(null,e),disconnect:ze.bind(null,e),removeListeners(){ne(d,"<rb>Deprecated Method Name</>\n\nThe [removeListeners()</> method has been renamed to [disconnect()</>.\n"),this.disconnect()},resize(){ne(d,"<rb>Deprecated Method</>\n \nUse of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As their are no longer any edge cases that require triggering a resize from the parent page, it is recommended to remove this method from your code."),Re.bind(null,"Window resize",x,d)},moveToAnchor(e){((e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${i=t,i.charAt(0).toUpperCase()+i.slice(1)}`);var i})(e,"string","moveToAnchor(anchor) anchor"),Re("Move to anchor",`moveToAnchor:${e}`,d)},sendMessage(e){e=JSON.stringify(e),Re(z,`${z}:${e}`,d)}};e.iframeResizer=t,e.iFrameResizer=t}}function i(e,n){const i=i=>()=>setTimeout(()=>{P[e]&&!0!==P[e].initialised&&(Re(i,n,e),ge(e,P),P[e].firstRun||P[d]?.heightCalculationMethod in I&&xe({iframe:t,height:1,width:1,type:b}))}),{waitForLoad:o}=P[e];if(se(t,v,i($)),!0===o)return;const{src:r,srcdoc:s}=t;(s||null!=r&&""!==r&&"about:blank"!==r)&&i(b)()}function o(e){return e?(("sizeWidth"in e||"sizeHeight"in e||y in e)&&ne(d,`<rb>Deprecated Option</>\n\nThe <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <i>"${R}"</>, <i>"${S}"</> or <i>"${E}"</>.\n`),e):{}}function r(e){const t=P[e]?.iframe?.title;return""===t||void 0===t}function s(e,t){F(P[d],e)&&(ne(d,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${t}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),P[d][t]=P[d][e],delete P[d][e])}const a=e=>F(e,"onMouseEnter")||F(e,"onMouseLeave");function l(e){var n,i;P[d]={...P[d],iframe:t,remoteHost:t?.src.split("/").slice(0,3).join("/"),...ye,...o(e),mouseEvents:a(e),mode:he(e),syncTitle:r(d)},s("offset","offsetSize"),s("onClose","onBeforeClose"),s("onClosed","onAfterClose"),K(d,"setup"),function(){const{direction:e}=P[d];switch(e){case R:break;case S:P[d].sizeHeight=!1;case"both":P[d].sizeWidth=!0;break;case E:P[d].sizeWidth=!1,P[d].sizeHeight=!1,P[d].autoResize=!1;break;default:throw new TypeError(d,`Direction value of "${e}" is not valid`)}G(d,`direction: %c${e}`,p)}(),(n=e?.offsetSize||e?.offset)&&(P[d].direction===R?(P[d].offsetHeight=n,G(d,`Offset height: %c${n}`,p)):(P[d].offsetWidth=n,G(d,`Offset width: %c${n}`,p))),function(e){e?.offset&&ne(d,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.")}(e),P[d].warningTimeout||X(d,"warningTimeout:%c disabled",p),null===P[d].postMessageTarget&&(P[d].postMessageTarget=t.contentWindow),P[d].targetOrigin=!0===P[d].checkOrigin?""===(i=P[d].remoteHost)||null!==i.match(/^(about:blank|javascript:|file:\/\/)/)?"*":i:"*"}const c=()=>"iframeResizer"in t,d=function(n){if(n&&"string"!=typeof n)throw new TypeError("Invalid id for iFrame. Expected String");return""!==n&&n||(n=function(){let t=e?.id||ye.id+Oe++;return null!==document.getElementById(t)&&(t+=Oe++),t}(),t.id=n,K(n,"assignId"),G(n,`Added missing iframe ID: ${n} (${t.src})`)),n}(t.id);if("object"!=typeof e)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=W,e.logExpand=t.includes("ifrlog=expanded"))}(e),function(e,t){const n=F(t,"log"),i="string"==typeof t.log,o=n?!!i||t.log:ye.log;F(t,"logExpand")||(t.logExpand=n&&i?t.log===A:ye.logExpand),function(e){-1===e?.log&&(e.log=!1,Ce=!0)}(t),function({enabled:e,expand:t,iframeId:n}){const i=H({expand:t,label:V(n)});D=e,P[n]||(P[n]={console:i})}({enabled:o,expand:t.logExpand,iframeId:e}),i&&!(t.log in L)&&Q(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=o}(d,e),te(d,function(e){c()?_(d,`Ignored iframe (${d}), already setup.`):(l(e),function(){if(Ie)return;const{mode:e}=P[d];-1!==e&&Ae(d,e)}(),Ne(),function(){switch(G(d,`Iframe scrolling ${P[d]?.scrolling?"enabled":"disabled"} for ${d}`),t.style.overflow=!1===P[d]?.scrolling?"hidden":"auto",P[d]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=P[d]?P[d].scrolling:"no"}}(),function(){const{bodyMargin:e}=P[d];"number"!=typeof e&&"0"!==e||(P[d].bodyMargin=`${e}px`)}(),i(d,Se(d)),n(),G(d,"Setup complete"))})(e),t?.iframeResizer};function Le(){!1===document.hidden&&(K("document","visibilityChange"),G("document","Visibility Change:",document.hidden?"hidden":"visible"),function(e,t){const n=e=>P[e]?.autoResize&&!P[e]?.firstRun;Object.keys(P).forEach(function(i){n(i)&&Re(e,t,i)})}("tabVisible",x))}const Ne=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{se(window,z,we),se(document,"visibilitychange",Le),window.iframeParentListener=e=>setTimeout(()=>we({data:e,sameOrigin:!0}))}),Fe=`[${g}] `;const Be=function(){function e(e){switch(!0){case!e:throw new TypeError(`${Fe}iframe is not defined`);case!e.tagName:throw new TypeError(`${Fe}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${Fe}Expected <IFRAME> tag, found <${e.tagName}>`);default:t(e),n.push(e)}}let t,n;return function(i,o){if("undefined"==typeof window)return[];switch(t=We(i),n=[],typeof o){case"undefined":case"string":document.querySelectorAll(o||"iframe").forEach(e);break;case"object":e(o);break;default:throw new TypeError(`${Fe}Unexpected data type (${typeof o})`)}return Object.freeze(n)}}();return"undefined"!=typeof window&&(window.iFrameResize=window.iFrameResize||function(...e){oe("iFrameResize()","iframeResize()","","parent"),Be(...e)}),Be});
|
|
20
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).iframeResize=t()}(this,function(){"use strict";console.info("IFRAME-RESIZER 5\n\nThis package has been split into separate packages for Parent and Child pages. Along with new packages for jQuery, React and Vue.\n\nGoing forward you are advised to use the new separate packages for Parent and Child pages, rather than this combined package.\n\nPlease see https://iframe-resizer.com/upgrade for more details.\n");const e="5.5.7-beta.1",t="iframeResizer",n=":",o="autoResize",i="init",r="iframeReady",a="load",s="message",l="onload",c="pageInfo",d="parentInfo",u="reset",f="resize",p="scroll",m="child",h="parent",g="string",y="object",b="function",w="undefined",v="auto",z="none",$="vertical",j="horizontal",k="[iFrameSizer]",T=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),x=Object.freeze({[l]:1,[i]:1,[r]:1}),M="expanded",E="collapsed",R=Object.freeze({[M]:1,[E]:1}),S="font-weight: normal;",O=S+"font-style: italic;",I="default",C=Object.freeze({assert:!0,error:!0,warn:!0}),A={expand:!1,defaultEvent:void 0,event:void 0,label:"AutoConsoleGroup",showTime:!0},W={profile:0,profileEnd:0,timeStamp:0,trace:0},L=Object.assign(console);const{fromEntries:N,keys:F}=Object,P=e=>[e,L[e]],B=e=>t=>[t,function(n){e[t]=n}],H=(e,t)=>N(F(e).map(t));const q=!(typeof window>"u"||"function"!=typeof window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches,D=q?"color: #A9C7FB;":"color: #135CD2;",U=q?"color: #E3E3E3;":"color: #1F1F1F;",J=e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(t)),V=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),Z=e=>e,G={},X=(Y=function(e={}){const t={},n={},o=[],i={...A,expand:!e.collapsed||A.expanded,...e};let r="";function a(){o.length=0,r=""}function s(){delete i.event,a()}const l=()=>!!o.some(([e])=>e in C)||!!i.expand;function c(){if(0!==o.length){L[l()?"group":"groupCollapsed"](`%c${i.label}%c ${(e=>{const t=e.event||e.defaultEvent;return t?`${t}`:""})(i)} %c${i.showTime?r:""}`,S,"font-weight: bold;",O);for(const[e,...t]of o)L.assert(e in L,`Unknown console method: ${e}`),e in L&&L[e](...t);L.groupEnd(),s()}else s()}function d(){""===r&&(r=function(){const e=new Date,t=(t,n)=>e[t]().toString().padStart(n,"0");return`@ ${t("getHours",2)}:${t("getMinutes",2)}:${t("getSeconds",2)}.${t("getMilliseconds",3)}`}())}function u(e,...t){0===o.length&&(d(),queueMicrotask(()=>queueMicrotask(c))),o.push([e,...t])}function f(e=I,...n){t[e]?u("log",`${e}: ${performance.now()-t[e]} ms`,...n):u("timeLog",e,...n)}return{...H(i,B(i)),...H(console,e=>[e,(...t)=>u(e,...t)]),...H(W,P),assert:function(e,...t){!0!==e&&u("assert",e,...t)},count:function(e=I){n[e]?n[e]+=1:n[e]=1,u("log",`${e}: ${n[e]}`)},countReset:function(e=I){delete n[e]},endAutoGroup:c,errorBoundary:e=>(...t)=>{let n;try{n=e(...t)}catch(e){if(!Error.prototype.isPrototypeOf(e))throw e;u("error",e),c()}return n},event:function(e){d(),i.event=e},purge:a,time:function(e=I){d(),t[e]=performance.now()},timeEnd:function(e=I){f(e),delete t[e]},timeLog:f,touch:d}},Y?.__esModule?Y.default:Y);var Y;let _=!0;const Q=X({expand:!1,label:h}),K=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const ee=e=>(t,...n)=>G[t]?G[t].console[e](...n):Q[e](...n),te=e=>(t,...n)=>!0===(e=>G[e]?G[e].log:_)(t)?ee(e)(t,...n):null,ne=te("log"),oe=ne,ie=te("debug"),re=ee("warn"),ae=ee("error"),se=ee("event"),le=ee("purge"),ce=ee("errorBoundary");const de=(e,...n)=>G[e]?G[e].console.warn(J(Z)(...n)):queueMicrotask(()=>console?.warn(J((e=>(...n)=>[`${t}(${e})`,...n].join(" "))(e))(...n))),ue=(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</>.`))(de),fe=ue("Function"),pe=ue("Option"),me=(e,t,n,o)=>e.addEventListener(t,n,o||!1),he=(e,t,n)=>e.removeEventListener(t,n,!1),ge=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let o,i=0;i<e.length;i++)o=e.codePointAt(i),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)},ye=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),be=["spjluzl","rlf","clyzpvu"],we=["<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.","Pu whnl spurpun ylxbpylz h Wyvmlzzpvuhs vy Ibzpulzz spjluzl. Wslhzl zll <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</> mvy tvyl klahpsz."],ve=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],ze=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),$e=e=>ye(we[e]),je=e=>{const t=e[ye(be[0])]||e[ye(be[1])]||e[ye(be[2])];if(!t)return-1;const n=t.split("-");let o=function(e=""){let t=-2;const n=ge(ye(e));return n in ze&&(t=ze[n]),t}(n[0]);return 0===o||(e=>e[2]===ge(e[0]+e[1]))(n)||(o=-2),o};function ke(e,t){const{msgTimeout:n,warningTimeout:o}=t[e];o&&(n&&clearTimeout(n),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{initialised:n,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,n||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:n,waitForLoad:o}=t[e],{sandbox:i}=n,r=typeof i===y&&i.length>0&&!(i.contains("allow-scripts")&&i.contains("allow-same-origin"));se(e,"noResponse"),de(e,`<rb>No response from iframe</>\n \nThe iframe (<i>${e}</>) has not responded within ${t[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${o?"\nThe <b>waitForLoad</> option is currently set to <b>'true'</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'allow-scripts'</> values.\n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`)}(e,t))},o))}const Te=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:$,firstRun:!0,inPageLinks:!1,heightCalculationMethod:v,id:"iFrameResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:v,onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{typeof G[e.id].onInit===b&&(pe("init()","onReady()","",e.id),G[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),xe={position:null,version:e};function Me(t){function r(){We(N),Ce(B),I("onResized",N)}function l(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function m(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const y=e=>W.slice(W.indexOf(n)+7+e);const b=(e,t)=>(n,o)=>{const i={};var r,a;r=function(){Ne(`${n} (${e})`,`${e}:${t()}`,o)},i[a=o]||(r(),i[a]=requestAnimationFrame(()=>{i[a]=null}))},w=(e,t)=>()=>{let n=!1;const o=t=>()=>{G[c]?n&&n!==t||(e(t,c),n=t,requestAnimationFrame(()=>{n=!1})):l()},i=o(p),r=o("resize window");function s(e,n){ne(c,`${e}listeners for send${t}`),n(window,p,i),n(window,f,r)}function l(){se(c,`stop${t}`),s("Remove ",he),d.disconnect(),u.disconnect(),he(G[c].iframe,a,l)}const c=B,d=new ResizeObserver(o("pageObserver")),u=new ResizeObserver(o("iframeObserver"));G[c]&&(G[c][`stop${t}`]=l,me(G[c].iframe,a,l),s("Add ",me),d.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),u.observe(G[c].iframe,{attributes:!0,childList:!1,subtree:!1}))},v=e=>()=>{e in G[B]&&(G[B][e](),delete G[B][e])},z=b(c,function(){const e=document.body.getBoundingClientRect(),t=N.iframe.getBoundingClientRect(),{scrollY:n,scrollX:o,innerHeight:i,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(a,i||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:n,scrollLeft:o,documentHeight:a,documentWidth:s,windowHeight:i,windowWidth:r})}),$=b(d,function(){const{iframe:e}=N,{scrollWidth:t,scrollHeight:n}=document.documentElement,{width:o,height:i,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:n},viewport:{width:o,height:i,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})}),j=w(z,"PageInfo"),T=w($,"ParentInfo"),x=v("stopPageInfo"),M=v("stopParentInfo");function E(e){const t=e.getBoundingClientRect();return Oe(B),{x:Number(t.left)+Number(xe.position.x),y:Number(t.top)+Number(xe.position.y)}}function R(e){const t=e?E(N.iframe):{x:0,y:0};oe(B,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,D,U,D);const n=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(N,t),o=window.parentIframe||window.parentIFrame;o?function(t,n){setTimeout(()=>t["scrollTo"+(e?"Offset":"")](n.x,n.y))}(o,n):function(e){xe.position=e,S(B)}(n)}function S(e){const{x:t,y:n}=xe.position,o=G[e]?.iframe;!1!==I("onScroll",{iframe:o,top:n,left:t,x:t,y:n})?Ce(e):Ie()}function O(e){let t={};if(0===N.width&&0===N.height){const e=y(9).split(n);t={x:e[1],y:e[0]}}else t={x:N.width,y:N.height};I(e,{iframe:N.iframe,screenX:Number(t.x),screenY:Number(t.y),type:N.type})}const I=(e,t)=>Ee(B,e,t);function C(){const{height:t,iframe:n,msg:a,type:l,width:f}=N;switch(G[B]?.firstRun&&function(){if(!G[B])return;ne(B,`First run for ${B}`),He(B,N.mode),G[B].firstRun=!1}(),l){case"close":Se(n);break;case s:m=y(6),ne(B,`onMessage passed: {iframe: %c${N.iframe.id}%c, message: %c${m}%c}`,D,U,D,U),I("onMessage",{iframe:N.iframe,message:JSON.parse(m)});break;case"mouseenter":O("onMouseEnter");break;case"mouseleave":O("onMouseLeave");break;case"beforeUnload":oe(B,"Ready state reset"),G[B].initialised=!1;break;case o:G[B].autoResize=JSON.parse(y(9));break;case"scrollBy":!function(){const e=N.width,t=N.height,n=window.parentIframe||window.parentIFrame||window;oe(B,`scrollBy: x: %c${e}%c y: %c${t}`,D,U,D),n.scrollBy(e,t)}();break;case"scrollTo":R(!1);break;case"scrollToOffset":R(!0);break;case c:j();break;case d:T();break;case"pageInfoStop":x();break;case"parentInfoStop":M();break;case"inPageLink":!function(e){const t=e.split("#")[1]||"",n=decodeURIComponent(t);let o=document.getElementById(n)||document.getElementsByName(n)[0];o?function(){const e=E(o);oe(B,`Moving to in page link: %c#${t}`,D),xe.position={x:e.x,y:e.y},S(B),window.location.hash=t}():window.top!==window.self?function(){const e=window.parentIframe||window.parentIFrame;e?e.moveToAnchor(t):ne(B,`In page link #${t} not found`)}():ne(B,`In page link #${t} not found`)}(y(9));break;case"title":!function(e,t){G[t]?.syncTitle&&(G[t].iframe.title=e,oe(t,`Set iframe title attribute: %c${e}`,D))}(a,B);break;case u:Ae(N);break;case i:r(),function(e){try{G[e].sameOrigin=!!G[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){G[e].sameOrigin=!1}ne(e,`sameOrigin: %c${G[e].sameOrigin}`,D)}(B),(p=a)!==e&&(void 0!==p?ne(B,`Version mismatch (Child: %c${p}%c !== Parent: %c${e})`,D,U,D):de(B,"<rb>Legacy version detected in iframe</>\n\nDetected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.\n\nSee <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.\n")),G[B].initialised=!0,I("onReady",n);break;default:if(0===f&&0===t)return void re(B,`Unsupported message received (${l}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===f||0===t)return void ne(B,"Ignoring message with 0 height or width");if(document.hidden)return void ne(B,"Page hidden - ignored resize request");r()}var p,m}function A(e){if(!G[e])throw new Error(`${N.type} No settings for ${e}. Message was: ${W}`)}let W=t.data;if("[iFrameResizerChild]Ready"===W)return L=t.source,void Object.values(G).forEach((e=>({initChild:t,postMessageTarget:n})=>{e===n&&t()})(L));var L;if(!(e=>k===`${e}`.slice(0,13)&&e.slice(13).split(n)[0]in G)(W)){if(typeof W!==g)return;return se(h,"ignoredMessage"),void ie(h,W)}const N=function(e){const t=e.slice(13).split(n),o=t[1]?Number(t[1]):0,i=G[t[0]]?.iframe,r=getComputedStyle(i),a={iframe:i,id:t[0],height:o+l(r)+m(r),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(a.mode=t[5]),a}(W),{id:F,type:P}=N,B=F;B?(se(B,P),ce(B,function(e){A(B),function(){const e=N.type in{true:1,false:1,undefined:1};return e&&ne(B,"Ignoring init message from meta parent page"),e}()||(ne(B,`Received: %c${e}`,D),(null!==N.iframe||(re(B,`The iframe (${N.id}) was not found.`),0))&&function(){const{origin:e,sameOrigin:n}=t;if(n)return!0;let o=G[B]?.checkOrigin;if(o&&"null"!=`${e}`&&!(o.constructor===Array?function(){let t=0,n=!1;for(ne(B,`Checking connection is from allowed list of origins: %c${o}`,D);t<o.length;t++)if(o[t]===e){n=!0;break}return n}():function(){const t=G[B]?.remoteHost;return ne(B,`Checking connection is from: %c${t}`,D),e===t}()))throw new Error(`Unexpected message received from: ${e} for ${N.iframe.id}. Message was: ${t.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&C())})(W)):re("","iframeResizer received messageData without id, message was: ",W)}function Ee(e,t,n){let o=null,i=null;if(G[e]){if(o=G[e][t],typeof o!==b)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{i=o(n)}catch(n){console.error(n),re(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,n)}return i}function Re(e){const{id:t}=e;ne(t,"Disconnected from iframe"),delete G[t],delete e.iframeResizer}function Se(e){const{id:t}=e;if(!1!==Ee(t,"onBeforeClose",t)){ne(t,`Removing iFrame: %c${t}`,D);try{e.parentNode&&e.remove()}catch(e){re(t,e)}Ee(t,"onAfterClose",t),Re(e)}else ne(t,"Close iframe cancelled by onBeforeClose")}function Oe(e){null===xe.position&&(xe.position={x:window.scrollX,y:window.scrollY},ne(e,`Get page position: %c${xe.position.x}%c, %c${xe.position.y}`,D,U,D))}function Ie(){xe.position=null}function Ce(e){null!==xe.position&&(window.scrollTo(xe.position.x,xe.position.y),oe(e,`Set page position: %c${xe.position.x}%c, %c${xe.position.y}`,D,U,D),Ie())}function Ae(e){ne(e.id,"Size reset requested by "+(e.type===i?"parent page":"child page")),Oe(e.id),We(e),Ne(u,u,e.id)}function We(e){function t(t){const o=`${e[t]}px`;e.iframe.style[t]=o,oe(n,`Set ${t}: %c${o}`,D)}const{id:n}=e,{sizeHeight:o,sizeWidth:i}=G[n];o&&t("height"),i&&t("width")}const Le=e=>e.split(n).filter((e,t)=>19!==t).join(n);function Ne(e,t,n){function o(o){const i=e in x?Le(t):t;oe(n,o,D,U,D),oe(n,`Message data: %c${i}`,D)}se(n,e),G[n]&&(G[n]?.postMessageTarget?function(){const{iframe:i,postMessageTarget:r,sameOrigin:a,targetOrigin:s}=G[n];if(a)try{return i.contentWindow.iframeChildListener(k+t),void o(`Sending message to iframe %c${n}%c via same origin%c`)}catch(t){e in x?(G[n].sameOrigin=!1,ne(n,"New iframe does not support same origin")):re(n,"Same origin messaging failed, falling back to postMessage")}o(`Sending message to iframe: %c${n}%c targetOrigin: %c${s}`),r.postMessage(k+t,s)}():re(n,`Iframe(${n}) not found`))}let Fe=0,Pe=!1,Be=!1;function He(t,n=-3){if(Pe)return;const o=Math.max(G[t].mode,n);if(o>G[t].mode&&(G[t].mode=o),o<0)throw le(t),G[t].vAdvised||de(t||"Parent",`${$e(o+2)}${$e(2)}`),G[t].vAdvised=!0,$e(o+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");o>0&&Be||function(e,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,_||t<1?"font-weight: bold;":S))}(`v${e} (${(e=>ye(ve[e]))(o)})`,o),o<1&&de("Parent",$e(3)),Pe=!0}const qe=e=>c=>{function d(){G[O]?.heightCalculationMethod in T&&Ae({iframe:c,height:1,width:1,type:i})}function u(){if(G[O]){const{iframe:e}=G[O],t={close:Se.bind(null,e),disconnect:Re.bind(null,e),removeListeners(){de(O,"<rb>Deprecated Method Name</>\n\nThe [removeListeners()</> method has been renamed to [disconnect()</>.\n"),this.disconnect()},resize(){de(O,"<rb>Deprecated Method</>\n \nUse of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As their are no longer any edge cases that require triggering a resize from the parent page, it is recommended to remove this method from your code."),Ne.bind(null,"Window resize",f,O)},moveToAnchor(e){((e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,g,"moveToAnchor(anchor) anchor"),Ne("Move to anchor",`moveToAnchor:${e}`,O)},sendMessage(e){e=JSON.stringify(e),Ne(s,`${s}:${e}`,O)}};e.iframeResizer=t,e.iFrameResizer=t}}function p(e,t){const n=n=>()=>{if(!G[e])return;const{firstRun:o,iframe:r}=G[e];Ne(n,t,e),(e=>e===i)(n)&&(e=>"lazy"===e.loading)(r)||ke(e,G),o||d()},{iframe:o}=G[e];G[e].initChild=n(r),function(e,t){me(e,a,()=>setTimeout(t,1))}(o,n(l)),function(e,t){const{iframe:n,waitForLoad:o}=G[e];!0!==o&&((e=>{const{src:t,srcdoc:n}=e;return!n&&(null==t||""===t||"about:blank"===t)})(n)?setTimeout(()=>{se(e,"noContent"),oe(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(t))}(e,n(i))}function h(e){return e?(("sizeWidth"in e||"sizeHeight"in e||o in e)&&de(O,`<rb>Deprecated Option</>\n\nThe <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <i>"${$}"</>, <i>"${j}"</> or <i>"${z}"</>.\n`),e):{}}function b(e){const t=G[e]?.iframe?.title;return""===t||void 0===t}function w(e,t){V(G[O],e)&&(de(O,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${t}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),G[O][t]=G[O][e],delete G[O][e])}const k=e=>V(e,"onMouseEnter")||V(e,"onMouseLeave");function x(e){var t,n;G[O]={...G[O],iframe:c,remoteHost:c?.src.split("/").slice(0,3).join("/"),...Te,...h(e),mouseEvents:k(e),mode:je(e),syncTitle:b(O)},w("offset","offsetSize"),w("onClose","onBeforeClose"),w("onClosed","onAfterClose"),se(O,"setup"),function(){const{direction:e}=G[O];switch(e){case $:break;case j:G[O].sizeHeight=!1;case"both":G[O].sizeWidth=!0;break;case z:G[O].sizeWidth=!1,G[O].sizeHeight=!1,G[O].autoResize=!1;break;default:throw new TypeError(O,`Direction value of "${e}" is not valid`)}ne(O,`direction: %c${e}`,D)}(),(t=e?.offsetSize||e?.offset)&&(G[O].direction===$?(G[O].offsetHeight=t,ne(O,`Offset height: %c${t}`,D)):(G[O].offsetWidth=t,ne(O,`Offset width: %c${t}`,D))),function(e){e?.offset&&de(O,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.")}(e),G[O].warningTimeout||oe(O,"warningTimeout:%c disabled",D),null===G[O].postMessageTarget&&(G[O].postMessageTarget=c.contentWindow),G[O].targetOrigin=!0===G[O].checkOrigin?""===(n=G[O].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}const S=()=>t in c,O=function(t){if(t&&typeof t!==g)throw new TypeError("Invalid id for iFrame. Expected String");return""!==t&&t||(t=function(){let t=e?.id||Te.id+Fe++;return null!==document.getElementById(t)&&(t+=Fe++),t}(),c.id=t,se(t,"assignId"),ne(t,`Added missing iframe ID: ${t} (${c.src})`)),t}(c.id);if(typeof e!==y)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=E,e.logExpand=t.includes("ifrlog=expanded"))}(e),function(e,t){const n=V(t,"log"),o=typeof t.log===g,i=n?!!o||t.log:Te.log;V(t,"logExpand")||(t.logExpand=n&&o?t.log===M:Te.logExpand),function(e){-1===e?.log&&(e.log=!1,Be=!0)}(t),function({enabled:e,expand:t,iframeId:n}){const o=X({expand:t,label:K(n)});_=e,G[n]||(G[n]={console:o})}({enabled:i,expand:t.logExpand,iframeId:e}),o&&!(t.log in R)&&ae(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=i}(O,e),ce(O,function(e){S()?re(O,`Ignored iframe (${O}), already setup.`):(x(e),ne(O,`src: %c${c.srcdoc||c.src}`,D),function(){if(Pe)return;const{mode:e}=G[O];-1!==e&&He(O,e)}(),Ue(),function(){switch(ne(O,`Iframe scrolling ${G[O]?.scrolling?"enabled":"disabled"} for ${O}`),c.style.overflow=!1===G[O]?.scrolling?"hidden":v,G[O]?.scrolling){case"omit":break;case!0:c.scrolling="yes";break;case!1:c.scrolling="no";break;default:c.scrolling=G[O]?G[O].scrolling:"no"}}(),function(){const{bodyMargin:e}=G[O];"number"!=typeof e&&"0"!==e||(G[O].bodyMargin=`${e}px`)}(),p(O,function(e){const{autoResize:t,bodyBackground:o,bodyMargin:i,bodyPadding:r,heightCalculationMethod:a,inPageLinks:s,license:l,log:c,logExpand:d,mouseEvents:u,offsetHeight:f,offsetWidth:p,mode:h,sizeHeight:g,sizeWidth:y,tolerance:b,widthCalculationMethod:w}=G[e];return[e,"8",y,c,"32",!0,t,i,a,o,r,b,s,m,w,u,f,p,g,l,xe.version,h,"",d].join(n)}(O)),u(),ne(O,"Setup complete"))})(e),c?.iframeResizer};function De(){!0!==document.hidden&&((e,t)=>{Object.values(G).filter(({autoResize:e,firstRun:t})=>e&&!t).forEach(({iframe:n})=>Ne(e,t,n.id))})("tabVisible",f)}const Ue=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{me(window,s,Me),me(document,"visibilitychange",De),window.iframeParentListener=e=>setTimeout(()=>Me({data:e,sameOrigin:!0}))}),Je=`[${t}] `;const Ve=function(){function e(e){switch(!0){case!e:throw new TypeError(`${Je}iframe is not defined`);case!e.tagName:throw new TypeError(`${Je}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${Je}Expected <IFRAME> tag, found <${e.tagName}>`);default:t(e),n.push(e)}}let t,n;return function(o,i){if(typeof window===w)return[];switch(t=qe(o),n=[],typeof i){case w:case g:document.querySelectorAll(i||"iframe").forEach(e);break;case y:e(i);break;default:throw new TypeError(`${Je}Unexpected data type (${typeof i})`)}return Object.freeze(n)}}();return typeof window!==w&&(window.iFrameResize=window.iFrameResize||function(...e){fe("iFrameResize()","iframeResize()","",h),Ve(...e)}),Ve});
|
|
21
21
|
//# sourceMappingURL=iframeResizer.js.map
|