Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iframe-resizer/parent

Package Overview
Dependencies
Maintainers
0
Versions
61
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.2.0-beta.3 to 5.2.0-beta.4

2

index.cjs.js
/*!
* @preserve
*
* @module iframe-resizer/parent 5.2.0-beta.3 (cjs) - 2024-07-11
* @module iframe-resizer/parent 5.2.0-beta.4 (cjs) - 2024-07-11
*

@@ -6,0 +6,0 @@ * @license GPL-3.0 for non-commercial use only.

/*!
* @preserve
*
* @module iframe-resizer/parent 5.2.0-beta.3 (esm) - 2024-07-11
* @module iframe-resizer/parent 5.2.0-beta.4 (esm) - 2024-07-11
*

@@ -6,0 +6,0 @@ * @license GPL-3.0 for non-commercial use only.

/*!
* @preserve
*
* @module iframe-resizer/parent 5.2.0-beta.3 (umd) - 2024-07-11
* @module iframe-resizer/parent 5.2.0-beta.4 (umd) - 2024-07-11
*

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

!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e="undefined"!=typeof globalThis?globalThis:e||self).iframeResize=i()}(this,(function(){"use strict";const e="[iframe-resizer]";let i={},t=!1;const n=i=>`${e}[${function(e){return window.top===window.self?`Parent page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested parent page: ${e}`}(i)}]`,o=(e,i,...t)=>window?.console[e](n(i),...t),r=(e,...n)=>!0===(e=>i[e]?i[e].log:t)(e)?o("log",e,...n):null,a=(e,...i)=>o("warn",e,...i),s=(i,t)=>console?.warn((e=>i=>window.chrome?e(i.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e(i.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))((i=>(...t)=>[`${e}[${i}]`,...t].join(" "))(i))(t)),l="5.2.0-beta.3",c="[iFrameSizer]",d=c.length,u=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),f=(e,i,t,n)=>e.addEventListener(i,t,n||!1),p=(e,i,t)=>e.removeEventListener(i,t,!1),m=e=>{if(!e)return"";let i=-559038744,t=1103547984;for(let n,o=0;o<e.length;o++)n=e.codePointAt(o),i=Math.imul(i^n,2246822519),t=Math.imul(t^n,3266489917);return i^=Math.imul(i^t>>>15,1935289751),t^=Math.imul(t^i>>>15,3405138345),i^=t>>>16,t^=i>>>16,(2097152*(t>>>0)+(i>>>11)).toString(36)},h=e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))),g=["<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</>."],y=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],w=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,i)=>[e,Math.max(0,i-1)]))),b=e=>h(g[e]),v=e=>{const i=e[h("spjluzl")];if(!i)return-1;const t=i.split("-");let n=function(e=""){let i=-2;const t=m(h(e));return t in w&&(i=w[t]),i}(t[0]);return 0===n||(e=>e[2]===m(e[0]+e[1]))(t)||(n=-2),n},z={},$=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,waitForLoad:!1,widthCalculationMethod:"auto",onClose:()=>!0,onClosed(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof z[e.id].onInit&&(s(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 "),z[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),j={position:null,version:l};function T(e){function i(){E(H),M(P),L("onResized",H)}function t(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function n(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function o(e){return D.slice(D.indexOf(":")+7+e)}const u=(e,i)=>(t,n)=>{const o={};var r,a;r=function(){W(`Send ${e} (${t})`,`${e}:${i()}`,n)},o[a=n]||(r(),o[a]=requestAnimationFrame((()=>{o[a]=null})))},m=(e,i)=>()=>{const t=i=>()=>{z[a]?e(i,a):o()};function n(e,n){r(a,`${e} listeners for send${i}`),n(window,"scroll",t("scroll")),n(window,"resize",t("resize window"))}function o(){n("Remove ",p),s.disconnect(),l.disconnect()}const a=P,s=new ResizeObserver(t("page observed")),l=new ResizeObserver(t("iframe observed"));n("Add ",f),s.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),l.observe(z[a].iframe,{attributes:!0,childList:!1,subtree:!1}),z[a]&&(z[a][`stop${i}`]=o)},h=e=>()=>{e in z[P]&&(z[P][e](),delete z[P][e])},g=u("pageInfo",(function(){const e=document.body.getBoundingClientRect(),i=H.iframe.getBoundingClientRect(),{scrollY:t,scrollX:n,innerHeight:o,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(a,o||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(i.top-e.top,10),offsetLeft:parseInt(i.left-e.left,10),scrollTop:t,scrollLeft:n,documentHeight:a,documentWidth:s,windowHeight:o,windowWidth:r})})),y=u("parentInfo",(function(){const{iframe:e}=H,{scrollWidth:i,scrollHeight:t}=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:i,scrollHeight:t},viewport:{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})})),w=m(g,"PageInfo"),b=m(y,"ParentInfo"),v=h("stopPageInfo"),$=h("stopParentInfo");function T(e){const i=e.getBoundingClientRect();return S(P),{x:Number(i.left)+Number(j.position.x),y:Number(i.top)+Number(j.position.y)}}function I(e){const i=e?T(H.iframe):{x:0,y:0};let t=((e,i)=>({x:e.width+i.x,y:e.height+i.y}))(H,i);r(P,`Reposition requested from iFrame (offset x:${i.x} y:${i.y})`),window.top===window.self?(j.position=t,C(P),r(P,"--")):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](t.x,t.y):a(P,"Unable to scroll to requested position, window.parentIFrame not found")}function C(e){const{x:i,y:t}=j.position,n=z[e]?.iframe;!1!==L("onScroll",{iframe:n,top:t,left:i,x:i,y:t})?M(e):x()}function A(e){let i={};if(0===H.width&&0===H.height){const e=o(9).split(":");i={x:e[1],y:e[0]}}else i={x:H.width,y:H.height};L(e,{iframe:H.iframe,screenX:Number(i.x),screenY:Number(i.y),type:H.type})}const L=(e,i)=>k(P,e,i);let D=e.data,H={},P=null;"[iFrameResizerChild]Ready"!==D?c===`${D}`.slice(0,d)&&D.slice(d).split(":")[0]in z?(H=function(){const e=D.slice(d).split(":"),i=e[1]?Number(e[1]):0,o=z[e[0]]?.iframe,r=getComputedStyle(o);return{iframe:o,id:e[0],height:i+t(r)+n(r),width:Number(e[2]),type:e[3],msg:e[4]}}(),P=H.id,P?(function(e){if(!z[e])throw new Error(`${H.type} No settings for ${e}. Message was: ${D}`)}(P),function(){const e=H.type in{true:1,false:1,undefined:1};return e&&r(P,"Ignoring init message from meta parent page"),e}()||(r(P,`Received: ${D}`),z[P].loaded=!0,function(){let e=!0;return null===H.iframe&&(a(P,`The iframe (${H.id}) was not found.`),e=!1),e}()&&function(){const{origin:i,sameDomain:t}=e;if(t)return!0;let n=z[P]?.checkOrigin;if(n&&"null"!=`${i}`&&!(n.constructor===Array?function(){let e=0,t=!1;for(r(P,`Checking connection is from allowed list of origins: ${n}`);e<n.length;e++)if(n[e]===i){t=!0;break}return t}():function(){const e=z[P]?.remoteHost;return r(P,`Checking connection is from: ${e}`),i===e}()))throw new Error(`Unexpected message received from: ${i} for ${H.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(z[P]?.firstRun&&z[P]&&(z[P].firstRun=!1),H.type){case"close":R(H.iframe);break;case"message":t=o(6),r(P,`onMessage passed: {iframe: ${H.iframe.id}, message: ${t}}`),L("onMessage",{iframe:H.iframe,message:JSON.parse(t)}),r(P,"--");break;case"mouseenter":A("onMouseEnter");break;case"mouseleave":A("onMouseLeave");break;case"autoResize":z[P].autoResize=JSON.parse(o(9));break;case"scrollBy":!function(){const e=H.width,i=H.height,t=window.parentIframe||window;r(P,`Scroll request received by parent: x: ${e} y: ${i}`),t.scrollBy(e,i)}();break;case"scrollTo":I(!1);break;case"scrollToOffset":I(!0);break;case"pageInfo":g("start",P),w();break;case"parentInfo":y("start",P),b();break;case"pageInfoStop":v();break;case"parentInfoStop":$();break;case"inPageLink":!function(e){const i=e.split("#")[1]||"",t=decodeURIComponent(i);let n=document.getElementById(t)||document.getElementsByName(t)[0];n?function(){const e=T(n);r(P,`Moving to in page link (#${i}) at x: ${e.x} y: ${e.y}`),j.position={x:e.x,y:e.y},C(P),window.location.hash=i,r(P,"--")}():window.top!==window.self?window.parentIFrame?window.parentIFrame.moveToAnchor(i):r(P,`In page link #${i} not found and window.parentIFrame not found`):r(P,`In page link #${i} not found`)}(o(9));break;case"title":!function(e,i){z[i]?.syncTitle&&(z[i].iframe.title=e,r(i,`Set title attribute to: ${e}`))}(H.msg,P);break;case"reset":F(H);break;case"init":i(),function(e){try{z[e].sameDomain=!!z[e]?.iframe?.contentWindow?.iframeChildListener}catch(i){z[e].sameDomain=!1}r(e,`sameDomain: ${z[e].sameDomain}`)}(P),(e=H.msg)!==l&&(void 0!==e?r(P,`Version mismatch (Child: ${e} !== Parent: ${l})`):s(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")),O=!0,L("onReady",H.iframe);break;default:if(0===H.width&&0===H.height)return void a(`Unsupported message received (${H.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===H.width||0===H.height)return void r(P,"Ignoring message with 0 height or width");if(document.hidden)return void r(P,"Page hidden - ignored resize request");i()}var e,t}())):a("iframeResizer received messageData without id, message was: ",D)):null!==P&&r(P,"Ignored:",D):Object.keys(z).forEach((e=>{z[e].mode>=0&&W("iFrame requested init",N(e),e)}))}function k(e,i,t){let n=null,o=null;if(z[e]){if(n=z[e][i],"function"!=typeof n)throw new TypeError(`${i} on iFrame[${e}] is not a function`);o=n(t)}return o}function I(e){const i=e.id;delete z[i]}function R(e){const i=e.id;if(!1!==k(i,"onClose",i)){r(i,`Removing iFrame: ${i}`);try{e.parentNode&&e.remove()}catch(e){a(e)}k(i,"onClosed",i),r(i,"--"),I(e)}else r(i,"Close iframe cancelled by onClose event")}function S(e){null===j.position&&(j.position={x:window.scrollX,y:window.scrollY},r(e,`Get page position: ${j.position.x}, ${j.position.y}`))}function x(){j.position=null}function M(e){null!==j.position&&(window.scrollTo(j.position.x,j.position.y),r(e,`Set page position: ${j.position.x}, ${j.position.y}`),x())}function F(e){r(e.id,"Size reset requested by "+("init"===e.type?"parent page":"child page")),S(e.id),E(e),W("reset","reset",e.id)}function E(e){const i=e.id;function t(t){const n=`${e[t]}px`;e.iframe.style[t]=n,r(i,`IFrame (${i}) ${t} set to ${n}`)}z[i].sizeHeight&&t("height"),z[i].sizeWidth&&t("width")}function W(e,i,t,n){z[t]&&(z[t]?.postMessageTarget?function(){const{postMessageTarget:n,targetOrigin:o}=z[t];if(z[t].sameDomain)try{return z[t].iframe.contentWindow.iframeChildListener(c+i),void r(t,`[${e}] Sending message to iframe[${t}] (${i}) via sameDomain`)}catch(e){r(t,"Same domain connection failed. Trying cross domain")}r(t,`[${e}] Sending message to iframe[${t}] (${i}) targetOrigin: ${o}`),n.postMessage(c+i,o)}():a(t,`[${e}] IFrame(${t}) not found`),n&&z[t]?.warningTimeout&&(z[t].msgTimeout=setTimeout((function(){if(void 0===z[t])return;const{waitForLoad:e}=z[t];z[t].loaded||z[t].loadErrorShown||(z[t].loadErrorShown=!0,s(t,`\n<rb>No response from iFrame</>\n \nThe iframe (<i>${t}</>) has not responded within ${z[t].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${e?"\nThe <b>waitForLoad</> option is currently set to <b>true</>. If the iframe loads before the JavaScript runs, this option will prevent <i>iframe-resizer</> from initialising. To disable this, set the <b>waitForLoad</> option to <b>false</>. \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`))}),z[t].warningTimeout)))}function N(e){const i=z[e];return[e,"8",i.sizeWidth,i.log,"32",!0,i.autoResize,i.bodyMargin,i.heightCalculationMethod,i.bodyBackground,i.bodyPadding,i.tolerance,i.inPageLinks,"child",i.widthCalculationMethod,i.mouseEvents,i.offsetHeight,i.offsetWidth,i.sizeHeight,i.license,j.version,i.mode].join(":")}i=z;let C=0,O=!1,A=!1;const L=e=>i=>{function n(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)&&s(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>"vertical"</>, <i>"horizontal"</> or <i>"horizontal"</>.\n'),e}function c(e){const i=z[e]?.iframe?.title;return""===i||void 0===i}const d=function(n){if(n&&"string"!=typeof n)throw new TypeError("Invalid id for iFrame. Expected String");var o;return""!==n&&n||(i.id=n=function(){let i=e?.id||$.id+C++;return null!==document.getElementById(i)&&(i+=C++),i}(),o=(e||{}).log,t=o,r(n,`Added missing iframe ID: ${n} (${i.src})`)),n}(i.id);return d in z&&"iFrameResizer"in i?a(d,"Ignored iFrame, already setup."):(function(e){var t,o;z[d]={iframe:i,firstRun:!0,remoteHost:i?.src.split("/").slice(0,3).join("/"),...$,...n(e),mode:v(e),syncTitle:c(d)},function(){if("horizontal"===z[d].direction)return z[d].sizeWidth=!0,z[d].sizeHeight=!1,void r(d,'Direction set to "horizontal"');if("none"===z[d].direction)return z[d].sizeWidth=!1,z[d].sizeHeight=!1,z[d].autoResize=!1,void r(d,'Direction set to "none"');if("vertical"!==z[d].direction)throw new TypeError(d,`Direction value of "${z[d].direction}" is not valid`);r(d,'Direction set to "vertical"')}(),(t=e?.offsetSize||e?.offset)&&("vertical"===z[d].direction?(z[d].offsetHeight=t,r(d,`Offset height set to ${t}`)):(z[d].offsetWidth=t,r(d,`Offset width set to ${t}`))),e?.offset&&s("<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</>."),null===z[d].postMessageTarget&&(z[d].postMessageTarget=i.contentWindow),z[d].targetOrigin=!0===z[d].checkOrigin?""===(o=z[d].remoteHost)||null!==o.match(/^(about:blank|javascript:|file:\/\/)/)?"*":o:"*"}(e),function(){const{mode:e}=z[d];e<0&&s("Parent",`${b(e+2)}${b(2)}`),A||e<0||(A=!0,((e,...i)=>{o("info",e,...i)})(`v${l} (${(e=>h(y[e]))(e)})`),e<1&&s("Parent",b(3)))}(),H(),function(){switch(r(d,`IFrame scrolling ${z[d]?.scrolling?"enabled":"disabled"} for ${d}`),i.style.overflow=!1===z[d]?.scrolling?"hidden":"auto",z[d]?.scrolling){case"omit":break;case!0:i.scrolling="yes";break;case!1:i.scrolling="no";break;default:i.scrolling=z[d]?z[d].scrolling:"no"}}(),function(){const{bodyMargin:e}=z[d];"number"!=typeof e&&"0"!==e||(z[d].bodyMargin=`${e}px`)}(),function(e){const{id:t}=i;-1!==z[t].mode&&-2!==z[t].mode&&(f(i,"load",(function(){W("iFrame.onload",`${e}:${O}`,t,!0),function(){const e=z[d]?.firstRun,t=z[d]?.heightCalculationMethod in u;!e&&t&&F({iframe:i,height:0,width:0,type:"init"})}()})),!1===z[t].waitForLoad&&W("init",`${e}:${O}`,t,!0))}(N(d)),function(){if(z[d]){const e={close:R.bind(null,z[d].iframe),disconnect:I.bind(null,z[d].iframe),removeListeners(){s(d,"\n<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize:W.bind(null,"Window resize","resize",d),moveToAnchor(e){W("Move to anchor",`moveToAnchor:${e}`,d)},sendMessage(e){W("Send Message",`message:${e=JSON.stringify(e)}`,d)}};z[d].iframe.iframeResizer=e,z[d].iframe.iFrameResizer=e}}()),i?.iFrameResizer};function D(){!1===document.hidden&&(r("document","Trigger event: Visibility change"),function(e,i){const t=e=>z[e]?.autoResize&&!z[e]?.firstRun;Object.keys(z).forEach((function(n){t(n)&&W(e,i,n)}))}("Tab Visible","resize"))}const H=(e=>{let i=!1;return function(){return i?void 0:(i=!0,Reflect.apply(e,this,arguments))}})((()=>{f(window,"message",T),f(document,"visibilitychange",D),window.iframeParentListener=e=>T({data:e,sameDomain:!0})})),P="[iframeResizer] ";const B=function(){function e(e){switch(!0){case!e:throw new TypeError(`${P}iframe is not defined`);case!e.tagName:throw new TypeError(`${P}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${P}Expected <IFRAME> tag, found <${e.tagName}>`);default:i(e),t.push(e)}}let i,t;return function(n,o){if("undefined"==typeof window)return[];switch(i=L(n),t=[],typeof o){case"undefined":case"string":document.querySelectorAll(o||"iframe").forEach(e);break;case"object":e(o);break;default:throw new TypeError(`${P}Unexpected data type (${typeof o})`)}return Object.freeze(t)}}();return"undefined"!=typeof window&&(window.iFrameResize=function(...e){s("","Deprecated: iFrameResize(), please use iframeResize()"),B(...e)}),B}));
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e="undefined"!=typeof globalThis?globalThis:e||self).iframeResize=i()}(this,(function(){"use strict";const e="[iframe-resizer]";let i={},t=!1;const n=i=>`${e}[${function(e){return window.top===window.self?`Parent page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested parent page: ${e}`}(i)}]`,o=(e,i,...t)=>window?.console[e](n(i),...t),r=(e,...n)=>!0===(e=>i[e]?i[e].log:t)(e)?o("log",e,...n):null,a=(e,...i)=>o("warn",e,...i),s=(i,t)=>console?.warn((e=>i=>window.chrome?e(i.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e(i.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))((i=>(...t)=>[`${e}[${i}]`,...t].join(" "))(i))(t)),l="5.2.0-beta.4",c="[iFrameSizer]",d=c.length,u=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),f=(e,i,t,n)=>e.addEventListener(i,t,n||!1),p=(e,i,t)=>e.removeEventListener(i,t,!1),m=e=>{if(!e)return"";let i=-559038744,t=1103547984;for(let n,o=0;o<e.length;o++)n=e.codePointAt(o),i=Math.imul(i^n,2246822519),t=Math.imul(t^n,3266489917);return i^=Math.imul(i^t>>>15,1935289751),t^=Math.imul(t^i>>>15,3405138345),i^=t>>>16,t^=i>>>16,(2097152*(t>>>0)+(i>>>11)).toString(36)},h=e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))),g=["<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</>."],y=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],w=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,i)=>[e,Math.max(0,i-1)]))),b=e=>h(g[e]),v=e=>{const i=e[h("spjluzl")];if(!i)return-1;const t=i.split("-");let n=function(e=""){let i=-2;const t=m(h(e));return t in w&&(i=w[t]),i}(t[0]);return 0===n||(e=>e[2]===m(e[0]+e[1]))(t)||(n=-2),n},z={},$=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,waitForLoad:!1,widthCalculationMethod:"auto",onClose:()=>!0,onClosed(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof z[e.id].onInit&&(s(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 "),z[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),j={position:null,version:l};function T(e){function i(){E(H),M(P),L("onResized",H)}function t(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function n(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function o(e){return D.slice(D.indexOf(":")+7+e)}const u=(e,i)=>(t,n)=>{const o={};var r,a;r=function(){W(`Send ${e} (${t})`,`${e}:${i()}`,n)},o[a=n]||(r(),o[a]=requestAnimationFrame((()=>{o[a]=null})))},m=(e,i)=>()=>{const t=i=>()=>{z[a]?e(i,a):o()};function n(e,n){r(a,`${e} listeners for send${i}`),n(window,"scroll",t("scroll")),n(window,"resize",t("resize window"))}function o(){n("Remove ",p),s.disconnect(),l.disconnect()}const a=P,s=new ResizeObserver(t("page observed")),l=new ResizeObserver(t("iframe observed"));n("Add ",f),s.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),l.observe(z[a].iframe,{attributes:!0,childList:!1,subtree:!1}),z[a]&&(z[a][`stop${i}`]=o)},h=e=>()=>{e in z[P]&&(z[P][e](),delete z[P][e])},g=u("pageInfo",(function(){const e=document.body.getBoundingClientRect(),i=H.iframe.getBoundingClientRect(),{scrollY:t,scrollX:n,innerHeight:o,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(a,o||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(i.top-e.top,10),offsetLeft:parseInt(i.left-e.left,10),scrollTop:t,scrollLeft:n,documentHeight:a,documentWidth:s,windowHeight:o,windowWidth:r})})),y=u("parentInfo",(function(){const{iframe:e}=H,{scrollWidth:i,scrollHeight:t}=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:i,scrollHeight:t},viewport:{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})})),w=m(g,"PageInfo"),b=m(y,"ParentInfo"),v=h("stopPageInfo"),$=h("stopParentInfo");function T(e){const i=e.getBoundingClientRect();return S(P),{x:Number(i.left)+Number(j.position.x),y:Number(i.top)+Number(j.position.y)}}function I(e){const i=e?T(H.iframe):{x:0,y:0};let t=((e,i)=>({x:e.width+i.x,y:e.height+i.y}))(H,i);r(P,`Reposition requested from iFrame (offset x:${i.x} y:${i.y})`),window.top===window.self?(j.position=t,C(P),r(P,"--")):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](t.x,t.y):a(P,"Unable to scroll to requested position, window.parentIFrame not found")}function C(e){const{x:i,y:t}=j.position,n=z[e]?.iframe;!1!==L("onScroll",{iframe:n,top:t,left:i,x:i,y:t})?M(e):x()}function A(e){let i={};if(0===H.width&&0===H.height){const e=o(9).split(":");i={x:e[1],y:e[0]}}else i={x:H.width,y:H.height};L(e,{iframe:H.iframe,screenX:Number(i.x),screenY:Number(i.y),type:H.type})}const L=(e,i)=>k(P,e,i);let D=e.data,H={},P=null;"[iFrameResizerChild]Ready"!==D?c===`${D}`.slice(0,d)&&D.slice(d).split(":")[0]in z?(H=function(){const e=D.slice(d).split(":"),i=e[1]?Number(e[1]):0,o=z[e[0]]?.iframe,r=getComputedStyle(o);return{iframe:o,id:e[0],height:i+t(r)+n(r),width:Number(e[2]),type:e[3],msg:e[4]}}(),P=H.id,P?(function(e){if(!z[e])throw new Error(`${H.type} No settings for ${e}. Message was: ${D}`)}(P),function(){const e=H.type in{true:1,false:1,undefined:1};return e&&r(P,"Ignoring init message from meta parent page"),e}()||(r(P,`Received: ${D}`),z[P].loaded=!0,function(){let e=!0;return null===H.iframe&&(a(P,`The iframe (${H.id}) was not found.`),e=!1),e}()&&function(){const{origin:i,sameDomain:t}=e;if(t)return!0;let n=z[P]?.checkOrigin;if(n&&"null"!=`${i}`&&!(n.constructor===Array?function(){let e=0,t=!1;for(r(P,`Checking connection is from allowed list of origins: ${n}`);e<n.length;e++)if(n[e]===i){t=!0;break}return t}():function(){const e=z[P]?.remoteHost;return r(P,`Checking connection is from: ${e}`),i===e}()))throw new Error(`Unexpected message received from: ${i} for ${H.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(z[P]?.firstRun&&z[P]&&(z[P].firstRun=!1),H.type){case"close":R(H.iframe);break;case"message":t=o(6),r(P,`onMessage passed: {iframe: ${H.iframe.id}, message: ${t}}`),L("onMessage",{iframe:H.iframe,message:JSON.parse(t)}),r(P,"--");break;case"mouseenter":A("onMouseEnter");break;case"mouseleave":A("onMouseLeave");break;case"autoResize":z[P].autoResize=JSON.parse(o(9));break;case"scrollBy":!function(){const e=H.width,i=H.height,t=window.parentIframe||window;r(P,`Scroll request received by parent: x: ${e} y: ${i}`),t.scrollBy(e,i)}();break;case"scrollTo":I(!1);break;case"scrollToOffset":I(!0);break;case"pageInfo":g("start",P),w();break;case"parentInfo":y("start",P),b();break;case"pageInfoStop":v();break;case"parentInfoStop":$();break;case"inPageLink":!function(e){const i=e.split("#")[1]||"",t=decodeURIComponent(i);let n=document.getElementById(t)||document.getElementsByName(t)[0];n?function(){const e=T(n);r(P,`Moving to in page link (#${i}) at x: ${e.x} y: ${e.y}`),j.position={x:e.x,y:e.y},C(P),window.location.hash=i,r(P,"--")}():window.top!==window.self?window.parentIFrame?window.parentIFrame.moveToAnchor(i):r(P,`In page link #${i} not found and window.parentIFrame not found`):r(P,`In page link #${i} not found`)}(o(9));break;case"title":!function(e,i){z[i]?.syncTitle&&(z[i].iframe.title=e,r(i,`Set title attribute to: ${e}`))}(H.msg,P);break;case"reset":F(H);break;case"init":i(),function(e){try{z[e].sameDomain=!!z[e]?.iframe?.contentWindow?.iframeChildListener}catch(i){z[e].sameDomain=!1}r(e,`sameDomain: ${z[e].sameDomain}`)}(P),(e=H.msg)!==l&&(void 0!==e?r(P,`Version mismatch (Child: ${e} !== Parent: ${l})`):s(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")),O=!0,L("onReady",H.iframe);break;default:if(0===H.width&&0===H.height)return void a(`Unsupported message received (${H.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===H.width||0===H.height)return void r(P,"Ignoring message with 0 height or width");if(document.hidden)return void r(P,"Page hidden - ignored resize request");i()}var e,t}())):a("iframeResizer received messageData without id, message was: ",D)):null!==P&&r(P,"Ignored:",D):Object.keys(z).forEach((e=>{z[e].mode>=0&&W("iFrame requested init",N(e),e)}))}function k(e,i,t){let n=null,o=null;if(z[e]){if(n=z[e][i],"function"!=typeof n)throw new TypeError(`${i} on iFrame[${e}] is not a function`);o=n(t)}return o}function I(e){const i=e.id;delete z[i]}function R(e){const i=e.id;if(!1!==k(i,"onClose",i)){r(i,`Removing iFrame: ${i}`);try{e.parentNode&&e.remove()}catch(e){a(e)}k(i,"onClosed",i),r(i,"--"),I(e)}else r(i,"Close iframe cancelled by onClose event")}function S(e){null===j.position&&(j.position={x:window.scrollX,y:window.scrollY},r(e,`Get page position: ${j.position.x}, ${j.position.y}`))}function x(){j.position=null}function M(e){null!==j.position&&(window.scrollTo(j.position.x,j.position.y),r(e,`Set page position: ${j.position.x}, ${j.position.y}`),x())}function F(e){r(e.id,"Size reset requested by "+("init"===e.type?"parent page":"child page")),S(e.id),E(e),W("reset","reset",e.id)}function E(e){const i=e.id;function t(t){const n=`${e[t]}px`;e.iframe.style[t]=n,r(i,`IFrame (${i}) ${t} set to ${n}`)}z[i].sizeHeight&&t("height"),z[i].sizeWidth&&t("width")}function W(e,i,t,n){z[t]&&(z[t]?.postMessageTarget?function(){const{postMessageTarget:n,targetOrigin:o}=z[t];if(z[t].sameDomain)try{return z[t].iframe.contentWindow.iframeChildListener(c+i),void r(t,`[${e}] Sending message to iframe[${t}] (${i}) via sameDomain`)}catch(e){r(t,"Same domain connection failed. Trying cross domain")}r(t,`[${e}] Sending message to iframe[${t}] (${i}) targetOrigin: ${o}`),n.postMessage(c+i,o)}():a(t,`[${e}] IFrame(${t}) not found`),n&&z[t]?.warningTimeout&&(z[t].msgTimeout=setTimeout((function(){if(void 0===z[t])return;const{waitForLoad:e}=z[t];z[t].loaded||z[t].loadErrorShown||(z[t].loadErrorShown=!0,s(t,`\n<rb>No response from iFrame</>\n \nThe iframe (<i>${t}</>) has not responded within ${z[t].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${e?"\nThe <b>waitForLoad</> option is currently set to <b>true</>. If the iframe loads before the JavaScript runs, this option will prevent <i>iframe-resizer</> from initialising. To disable this, set the <b>waitForLoad</> option to <b>false</>. \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`))}),z[t].warningTimeout)))}function N(e){const i=z[e];return[e,"8",i.sizeWidth,i.log,"32",!0,i.autoResize,i.bodyMargin,i.heightCalculationMethod,i.bodyBackground,i.bodyPadding,i.tolerance,i.inPageLinks,"child",i.widthCalculationMethod,i.mouseEvents,i.offsetHeight,i.offsetWidth,i.sizeHeight,i.license,j.version,i.mode].join(":")}i=z;let C=0,O=!1,A=!1;const L=e=>i=>{function n(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)&&s(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>"vertical"</>, <i>"horizontal"</> or <i>"horizontal"</>.\n'),e}function c(e){const i=z[e]?.iframe?.title;return""===i||void 0===i}const d=function(n){if(n&&"string"!=typeof n)throw new TypeError("Invalid id for iFrame. Expected String");var o;return""!==n&&n||(i.id=n=function(){let i=e?.id||$.id+C++;return null!==document.getElementById(i)&&(i+=C++),i}(),o=(e||{}).log,t=o,r(n,`Added missing iframe ID: ${n} (${i.src})`)),n}(i.id);return d in z&&"iFrameResizer"in i?a(d,"Ignored iFrame, already setup."):(function(e){var t,o;z[d]={iframe:i,firstRun:!0,remoteHost:i?.src.split("/").slice(0,3).join("/"),...$,...n(e),mode:v(e),syncTitle:c(d)},function(){if("horizontal"===z[d].direction)return z[d].sizeWidth=!0,z[d].sizeHeight=!1,void r(d,'Direction set to "horizontal"');if("none"===z[d].direction)return z[d].sizeWidth=!1,z[d].sizeHeight=!1,z[d].autoResize=!1,void r(d,'Direction set to "none"');if("vertical"!==z[d].direction)throw new TypeError(d,`Direction value of "${z[d].direction}" is not valid`);r(d,'Direction set to "vertical"')}(),(t=e?.offsetSize||e?.offset)&&("vertical"===z[d].direction?(z[d].offsetHeight=t,r(d,`Offset height set to ${t}`)):(z[d].offsetWidth=t,r(d,`Offset width set to ${t}`))),e?.offset&&s("<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</>."),null===z[d].postMessageTarget&&(z[d].postMessageTarget=i.contentWindow),z[d].targetOrigin=!0===z[d].checkOrigin?""===(o=z[d].remoteHost)||null!==o.match(/^(about:blank|javascript:|file:\/\/)/)?"*":o:"*"}(e),function(){const{mode:e}=z[d];e<0&&s("Parent",`${b(e+2)}${b(2)}`),A||e<0||(A=!0,((e,...i)=>{o("info",e,...i)})(`v${l} (${(e=>h(y[e]))(e)})`),e<1&&s("Parent",b(3)))}(),H(),function(){switch(r(d,`IFrame scrolling ${z[d]?.scrolling?"enabled":"disabled"} for ${d}`),i.style.overflow=!1===z[d]?.scrolling?"hidden":"auto",z[d]?.scrolling){case"omit":break;case!0:i.scrolling="yes";break;case!1:i.scrolling="no";break;default:i.scrolling=z[d]?z[d].scrolling:"no"}}(),function(){const{bodyMargin:e}=z[d];"number"!=typeof e&&"0"!==e||(z[d].bodyMargin=`${e}px`)}(),function(e){const{id:t}=i;-1!==z[t].mode&&-2!==z[t].mode&&(f(i,"load",(function(){W("iFrame.onload",`${e}:${O}`,t,!0),function(){const e=z[d]?.firstRun,t=z[d]?.heightCalculationMethod in u;!e&&t&&F({iframe:i,height:0,width:0,type:"init"})}()})),!1===z[t].waitForLoad&&W("init",`${e}:${O}`,t,!0))}(N(d)),function(){if(z[d]){const e={close:R.bind(null,z[d].iframe),disconnect:I.bind(null,z[d].iframe),removeListeners(){s(d,"\n<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize:W.bind(null,"Window resize","resize",d),moveToAnchor(e){W("Move to anchor",`moveToAnchor:${e}`,d)},sendMessage(e){W("Send Message",`message:${e=JSON.stringify(e)}`,d)}};z[d].iframe.iframeResizer=e,z[d].iframe.iFrameResizer=e}}()),i?.iFrameResizer};function D(){!1===document.hidden&&(r("document","Trigger event: Visibility change"),function(e,i){const t=e=>z[e]?.autoResize&&!z[e]?.firstRun;Object.keys(z).forEach((function(n){t(n)&&W(e,i,n)}))}("Tab Visible","resize"))}const H=(e=>{let i=!1;return function(){return i?void 0:(i=!0,Reflect.apply(e,this,arguments))}})((()=>{f(window,"message",T),f(document,"visibilitychange",D),window.iframeParentListener=e=>T({data:e,sameDomain:!0})})),P="[iframeResizer] ";const B=function(){function e(e){switch(!0){case!e:throw new TypeError(`${P}iframe is not defined`);case!e.tagName:throw new TypeError(`${P}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${P}Expected <IFRAME> tag, found <${e.tagName}>`);default:i(e),t.push(e)}}let i,t;return function(n,o){if("undefined"==typeof window)return[];switch(i=L(n),t=[],typeof o){case"undefined":case"string":document.querySelectorAll(o||"iframe").forEach(e);break;case"object":e(o);break;default:throw new TypeError(`${P}Unexpected data type (${typeof o})`)}return Object.freeze(t)}}();return"undefined"!=typeof window&&(window.iFrameResize=function(...e){s("","Deprecated: iFrameResize(), please use iframeResize()"),B(...e)}),B}));
//# sourceMappingURL=index.umd.js.map
{
"name": "@iframe-resizer/parent",
"version": "5.2.0-beta.3",
"version": "5.2.0-beta.4",
"license": "GPL-3.0",

@@ -43,4 +43,4 @@ "homepage": "https://iframe-resizer.com",

"dependencies": {
"@iframe-resizer/core": "5.2.0-beta.3"
"@iframe-resizer/core": "5.2.0-beta.4"
}
}

@@ -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.2.0-beta.3 2024-07-11 - 10:58:03.570Z_
_iframe-resizer version 5.2.0-beta.4 2024-07-11 - 13:40:16.253Z_
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