@iframe-resizer/jquery 5.0.0-alpha.9 → 5.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,23 @@
1
+ <img src="https://iframe-resizer.com/logo-full.png" alt="" title="" />
2
+
1
3
  # @iframe-resizer/jquery
2
4
 
3
- > _Keep same and cross domain iframes sized to their content_
5
+ This package is package is part of _iframe-resizer_, see our website http://iframe-resizer.com/ for details on using this library.
6
+
7
+ ## Install
8
+
9
+ Using npm:
4
10
 
5
- 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.
11
+ ```bash
12
+ npm install @iframe-resizer/jquery --save
13
+ ```
6
14
 
7
- This version has an unstable API and should not be used on production sites.
15
+ or using yarn:
8
16
 
9
- Alpha version 5 docs: http://iframe-resizer.com/.
17
+ ```bash
18
+ npm add @iframe-resizer/jquery
19
+ ```
10
20
 
11
21
  ---
12
22
 
13
- _iframe-resizer version 5.0.0-alpha.9 2024-04-24 - 10:43:22.139Z_
23
+ _iframe-resizer version 5.0.0-beta.1 2024-05-09 - 16:34:22.278Z_
package/index.cjs.js CHANGED
@@ -1,20 +1,20 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/jquery 5.0.0-alpha.9 (cjs) - 2024-04-24
4
+ * @module iframe-resizer/jquery 5.0.0-beta.1 (cjs) - 2024-05-09
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
8
- * http://iframe-resizer.com/pricing
8
+ * https://iframe-resizer.com/pricing
9
9
  *
10
10
  * @desciption Keep same and cross domain iFrames sized to their content
11
11
  *
12
12
  * @author David J. Bradshaw <dave@bradshaw.net>
13
13
  *
14
- * @see {@link http://iframe-resizer.com}
14
+ * @see {@link https://iframe-resizer.com}
15
15
  *
16
16
  * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.
17
17
  */
18
18
 
19
19
 
20
- "use strict";const e=require("@iframe-resizer/core");const i=e=>`[iframeResizer][${function(e){return window.top===window.self?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(e)}]`,r=(e,...r)=>((e,r,...n)=>window?.console[e](i(r),...n))("warn",e,...r);switch(!0){case void 0===window.jQuery:r("","Unable to bind to jQuery, it is not available.");break;case!window.jQuery.fn:r("","Unable to bind to jQuery, it is not fully loaded.");break;case window.jQuery.fn.iframeResize:r("","iframeResize is already assigned to jQuery.fn.");break;default:window.jQuery.fn.iframeResize=function(i){const r=e(i);return this.filter("iframe").each(r).end()},window.jQuery.fn.iFrameResize=function(e){return r("","Deprecated: Use the iframeResize method instead of iFrameResize"),this.iframeResize(e)}}
20
+ "use strict";const e=require("@iframe-resizer/core");const i=e=>`[iframe-resizer][${function(e){return window.top===window.self?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(e)}]`,r=(e,...r)=>((e,r,...n)=>window?.console[e](i(r),...n))("warn",e,...r);switch(!0){case void 0===window.jQuery:r("","Unable to bind to jQuery, it is not available.");break;case!window.jQuery.fn:r("","Unable to bind to jQuery, it is not fully loaded.");break;case window.jQuery.fn.iframeResize:r("","iframeResize is already assigned to jQuery.fn.");break;default:window.jQuery.fn.iframeResize=function(i){const r=e(i);return this.filter("iframe").each(r).end()},window.jQuery.fn.iFrameResize=function(e){return r("","Deprecated: Use the iframeResize method instead of iFrameResize"),this.iframeResize(e)}}
package/index.esm.js CHANGED
@@ -1,20 +1,20 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/jquery 5.0.0-alpha.9 (esm) - 2024-04-24
4
+ * @module iframe-resizer/jquery 5.0.0-beta.1 (esm) - 2024-05-09
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
8
- * http://iframe-resizer.com/pricing
8
+ * https://iframe-resizer.com/pricing
9
9
  *
10
10
  * @desciption Keep same and cross domain iFrames sized to their content
11
11
  *
12
12
  * @author David J. Bradshaw <dave@bradshaw.net>
13
13
  *
14
- * @see {@link http://iframe-resizer.com}
14
+ * @see {@link https://iframe-resizer.com}
15
15
  *
16
16
  * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.
17
17
  */
18
18
 
19
19
 
20
- import e from"@iframe-resizer/core";const i=e=>`[iframeResizer][${function(e){return window.top===window.self?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(e)}]`,r=(e,...r)=>((e,r,...n)=>window?.console[e](i(r),...n))("warn",e,...r);switch(!0){case void 0===window.jQuery:r("","Unable to bind to jQuery, it is not available.");break;case!window.jQuery.fn:r("","Unable to bind to jQuery, it is not fully loaded.");break;case window.jQuery.fn.iframeResize:r("","iframeResize is already assigned to jQuery.fn.");break;default:window.jQuery.fn.iframeResize=function(i){const r=e(i);return this.filter("iframe").each(r).end()},window.jQuery.fn.iFrameResize=function(e){return r("","Deprecated: Use the iframeResize method instead of iFrameResize"),this.iframeResize(e)}}
20
+ import e from"@iframe-resizer/core";const i=e=>`[iframe-resizer][${function(e){return window.top===window.self?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(e)}]`,r=(e,...r)=>((e,r,...n)=>window?.console[e](i(r),...n))("warn",e,...r);switch(!0){case void 0===window.jQuery:r("","Unable to bind to jQuery, it is not available.");break;case!window.jQuery.fn:r("","Unable to bind to jQuery, it is not fully loaded.");break;case window.jQuery.fn.iframeResize:r("","iframeResize is already assigned to jQuery.fn.");break;default:window.jQuery.fn.iframeResize=function(i){const r=e(i);return this.filter("iframe").each(r).end()},window.jQuery.fn.iFrameResize=function(e){return r("","Deprecated: Use the iframeResize method instead of iFrameResize"),this.iframeResize(e)}}
package/index.umd.js CHANGED
@@ -1,20 +1,20 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/jquery 5.0.0-alpha.9 (umd) - 2024-04-24
4
+ * @module iframe-resizer/jquery 5.0.0-beta.1 (umd) - 2024-05-09
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
8
- * http://iframe-resizer.com/pricing
8
+ * https://iframe-resizer.com/pricing
9
9
  *
10
10
  * @desciption Keep same and cross domain iFrames sized to their content
11
11
  *
12
12
  * @author David J. Bradshaw <dave@bradshaw.net>
13
13
  *
14
- * @see {@link http://iframe-resizer.com}
14
+ * @see {@link https://iframe-resizer.com}
15
15
  *
16
16
  * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.
17
17
  */
18
18
 
19
19
 
20
- !function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.0.0-alpha.9",n="[iFrameSizer]",i=n.length,t=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),o=(e,n,i,t)=>e.addEventListener(n,i,t||!1),r=(e,n,i)=>e.removeEventListener(n,i,!1),s="[iframeResizer]";const a=e=>`${s}[${function(e){return window.top===window.self?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(e)}]`,c=(e,n,...i)=>window?.console[e](a(n),...i),d=(e,...n)=>c("info",e,...n),l=(e,...n)=>c("warn",e,...n),u=(e,n)=>window?.console.warn(((e,...n)=>[`${s}[${e}]`,...n])(e,window.chrome?n:n.replaceAll(/\u001B\[[\d;]*m/gi,""))),f=e=>!Number.isNaN(e),m=e=>{if(!e)return"";let n=-559038744,i=1103547984;for(let t,o=0;o<e.length;o++)t=e.codePointAt(o),n=Math.imul(n^t,2246822519),i=Math.imul(i^t,3266489917);return n^=Math.imul(n^i>>>15,1935289751),i^=Math.imul(i^n>>>15,3405138345),n^=i>>>16,i^=n>>>16,(2097152*(i>>>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&&(u(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:e};function w(e){function t(){c("Height"),c("Width"),k(j),R(),C("onResized",j)}function s(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function a(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function c(e){const n=Number(h[B][`max${e}`]),i=Number(h[B][`min${e}`]),t=e.toLowerCase();let o=Number(j[t]);o<i&&(o=i),o>n&&(o=n),j[t]=`${o}`}function d(e){return L.slice(L.indexOf(":")+7+e)}const u=(e,n)=>(i,t)=>{const o={};var r,s;r=function(){I(`Send ${e} (${i})`,`${e}:${n()}`,t)},o[s=t]||(r(),o[s]=requestAnimationFrame((()=>{o[s]=null})))},f=(e,n)=>()=>{const i=n=>()=>{h[a]?e(n,a):s()};function t(e,n){n(window,"scroll",i("scroll")),n(window,"resize",i("resize window"))}function s(){t(0,r),c.disconnect()}const a=B,c=new ResizeObserver(i("iframe observed"));t(0,o),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),h[a]&&(h[a][`stop${n}`]=s)},m=e=>()=>{e in h[B]&&(h[B][e](),delete h[B][e])},g=u("pageInfo",(function(){const e=document.body.getBoundingClientRect(),n=j.iframe.getBoundingClientRect(),{scrollY:i,scrollX:t,innerHeight:o,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(s,o||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(n.top-e.top,10),offsetLeft:parseInt(n.left-e.left,10),scrollTop:i,scrollLeft:t,documentHeight:s,documentWidth:a,windowHeight:o,windowWidth:r})})),w=u("parentInfo",(function(){const{iframe:e}=j,{scrollWidth:n,scrollHeight:i}=document.documentElement,{width:t,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:c,scale:d}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:n,scrollHeight:i},viewport:{width:t,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:c,scale:d}})})),y=f(g,"PageInfo"),x=f(w,"ParentInfo"),N=m("stopPageInfo"),H=m("stopParentInfo");function E(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?E(j.iframe):{x:0,y:0};let i=((e,n)=>({x:Number(e.width)+n.x,y:Number(e.height)+n.y}))(j,n);window.top===window.self?(p.position=i,O()):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):l(B,"Unable to scroll to requested position, window.parentIFrame not found")}function O(){!1!==C("onScroll",p.position)?R():$()}function S(e){let n={};if(0===Number(j.width)&&0===Number(j.height)){const e=d(9).split(":");n={x:e[1],y:e[0]}}else n={x:j.width,y:j.height};C(e,{iframe:j.iframe,screenX:Number(n.x),screenY:Number(n.y),type:j.type})}const C=(e,n)=>b(B,e,n);let L=e.data,j={},B=null;"[iFrameResizerChild]Ready"!==L?n===`${L}`.slice(0,i)&&L.slice(i).split(":")[0]in h&&(j=function(){const e=L.slice(i).split(":"),n=e[1]?Number(e[1]):0,t=h[e[0]]?.iframe,o=getComputedStyle(t);return{iframe:t,id:e[0],height:n+s(o)+a(o),width:Number(e[2]),type:e[3]}}(),B=j.id,B?(function(e){if(!h[e])throw new Error(`${j.type} No settings for ${e}. Message was: ${L}`)}(B),j.type in{true:1,false:1,undefined:1}||(h[B].loaded=!0,function(){let e=!0;return null===j.iframe&&(l(B,`The iframe (${j.id}) was not found.`),e=!1),e}()&&function(){const{origin:n,sameDomain:i}=e;if(i)return!0;let t=h[B]?.checkOrigin;if(t&&"null"!=`${n}`&&!(t.constructor===Array?function(){let e=0,i=!1;for(;e<t.length;e++)if(t[e]===n){i=!0;break}return i}():function(){const e=h[B]?.remoteHost;return n===e}()))throw new Error(`Unexpected message received from: ${n} for ${j.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),j.type){case"close":z(j.iframe);break;case"message":e=d(6),C("onMessage",{iframe:j.iframe,message:JSON.parse(e)});break;case"mouseenter":S("onMouseEnter");break;case"mouseleave":S("onMouseLeave");break;case"autoResize":h[B].autoResize=JSON.parse(d(9));break;case"scrollTo":F(!1);break;case"scrollToOffset":F(!0);break;case"pageInfo":g("start",B),y();break;case"parentInfo":w("start",B),x();break;case"pageInfoStop":N();break;case"parentInfoStop":H();break;case"inPageLink":!function(e){const n=e.split("#")[1]||"",i=decodeURIComponent(n);let t=document.getElementById(i)||document.getElementsByName(i)[0];t?function(){const e=E(t);p.position={x:e.x,y:e.y},O()}():window.top!==window.self&&window.parentIFrame&&window.parentIFrame.moveToAnchor(n)}(d(9));break;case"reset":T(j);break;case"init":t(),function(e){try{h[e].sameDomain=!!h[e]?.iframe?.contentWindow?.iframeChildListener}catch(n){h[e].sameDomain=!1}}(B),W=!0,C("onReady",j.iframe);break;default:if(0===j.width&&0===j.height)return void l(`Unsupported message received (${j.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===j.width||0===j.height)return;if(document.hidden)return;t()}var e}())):l("iframeResizer received messageData without id, message was: ",L)):Object.keys(h).forEach((e=>I("iFrame requested init",M(e),e)))}function b(e,n,i){let t=null,o=null;if(h[e]){if(t=h[e][n],"function"!=typeof t)throw new TypeError(`${n} on iFrame[${e}] is not a function`);o=t(i)}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){l(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 R(e){null!==p.position&&(window.scrollTo(p.position.x,p.position.y),$())}function T(e){v(e.id),k(e),I("reset","reset",e.id)}function k(e){const n=e.id;function i(n){const i=`${e[n]}px`;e.iframe.style[n]=i}h[n].sizeHeight&&i("height"),h[n].sizeWidth&&i("width")}function I(e,i,t,o){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(n+i)}catch(e){d(t,"Same domain connection failed. Trying cross domain"),h[t].sameDomain=!1}e.postMessage(n+i,o)}():l(t,`[${e}] IFrame(${t}) not found`),o&&h[t]?.warningTimeout&&(h[t].msgTimeout=setTimeout((function(){void 0!==h[t]&&(h[t].loaded||h[t].loadErrorShown||(h[t].loadErrorShown=!0,u(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 M(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 x=0,W=!1;const N=n=>i=>{function r(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)&&u(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(e){if(e&&"string"!=typeof e)throw new TypeError("Invaild id for iFrame. Expected String");return""!==e&&e||(i.id=e=function(){let e=n?.id||g.id+x++;return null!==document.getElementById(e)&&(e+=x++),e}(),(n||{}).log),e}(i.id);return s in h&&"iFrameResizer"in i?l(s,"Ignored iFrame, already setup."):(d(`v${e}`),u(i.id,"Alpha Release\n \nDo not use in production, API is not stable."),function(e){var n;h[s]={iframe:i,firstRun:!0,remoteHost:i?.src.split("/").slice(0,3).join("/"),...g,...r(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=i.contentWindow),h[s].targetOrigin=!0===h[s].checkOrigin?""===(n=h[s].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}(n),E(),function(){switch(i.style.overflow=!1===h[s]?.scrolling?"hidden":"auto",h[s]?.scrolling){case"omit":break;case!0:i.scrolling="yes";break;case!1:i.scrolling="no";break;default:i.scrolling=h[s]?h[s].scrolling:"no"}}(),function(){function e(e){const n=h[s][e];1/0!==n&&0!==n&&(i.style[e]=f(n)?`${n}px`:n)}function n(e){if(f(`min${e}`)&&f(`max${e}`)&&h[s][`min${e}`]>h[s][`max${e}`])throw new Error(`Value for min${e} can not be greater than max${e}`)}n("Height"),n("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:n}=i;o(i,"load",(function(){I("iFrame.onload",`${e}:${W}`,n,!0),function(){const e=h[s]?.firstRun,n=h[s]?.heightCalculationMethod in t;!e&&n&&T({iframe:i,height:0,width:0,type:"init"})}()})),I("init",`${e}:${W}`,n,!0)}(M(s)),function(){if(h[s]){const e={close:z.bind(null,h[s].iframe),disconnect:y.bind(null,h[s].iframe),removeListeners(){u(s,"\nDeprecated Method Namem\n\nThe emoveListeners() method has been renamed to isconnect().\n"),this.disconnect()},resize:I.bind(null,"Window resize","resize",s),moveToAnchor(e){I("Move to anchor",`moveToAnchor:${e}`,s)},sendMessage(e){I("Send Message",`message:${e=JSON.stringify(e)}`,s)}};h[s].iframe.iframeResizer=e,h[s].iframe.iFrameResizer=e}}()),i?.iFrameResizer};function H(){!1===document.hidden&&function(e,n){const i=e=>h[e]?.autoResize&&!h[e]?.firstRun;Object.keys(h).forEach((function(t){i(t)&&I(e,n,t)}))}("Tab Visible","resize")}const E=(e=>{let n=!1;return function(){return n?void 0:(n=!0,Reflect.apply(e,this,arguments))}})((()=>{o(window,"message",w),o(document,"visibilitychange",H),window.iframeParentListener=e=>w({data:e,sameDomain:!0})}));switch(!0){case void 0===window.jQuery:l("","Unable to bind to jQuery, it is not available.");break;case!window.jQuery.fn:l("","Unable to bind to jQuery, it is not fully loaded.");break;case window.jQuery.fn.iframeResize:l("","iframeResize is already assigned to jQuery.fn.");break;default:window.jQuery.fn.iframeResize=function(e){const n=N(e);return this.filter("iframe").each(n).end()},window.jQuery.fn.iFrameResize=function(e){return l("","Deprecated: Use the iframeResize method instead of iFrameResize"),this.iframeResize(e)}}}));
20
+ !function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.0.0-beta.1",i="[iFrameSizer]",n=i.length,t=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),o=e=>{if(!e)return"";let i=-559038744,n=1103547984;for(let t,o=0;o<e.length;o++)t=e.codePointAt(o),i=Math.imul(i^t,2246822519),n=Math.imul(n^t,3266489917);return i^=Math.imul(i^n>>>15,1935289751),n^=Math.imul(n^i>>>15,3405138345),i^=n>>>16,n^=i>>>16,(2097152*(n>>>0)+(i>>>11)).toString(36)},r=(e,i,n,t)=>e.addEventListener(i,n,t||!1),s=(e,i,n)=>e.removeEventListener(i,n,!1),a="[iframe-resizer]";const c=e=>`${a}[${function(e){return window.top===window.self?`Host page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested host page: ${e}`}(e)}]`,d=(e,i,...n)=>window?.console[e](c(i),...n),l=(e,...i)=>d("warn",e,...i),f=(e,i)=>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,"")))((e=>(...i)=>[`${a}[${e}]`,...i].join(" "))(e))(i)),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&&(f(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:e};function g(e){function t(){T(N),v(),L("onResized",N)}function o(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function a(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function c(e){return C.slice(C.indexOf(":")+7+e)}const d=(e,i)=>(n,t)=>{const o={};var r,s;r=function(){$(`Send ${e} (${n})`,`${e}:${i()}`,t)},o[s=t]||(r(),o[s]=requestAnimationFrame((()=>{o[s]=null})))},f=(e,i)=>()=>{const n=i=>()=>{u[a]?e(i,a):o()};function t(e,i){i(window,"scroll",n("scroll")),i(window,"resize",n("resize window"))}function o(){t(0,s),c.disconnect(),d.disconnect()}const a=j,c=new ResizeObserver(n("page observed")),d=new ResizeObserver(n("iframe observed"));t(0,r),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(u[a].iframe,{attributes:!0,childList:!1,subtree:!1}),u[a]&&(u[a][`stop${i}`]=o)},m=e=>()=>{e in u[j]&&(u[j][e](),delete u[j][e])},g=d("pageInfo",(function(){const e=document.body.getBoundingClientRect(),i=N.iframe.getBoundingClientRect(),{scrollY:n,scrollX:t,innerHeight:o,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(s,o||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(i.top-e.top,10),offsetLeft:parseInt(i.left-e.left,10),scrollTop:n,scrollLeft:t,documentHeight:s,documentWidth:a,windowHeight:o,windowWidth:r})})),w=d("parentInfo",(function(){const{iframe:e}=N,{scrollWidth:i,scrollHeight:n}=document.documentElement,{width:t,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:c,scale:d}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:i,scrollHeight:n},viewport:{width:t,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:c,scale:d}})})),I=f(g,"PageInfo"),x=f(w,"ParentInfo"),W=m("stopPageInfo"),F=m("stopParentInfo");function E(e){const i=e.getBoundingClientRect();return y(),{x:Number(i.left)+Number(h.position.x),y:Number(i.top)+Number(h.position.y)}}function O(e){const i=e?E(N.iframe):{x:0,y:0};let n=((e,i)=>({x:e.width+i.x,y:e.height+i.y}))(N,i);window.top===window.self?(h.position=n,H()):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](n.x,n.y):l(j,"Unable to scroll to requested position, window.parentIFrame not found")}function H(){!1!==L("onScroll",h.position)?v():z()}function S(e){let i={};if(0===N.width&&0===N.height){const e=c(9).split(":");i={x:e[1],y:e[0]}}else i={x:N.width,y:N.height};L(e,{iframe:N.iframe,screenX:Number(i.x),screenY:Number(i.y),type:N.type})}const L=(e,i)=>p(j,e,i);let C=e.data,N={},j=null;"[iFrameResizerChild]Ready"!==C?i===`${C}`.slice(0,n)&&C.slice(n).split(":")[0]in u&&(N=function(){const e=C.slice(n).split(":"),i=e[1]?Number(e[1]):0,t=u[e[0]]?.iframe,r=getComputedStyle(t);return{iframe:t,id:e[0],height:i+o(r)+a(r),width:Number(e[2]),type:e[3]}}(),j=N.id,j?(function(e){if(!u[e])throw new Error(`${N.type} No settings for ${e}. Message was: ${C}`)}(j),N.type in{true:1,false:1,undefined:1}||(u[j].loaded=!0,function(){let e=!0;return null===N.iframe&&(l(j,`The iframe (${N.id}) was not found.`),e=!1),e}()&&function(){const{origin:i,sameDomain:n}=e;if(n)return!0;let t=u[j]?.checkOrigin;if(t&&"null"!=`${i}`&&!(t.constructor===Array?function(){let e=0,n=!1;for(;e<t.length;e++)if(t[e]===i){n=!0;break}return n}():function(){const e=u[j]?.remoteHost;return i===e}()))throw new Error(`Unexpected message received from: ${i} for ${N.iframe.id}. Message was: ${e.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&function(){switch(u[j]?.firstRun&&u[j]&&(u[j].firstRun=!1),N.type){case"close":b(N.iframe);break;case"message":e=c(6),L("onMessage",{iframe:N.iframe,message:JSON.parse(e)});break;case"mouseenter":S("onMouseEnter");break;case"mouseleave":S("onMouseLeave");break;case"autoResize":u[j].autoResize=JSON.parse(c(9));break;case"scrollTo":O(!1);break;case"scrollToOffset":O(!0);break;case"pageInfo":g("start",j),I();break;case"parentInfo":w("start",j),x();break;case"pageInfoStop":W();break;case"parentInfoStop":F();break;case"inPageLink":!function(e){const i=e.split("#")[1]||"",n=decodeURIComponent(i);let t=document.getElementById(n)||document.getElementsByName(n)[0];t?function(){const e=E(t);h.position={x:e.x,y:e.y},H()}():window.top!==window.self&&window.parentIFrame&&window.parentIFrame.moveToAnchor(i)}(c(9));break;case"reset":R(N);break;case"init":t(),function(e){try{u[e].sameDomain=!!u[e]?.iframe?.contentWindow?.iframeChildListener}catch(i){u[e].sameDomain=!1}}(j),M=!0,L("onReady",N.iframe);break;default:if(0===N.width&&0===N.height)return void l(`Unsupported message received (${N.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===N.width||0===N.height)return;if(document.hidden)return;t()}var e}())):l("iframeResizer received messageData without id, message was: ",C)):Object.keys(u).forEach((e=>$("iFrame requested init",k(e),e)))}function p(e,i,n){let t=null,o=null;if(u[e]){if(t=u[e][i],"function"!=typeof t)throw new TypeError(`${i} on iFrame[${e}] is not a function`);o=t(n)}return o}function w(e){const i=e.id;delete u[i]}function b(e){const i=e.id;if(!1!==p(i,"onClose",i)){try{e.parentNode&&e.remove()}catch(e){l(e)}p(i,"onClosed",i),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 R(e){y(e.id),T(e),$("reset","reset",e.id)}function T(e){const i=e.id;function n(i){const n=`${e[i]}px`;e.iframe.style[i]=n}u[i].sizeHeight&&n("height"),u[i].sizeWidth&&n("width")}function $(e,n,t,o){u[t]&&(u[t]?.postMessageTarget?function(){const{postMessageTarget:e,targetOrigin:o}=u[t];if(u[t].sameDomain)try{return void u[t].iframe.contentWindow.iframeChildListener(i+n)}catch(e){u[t].sameDomain=!1}e.postMessage(i+n,o)}():l(t,`[${e}] IFrame(${t}) not found`),o&&u[t]?.warningTimeout&&(u[t].msgTimeout=setTimeout((function(){void 0!==u[t]&&(u[t].loaded||u[t].loadErrorShown||(u[t].loadErrorShown=!0,f(t,`\n<rb>No response from iFrame</>\n \nThe iframe (<i>${t}</>) has not responded within ${u[t].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[t].warningTimeout)))}function k(e){const i=u[e];return[e,"8",i.sizeWidth,i.log,"32",i.enablePublicMethods,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,o(i.license),h.version].join(":")}let I=0,M=!1;const x=i=>n=>{function o(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)&&f(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(e){if(e&&"string"!=typeof e)throw new TypeError("Invaild id for iFrame. Expected String");return""!==e&&e||(n.id=e=function(){let e=i?.id||m.id+I++;return null!==document.getElementById(e)&&(e+=I++),e}(),(i||{}).log),e}(n.id);return s in u&&"iFrameResizer"in n?l(s,"Ignored iFrame, already setup."):(W||(W=!0,((e,...i)=>{d("info",e,...i)})(`v${e}`)),function(e){var i,t;u[s]={iframe:n,firstRun:!0,remoteHost:n?.src.split("/").slice(0,3).join("/"),...m,...o(e)},function(){if("horizontal"===u[s].direction)return u[s].sizeWidth=!0,void(u[s].sizeHeight=!1);if("none"===u[s].direction)return u[s].sizeWidth=!1,u[s].sizeHeight=!1,void(u[s].autoResize=!1);if("vertical"!==u[s].direction)throw new TypeError(s,`Direction value of "${u[s].direction}" is not valid`)}(),i=e?.offset,i&&("vertical"===u[s].direction?u[s].offsetHeight=i:u[s].offsetWidth=i),null===u[s].postMessageTarget&&(u[s].postMessageTarget=n.contentWindow),u[s].targetOrigin=!0===u[s].checkOrigin?""===(t=u[s].remoteHost)||null!==t.match(/^(about:blank|javascript:|file:\/\/)/)?"*":t:"*"}(i),E(),function(){switch(n.style.overflow=!1===u[s]?.scrolling?"hidden":"auto",u[s]?.scrolling){case"omit":break;case!0:n.scrolling="yes";break;case!1:n.scrolling="no";break;default:n.scrolling=u[s]?u[s].scrolling:"no"}}(),function(){const{bodyMargin:e}=u[s];"number"!=typeof e&&"0"!==e||(u[s].bodyMargin=`${e}px`)}(),function(e){const{id:i}=n;r(n,"load",(function(){$("iFrame.onload",`${e}:${M}`,i,!0),function(){const e=u[s]?.firstRun,i=u[s]?.heightCalculationMethod in t;!e&&i&&R({iframe:n,height:0,width:0,type:"init"})}()})),$("init",`${e}:${M}`,i,!0)}(k(s)),function(){if(u[s]){const e={close:b.bind(null,u[s].iframe),disconnect:w.bind(null,u[s].iframe),removeListeners(){f(s,"\n<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize:$.bind(null,"Window resize","resize",s),moveToAnchor(e){$("Move to anchor",`moveToAnchor:${e}`,s)},sendMessage(e){$("Send Message",`message:${e=JSON.stringify(e)}`,s)}};u[s].iframe.iframeResizer=e,u[s].iframe.iFrameResizer=e}}()),n?.iFrameResizer};let W=!1;function F(){!1===document.hidden&&function(e,i){const n=e=>u[e]?.autoResize&&!u[e]?.firstRun;Object.keys(u).forEach((function(t){n(t)&&$(e,i,t)}))}("Tab Visible","resize")}const E=(e=>{let i=!1;return function(){return i?void 0:(i=!0,Reflect.apply(e,this,arguments))}})((()=>{r(window,"message",g),r(document,"visibilitychange",F),window.iframeParentListener=e=>g({data:e,sameDomain:!0})}));switch(!0){case void 0===window.jQuery:l("","Unable to bind to jQuery, it is not available.");break;case!window.jQuery.fn:l("","Unable to bind to jQuery, it is not fully loaded.");break;case window.jQuery.fn.iframeResize:l("","iframeResize is already assigned to jQuery.fn.");break;default:window.jQuery.fn.iframeResize=function(e){const i=x(e);return this.filter("iframe").each(i).end()},window.jQuery.fn.iFrameResize=function(e){return l("","Deprecated: Use the iframeResize method instead of iFrameResize"),this.iframeResize(e)}}}));
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@iframe-resizer/jquery",
3
- "version": "5.0.0-alpha.9",
3
+ "version": "5.0.0-beta.1",
4
4
  "license": "GPL-3.0",
5
- "homepage": "http://iframe-resizer.com",
5
+ "homepage": "https://iframe-resizer.com",
6
6
  "author": {
7
7
  "name": "David J. Bradshaw",
8
8
  "email": "dave@bradshaw.net"
@@ -41,6 +41,6 @@
41
41
  "jquery"
42
42
  ],
43
43
  "dependencies": {
44
- "@iframe-resizer/core": "5.0.0-alpha.9"
44
+ "@iframe-resizer/core": "5.0.0-beta.1"
45
45
  }
46
46
  }