New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@iframe-resizer/parent

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iframe-resizer/parent - npm Package Compare versions

Comparing version 5.0.1 to 5.0.2

3

iframe-resizer.parent.d.ts

@@ -166,3 +166,3 @@ /**

}
function iframeResize(

@@ -180,2 +180,3 @@ options: IFrameOptions,

export default iframeResize;
}
/*!
* @preserve
*
* @module iframe-resizer/parent 5.0.1 (cjs) - 2024-05-21
* @module iframe-resizer/parent 5.0.2 (cjs) - 2024-05-30
*

@@ -12,3 +12,3 @@ * @license GPL-3.0 for non-commercial use only.

*
* @author David J. Bradshaw <dave@bradshaw.net>
* @author David J. Bradshaw <info@iframe-resizer.com>
*

@@ -21,2 +21,57 @@ * @see {@link https://iframe-resizer.com}

"use strict";const e=require("@iframe-resizer/core"),r="[iframeResizer] ";const t=function(){function t(e){switch(!0){case!e:throw new TypeError(`${r}iframe is not defined`);case!e.tagName:throw new TypeError(`${r}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${r}Expected <IFRAME> tag, found <${e.tagName}>`);default:o(e),a.push(e)}}let o,a;return function(n,c){if("undefined"==typeof window)return[];switch(o=e(n),a=[],typeof c){case"undefined":case"string":document.querySelectorAll(c||"iframe").forEach(t);break;case"object":t(c);break;default:throw new TypeError(`${r}Unexpected data type (${typeof c})`)}return Object.freeze(a)}}();module.exports=t;
'use strict';
const connectResizer = require('@iframe-resizer/core');
const id = '[iframeResizer] ';
function createIframeResize() {
function setup(element) {
switch (true) {
case !element:
throw new TypeError(`${id}iframe is not defined`)
case !element.tagName:
throw new TypeError(`${id}Not a valid DOM element`)
case element.tagName.toUpperCase() !== 'IFRAME':
throw new TypeError(
`${id}Expected <IFRAME> tag, found <${element.tagName}>`,
)
default:
connectWithOptions(element);
iFrames.push(element);
}
}
let connectWithOptions;
let iFrames;
return function (options, target) {
if (typeof window === 'undefined') return [] // don't run for server side render
connectWithOptions = connectResizer(options);
iFrames = []; // Only return iFrames past in on this call
switch (typeof target) {
case 'undefined':
case 'string':
document.querySelectorAll(target || 'iframe').forEach(setup);
break
case 'object':
setup(target);
break
default:
throw new TypeError(`${id}Unexpected data type (${typeof target})`)
}
return Object.freeze(iFrames)
}
}
const esm = createIframeResize();
module.exports = esm;
/*!
* @preserve
*
* @module iframe-resizer/parent 5.0.1 (esm) - 2024-05-21
* @module iframe-resizer/parent 5.0.2 (esm) - 2024-05-30
*

@@ -12,3 +12,3 @@ * @license GPL-3.0 for non-commercial use only.

*
* @author David J. Bradshaw <dave@bradshaw.net>
* @author David J. Bradshaw <info@iframe-resizer.com>
*

@@ -21,2 +21,55 @@ * @see {@link https://iframe-resizer.com}

import e from"@iframe-resizer/core";const r="[iframeResizer] ";const t=function(){function t(e){switch(!0){case!e:throw new TypeError(`${r}iframe is not defined`);case!e.tagName:throw new TypeError(`${r}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${r}Expected <IFRAME> tag, found <${e.tagName}>`);default:a(e),o.push(e)}}let a,o;return function(n,c){if("undefined"==typeof window)return[];switch(a=e(n),o=[],typeof c){case"undefined":case"string":document.querySelectorAll(c||"iframe").forEach(t);break;case"object":t(c);break;default:throw new TypeError(`${r}Unexpected data type (${typeof c})`)}return Object.freeze(o)}}();export{t as default};
import connectResizer from '@iframe-resizer/core';
const id = '[iframeResizer] ';
function createIframeResize() {
function setup(element) {
switch (true) {
case !element:
throw new TypeError(`${id}iframe is not defined`)
case !element.tagName:
throw new TypeError(`${id}Not a valid DOM element`)
case element.tagName.toUpperCase() !== 'IFRAME':
throw new TypeError(
`${id}Expected <IFRAME> tag, found <${element.tagName}>`,
)
default:
connectWithOptions(element);
iFrames.push(element);
}
}
let connectWithOptions;
let iFrames;
return function (options, target) {
if (typeof window === 'undefined') return [] // don't run for server side render
connectWithOptions = connectResizer(options);
iFrames = []; // Only return iFrames past in on this call
switch (typeof target) {
case 'undefined':
case 'string':
document.querySelectorAll(target || 'iframe').forEach(setup);
break
case 'object':
setup(target);
break
default:
throw new TypeError(`${id}Unexpected data type (${typeof target})`)
}
return Object.freeze(iFrames)
}
}
const esm = createIframeResize();
export { esm as default };
/*!
* @preserve
*
* @module iframe-resizer/parent 5.0.1 (umd) - 2024-05-21
* @module iframe-resizer/parent 5.0.2 (umd) - 2024-05-30
*

@@ -12,3 +12,3 @@ * @license GPL-3.0 for non-commercial use only.

*
* @author David J. Bradshaw <dave@bradshaw.net>
* @author David J. Bradshaw <info@iframe-resizer.com>
*

@@ -21,2 +21,1260 @@ * @see {@link https://iframe-resizer.com}

!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";const e="[iframe-resizer]";const t=t=>`${e}[${function(e){return window.top===window.self?`Parent page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested parent page: ${e}`}(t)}]`,i=(e,i,...n)=>window?.console[e](t(i),...n),n=(e,...t)=>i("warn",e,...t),o=(t,i)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e(t.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))((t=>(...i)=>[`${e}[${t}]`,...i].join(" "))(t))(i)),r="5.0.1",a="[iFrameSizer]",s=a.length,l=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),c=(e,t,i,n)=>e.addEventListener(t,i,n||!1),d=(e,t,i)=>e.removeEventListener(t,i,!1),u=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let n,o=0;o<e.length;o++)n=e.codePointAt(o),t=Math.imul(t^n,2246822519),i=Math.imul(i^n,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},f=e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))),p=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>."],m=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],h=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)]))),y=e=>f(p[e]),g=e=>{const t=e[f("spjluzl")];if(!t)return-1;const i=t.split("-");let n=function(e=""){let t=-2;const i=u(f(e));return i in h&&(t=h[i]),t}(i[0]);return 0===n||(e=>e[2]===u(e[0]+e[1]))(i)||(n=-2),n},w={},b=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:"vertical",inPageLinks:!1,heightCalculationMethod:"auto",id:"iFrameResizer",log:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"auto",onClose:()=>!0,onClosed(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof w[e.id].onInit&&(o(e.id,"\nDeprecated Option\n\nThe onInit() function is deprecated and has been replaced with onReady(). It will be removed in a future version of iFrame Resizer.\n "),w[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),v={position:null,version:r};function z(e){function t(){x(L),M(),C("onResized",L)}function i(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function l(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function u(e){return H.slice(H.indexOf(":")+7+e)}const f=(e,t)=>(i,n)=>{const o={};var r,a;r=function(){S(`Send ${e} (${i})`,`${e}:${t()}`,n)},o[a=n]||(r(),o[a]=requestAnimationFrame((()=>{o[a]=null})))},p=(e,t)=>()=>{const i=t=>()=>{w[r]?e(t,r):o()};function n(e,t){t(window,"scroll",i("scroll")),t(window,"resize",i("resize window"))}function o(){n(0,d),a.disconnect(),s.disconnect()}const r=P,a=new ResizeObserver(i("page observed")),s=new ResizeObserver(i("iframe observed"));n(0,c),a.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),s.observe(w[r].iframe,{attributes:!0,childList:!1,subtree:!1}),w[r]&&(w[r][`stop${t}`]=o)},m=e=>()=>{e in w[P]&&(w[P][e](),delete w[P][e])},h=f("pageInfo",(function(){const e=document.body.getBoundingClientRect(),t=L.iframe.getBoundingClientRect(),{scrollY:i,scrollX:n,innerHeight:o,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(a,o||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:n,documentHeight:a,documentWidth:s,windowHeight:o,windowWidth:r})})),y=f("parentInfo",(function(){const{iframe:e}=L,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})})),g=p(h,"PageInfo"),b=p(y,"ParentInfo"),z=m("stopPageInfo"),T=m("stopParentInfo");function W(e){const t=e.getBoundingClientRect();return k(),{x:Number(t.left)+Number(v.position.x),y:Number(t.top)+Number(v.position.y)}}function F(e){const t=e?W(L.iframe):{x:0,y:0};let i=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(L,t);window.top===window.self?(v.position=i,O(P)):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):n(P,"Unable to scroll to requested position, window.parentIFrame not found")}function O(e){const{x:t,y:i}=v.position,n=w[e]?.iframe;!1!==C("onScroll",{iframe:n,top:i,left:t,x:t,y:i})?M():R()}function A(e){let t={};if(0===L.width&&0===L.height){const e=u(9).split(":");t={x:e[1],y:e[0]}}else t={x:L.width,y:L.height};C(e,{iframe:L.iframe,screenX:Number(t.x),screenY:Number(t.y),type:L.type})}const C=(e,t)=>j(P,e,t);let H=e.data,L={},P=null;"[iFrameResizerChild]Ready"!==H?a===`${H}`.slice(0,s)&&H.slice(s).split(":")[0]in w&&(L=function(){const e=H.slice(s).split(":"),t=e[1]?Number(e[1]):0,n=w[e[0]]?.iframe,o=getComputedStyle(n);return{iframe:n,id:e[0],height:t+i(o)+l(o),width:Number(e[2]),type:e[3],version:e[4]}}(),P=L.id,P?(function(e){if(!w[e])throw new Error(`${L.type} No settings for ${e}. Message was: ${H}`)}(P),L.type in{true:1,false:1,undefined:1}||(w[P].loaded=!0,function(){let e=!0;return null===L.iframe&&(n(P,`The iframe (${L.id}) was not found.`),e=!1),e}()&&function(){const{origin:t,sameDomain:i}=e;if(i)return!0;let n=w[P]?.checkOrigin;if(n&&"null"!=`${t}`&&!(n.constructor===Array?function(){let e=0,i=!1;for(;e<n.length;e++)if(n[e]===t){i=!0;break}return i}():function(){const e=w[P]?.remoteHost;return t===e}()))throw new Error(`Unexpected message received from: ${t} for ${L.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}()&&function(){switch(w[P]?.firstRun&&w[P]&&(w[P].firstRun=!1),L.type){case"close":$(L.iframe);break;case"message":i=u(6),C("onMessage",{iframe:L.iframe,message:JSON.parse(i)});break;case"mouseenter":A("onMouseEnter");break;case"mouseleave":A("onMouseLeave");break;case"autoResize":w[P].autoResize=JSON.parse(u(9));break;case"scrollTo":F(!1);break;case"scrollToOffset":F(!0);break;case"pageInfo":h("start",P),g();break;case"parentInfo":y("start",P),b();break;case"pageInfoStop":z();break;case"parentInfoStop":T();break;case"inPageLink":!function(e){const t=e.split("#")[1]||"",i=decodeURIComponent(t);let n=document.getElementById(i)||document.getElementsByName(i)[0];n?function(){const e=W(n);v.position={x:e.x,y:e.y},O(P)}():window.top!==window.self&&window.parentIFrame&&window.parentIFrame.moveToAnchor(t)}(u(9));break;case"reset":I(L);break;case"init":t(),function(e){try{w[e].sameDomain=!!w[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){w[e].sameDomain=!1}}(P),(e=L.version)!==r&&(void 0!==e||o(P,"<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")),N=!0,C("onReady",L.iframe);break;default:if(0===L.width&&0===L.height)return void n(`Unsupported message received (${L.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===L.width||0===L.height)return;if(document.hidden)return;t()}var e,i}())):n("iframeResizer received messageData without id, message was: ",H)):Object.keys(w).forEach((e=>{w[e].mode>=0&&S("iFrame requested init",E(e),e)}))}function j(e,t,i){let n=null,o=null;if(w[e]){if(n=w[e][t],"function"!=typeof n)throw new TypeError(`${t} on iFrame[${e}] is not a function`);o=n(i)}return o}function T(e){const t=e.id;delete w[t]}function $(e){const t=e.id;if(!1!==j(t,"onClose",t)){try{e.parentNode&&e.remove()}catch(e){n(e)}j(t,"onClosed",t),T(e)}}function k(e){null===v.position&&(v.position={x:window.scrollX,y:window.scrollY})}function R(){v.position=null}function M(e){null!==v.position&&(window.scrollTo(v.position.x,v.position.y),R())}function I(e){k(e.id),x(e),S("reset","reset",e.id)}function x(e){const t=e.id;function i(t){const i=`${e[t]}px`;e.iframe.style[t]=i}w[t].sizeHeight&&i("height"),w[t].sizeWidth&&i("width")}function S(e,t,i,r){w[i]&&(w[i]?.postMessageTarget?function(){const{postMessageTarget:e,targetOrigin:n}=w[i];if(w[i].sameDomain)try{return void w[i].iframe.contentWindow.iframeChildListener(a+t)}catch(e){w[i].sameDomain=!1}e.postMessage(a+t,n)}():n(i,`[${e}] IFrame(${i}) not found`),r&&w[i]?.warningTimeout&&(w[i].msgTimeout=setTimeout((function(){void 0!==w[i]&&(w[i].loaded||w[i].loadErrorShown||(w[i].loadErrorShown=!0,o(i,`\n<rb>No response from iFrame</>\n \nThe iframe (<i>${i}</>) has not responded within ${w[i].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\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`)))}),w[i].warningTimeout)))}function E(e){const t=w[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,v.version,t.mode].join(":")}let W=0,N=!1,F=!1;const O=e=>t=>{function a(e){if(!e)return{};if("object"!=typeof e)throw new TypeError("Options is not an object");return("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&o(s,'<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>"vertical"</>, <i>"horizontal"</> or <i>"horizontal"</>.\n'),e}const s=function(i){if(i&&"string"!=typeof i)throw new TypeError("Invalid id for iFrame. Expected String");return""!==i&&i||(t.id=i=function(){let t=e?.id||b.id+W++;return null!==document.getElementById(t)&&(t+=W++),t}(),(e||{}).log),i}(t.id);return s in w&&"iFrameResizer"in t?n(s,"Ignored iFrame, already setup."):(function(e){var i,n;w[s]={iframe:t,firstRun:!0,remoteHost:t?.src.split("/").slice(0,3).join("/"),...b,...a(e),mode:g(e)},function(){if("horizontal"===w[s].direction)return w[s].sizeWidth=!0,void(w[s].sizeHeight=!1);if("none"===w[s].direction)return w[s].sizeWidth=!1,w[s].sizeHeight=!1,void(w[s].autoResize=!1);if("vertical"!==w[s].direction)throw new TypeError(s,`Direction value of "${w[s].direction}" is not valid`)}(),i=e?.offset,i&&("vertical"===w[s].direction?w[s].offsetHeight=i:w[s].offsetWidth=i),null===w[s].postMessageTarget&&(w[s].postMessageTarget=t.contentWindow),w[s].targetOrigin=!0===w[s].checkOrigin?""===(n=w[s].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}(e),function(){const{mode:e}=w[s];e<0&&o("Parent",`${y(e+2)}${y(2)}`),F||e<0||(F=!0,((e,...t)=>{i("info",e,...t)})(`v${r} (${(e=>f(m[e]))(e)})`),e<1&&o("Parent",y(3)))}(),C(),function(){switch(t.style.overflow=!1===w[s]?.scrolling?"hidden":"auto",w[s]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=w[s]?w[s].scrolling:"no"}}(),function(){const{bodyMargin:e}=w[s];"number"!=typeof e&&"0"!==e||(w[s].bodyMargin=`${e}px`)}(),function(e){const{id:i}=t;w[s].mode>=0&&(c(t,"load",(function(){S("iFrame.onload",`${e}:${N}`,i,!0),function(){const e=w[s]?.firstRun,i=w[s]?.heightCalculationMethod in l;!e&&i&&I({iframe:t,height:0,width:0,type:"init"})}()})),S("init",`${e}:${N}`,i,!0))}(E(s)),function(){if(w[s]){const e={close:$.bind(null,w[s].iframe),disconnect:T.bind(null,w[s].iframe),removeListeners(){o(s,"\n<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize:S.bind(null,"Window resize","resize",s),moveToAnchor(e){S("Move to anchor",`moveToAnchor:${e}`,s)},sendMessage(e){S("Send Message",`message:${e=JSON.stringify(e)}`,s)}};w[s].iframe.iframeResizer=e,w[s].iframe.iFrameResizer=e}}()),t?.iFrameResizer};function A(){!1===document.hidden&&function(e,t){const i=e=>w[e]?.autoResize&&!w[e]?.firstRun;Object.keys(w).forEach((function(n){i(n)&&S(e,t,n)}))}("Tab Visible","resize")}const C=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})((()=>{c(window,"message",z),c(document,"visibilitychange",A),window.iframeParentListener=e=>z({data:e,sameDomain:!0})})),H="[iframeResizer] ";const L=function(){function e(e){switch(!0){case!e:throw new TypeError(`${H}iframe is not defined`);case!e.tagName:throw new TypeError(`${H}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${H}Expected <IFRAME> tag, found <${e.tagName}>`);default:t(e),i.push(e)}}let t,i;return function(n,o){if("undefined"==typeof window)return[];switch(t=O(n),i=[],typeof o){case"undefined":case"string":document.querySelectorAll(o||"iframe").forEach(e);break;case"object":e(o);break;default:throw new TypeError(`${H}Unexpected data type (${typeof o})`)}return Object.freeze(i)}}();return"undefined"!=typeof window&&(window.iFrameResize=function(...e){o("","Deprecated: iFrameResize(), please use iframeResize()"),L(...e)}),L}));
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.iframeResize = factory());
})(this, (function () { 'use strict';
const encode = (s) =>
s
.replaceAll('<br>', '\n')
.replaceAll('<rb>', '\u001B[31;1m')
.replaceAll('</>', '\u001B[m')
.replaceAll('<b>', '\u001B[1m')
.replaceAll('<i>', '\u001B[3m')
.replaceAll('<u>', '\u001B[4m');
const remove = (s) => s.replaceAll('<br>', '\n').replaceAll(/<[/a-z]+>/gi, '');
const formatAdvise = (formatLogMsg) => (msg) =>
window.chrome // Only show formatting in Chrome as not supported in other browsers
? formatLogMsg(encode(msg))
: formatLogMsg(remove(msg));
const msgId$1 = '[iframe-resizer]';
function setLogEnabled(enabled) {
}
function getMyID(iframeId) {
if (window.top === window.self) {
return `Parent page: ${iframeId}`
}
return window?.parentIFrame?.getId
? `${window.parentIFrame.getId()}: ${iframeId}`
: `Nested parent page: ${iframeId}`
}
const formatLogHeader = (iframeId) => `${msgId$1}[${getMyID(iframeId)}]`;
const formatLogMsg =
(iframeId) =>
(...msg) =>
[`${msgId$1}[${iframeId}]`, ...msg].join(' ');
const output = (type, iframeId, ...msg) =>
// eslint-disable-next-line no-console
window?.console[type](formatLogHeader(iframeId), ...msg);
const info = (iframeId, ...msg) => output('info', iframeId, ...msg);
const warn = (iframeId, ...msg) => output('warn', iframeId, ...msg);
const advise = (iframeId, msg) =>
// eslint-disable-next-line no-console
console?.warn(formatAdvise(formatLogMsg(iframeId))(msg));
const VERSION = '5.0.2';
const msgHeader = 'message';
const msgHeaderLen = msgHeader.length;
const msgId = '[iFrameSizer]'; // Must match iframe msg ID
const msgIdLen = msgId.length;
const resetRequiredMethods = Object.freeze({
max: 1,
scroll: 1,
bodyScroll: 1,
documentElementScroll: 1,
});
const addEventListener = (el, evt, func, options) =>
el.addEventListener(evt, func, options || false);
const removeEventListener = (el, evt, func) =>
el.removeEventListener(evt, func, false);
const l = (l) => {
if (!l) return ''
let p = -559038744,
y = 1103547984;
for (let z, t = 0; t < l.length; t++)
(z = l.codePointAt(t)),
(p = Math.imul(p ^ z, 2246822519)),
(y = Math.imul(y ^ z, 3266489917));
return (
(p ^= Math.imul(p ^ (y >>> 15), 1935289751)),
(y ^= Math.imul(y ^ (p >>> 15), 3405138345)),
(p ^= y >>> 16),
(y ^= p >>> 16),
(2097152 * (y >>> 0) + (p >>> 11)).toString(36)
)
},
p = (l) =>
l.replaceAll(/[A-Za-z]/g, (l) =>
String.fromCodePoint(
(l <= 'Z' ? 90 : 122) >= (l = l.codePointAt(0) + 19) ? l : l - 26,
),
),
y = [
'<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</>.',
],
z = ['NWSc3', 'zvsv', 'wyv', 'ibzpulzz', 'vlt'],
t = Object.fromEntries(
[
'2cgs7fdf4xb',
'1c9ctcccr4z',
'1q2pc4eebgb',
'ueokt0969w',
'w2zxchhgqz',
'1umuxblj2e5',
].map((l, p) => [l, Math.max(0, p - 1)]),
);
const getModeData = (l) => p(y[l]);
const getModeLabel = (l) => p(z[l]);
const setMode = (y) => {
const z = y[p('spjluzl')];
if (!z) return -1
const u = z.split('-');
let v = (function (y = '') {
let z = -2;
const u = l(p(y));
return u in t && (z = t[u]), z
})(u[0]);
return 0 === v || ((p) => p[2] === l(p[0] + p[1]))(u) || (v = -2), v
};
const once = (fn) => {
let done = false;
return function () {
return done
? undefined
: ((done = true), Reflect.apply(fn, this, arguments))
}
};
const settings = {};
const onReadyDeprecated = (messageData) => {
if (typeof settings[messageData.id].onInit === 'function') {
advise(
messageData.id,
`
\u001B[31;1mDeprecated Option\u001B[m
The \u001B[1monInit()\u001B[m function is deprecated and has been replaced with \u001B[1monReady()\u001B[m. It will be removed in a future version of iFrame Resizer.
`,
);
settings[messageData.id].onInit(messageData);
}
};
const defaults = Object.freeze({
autoResize: true,
bodyBackground: null,
bodyMargin: null,
bodyPadding: null,
checkOrigin: true,
direction: 'vertical',
inPageLinks: false,
heightCalculationMethod: 'auto',
id: 'iFrameResizer',
log: false,
license: undefined,
mouseEvents: true,
offsetHeight: null,
offsetWidth: null,
postMessageTarget: null,
sameDomain: false,
scrolling: false,
sizeHeight: true,
sizeWidth: false,
warningTimeout: 5000,
tolerance: 0,
widthCalculationMethod: 'auto',
onClose: () => true,
onClosed() {},
onInit: false,
onMessage: null,
onMouseEnter() {},
onMouseLeave() {},
onReady: onReadyDeprecated,
onResized() {},
onScroll: () => true,
});
const page = {
position: null,
version: VERSION,
};
function iframeListener(event) {
function resizeIFrame() {
setSize(messageData);
setPagePosition();
on('onResized', messageData);
}
function getPaddingEnds(compStyle) {
if (compStyle.boxSizing !== 'border-box') {
return 0
}
const top = compStyle.paddingTop ? parseInt(compStyle.paddingTop, 10) : 0;
const bot = compStyle.paddingBottom
? parseInt(compStyle.paddingBottom, 10)
: 0;
return top + bot
}
function getBorderEnds(compStyle) {
if (compStyle.boxSizing !== 'border-box') {
return 0
}
const top = compStyle.borderTopWidth
? parseInt(compStyle.borderTopWidth, 10)
: 0;
const bot = compStyle.borderBottomWidth
? parseInt(compStyle.borderBottomWidth, 10)
: 0;
return top + bot
}
function processMsg() {
const data = msg.slice(msgIdLen).split(':');
const height = data[1] ? Number(data[1]) : 0;
const iframe = settings[data[0]]?.iframe;
const compStyle = getComputedStyle(iframe);
return {
iframe,
id: data[0],
height: height + getPaddingEnds(compStyle) + getBorderEnds(compStyle),
width: Number(data[2]),
type: data[3],
version: data[4],
}
}
function isMessageFromIFrame() {
function checkAllowedOrigin() {
function checkList() {
let i = 0;
let retCode = false;
for (; i < checkOrigin.length; i++) {
if (checkOrigin[i] === origin) {
retCode = true;
break
}
}
return retCode
}
function checkSingle() {
const remoteHost = settings[iframeId]?.remoteHost;
return origin === remoteHost
}
return checkOrigin.constructor === Array ? checkList() : checkSingle()
}
const { origin, sameDomain } = event;
if (sameDomain) {
return true
}
let checkOrigin = settings[iframeId]?.checkOrigin;
if (checkOrigin && `${origin}` !== 'null' && !checkAllowedOrigin()) {
throw new Error(
`Unexpected message received from: ${origin} for ${messageData.iframe.id}. Message was: ${event.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`,
)
}
return true
}
function isMessageForUs() {
return (
msgId === `${msg}`.slice(0, msgIdLen) &&
msg.slice(msgIdLen).split(':')[0] in settings
) // ''+Protects against non-string msg
}
function isMessageFromMetaParent() {
// Test if this message is from a parent above us. This is an ugly test, however, updating
// the message format would break backwards compatibility.
const retCode = messageData.type in { true: 1, false: 1, undefined: 1 };
return retCode
}
function getMsgBody(offset) {
return msg.slice(msg.indexOf(':') + msgHeaderLen + offset)
}
function forwardMsgFromIFrame(msgBody) {
on('onMessage', {
iframe: messageData.iframe,
message: JSON.parse(msgBody),
});
}
function getPageInfo() {
const bodyPosition = document.body.getBoundingClientRect();
const iFramePosition = messageData.iframe.getBoundingClientRect();
const { scrollY, scrollX, innerHeight, innerWidth } = window;
const { clientHeight, clientWidth } = document.documentElement;
return JSON.stringify({
iframeHeight: iFramePosition.height,
iframeWidth: iFramePosition.width,
clientHeight: Math.max(clientHeight, innerHeight || 0),
clientWidth: Math.max(clientWidth, innerWidth || 0),
offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10),
offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10),
scrollTop: scrollY,
scrollLeft: scrollX,
documentHeight: clientHeight,
documentWidth: clientWidth,
windowHeight: innerHeight,
windowWidth: innerWidth,
})
}
function getParentProperties() {
const { iframe } = messageData;
const { scrollWidth, scrollHeight } = document.documentElement;
const { width, height, offsetLeft, offsetTop, pageLeft, pageTop, scale } =
window.visualViewport;
return JSON.stringify({
iframe: iframe.getBoundingClientRect(),
document: {
scrollWidth,
scrollHeight,
},
viewport: {
width,
height,
offsetLeft,
offsetTop,
pageLeft,
pageTop,
scale,
},
})
}
const sendInfoToIframe = (type, infoFunction) => (requestType, iframeId) => {
const gate = {};
function throttle(func, frameId) {
if (!gate[frameId]) {
func();
gate[frameId] = requestAnimationFrame(() => {
gate[frameId] = null;
});
}
}
function gatedTrigger() {
trigger(
`Send ${type} (${requestType})`,
`${type}:${infoFunction()}`,
iframeId,
);
}
throttle(gatedTrigger, iframeId);
};
const startInfoMonitor = (sendInfoToIframe, type) => () => {
const sendInfo = (requestType) => () => {
if (settings[id]) {
sendInfoToIframe(requestType, id);
} else {
stop();
}
};
function setListener(requestType, listener) {
listener(window, 'scroll', sendInfo('scroll'));
listener(window, 'resize', sendInfo('resize window'));
}
function stop() {
setListener('Remove ', removeEventListener);
pageObserver.disconnect();
iframeObserver.disconnect();
}
function start() {
setListener('Add ', addEventListener);
pageObserver.observe(document.body, {
attributes: true,
childList: true,
subtree: true,
});
iframeObserver.observe(settings[id].iframe, {
attributes: true,
childList: false,
subtree: false,
});
}
const id = iframeId; // Create locally scoped copy of iFrame ID
const pageObserver = new ResizeObserver(sendInfo('page observed'));
const iframeObserver = new ResizeObserver(sendInfo('iframe observed'));
start();
if (settings[id]) {
settings[id][`stop${type}`] = stop;
}
};
const stopInfoMonitor = (stopFunction) => () => {
if (stopFunction in settings[iframeId]) {
settings[iframeId][stopFunction]();
delete settings[iframeId][stopFunction];
}
};
const sendPageInfoToIframe = sendInfoToIframe('pageInfo', getPageInfo);
const sendParentInfoToIframe = sendInfoToIframe(
'parentInfo',
getParentProperties,
);
const startPageInfoMonitor = startInfoMonitor(
sendPageInfoToIframe,
'PageInfo',
);
const startParentInfoMonitor = startInfoMonitor(
sendParentInfoToIframe,
'ParentInfo',
);
const stopPageInfoMonitor = stopInfoMonitor('stopPageInfo');
const stopParentInfoMonitor = stopInfoMonitor('stopParentInfo');
function checkIFrameExists() {
let retBool = true;
if (messageData.iframe === null) {
warn(iframeId, `The iframe (${messageData.id}) was not found.`);
retBool = false;
}
return retBool
}
function getElementPosition(target) {
const iFramePosition = target.getBoundingClientRect();
getPagePosition();
return {
x: Number(iFramePosition.left) + Number(page.position.x),
y: Number(iFramePosition.top) + Number(page.position.y),
}
}
function scrollRequestFromChild(addOffset) {
/* istanbul ignore next */ // Not testable in Karma
function reposition() {
page.position = newPosition;
scrollTo(iframeId);
}
function scrollParent() {
if (window.parentIFrame) {
window.parentIFrame[`scrollTo${addOffset ? 'Offset' : ''}`](
newPosition.x,
newPosition.y,
);
} else {
warn(
iframeId,
'Unable to scroll to requested position, window.parentIFrame not found',
);
}
}
const calcOffset = (messageData, offset) => ({
x: messageData.width + offset.x,
y: messageData.height + offset.y,
});
const offset = addOffset
? getElementPosition(messageData.iframe)
: { x: 0, y: 0 };
let newPosition = calcOffset(messageData, offset);
if (window.top === window.self) {
reposition();
} else {
scrollParent();
}
}
function scrollTo(iframeId) {
const { x, y } = page.position;
const iframe = settings[iframeId]?.iframe;
if (on('onScroll', { iframe, top: y, left: x, x, y }) === false) {
unsetPagePosition();
return
}
setPagePosition();
}
function findTarget(location) {
function jumpToTarget() {
const jumpPosition = getElementPosition(target);
page.position = {
x: jumpPosition.x,
y: jumpPosition.y,
};
scrollTo(iframeId);
}
function jumpToParent() {
if (window.parentIFrame) {
window.parentIFrame.moveToAnchor(hash);
return
}
}
const hash = location.split('#')[1] || '';
const hashData = decodeURIComponent(hash);
let target =
document.getElementById(hashData) ||
document.getElementsByName(hashData)[0];
if (target) {
jumpToTarget();
return
}
if (window.top === window.self) {
return
}
jumpToParent();
}
function onMouse(event) {
let mousePos = {};
if (messageData.width === 0 && messageData.height === 0) {
const data = getMsgBody(9).split(':');
mousePos = {
x: data[1],
y: data[0],
};
} else {
mousePos = {
x: messageData.width,
y: messageData.height,
};
}
on(event, {
iframe: messageData.iframe,
screenX: Number(mousePos.x),
screenY: Number(mousePos.y),
type: messageData.type,
});
}
const on = (funcName, val) => chkEvent(iframeId, funcName, val);
function checkSameDomain(id) {
try {
settings[id].sameDomain =
!!settings[id]?.iframe?.contentWindow?.iframeChildListener;
} catch (error) {
settings[id].sameDomain = false;
}
}
function checkVersion(version) {
if (version === VERSION) return
if (version === undefined) {
advise(
iframeId,
`<rb>Legacy version detected in iframe</>
Detected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.
See <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.
`,
);
return
}
}
function started() {
setup = true;
}
function actionMsg() {
if (settings[iframeId]?.firstRun) firstRun();
switch (messageData.type) {
case 'close':
closeIFrame(messageData.iframe);
break
case 'message':
forwardMsgFromIFrame(getMsgBody(6));
break
case 'mouseenter':
onMouse('onMouseEnter');
break
case 'mouseleave':
onMouse('onMouseLeave');
break
case 'autoResize':
settings[iframeId].autoResize = JSON.parse(getMsgBody(9));
break
case 'scrollTo':
scrollRequestFromChild(false);
break
case 'scrollToOffset':
scrollRequestFromChild(true);
break
case 'pageInfo':
sendPageInfoToIframe('start', iframeId);
startPageInfoMonitor();
break
case 'parentInfo':
sendParentInfoToIframe('start', iframeId);
startParentInfoMonitor();
break
case 'pageInfoStop':
stopPageInfoMonitor();
break
case 'parentInfoStop':
stopParentInfoMonitor();
break
case 'inPageLink':
findTarget(getMsgBody(9));
break
case 'reset':
resetIFrame(messageData);
break
case 'init':
resizeIFrame();
checkSameDomain(iframeId);
checkVersion(messageData.version);
started();
on('onReady', messageData.iframe);
break
default:
if (messageData.width === 0 && messageData.height === 0) {
warn(
`Unsupported message received (${messageData.type}), this is likely due to the iframe containing a later ` +
`version of iframe-resizer than the parent page`,
);
return
}
if (messageData.width === 0 || messageData.height === 0) {
return
}
// Recheck document.hidden here, as only Firefox
// correctly supports this in the iframe
if (document.hidden) {
return
}
resizeIFrame();
}
}
function checkSettings(iframeId) {
if (!settings[iframeId]) {
throw new Error(
`${messageData.type} No settings for ${iframeId}. Message was: ${msg}`,
)
}
}
function iFrameReadyMsgReceived() {
Object.keys(settings).forEach((iframeId) => {
if (settings[iframeId].mode >= 0)
trigger('iFrame requested init', createOutgoingMsg(iframeId), iframeId);
});
}
function firstRun() {
if (settings[iframeId]) {
settings[iframeId].firstRun = false;
}
}
let msg = event.data;
let messageData = {};
let iframeId = null;
if (msg === '[iFrameResizerChild]Ready') {
iFrameReadyMsgReceived();
return
}
if (!isMessageForUs()) {
return
}
messageData = processMsg();
iframeId = messageData.id;
if (!iframeId) {
warn('iframeResizer received messageData without id, message was: ', msg);
return
}
checkSettings(iframeId);
if (!isMessageFromMetaParent()) {
settings[iframeId].loaded = true;
if (checkIFrameExists() && isMessageFromIFrame()) {
actionMsg();
}
}
}
function chkEvent(iframeId, funcName, val) {
let func = null;
let retVal = null;
if (settings[iframeId]) {
func = settings[iframeId][funcName];
if (typeof func === 'function') {
retVal = func(val);
} else {
throw new TypeError(
`${funcName} on iFrame[${iframeId}] is not a function`,
)
}
}
return retVal
}
function removeIframeListeners(iframe) {
const iframeId = iframe.id;
delete settings[iframeId];
}
function closeIFrame(iframe) {
const iframeId = iframe.id;
if (chkEvent(iframeId, 'onClose', iframeId) === false) {
return
}
try {
// Catch race condition error with React
if (iframe.parentNode) {
iframe.remove();
}
} catch (error) {
warn(error);
}
chkEvent(iframeId, 'onClosed', iframeId);
removeIframeListeners(iframe);
}
function getPagePosition(iframeId) {
if (page.position === null) {
page.position = {
x: window.scrollX,
y: window.scrollY,
};
}
}
function unsetPagePosition() {
page.position = null;
}
function setPagePosition(iframeId) {
if (page.position !== null) {
window.scrollTo(page.position.x, page.position.y);
unsetPagePosition();
}
}
function resetIFrame(messageData) {
getPagePosition(messageData.id);
setSize(messageData);
trigger('reset', 'reset', messageData.id);
}
function setSize(messageData) {
const iframeId = messageData.id;
function setDimension(dimension) {
const size = `${messageData[dimension]}px`;
messageData.iframe.style[dimension] = size;
}
if (settings[iframeId].sizeHeight) {
setDimension('height');
}
if (settings[iframeId].sizeWidth) {
setDimension('width');
}
}
function trigger(calleeMsg, msg, id, noResponseWarning) {
function postMessageToIFrame() {
const { postMessageTarget, targetOrigin } = settings[id];
if (settings[id].sameDomain) {
try {
settings[id].iframe.contentWindow.iframeChildListener(msgId + msg);
return
} catch (error) {
settings[id].sameDomain = false;
}
}
postMessageTarget.postMessage(msgId + msg, targetOrigin);
}
function iFrameNotFound() {
warn(id, `[${calleeMsg}] IFrame(${id}) not found`);
}
function chkAndSend() {
if (!settings[id]?.postMessageTarget) {
iFrameNotFound();
return
}
postMessageToIFrame();
}
function warnOnNoResponse() {
function warning() {
if (settings[id] === undefined) return // iframe has been closed while we where waiting
if (!settings[id].loaded && !settings[id].loadErrorShown) {
settings[id].loadErrorShown = true;
advise(
id,
`
<rb>No response from iFrame</>
The iframe (<i>${id}</>) has not responded within ${settings[id].warningTimeout / 1000} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.
This 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.
`,
);
}
}
if (!!noResponseWarning && !!settings[id]?.warningTimeout) {
settings[id].msgTimeout = setTimeout(warning, settings[id].warningTimeout);
}
}
if (settings[id]) {
chkAndSend();
warnOnNoResponse();
}
}
function createOutgoingMsg(iframeId) {
const iframeSettings = settings[iframeId];
return [
iframeId,
'8', // Backwards compatibility (PaddingV1)
iframeSettings.sizeWidth,
iframeSettings.log,
'32', // Backwards compatibility (Interval)
true, // Backwards compatibility (EnablePublicMethods)
iframeSettings.autoResize,
iframeSettings.bodyMargin,
iframeSettings.heightCalculationMethod,
iframeSettings.bodyBackground,
iframeSettings.bodyPadding,
iframeSettings.tolerance,
iframeSettings.inPageLinks,
'child', // Backwards compatibility (resizeFrom)
iframeSettings.widthCalculationMethod,
iframeSettings.mouseEvents,
iframeSettings.offsetHeight,
iframeSettings.offsetWidth,
iframeSettings.sizeHeight,
iframeSettings.license,
page.version,
iframeSettings.mode,
].join(':')
}
let count = 0;
let setup = false;
let vAdvised = false;
const connectResizer = (options) => (iframe) => {
function newId() {
let id = options?.id || defaults.id + count++;
if (document.getElementById(id) !== null) {
id += count++;
}
return id
}
function ensureHasId(iframeId) {
if (iframeId && typeof iframeId !== 'string') {
throw new TypeError('Invalid id for iFrame. Expected String')
}
if (iframeId === '' || !iframeId) {
// eslint-disable-next-line no-multi-assign
iframe.id = iframeId = newId();
setLogEnabled((options || {}).log);
}
return iframeId
}
function setScrolling() {
iframe.style.overflow =
settings[iframeId]?.scrolling === false ? 'hidden' : 'auto';
switch (settings[iframeId]?.scrolling) {
case 'omit':
break
case true:
iframe.scrolling = 'yes';
break
case false:
iframe.scrolling = 'no';
break
default:
iframe.scrolling = settings[iframeId]
? settings[iframeId].scrolling
: 'no';
}
}
function setupBodyMarginValues() {
const { bodyMargin } = settings[iframeId];
if (typeof bodyMargin === 'number' || bodyMargin === '0') {
settings[iframeId].bodyMargin = `${bodyMargin}px`;
}
}
function checkReset() {
const firstRun = settings[iframeId]?.firstRun;
const resetRequestMethod =
settings[iframeId]?.heightCalculationMethod in resetRequiredMethods;
if (!firstRun && resetRequestMethod) {
resetIFrame({ iframe, height: 0, width: 0, type: 'init' });
}
}
function setupIFrameObject() {
if (settings[iframeId]) {
const resizer = {
close: closeIFrame.bind(null, settings[iframeId].iframe),
disconnect: removeIframeListeners.bind(null, settings[iframeId].iframe),
removeListeners() {
advise(
iframeId,
`
<rb>Deprecated Method Name</>
The \u001B[removeListeners()</> method has been renamed to \u001B[disconnect()</>.
`,
);
this.disconnect();
},
resize: trigger.bind(null, 'Window resize', 'resize', iframeId),
moveToAnchor(anchor) {
trigger('Move to anchor', `moveToAnchor:${anchor}`, iframeId);
},
sendMessage(message) {
message = JSON.stringify(message);
trigger('Send Message', `message:${message}`, iframeId);
},
};
settings[iframeId].iframe.iframeResizer = resizer;
settings[iframeId].iframe.iFrameResizer = resizer;
}
}
// We have to call trigger twice, as we can not be sure if all
// iframes have completed loading when this code runs. The
// event listener also catches the page changing in the iFrame.
function init(msg) {
function iFrameLoaded() {
trigger('iFrame.onload', `${msg}:${setup}`, id, true);
checkReset();
}
const { id } = iframe;
if (settings[iframeId].mode >= 0) {
addEventListener(iframe, 'load', iFrameLoaded);
trigger('init', `${msg}:${setup}`, id, true);
}
}
function checkOptions(options) {
if (!options) return {}
if (typeof options !== 'object') {
throw new TypeError('Options is not an object')
}
if (
'sizeWidth' in options ||
'sizeHeight' in options ||
'autoResize' in options
) {
advise(
iframeId,
`<rb>Deprecated Option</>
The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <i>"vertical"</>, <i>"horizontal"</> or <i>"horizontal"</>.
`,
);
}
return options
}
function checkMode() {
const { mode } = settings[iframeId];
if (mode < 0) advise('Parent', `${getModeData(mode + 2)}${getModeData(2)}`);
if (vAdvised || mode < 0) return
vAdvised = true;
info(`v${VERSION} (${getModeLabel(mode)})`);
if (mode < 1) advise('Parent', getModeData(3));
}
function setDirection() {
if (settings[iframeId].direction === 'horizontal') {
settings[iframeId].sizeWidth = true;
settings[iframeId].sizeHeight = false;
return
}
if (settings[iframeId].direction === 'none') {
settings[iframeId].sizeWidth = false;
settings[iframeId].sizeHeight = false;
settings[iframeId].autoResize = false;
return
}
if (settings[iframeId].direction !== 'vertical') {
throw new TypeError(
iframeId,
`Direction value of "${settings[iframeId].direction}" is not valid`,
)
}
}
function setOffset(offset) {
if (!offset) return
if (settings[iframeId].direction === 'vertical') {
settings[iframeId].offsetHeight = offset;
} else {
settings[iframeId].offsetWidth = offset;
}
}
function getTargetOrigin(remoteHost) {
return remoteHost === '' ||
remoteHost.match(/^(about:blank|javascript:|file:\/\/)/) !== null
? '*'
: remoteHost
}
function getPostMessageTarget() {
if (settings[iframeId].postMessageTarget === null)
settings[iframeId].postMessageTarget = iframe.contentWindow;
}
function processOptions(options) {
settings[iframeId] = {
iframe,
firstRun: true,
remoteHost: iframe?.src.split('/').slice(0, 3).join('/'),
...defaults,
...checkOptions(options),
mode: setMode(options),
};
setDirection();
setOffset(options?.offset);
getPostMessageTarget();
settings[iframeId].targetOrigin =
settings[iframeId].checkOrigin === true
? getTargetOrigin(settings[iframeId].remoteHost)
: '*';
}
function beenHere() {
return iframeId in settings && 'iFrameResizer' in iframe
}
const iframeId = ensureHasId(iframe.id);
if (beenHere()) {
warn(iframeId, 'Ignored iFrame, already setup.');
} else {
processOptions(options);
checkMode();
setupEventListenersOnce();
setScrolling();
setupBodyMarginValues();
init(createOutgoingMsg(iframeId));
setupIFrameObject();
}
return iframe?.iFrameResizer
};
function sendTriggerMsg(eventName, event) {
function triggerEnabledIframe(iframeId) {
if (isIFrameResizeEnabled(iframeId)) {
trigger(eventName, event, iframeId);
}
}
const isIFrameResizeEnabled = (iframeId) =>
settings[iframeId]?.autoResize && !settings[iframeId]?.firstRun;
Object.keys(settings).forEach(triggerEnabledIframe);
}
function tabVisible() {
if (document.hidden === false) {
sendTriggerMsg('Tab Visible', 'resize');
}
}
const setupEventListenersOnce = once(() => {
addEventListener(window, 'message', iframeListener);
addEventListener(document, 'visibilitychange', tabVisible);
window.iframeParentListener = (data) =>
iframeListener({ data, sameDomain: true });
});
const id = '[iframeResizer] ';
function createIframeResize() {
function setup(element) {
switch (true) {
case !element:
throw new TypeError(`${id}iframe is not defined`)
case !element.tagName:
throw new TypeError(`${id}Not a valid DOM element`)
case element.tagName.toUpperCase() !== 'IFRAME':
throw new TypeError(
`${id}Expected <IFRAME> tag, found <${element.tagName}>`,
)
default:
connectWithOptions(element);
iFrames.push(element);
}
}
let connectWithOptions;
let iFrames;
return function (options, target) {
if (typeof window === 'undefined') return [] // don't run for server side render
connectWithOptions = connectResizer(options);
iFrames = []; // Only return iFrames past in on this call
switch (typeof target) {
case 'undefined':
case 'string':
document.querySelectorAll(target || 'iframe').forEach(setup);
break
case 'object':
setup(target);
break
default:
throw new TypeError(`${id}Unexpected data type (${typeof target})`)
}
return Object.freeze(iFrames)
}
}
const iframeResize = createIframeResize();
if (typeof window !== 'undefined') {
window.iFrameResize = function (...args) {
advise('', 'Deprecated: iFrameResize(), please use iframeResize()');
iframeResize(...args);
};
}
return iframeResize;
}));
{
"name": "@iframe-resizer/parent",
"version": "5.0.1",
"version": "5.0.2",
"license": "GPL-3.0",

@@ -8,3 +8,3 @@ "homepage": "https://iframe-resizer.com",

"name": "David J. Bradshaw",
"email": "dave@bradshaw.net"
"email": "info@iframe-resizer.com"
},

@@ -19,3 +19,3 @@ "description": "Keep same and cross domain iFrames sized to their content.",

"type": "individual",
"url": "https://iframe-resizer.com/licenses/"
"url": "https://iframe-resizer.com/pricing/"
},

@@ -30,8 +30,8 @@ "main": "index.cjs.js",

"Resizer",
"auto-height",
"iframe-auto-height",
"height-iframe",
"responsive-iframes",
"Cross-Domain",
"resize",
"cross",
"same",
"domain",
"width",
"height",
"postMessage",

@@ -41,11 +41,9 @@ "mutationObserver",

"RWD",
"autoheight",
"CrossDomain",
"heightiframe",
"responsiveiframes",
"responsive",
"parent"
],
"dependencies": {
"@iframe-resizer/core": "5.0.1"
"@iframe-resizer/core": "5.0.2"
}
}

@@ -25,2 +25,2 @@ [<img src="https://iframe-resizer.com/logo-full.svg" alt="" title="" style="margin-bottom: -20px">](https://iframe-resizer.com)

_iframe-resizer version 5.0.1 2024-05-21 - 19:24:01.651Z_
_iframe-resizer version 5.0.2 2024-05-30 - 17:45:53.360Z_
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc