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.0-alpha.12 to 5.0.0-beta.1

2

iframe-resizer.parent.d.ts

@@ -180,3 +180,3 @@ /**

*/
getParentInfo(callback: ((data: PageInfo) => void) | false): void
getParentProperties(callback: ((data: PageInfo) => void)): void

@@ -183,0 +183,0 @@ /**

/*!
* @preserve
*
* @module iframe-resizer/parent 5.0.0-alpha.12 (cjs) - 2024-04-26
* @module iframe-resizer/parent 5.0.0-beta.1 (cjs) - 2024-05-09
*
* @license GPL-3.0 for non-commercial use only.
* For commercial use, you must purchase a license from
* http://iframe-resizer.com/pricing
* https://iframe-resizer.com/pricing
*

@@ -14,3 +14,3 @@ * @desciption Keep same and cross domain iFrames sized to their content

*
* @see {@link http://iframe-resizer.com}
* @see {@link https://iframe-resizer.com}
*

@@ -17,0 +17,0 @@ * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.

/*!
* @preserve
*
* @module iframe-resizer/parent 5.0.0-alpha.12 (esm) - 2024-04-26
* @module iframe-resizer/parent 5.0.0-beta.1 (esm) - 2024-05-09
*
* @license GPL-3.0 for non-commercial use only.
* For commercial use, you must purchase a license from
* http://iframe-resizer.com/pricing
* https://iframe-resizer.com/pricing
*

@@ -14,3 +14,3 @@ * @desciption Keep same and cross domain iFrames sized to their content

*
* @see {@link http://iframe-resizer.com}
* @see {@link https://iframe-resizer.com}
*

@@ -17,0 +17,0 @@ * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.

/*!
* @preserve
*
* @module iframe-resizer/parent 5.0.0-alpha.12 (umd) - 2024-04-26
* @module iframe-resizer/parent 5.0.0-beta.1 (umd) - 2024-05-09
*
* @license GPL-3.0 for non-commercial use only.
* For commercial use, you must purchase a license from
* http://iframe-resizer.com/pricing
* https://iframe-resizer.com/pricing
*

@@ -14,3 +14,3 @@ * @desciption Keep same and cross domain iFrames sized to their content

*
* @see {@link http://iframe-resizer.com}
* @see {@link https://iframe-resizer.com}
*

@@ -21,2 +21,2 @@ * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).iframeResize=n()}(this,(function(){"use strict";const e="[iframeResizer]";const n=n=>`${e}[${function(e){return window.top===window.self?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(n)}]`,t=(e,t,...i)=>window?.console[e](n(t),...i),i=(e,...n)=>t("info",e,...n),o=(e,...n)=>t("warn",e,...n),r=(n,t)=>window?.console.warn(((n,...t)=>[`${e}[${n}]`,...t])(n,window.chrome?t:t.replaceAll(/\u001B\[[\d;]*m/gi,""))),a="5.0.0-alpha.12",s="[iFrameSizer]",c=s.length,d=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),l=(e,n,t,i)=>e.addEventListener(n,t,i||!1),f=(e,n,t)=>e.removeEventListener(n,t,!1),u=e=>!Number.isNaN(e),m=e=>{if(!e)return"";let n=-559038744,t=1103547984;for(let i,o=0;o<e.length;o++)i=e.codePointAt(o),n=Math.imul(n^i,2246822519),t=Math.imul(t^i,3266489917);return n^=Math.imul(n^t>>>15,1935289751),t^=Math.imul(t^n>>>15,3405138345),n^=t>>>16,t^=n>>>16,(2097152*(t>>>0)+(n>>>11)).toString(36)},h={},g=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:"vertical",inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"auto",id:"iFrameResizer",log:!0,license:void 0,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,offsetHeight:0,offsetWidth:0,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 h[e.id].onInit&&(r(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 "),h[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),p={position:null,version:a};function w(e){function n(){r("Height"),r("Width"),M(D),T(),C("onResized",D)}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 i(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function r(e){const n=Number(h[B][`max${e}`]),t=Number(h[B][`min${e}`]),i=e.toLowerCase();let o=D[i];o<t&&(o=t),o>n&&(o=n),D[i]=o}function a(e){return L.slice(L.indexOf(":")+7+e)}const d=(e,n)=>(t,i)=>{const o={};var r,a;r=function(){x(`Send ${e} (${t})`,`${e}:${n()}`,i)},o[a=i]||(r(),o[a]=requestAnimationFrame((()=>{o[a]=null})))},u=(e,n)=>()=>{const t=n=>()=>{h[r]?e(n,r):o()};function i(e,n){n(window,"scroll",t("scroll")),n(window,"resize",t("resize window"))}function o(){i(0,f),a.disconnect()}const r=B,a=new ResizeObserver(t("iframe observed"));i(0,l),a.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),h[r]&&(h[r][`stop${n}`]=o)},m=e=>()=>{e in h[B]&&(h[B][e](),delete h[B][e])},g=d("pageInfo",(function(){const e=document.body.getBoundingClientRect(),n=D.iframe.getBoundingClientRect(),{scrollY:t,scrollX:i,innerHeight:o,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(a,o||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(n.top-e.top,10),offsetLeft:parseInt(n.left-e.left,10),scrollTop:t,scrollLeft:i,documentHeight:a,documentWidth:s,windowHeight:o,windowWidth:r})})),w=d("parentInfo",(function(){const{iframe:e}=D,{scrollWidth:n,scrollHeight:t}=document.documentElement,{width:i,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:c,scale:d}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:n,scrollHeight:t},viewport:{width:i,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:c,scale:d}})})),y=u(g,"PageInfo"),k=u(w,"ParentInfo"),W=m("stopPageInfo"),N=m("stopParentInfo");function H(e){const n=e.getBoundingClientRect();return v(),{x:Math.floor(Number(n.left)+Number(p.position.x)),y:Math.floor(Number(n.top)+Number(p.position.y))}}function F(e){const n=e?H(D.iframe):{x:0,y:0};let t=((e,n)=>({x:e.width+n.x,y:e.height+n.y}))(D,n);window.top===window.self?(p.position=t,O()):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](t.x,t.y):o(B,"Unable to scroll to requested position, window.parentIFrame not found")}function O(){!1!==C("onScroll",p.position)?T():$()}function S(e){let n={};if(0===D.width&&0===D.height){const e=a(9).split(":");n={x:e[1],y:e[0]}}else n={x:D.width,y:D.height};C(e,{iframe:D.iframe,screenX:Number(n.x),screenY:Number(n.y),type:D.type})}const C=(e,n)=>b(B,e,n);let L=e.data,D={},B=null;"[iFrameResizerChild]Ready"!==L?s===`${L}`.slice(0,c)&&L.slice(c).split(":")[0]in h&&(D=function(){const e=L.slice(c).split(":"),n=e[1]?Number(e[1]):0,o=h[e[0]]?.iframe,r=getComputedStyle(o);return{iframe:o,id:e[0],height:n+t(r)+i(r),width:Number(e[2]),type:e[3]}}(),B=D.id,B?(function(e){if(!h[e])throw new Error(`${D.type} No settings for ${e}. Message was: ${L}`)}(B),D.type in{true:1,false:1,undefined:1}||(h[B].loaded=!0,function(){let e=!0;return null===D.iframe&&(o(B,`The iframe (${D.id}) was not found.`),e=!1),e}()&&function(){const{origin:n,sameDomain:t}=e;if(t)return!0;let i=h[B]?.checkOrigin;if(i&&"null"!=`${n}`&&!(i.constructor===Array?function(){let e=0,t=!1;for(;e<i.length;e++)if(i[e]===n){t=!0;break}return t}():function(){const e=h[B]?.remoteHost;return n===e}()))throw new Error(`Unexpected message received from: ${n} for ${D.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(h[B]?.firstRun&&h[B]&&(h[B].firstRun=!1),D.type){case"close":z(D.iframe);break;case"message":e=a(6),C("onMessage",{iframe:D.iframe,message:JSON.parse(e)});break;case"mouseenter":S("onMouseEnter");break;case"mouseleave":S("onMouseLeave");break;case"autoResize":h[B].autoResize=JSON.parse(a(9));break;case"scrollTo":F(!1);break;case"scrollToOffset":F(!0);break;case"pageInfo":g("start",B),y();break;case"parentInfo":w("start",B),k();break;case"pageInfoStop":W();break;case"parentInfoStop":N();break;case"inPageLink":!function(e){const n=e.split("#")[1]||"",t=decodeURIComponent(n);let i=document.getElementById(t)||document.getElementsByName(t)[0];i?function(){const e=H(i);p.position={x:e.x,y:e.y},O()}():window.top!==window.self&&window.parentIFrame&&window.parentIFrame.moveToAnchor(n)}(a(9));break;case"reset":R(D);break;case"init":n(),function(e){try{h[e].sameDomain=!!h[e]?.iframe?.contentWindow?.iframeChildListener}catch(n){h[e].sameDomain=!1}}(B),E=!0,C("onReady",D.iframe);break;default:if(0===D.width&&0===D.height)return void o(`Unsupported message received (${D.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===D.width||0===D.height)return;if(document.hidden)return;n()}var e}())):o("iframeResizer received messageData without id, message was: ",L)):Object.keys(h).forEach((e=>x("iFrame requested init",I(e),e)))}function b(e,n,t){let i=null,o=null;if(h[e]){if(i=h[e][n],"function"!=typeof i)throw new TypeError(`${n} on iFrame[${e}] is not a function`);o=i(t)}return o}function y(e){const n=e.id;delete h[n]}function z(e){const n=e.id;if(!1!==b(n,"onClose",n)){try{e.parentNode&&e.remove()}catch(e){o(e)}b(n,"onClosed",n),y(e)}}function v(e){null===p.position&&(p.position={x:window.scrollX,y:window.scrollY})}function $(){p.position=null}function T(e){null!==p.position&&(window.scrollTo(p.position.x,p.position.y),$())}function R(e){v(e.id),M(e),x("reset","reset",e.id)}function M(e){const n=e.id;function t(n){const t=`${e[n]}px`;e.iframe.style[n]=t}h[n].sizeHeight&&t("height"),h[n].sizeWidth&&t("width")}function x(e,n,t,a){h[t]&&(h[t]?.postMessageTarget?function(){const{postMessageTarget:e,targetOrigin:o}=h[t];if(h[t].sameDomain)try{return void h[t].iframe.contentWindow.iframeChildListener(s+n)}catch(e){i(t,"Same domain connection failed. Trying cross domain"),h[t].sameDomain=!1}e.postMessage(s+n,o)}():o(t,`[${e}] IFrame(${t}) not found`),a&&h[t]?.warningTimeout&&(h[t].msgTimeout=setTimeout((function(){void 0!==h[t]&&(h[t].loaded||h[t].loadErrorShown||(h[t].loadErrorShown=!0,r(t,`\nNo response from iFrame\n \nThe iframe (${t}) has not responded within ${h[t].warningTimeout/1e3} seconds. Check @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 warningTimeout option to a higher value or zero to suppress this warning.\n`)))}),h[t].warningTimeout)))}function I(e){const n=h[e];return[e,"8",n.sizeWidth,n.log,"32",n.enablePublicMethods,n.autoResize,n.bodyMargin,n.heightCalculationMethod,n.bodyBackground,n.bodyPadding,n.tolerance,n.inPageLinks,"child",n.widthCalculationMethod,n.mouseEvents,n.offsetHeight,n.offsetWidth,n.sizeHeight,m(n.license),p.version].join(":")}let k=0,E=!1;const W=e=>n=>{function t(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)&&r(s,'\nDeprecated Optionm\n\nThe sizeWidth, sizeHeight and autoResize options have been replaced with new direction option which expects values of "vertical", "horizontal" or "horizontal".\n'),e}const s=function(t){if(t&&"string"!=typeof t)throw new TypeError("Invaild id for iFrame. Expected String");return""!==t&&t||(n.id=t=function(){let n=e?.id||g.id+k++;return null!==document.getElementById(n)&&(n+=k++),n}(),(e||{}).log),t}(n.id);return s in h&&"iFrameResizer"in n?o(s,"Ignored iFrame, already setup."):(i(`v${a}`),r(n.id,"Alpha Release\n \nDo not use in production, API is not stable."),function(e){var i;h[s]={iframe:n,firstRun:!0,remoteHost:n?.src.split("/").slice(0,3).join("/"),...g,...t(e)},function(){if("horizontal"===h[s].direction)return h[s].sizeWidth=!0,void(h[s].sizeHeight=!1);if("none"===h[s].direction)return h[s].sizeWidth=!1,h[s].sizeHeight=!1,void(h[s].autoResize=!1);if("vertical"!==h[s].direction)throw new TypeError(s,`Direction value of "${h[s].direction}" is not valid`)}(),null===h[s].postMessageTarget&&(h[s].postMessageTarget=n.contentWindow),h[s].targetOrigin=!0===h[s].checkOrigin?""===(i=h[s].remoteHost)||null!==i.match(/^(about:blank|javascript:|file:\/\/)/)?"*":i:"*"}(e),H(),function(){switch(n.style.overflow=!1===h[s]?.scrolling?"hidden":"auto",h[s]?.scrolling){case"omit":break;case!0:n.scrolling="yes";break;case!1:n.scrolling="no";break;default:n.scrolling=h[s]?h[s].scrolling:"no"}}(),function(){function e(e){const t=h[s][e];1/0!==t&&0!==t&&(n.style[e]=u(t)?`${t}px`:t)}function t(e){if(u(`min${e}`)&&u(`max${e}`)&&h[s][`min${e}`]>h[s][`max${e}`])throw new Error(`Value for min${e} can not be greater than max${e}`)}t("Height"),t("Width"),e("maxHeight"),e("minHeight"),e("maxWidth"),e("minWidth")}(),function(){const{bodyMargin:e}=h[s];"number"!=typeof e&&"0"!==e||(h[s].bodyMargin=`${e}px`)}(),function(e){const{id:t}=n;l(n,"load",(function(){x("iFrame.onload",`${e}:${E}`,t,!0),function(){const e=h[s]?.firstRun,t=h[s]?.heightCalculationMethod in d;!e&&t&&R({iframe:n,height:0,width:0,type:"init"})}()})),x("init",`${e}:${E}`,t,!0)}(I(s)),function(){if(h[s]){const e={close:z.bind(null,h[s].iframe),disconnect:y.bind(null,h[s].iframe),removeListeners(){r(s,"\nDeprecated Method Namem\n\nThe emoveListeners() method has been renamed to isconnect().\n"),this.disconnect()},resize:x.bind(null,"Window resize","resize",s),moveToAnchor(e){x("Move to anchor",`moveToAnchor:${e}`,s)},sendMessage(e){x("Send Message",`message:${e=JSON.stringify(e)}`,s)}};h[s].iframe.iframeResizer=e,h[s].iframe.iFrameResizer=e}}()),n?.iFrameResizer};function N(){!1===document.hidden&&function(e,n){const t=e=>h[e]?.autoResize&&!h[e]?.firstRun;Object.keys(h).forEach((function(i){t(i)&&x(e,n,i)}))}("Tab Visible","resize")}const H=(e=>{let n=!1;return function(){return n?void 0:(n=!0,Reflect.apply(e,this,arguments))}})((()=>{l(window,"message",w),l(document,"visibilitychange",N),window.iframeParentListener=e=>w({data:e,sameDomain:!0})})),F="[iframeResizer] ";const O=function(){function e(e){switch(!0){case!e:throw new TypeError(`${F}iframe is not defined`);case!e.tagName:throw new TypeError(`${F}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${F}Expected <IFRAME> tag, found <${e.tagName}>`);default:n(e),t.push(e)}}let n,t;return function(i,o){if("undefined"==typeof window)return[];switch(n=W(i),t=[],typeof o){case"undefined":case"string":document.querySelectorAll(o||"iframe").forEach(e);break;case"object":e(o);break;default:throw new TypeError(`${F}Unexpected data type (${typeof o})`)}return Object.freeze(t)}}();return"undefined"!=typeof window&&(window.iFrameResize=function(...e){r("","Deprecated: iFrameResize(), please use iframeResize()"),O(...e)}),O}));
!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?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(t)}]`,n=(e,n,...i)=>window?.console[e](t(n),...i),i=(e,...t)=>n("warn",e,...t),o=(t,n)=>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=>(...n)=>[`${e}[${t}]`,...n].join(" "))(t))(n)),r="5.0.0-beta.1",s="[iFrameSizer]",a=s.length,c=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),d=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)},l=(e,t,n,i)=>e.addEventListener(t,n,i||!1),f=(e,t,n)=>e.removeEventListener(t,n,!1),u={},m=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:"vertical",inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"auto",id:"iFrameResizer",log:!0,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 u[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 "),u[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),h={position:null,version:r};function p(e){function t(){$(L),v(),S("onResized",L)}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 o(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function r(e){return C.slice(C.indexOf(":")+7+e)}const c=(e,t)=>(n,i)=>{const o={};var r,s;r=function(){R(`Send ${e} (${n})`,`${e}:${t()}`,i)},o[s=i]||(r(),o[s]=requestAnimationFrame((()=>{o[s]=null})))},d=(e,t)=>()=>{const n=t=>()=>{u[r]?e(t,r):o()};function i(e,t){t(window,"scroll",n("scroll")),t(window,"resize",n("resize window"))}function o(){i(0,f),s.disconnect(),a.disconnect()}const r=A,s=new ResizeObserver(n("page observed")),a=new ResizeObserver(n("iframe observed"));i(0,l),s.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),a.observe(u[r].iframe,{attributes:!0,childList:!1,subtree:!1}),u[r]&&(u[r][`stop${t}`]=o)},m=e=>()=>{e in u[A]&&(u[A][e](),delete u[A][e])},p=c("pageInfo",(function(){const e=document.body.getBoundingClientRect(),t=L.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})})),w=c("parentInfo",(function(){const{iframe:e}=L,{scrollWidth:t,scrollHeight:n}=document.documentElement,{width:i,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:c,scale:d}=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:c,scale:d}})})),M=d(p,"PageInfo"),E=d(w,"ParentInfo"),x=m("stopPageInfo"),F=m("stopParentInfo");function W(e){const t=e.getBoundingClientRect();return y(),{x:Number(t.left)+Number(h.position.x),y:Number(t.top)+Number(h.position.y)}}function O(e){const t=e?W(L.iframe):{x:0,y:0};let n=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(L,t);window.top===window.self?(h.position=n,N()):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](n.x,n.y):i(A,"Unable to scroll to requested position, window.parentIFrame not found")}function N(){!1!==S("onScroll",h.position)?v():z()}function H(e){let t={};if(0===L.width&&0===L.height){const e=r(9).split(":");t={x:e[1],y:e[0]}}else t={x:L.width,y:L.height};S(e,{iframe:L.iframe,screenX:Number(t.x),screenY:Number(t.y),type:L.type})}const S=(e,t)=>g(A,e,t);let C=e.data,L={},A=null;"[iFrameResizerChild]Ready"!==C?s===`${C}`.slice(0,a)&&C.slice(a).split(":")[0]in u&&(L=function(){const e=C.slice(a).split(":"),t=e[1]?Number(e[1]):0,i=u[e[0]]?.iframe,r=getComputedStyle(i);return{iframe:i,id:e[0],height:t+n(r)+o(r),width:Number(e[2]),type:e[3]}}(),A=L.id,A?(function(e){if(!u[e])throw new Error(`${L.type} No settings for ${e}. Message was: ${C}`)}(A),L.type in{true:1,false:1,undefined:1}||(u[A].loaded=!0,function(){let e=!0;return null===L.iframe&&(i(A,`The iframe (${L.id}) was not found.`),e=!1),e}()&&function(){const{origin:t,sameDomain:n}=e;if(n)return!0;let i=u[A]?.checkOrigin;if(i&&"null"!=`${t}`&&!(i.constructor===Array?function(){let e=0,n=!1;for(;e<i.length;e++)if(i[e]===t){n=!0;break}return n}():function(){const e=u[A]?.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(u[A]?.firstRun&&u[A]&&(u[A].firstRun=!1),L.type){case"close":b(L.iframe);break;case"message":e=r(6),S("onMessage",{iframe:L.iframe,message:JSON.parse(e)});break;case"mouseenter":H("onMouseEnter");break;case"mouseleave":H("onMouseLeave");break;case"autoResize":u[A].autoResize=JSON.parse(r(9));break;case"scrollTo":O(!1);break;case"scrollToOffset":O(!0);break;case"pageInfo":p("start",A),M();break;case"parentInfo":w("start",A),E();break;case"pageInfoStop":x();break;case"parentInfoStop":F();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=W(i);h.position={x:e.x,y:e.y},N()}():window.top!==window.self&&window.parentIFrame&&window.parentIFrame.moveToAnchor(t)}(r(9));break;case"reset":T(L);break;case"init":t(),function(e){try{u[e].sameDomain=!!u[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){u[e].sameDomain=!1}}(A),k=!0,S("onReady",L.iframe);break;default:if(0===L.width&&0===L.height)return void i(`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("iframeResizer received messageData without id, message was: ",C)):Object.keys(u).forEach((e=>R("iFrame requested init",I(e),e)))}function g(e,t,n){let i=null,o=null;if(u[e]){if(i=u[e][t],"function"!=typeof i)throw new TypeError(`${t} on iFrame[${e}] is not a function`);o=i(n)}return o}function w(e){const t=e.id;delete u[t]}function b(e){const t=e.id;if(!1!==g(t,"onClose",t)){try{e.parentNode&&e.remove()}catch(e){i(e)}g(t,"onClosed",t),w(e)}}function y(e){null===h.position&&(h.position={x:window.scrollX,y:window.scrollY})}function z(){h.position=null}function v(e){null!==h.position&&(window.scrollTo(h.position.x,h.position.y),z())}function T(e){y(e.id),$(e),R("reset","reset",e.id)}function $(e){const t=e.id;function n(t){const n=`${e[t]}px`;e.iframe.style[t]=n}u[t].sizeHeight&&n("height"),u[t].sizeWidth&&n("width")}function R(e,t,n,r){u[n]&&(u[n]?.postMessageTarget?function(){const{postMessageTarget:e,targetOrigin:i}=u[n];if(u[n].sameDomain)try{return void u[n].iframe.contentWindow.iframeChildListener(s+t)}catch(e){u[n].sameDomain=!1}e.postMessage(s+t,i)}():i(n,`[${e}] IFrame(${n}) not found`),r&&u[n]?.warningTimeout&&(u[n].msgTimeout=setTimeout((function(){void 0!==u[n]&&(u[n].loaded||u[n].loadErrorShown||(u[n].loadErrorShown=!0,o(n,`\n<rb>No response from iFrame</>\n \nThe iframe (<i>${n}</>) has not responded within ${u[n].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`)))}),u[n].warningTimeout)))}function I(e){const t=u[e];return[e,"8",t.sizeWidth,t.log,"32",t.enablePublicMethods,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,d(t.license),h.version].join(":")}let M=0,k=!1;const E=e=>t=>{function s(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(a,'<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 a=function(n){if(n&&"string"!=typeof n)throw new TypeError("Invaild id for iFrame. Expected String");return""!==n&&n||(t.id=n=function(){let t=e?.id||m.id+M++;return null!==document.getElementById(t)&&(t+=M++),t}(),(e||{}).log),n}(t.id);return a in u&&"iFrameResizer"in t?i(a,"Ignored iFrame, already setup."):(x||(x=!0,((e,...t)=>{n("info",e,...t)})(`v${r}`)),function(e){var n,i;u[a]={iframe:t,firstRun:!0,remoteHost:t?.src.split("/").slice(0,3).join("/"),...m,...s(e)},function(){if("horizontal"===u[a].direction)return u[a].sizeWidth=!0,void(u[a].sizeHeight=!1);if("none"===u[a].direction)return u[a].sizeWidth=!1,u[a].sizeHeight=!1,void(u[a].autoResize=!1);if("vertical"!==u[a].direction)throw new TypeError(a,`Direction value of "${u[a].direction}" is not valid`)}(),n=e?.offset,n&&("vertical"===u[a].direction?u[a].offsetHeight=n:u[a].offsetWidth=n),null===u[a].postMessageTarget&&(u[a].postMessageTarget=t.contentWindow),u[a].targetOrigin=!0===u[a].checkOrigin?""===(i=u[a].remoteHost)||null!==i.match(/^(about:blank|javascript:|file:\/\/)/)?"*":i:"*"}(e),W(),function(){switch(t.style.overflow=!1===u[a]?.scrolling?"hidden":"auto",u[a]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=u[a]?u[a].scrolling:"no"}}(),function(){const{bodyMargin:e}=u[a];"number"!=typeof e&&"0"!==e||(u[a].bodyMargin=`${e}px`)}(),function(e){const{id:n}=t;l(t,"load",(function(){R("iFrame.onload",`${e}:${k}`,n,!0),function(){const e=u[a]?.firstRun,n=u[a]?.heightCalculationMethod in c;!e&&n&&T({iframe:t,height:0,width:0,type:"init"})}()})),R("init",`${e}:${k}`,n,!0)}(I(a)),function(){if(u[a]){const e={close:b.bind(null,u[a].iframe),disconnect:w.bind(null,u[a].iframe),removeListeners(){o(a,"\n<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize:R.bind(null,"Window resize","resize",a),moveToAnchor(e){R("Move to anchor",`moveToAnchor:${e}`,a)},sendMessage(e){R("Send Message",`message:${e=JSON.stringify(e)}`,a)}};u[a].iframe.iframeResizer=e,u[a].iframe.iFrameResizer=e}}()),t?.iFrameResizer};let x=!1;function F(){!1===document.hidden&&function(e,t){const n=e=>u[e]?.autoResize&&!u[e]?.firstRun;Object.keys(u).forEach((function(i){n(i)&&R(e,t,i)}))}("Tab Visible","resize")}const W=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})((()=>{l(window,"message",p),l(document,"visibilitychange",F),window.iframeParentListener=e=>p({data:e,sameDomain:!0})})),O="[iframeResizer] ";const N=function(){function e(e){switch(!0){case!e:throw new TypeError(`${O}iframe is not defined`);case!e.tagName:throw new TypeError(`${O}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${O}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=E(i),n=[],typeof o){case"undefined":case"string":document.querySelectorAll(o||"iframe").forEach(e);break;case"object":e(o);break;default:throw new TypeError(`${O}Unexpected data type (${typeof o})`)}return Object.freeze(n)}}();return"undefined"!=typeof window&&(window.iFrameResize=function(...e){o("","Deprecated: iFrameResize(), please use iframeResize()"),N(...e)}),N}));
{
"name": "@iframe-resizer/parent",
"version": "5.0.0-alpha.12",
"version": "5.0.0-beta.1",
"license": "GPL-3.0",
"homepage": "http://iframe-resizer.com",
"homepage": "https://iframe-resizer.com",
"author": {

@@ -45,4 +45,4 @@ "name": "David J. Bradshaw",

"dependencies": {
"@iframe-resizer/core": "5.0.0-alpha.12"
"@iframe-resizer/core": "5.0.0-beta.1"
}
}

@@ -5,10 +5,20 @@ <img src="https://iframe-resizer.com/logo-full.png" alt="" title="" />

This package is an alpha release of version 5 of _iframe-resizer_, for the production version see the [iframe-resizer](https://www.npmjs.com/package/iframe-resizer) package.
This package is package is part of _iframe-resizer_, see our website http://iframe-resizer.com/ for details on using this library.
This version has an unstable API and should not be used on production sites.
## Install
Alpha version 5 docs: http://iframe-resizer.com/.
Using npm:
```bash
npm install @iframe-resizer/parent --save
```
or using yarn:
```bash
npm add @iframe-resizer/parent
```
---
_iframe-resizer version 5.0.0-alpha.12 2024-04-26 - 15:47:40.987Z_
_iframe-resizer version 5.0.0-beta.1 2024-05-09 - 16:34:22.278Z_
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